diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2005-11-15 17:35:02 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2005-11-15 17:35:02 +0000 |
commit | 28742fa959f05142f2659f73a5ea1260175179a7 (patch) | |
tree | b29435e31924e409e58bf034cf30092e5e39cf2e /lib/gnutls_mpi.c | |
parent | dea22989089a7c2de01a606a9e6ed60caee2742f (diff) | |
download | gnutls-28742fa959f05142f2659f73a5ea1260175179a7.tar.gz |
added DHE-PSK ciphersuites and some cleanups.
Diffstat (limited to 'lib/gnutls_mpi.c')
-rw-r--r-- | lib/gnutls_mpi.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/gnutls_mpi.c b/lib/gnutls_mpi.c index d0fcd5da1d..5385f795e8 100644 --- a/lib/gnutls_mpi.c +++ b/lib/gnutls_mpi.c @@ -159,6 +159,35 @@ _gnutls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a) return GNUTLS_E_MPI_PRINT_FAILED; } +int +_gnutls_mpi_dprint(gnutls_datum_t * dest, const mpi_t a) +{ + int ret; + opaque *buf = NULL; + size_t bytes = 0; + + if (dest == NULL || a == NULL) + return GNUTLS_E_INVALID_REQUEST; + + gcry_mpi_print (GCRYMPI_FMT_USG, NULL, 0, &bytes, a); + + if (bytes != 0) + buf = gnutls_malloc (bytes); + if (buf == NULL) + return GNUTLS_E_MEMORY_ERROR; + + ret = gcry_mpi_print (GCRYMPI_FMT_USG, buf, bytes, &bytes, a); + if (!ret) + { + dest->data = buf; + dest->size = bytes; + return 0; + } + + gnutls_free (buf); + return GNUTLS_E_MPI_PRINT_FAILED; +} + /* this function reads an integer * from asn1 structs. Combines the read and mpi_scan |