mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 04:04:39 +02:00
Change mp_leading_bit (integer.c) to not to require a copy
This commit is contained in:
@@ -41804,7 +41804,7 @@ int wolfSSL_X509_NAME_print_ex(WOLFSSL_BIO* bio, WOLFSSL_X509_NAME* name,
|
|||||||
if (i < count - 1) {
|
if (i < count - 1) {
|
||||||
/* tmpSz+1 for last null char */
|
/* tmpSz+1 for last null char */
|
||||||
XSNPRINTF(tmp, tmpSz+1, "%s=%s,", buf, str->data);
|
XSNPRINTF(tmp, tmpSz+1, "%s=%s,", buf, str->data);
|
||||||
XSTRNCAT(fullName, tmp, tmpSz);
|
XSTRNCAT(fullName, tmp, tmpSz+1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XSNPRINTF(tmp, tmpSz, "%s=%s", buf, str->data);
|
XSNPRINTF(tmp, tmpSz, "%s=%s", buf, str->data);
|
||||||
|
@@ -271,23 +271,10 @@ int mp_count_bits (mp_int * a)
|
|||||||
|
|
||||||
int mp_leading_bit (mp_int * a)
|
int mp_leading_bit (mp_int * a)
|
||||||
{
|
{
|
||||||
int bit = 0;
|
int c = mp_count_bits(a);
|
||||||
mp_int t;
|
|
||||||
|
|
||||||
if (mp_init_copy(&t, a) != MP_OKAY)
|
if (c == 0) return 0;
|
||||||
return 0;
|
return (c % 8) == 0;
|
||||||
|
|
||||||
while (mp_iszero(&t) == MP_NO) {
|
|
||||||
#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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int mp_to_unsigned_bin_at_pos(int x, mp_int *t, unsigned char *b)
|
int mp_to_unsigned_bin_at_pos(int x, mp_int *t, unsigned char *b)
|
||||||
|
Reference in New Issue
Block a user