Commit b58c9966868bb95dd7cdf6e483ee3091ecf44e6a

Daniel Mendler 2019-05-23T23:39:47

use int32 and uint32 instead of sint and uint

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
diff --git a/bn_conversion.c b/bn_conversion.c
index 388b421..80854c7 100644
--- a/bn_conversion.c
+++ b/bn_conversion.c
@@ -52,44 +52,44 @@
         return a->sign == MP_NEG ? (int##w##_t)-res : (int##w##_t)res;  \
     }
 
-#ifdef BN_MP_SET_UINT_C
-MP_SET_UNSIGNED(mp_set_uint, 32)
+#ifdef BN_MP_SET_UINT32_C
+MP_SET_UNSIGNED(mp_set_uint32, 32)
 #endif
 
 #ifdef BN_MP_SET_UINT64_C
 MP_SET_UNSIGNED(mp_set_uint64, 64)
 #endif
 
-#ifdef BN_MP_SET_SINT_C
-MP_SET_SIGNED(mp_set_sint, mp_set_uint, 32)
+#ifdef BN_MP_SET_INT32_C
+MP_SET_SIGNED(mp_set_int32, mp_set_uint32, 32)
 #endif
 
-#ifdef BN_MP_SET_SINT64_C
-MP_SET_SIGNED(mp_set_sint64, mp_set_uint64, 64)
+#ifdef BN_MP_SET_INT64_C
+MP_SET_SIGNED(mp_set_int64, mp_set_uint64, 64)
 #endif
 
-#if defined(BN_MP_GET_SINT_C) || defined(BN_MP_GET_UINT_C)
-MP_GET_SIGNED(mp_get_sint, mp_get_mag, 32)
+#if defined(BN_MP_GET_INT32_C) || defined(BN_MP_GET_UINT32_C)
+MP_GET_SIGNED(mp_get_int32, mp_get_mag32, 32)
 #endif
 
-#if defined(BN_MP_GET_SINT64_C) || defined(BN_MP_GET_UINT64_C)
-MP_GET_SIGNED(mp_get_sint64, mp_get_mag64, 64)
+#if defined(BN_MP_GET_INT64_C) || defined(BN_MP_GET_UINT64_C)
+MP_GET_SIGNED(mp_get_int64, mp_get_mag64, 64)
 #endif
 
-#ifdef BN_MP_GET_MAG_C
-MP_GET_MAG(mp_get_mag, 32)
+#ifdef BN_MP_GET_MAG32_C
+MP_GET_MAG(mp_get_mag32, 32)
 #endif
 
 #ifdef BN_MP_GET_MAG64_C
 MP_GET_MAG(mp_get_mag64, 64)
 #endif
 
-#ifdef BN_MP_INIT_UINT_C
-MP_INIT_INT(mp_init_uint, mp_set_uint, uint32_t)
+#ifdef BN_MP_INIT_UINT32_C
+MP_INIT_INT(mp_init_uint32, mp_set_uint32, uint32_t)
 #endif
 
-#ifdef BN_MP_INIT_SINT_C
-MP_INIT_INT(mp_init_sint, mp_set_sint, int32_t)
+#ifdef BN_MP_INIT_INT32_C
+MP_INIT_INT(mp_init_int32, mp_set_int32, int32_t)
 #endif
 
 #endif
diff --git a/bn_deprecated.c b/bn_deprecated.c
index 4be7cc8..bb3d34d 100644
--- a/bn_deprecated.c
+++ b/bn_deprecated.c
@@ -149,13 +149,13 @@ mp_err mp_tc_div_2d(const mp_int *a, int b, mp_int *c)
 #ifdef BN_MP_INIT_SET_INT_C
 mp_err mp_init_set_int(mp_int *a, unsigned long b)
 {
-   return mp_init_uint(a, (uint32_t)b);
+   return mp_init_uint32(a, (uint32_t)b);
 }
 #endif
 #ifdef BN_MP_SET_INT_C
 mp_err mp_set_int(mp_int *a, unsigned long b)
 {
-   mp_set_uint(a, (uint32_t)b);
+   mp_set_uint32(a, (uint32_t)b);
    return MP_OKAY;
 }
 #endif
@@ -176,13 +176,13 @@ mp_err mp_set_long_long(mp_int *a, unsigned long long b)
 #ifdef BN_MP_GET_INT_C
 unsigned long mp_get_int(const mp_int *a)
 {
-   return mp_get_mag(a);
+   return mp_get_mag32(a);
 }
 #endif
 #ifdef BN_MP_GET_LONG_C
 unsigned long mp_get_long(const mp_int *a)
 {
-   return sizeof(long) > sizeof(int32_t) ? (unsigned long)mp_get_mag64(a) : (unsigned long)mp_get_mag(a);
+   return sizeof(long) > sizeof(int32_t) ? (unsigned long)mp_get_mag64(a) : (unsigned long)mp_get_mag32(a);
 }
 #endif
 #ifdef BN_MP_GET_LONG_LONG_C
diff --git a/bn_mp_ilogb.c b/bn_mp_ilogb.c
index 6e189fc..ac972b3 100644
--- a/bn_mp_ilogb.c
+++ b/bn_mp_ilogb.c
@@ -89,7 +89,7 @@ mp_err mp_ilogb(const mp_int *a, mp_digit base, mp_int *c)
       return MP_VAL;
    }
    if (base == 2u) {
-      mp_set_uint(c, (uint32_t)(mp_count_bits(a) - 1));
+      mp_set_uint32(c, (uint32_t)(mp_count_bits(a) - 1));
       return err;
    }
    if (a->used == 1) {
@@ -161,15 +161,15 @@ mp_err mp_ilogb(const mp_int *a, mp_digit base, mp_int *c)
          mp_exch(&bracket_mid, &bracket_low);
       }
       if (cmp == MP_EQ) {
-         mp_set_uint(c, mid);
+         mp_set_uint32(c, mid);
          goto LBL_END;
       }
    }
 
    if (mp_cmp(&bracket_high, a) == MP_EQ) {
-      mp_set_uint(c, high);
+      mp_set_uint32(c, high);
    } else {
-      mp_set_uint(c, low);
+      mp_set_uint32(c, low);
    }
 
 LBL_END:
diff --git a/bn_mp_is_square.c b/bn_mp_is_square.c
index f60f8da..254130c 100644
--- a/bn_mp_is_square.c
+++ b/bn_mp_is_square.c
@@ -58,13 +58,13 @@ mp_err mp_is_square(const mp_int *arg, mp_bool *ret)
    }
 
 
-   if ((err = mp_init_uint(&t, 11L*13L*17L*19L*23L*29L*31L)) != MP_OKAY) {
+   if ((err = mp_init_uint32(&t, 11L*13L*17L*19L*23L*29L*31L)) != MP_OKAY) {
       return err;
    }
    if ((err = mp_mod(arg, &t, &t)) != MP_OKAY) {
       goto LBL_ERR;
    }
-   r = mp_get_uint(&t);
+   r = mp_get_uint32(&t);
    /* Check for other prime modules, note it's not an ERROR but we must
     * free "t" so the easiest way is to goto LBL_ERR.  We know that err
     * is already equal to MP_OKAY from the mp_mod call
diff --git a/bn_mp_prime_frobenius_underwood.c b/bn_mp_prime_frobenius_underwood.c
index d3e325d..fc7c81a 100644
--- a/bn_mp_prime_frobenius_underwood.c
+++ b/bn_mp_prime_frobenius_underwood.c
@@ -43,7 +43,7 @@ mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result)
          continue;
       }
       /* (32764^2 - 4) < 2^31, no bigint for >MP_8BIT needed) */
-      mp_set_uint(&T1z, (uint32_t)a);
+      mp_set_uint32(&T1z, (uint32_t)a);
 
       if ((err = mp_sqr(&T1z, &T1z)) != MP_OKAY) {
          goto LBL_FU_ERR;
@@ -72,7 +72,7 @@ mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result)
       goto LBL_FU_ERR;
    }
    /* Composite if N and (a+4)*(2*a+5) are not coprime */
-   mp_set_uint(&T1z, (uint32_t)((a+4)*((2*a)+5)));
+   mp_set_uint32(&T1z, (uint32_t)((a+4)*((2*a)+5)));
 
    if ((err = mp_gcd(N, &T1z, &T1z)) != MP_OKAY) {
       goto LBL_FU_ERR;
@@ -157,7 +157,7 @@ mp_err mp_prime_frobenius_underwood(const mp_int *N, mp_bool *result)
       }
    }
 
-   mp_set_uint(&T1z, (uint32_t)((2 * a) + 5));
+   mp_set_uint32(&T1z, (uint32_t)((2 * a) + 5));
    if ((err = mp_mod(&T1z, N, &T1z)) != MP_OKAY) {
       goto LBL_FU_ERR;
    }
diff --git a/bn_mp_prime_strong_lucas_selfridge.c b/bn_mp_prime_strong_lucas_selfridge.c
index 5ec39e7..118b08a 100644
--- a/bn_mp_prime_strong_lucas_selfridge.c
+++ b/bn_mp_prime_strong_lucas_selfridge.c
@@ -32,7 +32,7 @@ static mp_err s_mp_mul_si(const mp_int *a, int32_t d, mp_int *c)
     * mp_digit might be smaller than a long, which excludes
     * the use of mp_mul_d() here.
     */
-   mp_set_sint(&t, d);
+   mp_set_int32(&t, d);
    err = mp_mul(a, &t, c);
    mp_clear(&t);
    return err;
@@ -83,7 +83,7 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
    for (;;) {
       Ds   = sign * D;
       sign = -sign;
-      mp_set_uint(&Dz, (uint32_t)D);
+      mp_set_uint32(&Dz, (uint32_t)D);
       if ((err = mp_gcd(a, &Dz, &gcd)) != MP_OKAY) {
          goto LBL_LS_ERR;
       }
@@ -179,23 +179,23 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
 
    if (Q < 0) {
       Q = -Q;
-      mp_set_uint(&Qmz, (uint32_t)Q);
+      mp_set_uint32(&Qmz, (uint32_t)Q);
       if ((err = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) {
          goto LBL_LS_ERR;
       }
       /* Initializes calculation of Q^d */
-      mp_set_uint(&Qkdz, (uint32_t)Q);
+      mp_set_uint32(&Qkdz, (uint32_t)Q);
       Qmz.sign = MP_NEG;
       Q2mz.sign = MP_NEG;
       Qkdz.sign = MP_NEG;
       Q = -Q;
    } else {
-      mp_set_uint(&Qmz, (uint32_t)Q);
+      mp_set_uint32(&Qmz, (uint32_t)Q);
       if ((err = mp_mul_2(&Qmz, &Q2mz)) != MP_OKAY) {
          goto LBL_LS_ERR;
       }
       /* Initializes calculation of Q^d */
-      mp_set_uint(&Qkdz, (uint32_t)Q);
+      mp_set_uint32(&Qkdz, (uint32_t)Q);
    }
 
    Nbits = mp_count_bits(&Dz);
diff --git a/bn_mp_sqrtmod_prime.c b/bn_mp_sqrtmod_prime.c
index bd37813..765c1a4 100644
--- a/bn_mp_sqrtmod_prime.c
+++ b/bn_mp_sqrtmod_prime.c
@@ -59,7 +59,7 @@ mp_err mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret)
    }
 
    /* find a Z such that the Legendre symbol (Z|prime) == -1 */
-   mp_set_uint(&Z, 2uL);
+   mp_set_uint32(&Z, 2uL);
    /* Z = 2 */
    while (1) {
       if ((err = mp_kronecker(&Z, prime, &legendre)) != MP_OKAY)     goto cleanup;
@@ -79,7 +79,7 @@ mp_err mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret)
    /* T = n ^ Q mod prime */
    if ((err = mp_copy(&S, &M)) != MP_OKAY)                       goto cleanup;
    /* M = S */
-   mp_set_uint(&two, 2uL);
+   mp_set_uint32(&two, 2uL);
 
    while (1) {
       if ((err = mp_copy(&T, &t1)) != MP_OKAY)                    goto cleanup;
diff --git a/demo/test.c b/demo/test.c
index f6ff0c5..c2f5c81 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -89,29 +89,29 @@ static int test_trivial_stuff(void)
    if (mp_isneg(&b) != MP_YES) {
       goto LBL_ERR;
    }
-   if (mp_get_sint(&b) != -4) {
+   if (mp_get_int32(&b) != -4) {
       goto LBL_ERR;
    }
-   if (mp_get_uint(&b) != (uint32_t)-4) {
+   if (mp_get_uint32(&b) != (uint32_t)-4) {
       goto LBL_ERR;
    }
-   if (mp_get_mag(&b) != 4) {
+   if (mp_get_mag32(&b) != 4) {
       goto LBL_ERR;
    }
    /* a: -5-> b: 1 */
    mp_add_d(&a, 6uL, &b);
-   if (mp_get_uint(&b) != 1) {
+   if (mp_get_uint32(&b) != 1) {
       goto LBL_ERR;
    }
    /* a: -5-> a: 1 */
    mp_add_d(&a, 6uL, &a);
-   if (mp_get_uint(&a) != 1) {
+   if (mp_get_uint32(&a) != 1) {
       goto LBL_ERR;
    }
    mp_zero(&a);
    /* a: 0-> a: 6 */
    mp_add_d(&a, 6uL, &a);
-   if (mp_get_uint(&a) != 6) {
+   if (mp_get_uint32(&a) != 6) {
       goto LBL_ERR;
    }
 
@@ -137,19 +137,19 @@ LBL_ERR:
 
 static int check_get_set_int32(mp_int *a, int32_t b)
 {
-   mp_set_sint(a, b);
-   if (mp_get_sint(a) != b) return EXIT_FAILURE;
-   if (mp_get_uint(a) != (uint32_t)b) return EXIT_FAILURE;
-   if (mp_get_mag(a) != uabs32(b)) return EXIT_FAILURE;
+   mp_set_int32(a, b);
+   if (mp_get_int32(a) != b) return EXIT_FAILURE;
+   if (mp_get_uint32(a) != (uint32_t)b) return EXIT_FAILURE;
+   if (mp_get_mag32(a) != uabs32(b)) return EXIT_FAILURE;
 
-   mp_set_uint(a, (uint32_t)b);
-   if (mp_get_uint(a) != (uint32_t)b) return EXIT_FAILURE;
-   if (mp_get_sint(a) != (int32_t)(uint32_t)b) return EXIT_FAILURE;
+   mp_set_uint32(a, (uint32_t)b);
+   if (mp_get_uint32(a) != (uint32_t)b) return EXIT_FAILURE;
+   if (mp_get_int32(a) != (int32_t)(uint32_t)b) return EXIT_FAILURE;
 
    return EXIT_SUCCESS;
 }
 
-static int test_mp_get_set_int(void)
+static int test_mp_get_set_int32(void)
 {
    int i;
    mp_int a;
@@ -180,14 +180,14 @@ LBL_ERR:
 
 static int check_get_set_int64(mp_int *a, int64_t b)
 {
-   mp_set_sint64(a, b);
-   if (mp_get_sint64(a) != b) return EXIT_FAILURE;
+   mp_set_int64(a, b);
+   if (mp_get_int64(a) != b) return EXIT_FAILURE;
    if (mp_get_uint64(a) != (uint64_t)b) return EXIT_FAILURE;
    if (mp_get_mag64(a) != uabs64(b)) return EXIT_FAILURE;
 
    mp_set_uint64(a, (uint64_t)b);
    if (mp_get_uint64(a) != (uint64_t)b) return EXIT_FAILURE;
-   if (mp_get_sint64(a) != (int64_t)(uint64_t)b) return EXIT_FAILURE;
+   if (mp_get_int64(a) != (int64_t)(uint64_t)b) return EXIT_FAILURE;
 
    return EXIT_SUCCESS;
 }
@@ -239,7 +239,7 @@ static int test_mp_fread_fwrite(void)
    if ((e = mp_fread(&b, 64, tmp)) != MP_OKAY) {
       goto LBL_ERR;
    }
-   if (mp_get_uint(&b) != 123456uL) {
+   if (mp_get_uint32(&b) != 123456uL) {
       goto LBL_ERR;
    }
    fclose(tmp);
@@ -732,7 +732,7 @@ LBL_ERR:
 
 }
 
-static int test_mp_get_uint(void)
+static int test_mp_get_uint32(void)
 {
    unsigned long t;
    int i;
@@ -745,19 +745,19 @@ static int test_mp_get_uint(void)
    for (i = 0; i < 1000; ++i) {
       t = (unsigned long)rand_long() & 0xFFFFFFFFuL;
       mp_set_ulong(&a, t);
-      if (t != mp_get_uint(&a)) {
-         printf("\nmp_get_uint() bad result!");
+      if (t != mp_get_uint32(&a)) {
+         printf("\nmp_get_uint32() bad result!");
          goto LBL_ERR;
       }
    }
    mp_set_ulong(&a, 0uL);
-   if (mp_get_uint(&a) != 0) {
-      printf("\nmp_get_uint() bad result!");
+   if (mp_get_uint32(&a) != 0) {
+      printf("\nmp_get_uint32() bad result!");
       goto LBL_ERR;
    }
    mp_set_ulong(&a, 0xFFFFFFFFuL);
-   if (mp_get_uint(&a) != 0xFFFFFFFFuL) {
-      printf("\nmp_get_uint() bad result!");
+   if (mp_get_uint32(&a) != 0xFFFFFFFFuL) {
+      printf("\nmp_get_uint32() bad result!");
       goto LBL_ERR;
    }
 
@@ -2143,7 +2143,7 @@ int unit_tests(int argc, char **argv)
    } test[] = {
 #define T(n) { #n, test_##n }
       T(trivial_stuff),
-      T(mp_get_set_int),
+      T(mp_get_set_int32),
       T(mp_get_set_int64),
       T(mp_and),
       T(mp_cnt_lsb),
@@ -2152,7 +2152,7 @@ int unit_tests(int argc, char **argv)
       T(mp_div_3),
       T(mp_dr_reduce),
       T(mp_fread_fwrite),
-      T(mp_get_uint),
+      T(mp_get_uint32),
       T(mp_get_uint64),
       T(mp_get_ulong),
       T(mp_ilogb),
diff --git a/doc/bn.tex b/doc/bn.tex
index 5b0584a..c9d6b56 100644
--- a/doc/bn.tex
+++ b/doc/bn.tex
@@ -824,11 +824,11 @@ int main(void)
 
 These functions can be used to set a constant with 32 or 64 bits.
 
-\index{mp\_set\_sint}
+\index{mp\_set\_int}
 \begin{alltt}
-void mp_set_sint (mp_int * a, int32_t b);
-void mp_set_uint (mp_int * a, uint32_t b);
-void mp_set_sint64 (mp_int * a, int64_t b);
+void mp_set_int32 (mp_int * a, int32_t b);
+void mp_set_uint32 (mp_int * a, uint32_t b);
+void mp_set_int64 (mp_int * a, int64_t b);
 void mp_set_uint64 (mp_int * a, uint64_t b);
 \end{alltt}
 
@@ -837,10 +837,10 @@ The value can be obtained again by calling the following functions.
 
 \index{mp\_get\_int}
 \begin{alltt}
-int32_t mp_get_sint (mp_int * a);
-uint32_t mp_get_uint (mp_int * a);
-uint32_t mp_get_mag (mp_int * a);
-int64_t mp_get_sint64 (mp_int * a);
+int32_t mp_get_int32 (mp_int * a);
+uint32_t mp_get_uint32 (mp_int * a);
+uint32_t mp_get_mag32 (mp_int * a);
+int64_t mp_get_int64 (mp_int * a);
 uint64_t mp_get_uint64 (mp_int * a);
 uint64_t mp_get_mag64 (mp_int * a);
 \end{alltt}
@@ -903,8 +903,8 @@ To both initialize and set small constants the following two functions are avail
 \index{mp\_init\_set} \index{mp\_init\_set\_int}
 \begin{alltt}
 int mp_init_set (mp_int * a, mp_digit b);
-int mp_init_set_sint (mp_int * a, int32_t b);
-int mp_init_set_uint (mp_int * a, uint32_t b);
+int mp_init_set_int32 (mp_int * a, int32_t b);
+int mp_init_set_uint32 (mp_int * a, uint32_t b);
 \end{alltt}
 
 Both functions work like the previous counterparts except they first mp\_init $a$ before setting the values.
diff --git a/tommath.h b/tommath.h
index 044aea6..ba10fef 100644
--- a/tommath.h
+++ b/tommath.h
@@ -275,48 +275,48 @@ double mp_get_double(const mp_int *a) MP_WUR;
 mp_err mp_set_double(mp_int *a, double b) MP_WUR;
 
 /* get integer, set integer and init with integer (int32_t) */
-int32_t mp_get_sint(const mp_int *a) MP_WUR;
-void mp_set_sint(mp_int *a, int32_t b);
-mp_err mp_init_sint(mp_int *a, int32_t b) MP_WUR;
+int32_t mp_get_int32(const mp_int *a) MP_WUR;
+void mp_set_int32(mp_int *a, int32_t b);
+mp_err mp_init_int32(mp_int *a, int32_t b) MP_WUR;
 
 /* get integer, set integer and init with integer, behaves like two complement for negative numbers (uint32_t) */
-#define mp_get_uint(a) ((uint32_t)mp_get_sint(a))
-void mp_set_uint(mp_int *a, uint32_t b);
-mp_err mp_init_uint(mp_int *a, uint32_t b) MP_WUR;
+#define mp_get_uint32(a) ((uint32_t)mp_get_int32(a))
+void mp_set_uint32(mp_int *a, uint32_t b);
+mp_err mp_init_uint32(mp_int *a, uint32_t b) MP_WUR;
 
 /* get integer, set integer and init with integer (int64_t) */
-int64_t mp_get_sint64(const mp_int *a) MP_WUR;
-void mp_set_sint64(mp_int *a, int64_t b);
+int64_t mp_get_int64(const mp_int *a) MP_WUR;
+void mp_set_int64(mp_int *a, int64_t b);
 
 /* get integer, set integer and init with integer, behaves like two complement for negative numbers (uint64_t) */
-#define mp_get_uint64(a) ((uint64_t)mp_get_sint64(a))
+#define mp_get_uint64(a) ((uint64_t)mp_get_int64(a))
 void mp_set_uint64(mp_int *a, uint64_t b);
 
 /* get magnitude */
-uint32_t mp_get_mag(const mp_int *a) MP_WUR;
+uint32_t mp_get_mag32(const mp_int *a) MP_WUR;
 uint64_t mp_get_mag64(const mp_int *a) MP_WUR;
 
 /* get integer, set integer (long) */
-#define mp_get_slong(a)        (sizeof (long) == 8 ? (long)mp_get_sint64(a) : (long)mp_get_sint(a))
-#define mp_set_llong(a, b)     (sizeof (long) == 8 ? mp_set_sint64((a), (b)) : mp_set_sint((a), (int32_t)(b)))
+#define mp_get_slong(a)        (sizeof (long) == 8 ? (long)mp_get_int64(a) : (long)mp_get_int32(a))
+#define mp_set_slong(a, b)     (sizeof (long) == 8 ? mp_set_int64((a), (b)) : mp_set_int32((a), (int32_t)(b)))
 
 /* get integer, set integer (unsigned long) */
-#define mp_get_ulong(a)       (sizeof (long) == 8 ? (unsigned long)mp_get_uint64(a) : (unsigned long)mp_get_uint(a))
-#define mp_get_maglong(a)     (sizeof (long) == 8 ? (unsigned long)mp_get_mag64(a) : (unsigned long)mp_get_mag(a))
-#define mp_set_ulong(a, b)    (sizeof (long) == 8 ? mp_set_uint64((a), (b)) : mp_set_uint((a), (uint32_t)(b)))
+#define mp_get_ulong(a)       (sizeof (long) == 8 ? (unsigned long)mp_get_uint64(a) : (unsigned long)mp_get_uint32(a))
+#define mp_set_ulong(a, b)    (sizeof (long) == 8 ? mp_set_uint64((a), (b)) : mp_set_uint32((a), (uint32_t)(b)))
+#define mp_get_mag_long(a)    (sizeof (long) == 8 ? (unsigned long)mp_get_mag64(a) : (unsigned long)mp_get_mag32(a))
 
 /* set to single unsigned digit, up to MP_DIGIT_MAX */
 void mp_set(mp_int *a, mp_digit b);
 mp_err mp_init_set(mp_int *a, mp_digit b) MP_WUR;
 
 /* get integer, set integer and init with integer (deprecated) */
-MP_DEPRECATED(mp_get_mag/mp_get_uint) unsigned long mp_get_int(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_get_magl/mp_get_ulong) unsigned long mp_get_long(const mp_int *a) MP_WUR;
+MP_DEPRECATED(mp_get_mag32/mp_get_uint32) unsigned long mp_get_int(const mp_int *a) MP_WUR;
+MP_DEPRECATED(mp_get_mag_long/mp_get_ulong) unsigned long mp_get_long(const mp_int *a) MP_WUR;
 MP_DEPRECATED(mp_get_mag64/mp_get_uint64) unsigned long long mp_get_long_long(const mp_int *a) MP_WUR;
-MP_DEPRECATED(mp_set_uint) mp_err mp_set_int(mp_int *a, unsigned long b);
+MP_DEPRECATED(mp_set_uint32) mp_err mp_set_int(mp_int *a, unsigned long b);
 MP_DEPRECATED(mp_set_ulong) mp_err mp_set_long(mp_int *a, unsigned long b);
 MP_DEPRECATED(mp_set_uint64) mp_err mp_set_long_long(mp_int *a, unsigned long long b);
-MP_DEPRECATED(mp_init_uint) mp_err mp_init_set_int(mp_int *a, unsigned long b) MP_WUR;
+MP_DEPRECATED(mp_init_uint32) mp_err mp_init_set_int(mp_int *a, unsigned long b) MP_WUR;
 
 /* copy, b = a */
 mp_err mp_copy(const mp_int *a, mp_int *b) MP_WUR;
diff --git a/tommath_class.h b/tommath_class.h
index ce74471..3c03d21 100644
--- a/tommath_class.h
+++ b/tommath_class.h
@@ -151,16 +151,16 @@
 #endif
 #if defined(BN_CONVERSION_C)
 #   define BN_MP_INIT_C
-#   define BN_MP_SET_UINT_C
+#   define BN_MP_SET_UINT32_C
 #   define BN_MP_SET_UINT64_C
-#   define BN_MP_SET_SINT_C
-#   define BN_MP_SET_SINT64_C
-#   define BN_MP_GET_SINT_C
-#   define BN_MP_GET_SINT64_C
-#   define BN_MP_GET_MAG_C
+#   define BN_MP_SET_INT32_C
+#   define BN_MP_SET_INT64_C
+#   define BN_MP_GET_INT32_C
+#   define BN_MP_GET_INT64_C
+#   define BN_MP_GET_MAG32_C
 #   define BN_MP_GET_MAG64_C
-#   define BN_MP_INIT_UINT_C
-#   define BN_MP_INIT_SINT_C
+#   define BN_MP_INIT_UINT32_C
+#   define BN_MP_INIT_INT32_C
 #endif
 
 #if defined(BN_CUTOFFS_C)
@@ -211,14 +211,14 @@
 #   define BN_MP_TC_DIV_2D_C
 #   define BN_MP_SIGNED_RSH_C
 #   define BN_MP_INIT_SET_INT_C
-#   define BN_MP_INIT_UINT_C
+#   define BN_MP_INIT_UINT32_C
 #   define BN_MP_SET_INT_C
-#   define BN_MP_SET_UINT_C
+#   define BN_MP_SET_UINT32_C
 #   define BN_MP_SET_LONG_C
 #   define BN_MP_SET_UINT64_C
 #   define BN_MP_SET_LONG_LONG_C
 #   define BN_MP_GET_INT_C
-#   define BN_MP_GET_MAG_C
+#   define BN_MP_GET_MAG32_C
 #   define BN_MP_GET_LONG_C
 #   define BN_MP_GET_MAG64_C
 #   define BN_MP_GET_LONG_LONG_C
@@ -447,7 +447,7 @@
 #endif
 
 #if defined(BN_MP_ILOGB_C)
-#   define BN_MP_SET_UINT_C
+#   define BN_MP_SET_UINT32_C
 #   define BN_MP_COUNT_BITS_C
 #   define BN_MP_SET_C
 #   define BN_MP_CMP_D_C
@@ -504,9 +504,9 @@
 
 #if defined(BN_MP_IS_SQUARE_C)
 #   define BN_MP_MOD_D_C
-#   define BN_MP_INIT_UINT_C
+#   define BN_MP_INIT_UINT32_C
 #   define BN_MP_MOD_C
-#   define BN_MP_GET_UINT_C
+#   define BN_MP_GET_UINT32_C
 #   define BN_MP_SQRT_C
 #   define BN_MP_SQR_C
 #   define BN_MP_CMP_MAG_C
@@ -653,7 +653,7 @@
 
 #if defined(BN_MP_PRIME_FROBENIUS_UNDERWOOD_C)
 #   define BN_MP_INIT_MULTI_C
-#   define BN_MP_SET_UINT_C
+#   define BN_MP_SET_UINT32_C
 #   define BN_MP_SQR_C
 #   define BN_MP_SUB_D_C
 #   define BN_MP_KRONECKER_C
@@ -735,11 +735,11 @@
 #if defined(BN_MP_PRIME_STRONG_LUCAS_SELFRIDGE_C)
 #   define BN_S_MP_MUL_SI_C
 #   define BN_MP_INIT_C
-#   define BN_MP_SET_SINT_C
+#   define BN_MP_SET_INT32_C
 #   define BN_MP_MUL_C
 #   define BN_MP_CLEAR_C
 #   define BN_MP_INIT_MULTI_C
-#   define BN_MP_SET_UINT_C
+#   define BN_MP_SET_UINT32_C
 #   define BN_MP_GCD_C
 #   define BN_MP_CMP_D_C
 #   define BN_MP_CMP_C
@@ -925,7 +925,7 @@
 #   define BN_MP_EXPTMOD_C
 #   define BN_MP_COPY_C
 #   define BN_MP_SUB_D_C
-#   define BN_MP_SET_UINT_C
+#   define BN_MP_SET_UINT32_C
 #   define BN_MP_SQRMOD_C
 #   define BN_MP_MULMOD_C
 #   define BN_MP_SET_C