Commit 2fefcaa0101f583c612bfb2136ef69812410f72a

Steffen Jaeckel 2019-10-15T14:21:30

copy implementation of mp_to_unsigned_bin_n() to mp_to_signed_bin_n()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/bn_deprecated.c b/bn_deprecated.c
index a2c4b2e..2056b20 100644
--- a/bn_deprecated.c
+++ b/bn_deprecated.c
@@ -281,11 +281,12 @@ mp_err mp_to_signed_bin(const mp_int *a, unsigned char *b)
 #ifdef BN_MP_TO_SIGNED_BIN_N_C
 mp_err mp_to_signed_bin_n(const mp_int *a, unsigned char *b, unsigned long *outlen)
 {
-   if (*outlen < (unsigned long)mp_sbin_size(a)) {
+   size_t n = mp_sbin_size(a);
+   if (*outlen < (unsigned long)n) {
       return MP_VAL;
    }
-   *outlen = (unsigned long)mp_sbin_size(a);
-   return mp_to_sbin(a, b, (size_t)(*outlen), NULL);
+   *outlen = (unsigned long)n;
+   return mp_to_sbin(a, b, n, NULL);
 }
 #endif
 #ifdef BN_MP_TORADIX_N_C