005-const-parameter-mp_int.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. From 01415ef8269e594a647f67ea0729ca8b590679de Mon Sep 17 00:00:00 2001
  2. From: Francois Perrad <[email protected]>
  3. Date: Thu, 22 Dec 2022 10:19:54 +0100
  4. Subject: const parameter mp_int
  5. ---
  6. bignum.c | 2 +-
  7. bignum.h | 2 +-
  8. buffer.c | 2 +-
  9. buffer.h | 2 +-
  10. dbrandom.c | 2 +-
  11. dbrandom.h | 2 +-
  12. dbutil.c | 2 +-
  13. dbutil.h | 2 +-
  14. genrsa.c | 4 ++--
  15. 9 files changed, 10 insertions(+), 10 deletions(-)
  16. --- a/bignum.c
  17. +++ b/bignum.c
  18. @@ -93,7 +93,7 @@ void bytes_to_mp(mp_int *mp, const unsig
  19. /* hash the ssh representation of the mp_int mp */
  20. void hash_process_mp(const struct ltc_hash_descriptor *hash_desc,
  21. - hash_state *hs, mp_int *mp) {
  22. + hash_state *hs, const mp_int *mp) {
  23. buffer * buf;
  24. buf = buf_new(512 + 20); /* max buffer is a 4096 bit key,
  25. --- a/bignum.h
  26. +++ b/bignum.h
  27. @@ -33,6 +33,6 @@ void m_mp_alloc_init_multi(mp_int **mp,
  28. void m_mp_free_multi(mp_int **mp, ...) ATTRIB_SENTINEL;
  29. void bytes_to_mp(mp_int *mp, const unsigned char* bytes, unsigned int len);
  30. void hash_process_mp(const struct ltc_hash_descriptor *hash_desc,
  31. - hash_state *hs, mp_int *mp);
  32. + hash_state *hs, const mp_int *mp);
  33. #endif /* DROPBEAR_BIGNUM_H_ */
  34. --- a/buffer.c
  35. +++ b/buffer.c
  36. @@ -299,7 +299,7 @@ void buf_putbytes(buffer *buf, const uns
  37. /* for our purposes we only need positive (or 0) numbers, so will
  38. * fail if we get negative numbers */
  39. -void buf_putmpint(buffer* buf, mp_int * mp) {
  40. +void buf_putmpint(buffer* buf, const mp_int * mp) {
  41. size_t written;
  42. unsigned int len, pad = 0;
  43. TRACE2(("enter buf_putmpint"))
  44. --- a/buffer.h
  45. +++ b/buffer.h
  46. @@ -65,7 +65,7 @@ void buf_putint(buffer* buf, unsigned in
  47. void buf_putstring(buffer* buf, const char* str, unsigned int len);
  48. void buf_putbufstring(buffer *buf, const buffer* buf_str);
  49. void buf_putbytes(buffer *buf, const unsigned char *bytes, unsigned int len);
  50. -void buf_putmpint(buffer* buf, mp_int * mp);
  51. +void buf_putmpint(buffer* buf, const mp_int * mp);
  52. int buf_getmpint(buffer* buf, mp_int* mp);
  53. unsigned int buf_getint(buffer* buf);
  54. --- a/dbrandom.c
  55. +++ b/dbrandom.c
  56. @@ -347,7 +347,7 @@ void genrandom(unsigned char* buf, unsig
  57. * rand must be an initialised *mp_int for the result.
  58. * the result rand satisfies: 0 < rand < max
  59. * */
  60. -void gen_random_mpint(mp_int *max, mp_int *rand) {
  61. +void gen_random_mpint(const mp_int *max, mp_int *rand) {
  62. unsigned char *randbuf = NULL;
  63. unsigned int len = 0;
  64. --- a/dbrandom.h
  65. +++ b/dbrandom.h
  66. @@ -30,6 +30,6 @@
  67. void seedrandom(void);
  68. void genrandom(unsigned char* buf, unsigned int len);
  69. void addrandom(const unsigned char * buf, unsigned int len);
  70. -void gen_random_mpint(mp_int *max, mp_int *rand);
  71. +void gen_random_mpint(const mp_int *max, mp_int *rand);
  72. #endif /* DROPBEAR_RANDOM_H_ */
  73. --- a/dbutil.c
  74. +++ b/dbutil.c
  75. @@ -442,7 +442,7 @@ void printhex(const char * label, const
  76. }
  77. }
  78. -void printmpint(const char *label, mp_int *mp) {
  79. +void printmpint(const char *label, const mp_int *mp) {
  80. buffer *buf = buf_new(1000);
  81. buf_putmpint(buf, mp);
  82. fprintf(stderr, "%d bits ", mp_count_bits(mp));
  83. --- a/dbutil.h
  84. +++ b/dbutil.h
  85. @@ -53,7 +53,7 @@ void dropbear_trace3(const char* format,
  86. void dropbear_trace4(const char* format, ...) ATTRIB_PRINTF(1,2);
  87. void dropbear_trace5(const char* format, ...) ATTRIB_PRINTF(1,2);
  88. void printhex(const char * label, const unsigned char * buf, int len);
  89. -void printmpint(const char *label, mp_int *mp);
  90. +void printmpint(const char *label, const mp_int *mp);
  91. void debug_start_net(void);
  92. extern int debug_trace;
  93. #endif
  94. --- a/genrsa.c
  95. +++ b/genrsa.c
  96. @@ -34,7 +34,7 @@
  97. #if DROPBEAR_RSA
  98. static void getrsaprime(mp_int* prime, mp_int *primeminus,
  99. - mp_int* rsa_e, unsigned int size_bytes);
  100. + const mp_int* rsa_e, unsigned int size_bytes);
  101. /* mostly taken from libtomcrypt's rsa key generation routine */
  102. dropbear_rsa_key * gen_rsa_priv_key(unsigned int size) {
  103. @@ -89,7 +89,7 @@ dropbear_rsa_key * gen_rsa_priv_key(unsi
  104. /* return a prime suitable for p or q */
  105. static void getrsaprime(mp_int* prime, mp_int *primeminus,
  106. - mp_int* rsa_e, unsigned int size_bytes) {
  107. + const mp_int* rsa_e, unsigned int size_bytes) {
  108. unsigned char *buf;
  109. int trials;