deprecate LTM_PRIME_* macros in favor of MP_PRIME_*
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
diff --git a/bn_mp_prime_random_ex.c b/bn_mp_prime_random_ex.c
index 360a091..146f4ff 100644
--- a/bn_mp_prime_random_ex.c
+++ b/bn_mp_prime_random_ex.c
@@ -7,9 +7,9 @@
*
* Flags are as follows:
*
- * LTM_PRIME_BBS - make prime congruent to 3 mod 4
- * LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS)
- * LTM_PRIME_2MSB_ON - make the 2nd highest bit one
+ * MP_PRIME_BBS - make prime congruent to 3 mod 4
+ * MP_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies MP_PRIME_BBS)
+ * MP_PRIME_2MSB_ON - make the 2nd highest bit one
*
* You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
* have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself
@@ -28,9 +28,9 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, mp_prime_callback
return MP_VAL;
}
- /* LTM_PRIME_SAFE implies LTM_PRIME_BBS */
- if ((flags & LTM_PRIME_SAFE) != 0) {
- flags |= LTM_PRIME_BBS;
+ /* MP_PRIME_SAFE implies MP_PRIME_BBS */
+ if ((flags & MP_PRIME_SAFE) != 0) {
+ flags |= MP_PRIME_BBS;
}
/* calc the byte size */
@@ -48,13 +48,13 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, mp_prime_callback
/* calc the maskOR_msb */
maskOR_msb = 0;
maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0;
- if ((flags & LTM_PRIME_2MSB_ON) != 0) {
+ if ((flags & MP_PRIME_2MSB_ON) != 0) {
maskOR_msb |= (unsigned char)(0x80 >> ((9 - size) & 7));
}
/* get the maskOR_lsb */
maskOR_lsb = 1;
- if ((flags & LTM_PRIME_BBS) != 0) {
+ if ((flags & MP_PRIME_BBS) != 0) {
maskOR_lsb |= 3;
}
@@ -86,7 +86,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, mp_prime_callback
continue;
}
- if ((flags & LTM_PRIME_SAFE) != 0) {
+ if ((flags & MP_PRIME_SAFE) != 0) {
/* see if (a-1)/2 is prime */
if ((err = mp_sub_d(a, 1uL, a)) != MP_OKAY) {
goto error;
@@ -102,7 +102,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, mp_prime_callback
}
} while (res == MP_NO);
- if ((flags & LTM_PRIME_SAFE) != 0) {
+ if ((flags & MP_PRIME_SAFE) != 0) {
/* restore a to the original value */
if ((err = mp_mul_2(a, a)) != MP_OKAY) {
goto error;
diff --git a/demo/test.c b/demo/test.c
index 9c71d5b..c72c493 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -782,7 +782,7 @@ static int test_mp_prime_random_ex(void)
printf("Testing (not safe-prime): %9d bits \r", ix);
fflush(stdout);
err = mp_prime_random_ex(&a, 8, ix,
- (rand() & 1) ? 0 : LTM_PRIME_2MSB_ON, myrng,
+ (rand() & 1) ? 0 : MP_PRIME_2MSB_ON, myrng,
NULL);
if (err != MP_OKAY) {
printf("\nfailed with error: %s\n", mp_error_to_string(err));
@@ -845,7 +845,7 @@ static int test_mp_prime_is_prime(void)
printf("Testing ( safe-prime): %9d bits \r", ix);
fflush(stdout);
err = mp_prime_random_ex(
- &a, 8, ix, ((rand() & 1) ? 0 : LTM_PRIME_2MSB_ON) | LTM_PRIME_SAFE,
+ &a, 8, ix, ((rand() & 1) ? 0 : MP_PRIME_2MSB_ON) | MP_PRIME_SAFE,
myrng, NULL);
if (err != MP_OKAY) {
printf("\nfailed with error: %s\n", mp_error_to_string(err));
diff --git a/tommath.h b/tommath.h
index ffd1a46..66bc269 100644
--- a/tommath.h
+++ b/tommath.h
@@ -115,9 +115,13 @@ typedef uint64_t mp_word;
#define MP_NO 0 /* no response */
/* Primality generation flags */
-#define LTM_PRIME_BBS 0x0001 /* BBS style prime */
-#define LTM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */
-#define LTM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */
+#define MP_PRIME_BBS 0x0001 /* BBS style prime */
+#define MP_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */
+#define MP_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */
+
+#define LTM_PRIME_BBS (MP_DEPRECATED_PRAGMA("LTM_PRIME_BBS has been deprecated, use MP_PRIME_BBS") MP_PRIME_BBS)
+#define LTM_PRIME_SAFE (MP_DEPRECATED_PRAGMA("LTM_PRIME_SAFE has been deprecated, use MP_PRIME_SAFE") MP_PRIME_SAFE)
+#define LTM_PRIME_2MSB_ON (MP_DEPRECATED_PRAGMA("LTM_PRIME_2MSB_ON has been deprecated, use MP_PRIME_2MSB_ON") MP_PRIME_2MSB_ON)
typedef int mp_err;
@@ -576,15 +580,15 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style);
*
* The prime generated will be larger than 2^(8*size).
*/
-#define mp_prime_random(a, t, size, bbs, cb, dat) mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?LTM_PRIME_BBS:0, cb, dat)
+#define mp_prime_random(a, t, size, bbs, cb, dat) mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?MP_PRIME_BBS:0, cb, dat)
/* makes a truly random prime of a given size (bits),
*
* Flags are as follows:
*
- * LTM_PRIME_BBS - make prime congruent to 3 mod 4
- * LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS)
- * LTM_PRIME_2MSB_ON - make the 2nd highest bit one
+ * MP_PRIME_BBS - make prime congruent to 3 mod 4
+ * MP_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies MP_PRIME_BBS)
+ * MP_PRIME_2MSB_ON - make the 2nd highest bit one
*
* You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
* have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself