diff options
Diffstat (limited to 'mpi/mpiutil.c')
-rw-r--r-- | mpi/mpiutil.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c index 433dda6b..57fe72a7 100644 --- a/mpi/mpiutil.c +++ b/mpi/mpiutil.c @@ -291,6 +291,22 @@ gcry_mpi_get_opaque( gcry_mpi_t a, unsigned int *nbits ) } +void * +_gcry_mpi_get_opaque_copy (gcry_mpi_t a, unsigned int *nbits) +{ + const void *s; + void *d; + unsigned int n; + + s = gcry_mpi_get_opaque (a, nbits); + if (!s && nbits) + return NULL; + n = (*nbits+7)/8; + d = gcry_is_secure (s)? gcry_malloc_secure (n) : gcry_malloc (n); + memcpy (d, s, n); + return d; +} + /**************** * Note: This copy function should not interpret the MPI * but copy it transparently. |