mbedcrypto: Make bignum_bn2dec() return char*.

This aligns it with libgcrypt/OpenSSL backends which uses char*.
It also aligns mbedcrypto's bignum_bn2hex() to use an unsigned
cast just like OpenSSL backend.

Signed-off-by: Simon Josefsson <simon@josefsson.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Simon Josefsson
2023-08-20 18:50:29 +02:00
committed by Jakub Jelen
parent 812576c122
commit 3417161b81
2 changed files with 4 additions and 4 deletions

View File

@@ -79,7 +79,7 @@ extern "C" {
bignum ssh_mbedcry_bn_new(void); bignum ssh_mbedcry_bn_new(void);
void ssh_mbedcry_bn_free(bignum num); void ssh_mbedcry_bn_free(bignum num);
unsigned char *ssh_mbedcry_bn2num(const_bignum num, int radix); char *ssh_mbedcry_bn2num(const_bignum num, int radix);
int ssh_mbedcry_rand(bignum rnd, int bits, int top, int bottom); int ssh_mbedcry_rand(bignum rnd, int bits, int top, int bottom);
int ssh_mbedcry_is_bit_set(bignum num, size_t pos); int ssh_mbedcry_is_bit_set(bignum num, size_t pos);
int ssh_mbedcry_rand_range(bignum dest, bignum max); int ssh_mbedcry_rand_range(bignum dest, bignum max);
@@ -105,7 +105,7 @@ int ssh_mbedcry_hex2bn(bignum *dest, char *data);
} while(0) } while(0)
#define bignum_bn2dec(num) ssh_mbedcry_bn2num(num, 10) #define bignum_bn2dec(num) ssh_mbedcry_bn2num(num, 10)
#define bignum_dec2bn(data, bn) mbedtls_mpi_read_string(bn, 10, data) #define bignum_dec2bn(data, bn) mbedtls_mpi_read_string(bn, 10, data)
#define bignum_bn2hex(num, dest) (*dest)=ssh_mbedcry_bn2num(num, 16) #define bignum_bn2hex(num, dest) (*dest)=(unsigned char *)ssh_mbedcry_bn2num(num, 16)
#define bignum_hex2bn(data, dest) ssh_mbedcry_hex2bn(dest, data) #define bignum_hex2bn(data, dest) ssh_mbedcry_hex2bn(dest, data)
#define bignum_rand(rnd, bits) ssh_mbedcry_rand((rnd), (bits), 0, 1) #define bignum_rand(rnd, bits) ssh_mbedcry_rand((rnd), (bits), 0, 1)
#define bignum_rand_range(rnd, max) ssh_mbedcry_rand_range(rnd, max) #define bignum_rand_range(rnd, max) ssh_mbedcry_rand_range(rnd, max)

View File

@@ -45,7 +45,7 @@ void ssh_mbedcry_bn_free(bignum bn)
SAFE_FREE(bn); SAFE_FREE(bn);
} }
unsigned char *ssh_mbedcry_bn2num(const_bignum num, int radix) char *ssh_mbedcry_bn2num(const_bignum num, int radix)
{ {
char *buf = NULL; char *buf = NULL;
size_t olen; size_t olen;
@@ -67,7 +67,7 @@ unsigned char *ssh_mbedcry_bn2num(const_bignum num, int radix)
return NULL; return NULL;
} }
return (unsigned char *) buf; return buf;
} }
int ssh_mbedcry_rand(bignum rnd, int bits, int top, int bottom) int ssh_mbedcry_rand(bignum rnd, int bits, int top, int bottom)