forked from wolfSSL/wolfssl
Merge pull request #2511 from tmael/BN_bn2hex
Fix for hex digits with fastmath and normal integer
This commit is contained in:
@ -24123,7 +24123,11 @@ static void test_wolfSSL_X509_get_serialNumber(void)
|
||||
X509_free(x509); /* free's a */
|
||||
|
||||
AssertNotNull(serialHex = BN_bn2hex(bn));
|
||||
#ifndef WC_DISABLE_RADIX_ZERO_PAD
|
||||
AssertStrEQ(serialHex, "01");
|
||||
#else
|
||||
AssertStrEQ(serialHex, "1");
|
||||
#endif
|
||||
OPENSSL_free(serialHex);
|
||||
|
||||
AssertIntEQ(BN_get_word(bn), 1);
|
||||
|
@ -5233,7 +5233,13 @@ int mp_toradix (mp_int *a, char *str, int radix)
|
||||
*str++ = mp_s_rmap[d];
|
||||
++digs;
|
||||
}
|
||||
|
||||
#ifndef WC_DISABLE_RADIX_ZERO_PAD
|
||||
/* For hexadecimal output, add zero padding when number of digits is odd */
|
||||
if ((digs & 1) && (radix == 16)) {
|
||||
*str++ = mp_s_rmap[0];
|
||||
++digs;
|
||||
}
|
||||
#endif
|
||||
/* reverse the digits of the string. In this case _s points
|
||||
* to the first digit [excluding the sign] of the number]
|
||||
*/
|
||||
|
@ -4779,7 +4779,13 @@ int mp_toradix (mp_int *a, char *str, int radix)
|
||||
*str++ = fp_s_rmap[d];
|
||||
++digs;
|
||||
}
|
||||
|
||||
#ifndef WC_DISABLE_RADIX_ZERO_PAD
|
||||
/* For hexadecimal output, add zero padding when number of digits is odd */
|
||||
if ((digs & 1) && (radix == 16)) {
|
||||
*str++ = fp_s_rmap[0];
|
||||
++digs;
|
||||
}
|
||||
#endif
|
||||
/* reverse the digits of the string. In this case _s points
|
||||
* to the first digit [excluding the sign] of the number]
|
||||
*/
|
||||
|
Reference in New Issue
Block a user