We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 55acc6a commit 20dcc92Copy full SHA for 20dcc92
bn_mp_fread.c
@@ -30,11 +30,11 @@ mp_err mp_fread(mp_int *a, int radix, FILE *stream)
30
do {
31
int y;
32
unsigned pos = (unsigned)(ch - (int)'(');
33
- if (mp_s_rmap_reverse_sz < pos) {
+ if (MP_RMAP_REVERSE_SIZE < pos) {
34
break;
35
}
36
37
- y = (int)mp_s_rmap_reverse[pos];
+ y = (int)s_mp_rmap_reverse[pos];
38
39
if ((y == 0xff) || (y >= radix)) {
40
bn_mp_radix_smap.c
@@ -4,8 +4,8 @@
4
/* SPDX-License-Identifier: Unlicense */
5
6
/* chars used in radix conversions */
7
-const char *const mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
8
-const uint8_t mp_s_rmap_reverse[] = {
+const char s_mp_rmap[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
+const uint8_t s_mp_rmap_reverse[] = {
9
0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, /* ()*+,-./ */
10
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 01234567 */
11
0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 89:;<=>? */
@@ -18,5 +18,5 @@ const uint8_t mp_s_rmap_reverse[] = {
18
0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, /* pqrstuvw */
19
0x3b, 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, /* xyz{|}~. */
20
};
21
-const size_t mp_s_rmap_reverse_sz = sizeof(mp_s_rmap_reverse);
+MP_STATIC_ASSERT(correct_rmap_reverse_size, sizeof(s_mp_rmap_reverse) == MP_RMAP_REVERSE_SIZE)
22
#endif
bn_mp_read_radix.c
@@ -43,10 +43,10 @@ mp_err mp_read_radix(mp_int *a, const char *str, int radix)
43
*/
44
ch = (radix <= 36) ? (char)MP_TOUPPER((int)*str) : *str;
45
pos = (unsigned)(ch - '(');
46
47
48
49
50
51
/* if the char was found in the map
52
* and is less than the given radix add it
bn_mp_to_radix.c
@@ -60,7 +60,7 @@ mp_err mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, i
60
if ((err = mp_div_d(&t, (mp_digit)radix, &t, &d)) != MP_OKAY) {
61
goto LBL_ERR;
62
63
- *str++ = mp_s_rmap[d];
+ *str++ = s_mp_rmap[d];
64
++digs;
65
66
/* reverse the digits of the string. In this case _s points
tommath_private.h
@@ -215,9 +215,9 @@ MP_PRIVATE mp_err s_mp_prime_is_divisible(const mp_int *a, mp_bool *result);
215
MP_PRIVATE mp_err s_mp_rand_jenkins(void *p, size_t n) MP_WUR;
216
MP_PRIVATE void s_mp_rand_jenkins_init(uint64_t seed);
217
218
-extern MP_PRIVATE const char *const mp_s_rmap;
219
-extern MP_PRIVATE const uint8_t mp_s_rmap_reverse[];
220
-extern MP_PRIVATE const size_t mp_s_rmap_reverse_sz;
+#define MP_RMAP_REVERSE_SIZE 88
+extern MP_PRIVATE const char s_mp_rmap[];
+extern MP_PRIVATE const uint8_t s_mp_rmap_reverse[];
221
extern MP_PRIVATE const mp_digit s_mp_prime_tab[];
222
223
/* number of primes */
0 commit comments