mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
Ensure that all leading zeros are skipped in sp_tohex.
This commit is contained in:
@ -12711,14 +12711,24 @@ int sp_tohex(sp_int* a, char* str)
|
||||
i = a->used - 1;
|
||||
#ifndef WC_DISABLE_RADIX_ZERO_PAD
|
||||
for (j = SP_WORD_SIZE - 8; j >= 0; j -= 8) {
|
||||
if (((a->dp[i] >> j) & 0xff) != 0)
|
||||
if (((a->dp[i] >> j) & 0xff) != 0) {
|
||||
break;
|
||||
}
|
||||
else if (j == 0) {
|
||||
j = SP_WORD_SIZE - 8;
|
||||
--i;
|
||||
}
|
||||
}
|
||||
j += 4;
|
||||
#else
|
||||
for (j = SP_WORD_SIZE - 4; j >= 0; j -= 4) {
|
||||
if (((a->dp[i] >> j) & 0xf) != 0)
|
||||
if (((a->dp[i] >> j) & 0xf) != 0) {
|
||||
break;
|
||||
}
|
||||
else if (j == 0) {
|
||||
j = SP_WORD_SIZE - 4;
|
||||
--i;
|
||||
}
|
||||
}
|
||||
#endif /* WC_DISABLE_RADIX_ZERO_PAD */
|
||||
for (; j >= 0; j -= 4) {
|
||||
|
Reference in New Issue
Block a user