From e71e83d95cbafbe6362592f399fa1db6c0866428 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Sun, 20 Aug 2023 18:50:29 +0200 Subject: [PATCH] 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 --- include/libssh/libmbedcrypto.h | 4 ++-- src/mbedcrypto_missing.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/libssh/libmbedcrypto.h b/include/libssh/libmbedcrypto.h index e6fc393cd..6cf186261 100644 --- a/include/libssh/libmbedcrypto.h +++ b/include/libssh/libmbedcrypto.h @@ -79,7 +79,7 @@ extern "C" { bignum ssh_mbedcry_bn_new(void); 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_is_bit_set(bignum num, size_t pos); int ssh_mbedcry_rand_range(bignum dest, bignum max); @@ -105,7 +105,7 @@ int ssh_mbedcry_hex2bn(bignum *dest, char *data); } while(0) #define bignum_bn2dec(num) ssh_mbedcry_bn2num(num, 10) #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_rand(rnd, bits) ssh_mbedcry_rand((rnd), (bits), 0, 1) #define bignum_rand_range(rnd, max) ssh_mbedcry_rand_range(rnd, max) diff --git a/src/mbedcrypto_missing.c b/src/mbedcrypto_missing.c index ac0d688c9..fb35ca473 100644 --- a/src/mbedcrypto_missing.c +++ b/src/mbedcrypto_missing.c @@ -45,7 +45,7 @@ void ssh_mbedcry_bn_free(bignum 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; size_t olen; @@ -67,7 +67,7 @@ unsigned char *ssh_mbedcry_bn2num(const_bignum num, int radix) return NULL; } - return (unsigned char *) buf; + return buf; } int ssh_mbedcry_rand(bignum rnd, int bits, int top, int bottom) -- GitLab