aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2019-08-06 20:22:50 +0200
committerAndreas Schneider <asn@cryptomilk.org>2019-08-07 09:49:00 +0200
commit4e25ee6124f23a727a9e430b738fad3124ae8ecc (patch)
treeb7c66e6849cd48309fe47ac096e22157b2f3cfd9
parent89ab7b23f81589eb958676b352cba41b80a5a106 (diff)
downloadlibssh-4e25ee6124f23a727a9e430b738fad3124ae8ecc.tar.gz
libssh-4e25ee6124f23a727a9e430b738fad3124ae8ecc.tar.xz
libssh-4e25ee6124f23a727a9e430b738fad3124ae8ecc.zip
bignum: Pass const to ssh_print_bignum()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
-rw-r--r--include/libssh/bignum.h2
-rw-r--r--include/libssh/libgcrypt.h5
-rw-r--r--include/libssh/libmbedcrypto.h2
-rw-r--r--src/bignum.c2
-rw-r--r--src/mbedcrypto_missing.c2
5 files changed, 8 insertions, 5 deletions
diff --git a/include/libssh/bignum.h b/include/libssh/bignum.h
index 3f82bc64..726ed7b9 100644
--- a/include/libssh/bignum.h
+++ b/include/libssh/bignum.h
@@ -27,7 +27,7 @@
bignum ssh_make_string_bn(ssh_string string);
ssh_string ssh_make_bignum_string(bignum num);
-void ssh_print_bignum(const char *which, const bignum num);
+void ssh_print_bignum(const char *which, const_bignum num);
#endif /* BIGNUM_H_ */
diff --git a/include/libssh/libgcrypt.h b/include/libssh/libgcrypt.h
index 795d33e1..347d851b 100644
--- a/include/libssh/libgcrypt.h
+++ b/include/libssh/libgcrypt.h
@@ -78,7 +78,10 @@ int ssh_gcry_rand_range(bignum rnd, bignum max);
#define bignum_bin2bn(data,datalen,dest) gcry_mpi_scan(dest,GCRYMPI_FMT_USG,data,datalen,NULL)
#define bignum_bn2dec(num) ssh_gcry_bn2dec(num)
#define bignum_dec2bn(num, data) ssh_gcry_dec2bn(data, num)
-#define bignum_bn2hex(num,data) gcry_mpi_aprint(GCRYMPI_FMT_HEX,data,NULL,num)
+
+#define bignum_bn2hex(num, data) \
+ gcry_mpi_aprint(GCRYMPI_FMT_HEX, data, NULL, (const gcry_mpi_t)num)
+
#define bignum_hex2bn(data, num) (gcry_mpi_scan(num,GCRYMPI_FMT_HEX,data,0,NULL)==0?1:0)
#define bignum_rand(num,bits) 1,gcry_mpi_randomize(num,bits,GCRY_STRONG_RANDOM),gcry_mpi_set_bit(num,bits-1),gcry_mpi_set_bit(num,0)
#define bignum_mod_exp(dest,generator,exp,modulo, ctx) 1,gcry_mpi_powm(dest,generator,exp,modulo)
diff --git a/include/libssh/libmbedcrypto.h b/include/libssh/libmbedcrypto.h
index 00d5ba8c..fe53019b 100644
--- a/include/libssh/libmbedcrypto.h
+++ b/include/libssh/libmbedcrypto.h
@@ -75,7 +75,7 @@ struct mbedtls_ecdsa_sig {
bignum ssh_mbedcry_bn_new(void);
void ssh_mbedcry_bn_free(bignum num);
-unsigned char *ssh_mbedcry_bn2num(bignum num, int radix);
+unsigned 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);
diff --git a/src/bignum.c b/src/bignum.c
index fdd2d81f..e264514a 100644
--- a/src/bignum.c
+++ b/src/bignum.c
@@ -77,7 +77,7 @@ bignum ssh_make_string_bn(ssh_string string)
}
/* prints the bignum on stderr */
-void ssh_print_bignum(const char *name, const bignum num)
+void ssh_print_bignum(const char *name, const_bignum num)
{
unsigned char *hex = NULL;
if (num != NULL) {
diff --git a/src/mbedcrypto_missing.c b/src/mbedcrypto_missing.c
index be290d2c..5e9da6c5 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(bignum num, int radix)
+unsigned char *ssh_mbedcry_bn2num(const_bignum num, int radix)
{
char *buf = NULL;
size_t olen;