forked from wolfSSL/wolfssl
ECDSA signatures need a zero padding for the ASN.1 storage of the R and S values
This commit is contained in:
@@ -179,6 +179,28 @@ mp_count_bits (mp_int * a)
|
||||
}
|
||||
|
||||
|
||||
int mp_leading_bit (mp_int * a)
|
||||
{
|
||||
int bit = 0;
|
||||
mp_int t;
|
||||
|
||||
if (mp_init_copy(&t, a) != MP_OKAY)
|
||||
return 0;
|
||||
|
||||
while (mp_iszero(&t) == 0) {
|
||||
#ifndef MP_8BIT
|
||||
bit = (t.dp[0] & 0x80) != 0;
|
||||
#else
|
||||
bit = (t.dp[0] | ((t.dp[1] & 0x01) << 7)) & 0x80 != 0;
|
||||
#endif
|
||||
if (mp_div_2d (&t, 8, &t, NULL) != MP_OKAY)
|
||||
break;
|
||||
}
|
||||
mp_clear(&t);
|
||||
return bit;
|
||||
}
|
||||
|
||||
|
||||
/* store in unsigned [big endian] format */
|
||||
int mp_to_unsigned_bin (mp_int * a, unsigned char *b)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user