diff options
Diffstat (limited to 'mpi/mpicoder.c')
-rw-r--r-- | mpi/mpicoder.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c index 9362aff65..a4b1c2095 100644 --- a/mpi/mpicoder.c +++ b/mpi/mpicoder.c @@ -268,8 +268,8 @@ mpi_get_keyid( MPI a, u32 *keyid ) * set to zero if the value of A is zero. If sign is not NULL, it will * be set to the sign of the A. */ -byte * -mpi_get_buffer( MPI a, unsigned *nbytes, int *sign ) +static byte * +do_get_buffer( MPI a, unsigned *nbytes, int *sign, int force_secure ) { byte *p, *buffer; mpi_limb_t alimb; @@ -278,7 +278,8 @@ mpi_get_buffer( MPI a, unsigned *nbytes, int *sign ) if( sign ) *sign = a->sign; *nbytes = a->nlimbs * BYTES_PER_MPI_LIMB; - p = buffer = a->secure ? m_alloc_secure( *nbytes) : m_alloc( *nbytes ); + p = buffer = force_secure || a->secure ? m_alloc_secure( *nbytes) + : m_alloc( *nbytes ); for(i=a->nlimbs-1; i >= 0; i-- ) { alimb = a->d[i]; @@ -310,6 +311,19 @@ mpi_get_buffer( MPI a, unsigned *nbytes, int *sign ) return buffer; } + +byte * +mpi_get_buffer( MPI a, unsigned *nbytes, int *sign ) +{ + return do_get_buffer( a, nbytes, sign, 0 ); +} + +byte * +mpi_get_secure_buffer( MPI a, unsigned *nbytes, int *sign ) +{ + return do_get_buffer( a, nbytes, sign, 1 ); +} + /**************** * Use BUFFER to update MPI. */ |