diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2001-06-15 22:05:32 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2001-06-15 22:05:32 +0000 |
commit | 780c45c9fcc8719cb13f6ff5abcc73b7725de5df (patch) | |
tree | a4223c147853208bda0450ca2209ba71bc6d2798 /lib/gnutls_datum.c | |
parent | 2a881f41279b151a28506d35ab63304e0f6dc1b2 (diff) | |
download | gnutls-780c45c9fcc8719cb13f6ff5abcc73b7725de5df.tar.gz |
more rsa stuff -- and cleanups
Diffstat (limited to 'lib/gnutls_datum.c')
-rw-r--r-- | lib/gnutls_datum.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/gnutls_datum.c b/lib/gnutls_datum.c index 8e137dcb18..b152c19c40 100644 --- a/lib/gnutls_datum.c +++ b/lib/gnutls_datum.c @@ -40,3 +40,21 @@ void WRITEdatum8( opaque* dest, gnutls_datum dat) { dest[0] = (uint8) dat.size; memcpy( &dest[1], dat.data, dat.size); } + +int gnutls_set_datum( gnutls_datum* dat, const void* data, int data_size) { + dat->data = gnutls_malloc(data_size); + if (dat->data==NULL) return GNUTLS_E_MEMORY_ERROR; + + dat->size = data_size; + memcpy( dat->data, data, data_size); + + return 0; +} + +void gnutls_free_datum( gnutls_datum* dat) { + if (dat->data!=NULL && dat->size!=0) + gnutls_free( dat->data); + + dat->data = NULL; + dat->size = 0; +} |