Skip to content

Commit c113118

Browse files
authored
Merge pull request #199 from libtom/remove-set-long-specialization
remove mp_set_long specialization
2 parents d256648 + 77143c3 commit c113118

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

bn_mp_set_long.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,7 @@
1212
* SPDX-License-Identifier: Unlicense
1313
*/
1414

15-
/* set a platform dependent unsigned long int */
16-
#if (ULONG_MAX != 0xFFFFFFFFUL) || (DIGIT_BIT < 32)
1715
MP_SET_XLONG(mp_set_long, unsigned long)
18-
#else
19-
int mp_set_long(mp_int *a, unsigned long b)
20-
{
21-
int x = 0;
22-
int res = mp_grow(a, (CHAR_BIT * sizeof(unsigned long) + DIGIT_BIT - 1) / DIGIT_BIT);
23-
if (res == MP_OKAY) {
24-
mp_zero(a);
25-
if (b) {
26-
a->dp[x++] = (mp_digit)b;
27-
}
28-
a->used = x;
29-
}
30-
return res;
31-
}
32-
33-
#endif
3416
#endif
3517

3618
/* ref: $Format:%D$ */

tommath_private.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ int func_name (mp_int * a, type b) \
8585
mp_zero(a); \
8686
while (b != 0u) { \
8787
a->dp[x++] = ((mp_digit)b & MP_MASK); \
88-
b >>= DIGIT_BIT; \
88+
if ((CHAR_BIT * sizeof (b)) <= DIGIT_BIT) { break; } \
89+
b >>= ((CHAR_BIT * sizeof (b)) <= DIGIT_BIT ? 0 : DIGIT_BIT); \
8990
} \
9091
a->used = x; \
9192
} \

0 commit comments

Comments
 (0)