1 From 01415ef8269e594a647f67ea0729ca8b590679de Mon Sep 17 00:00:00 2001
2 From: Francois Perrad <francois.perrad@gadz.org>
3 Date: Thu, 22 Dec 2022 10:19:54 +0100
4 Subject: const parameter mp_int
16 9 files changed, 10 insertions(+), 10 deletions(-)
20 @@ -93,7 +93,7 @@ void bytes_to_mp(mp_int *mp, const unsig
22 /* hash the ssh representation of the mp_int mp */
23 void hash_process_mp(const struct ltc_hash_descriptor *hash_desc,
24 - hash_state *hs, mp_int *mp) {
25 + hash_state *hs, const mp_int *mp) {
28 buf = buf_new(512 + 20); /* max buffer is a 4096 bit key,
31 @@ -33,6 +33,6 @@ void m_mp_alloc_init_multi(mp_int **mp,
32 void m_mp_free_multi(mp_int **mp, ...) ATTRIB_SENTINEL;
33 void bytes_to_mp(mp_int *mp, const unsigned char* bytes, unsigned int len);
34 void hash_process_mp(const struct ltc_hash_descriptor *hash_desc,
35 - hash_state *hs, mp_int *mp);
36 + hash_state *hs, const mp_int *mp);
38 #endif /* DROPBEAR_BIGNUM_H_ */
41 @@ -299,7 +299,7 @@ void buf_putbytes(buffer *buf, const uns
43 /* for our purposes we only need positive (or 0) numbers, so will
44 * fail if we get negative numbers */
45 -void buf_putmpint(buffer* buf, mp_int * mp) {
46 +void buf_putmpint(buffer* buf, const mp_int * mp) {
48 unsigned int len, pad = 0;
49 TRACE2(("enter buf_putmpint"))
52 @@ -65,7 +65,7 @@ void buf_putint(buffer* buf, unsigned in
53 void buf_putstring(buffer* buf, const char* str, unsigned int len);
54 void buf_putbufstring(buffer *buf, const buffer* buf_str);
55 void buf_putbytes(buffer *buf, const unsigned char *bytes, unsigned int len);
56 -void buf_putmpint(buffer* buf, mp_int * mp);
57 +void buf_putmpint(buffer* buf, const mp_int * mp);
58 int buf_getmpint(buffer* buf, mp_int* mp);
59 unsigned int buf_getint(buffer* buf);
63 @@ -347,7 +347,7 @@ void genrandom(unsigned char* buf, unsig
64 * rand must be an initialised *mp_int for the result.
65 * the result rand satisfies: 0 < rand < max
67 -void gen_random_mpint(mp_int *max, mp_int *rand) {
68 +void gen_random_mpint(const mp_int *max, mp_int *rand) {
70 unsigned char *randbuf = NULL;
75 void seedrandom(void);
76 void genrandom(unsigned char* buf, unsigned int len);
77 void addrandom(const unsigned char * buf, unsigned int len);
78 -void gen_random_mpint(mp_int *max, mp_int *rand);
79 +void gen_random_mpint(const mp_int *max, mp_int *rand);
81 #endif /* DROPBEAR_RANDOM_H_ */
84 @@ -442,7 +442,7 @@ void printhex(const char * label, const
88 -void printmpint(const char *label, mp_int *mp) {
89 +void printmpint(const char *label, const mp_int *mp) {
90 buffer *buf = buf_new(1000);
91 buf_putmpint(buf, mp);
92 fprintf(stderr, "%d bits ", mp_count_bits(mp));
95 @@ -53,7 +53,7 @@ void dropbear_trace3(const char* format,
96 void dropbear_trace4(const char* format, ...) ATTRIB_PRINTF(1,2);
97 void dropbear_trace5(const char* format, ...) ATTRIB_PRINTF(1,2);
98 void printhex(const char * label, const unsigned char * buf, int len);
99 -void printmpint(const char *label, mp_int *mp);
100 +void printmpint(const char *label, const mp_int *mp);
101 void debug_start_net(void);
102 extern int debug_trace;
109 static void getrsaprime(mp_int* prime, mp_int *primeminus,
110 - mp_int* rsa_e, unsigned int size_bytes);
111 + const mp_int* rsa_e, unsigned int size_bytes);
113 /* mostly taken from libtomcrypt's rsa key generation routine */
114 dropbear_rsa_key * gen_rsa_priv_key(unsigned int size) {
115 @@ -89,7 +89,7 @@ dropbear_rsa_key * gen_rsa_priv_key(unsi
117 /* return a prime suitable for p or q */
118 static void getrsaprime(mp_int* prime, mp_int *primeminus,
119 - mp_int* rsa_e, unsigned int size_bytes) {
120 + const mp_int* rsa_e, unsigned int size_bytes) {