diff options
Diffstat (limited to 'moduli.c')
-rw-r--r-- | moduli.c | 48 |
1 files changed, 24 insertions, 24 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: moduli.c,v 1.8 2004/05/21 08:43:03 markus Exp $ */ | 1 | /* $OpenBSD: moduli.c,v 1.9 2004/07/11 17:48:47 deraadt Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright 1994 Phil Karn <karn@qualcomm.com> | 3 | * Copyright 1994 Phil Karn <karn@qualcomm.com> |
4 | * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com> | 4 | * Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com> |
@@ -48,68 +48,68 @@ | |||
48 | */ | 48 | */ |
49 | 49 | ||
50 | /* need line long enough for largest moduli plus headers */ | 50 | /* need line long enough for largest moduli plus headers */ |
51 | #define QLINESIZE (100+8192) | 51 | #define QLINESIZE (100+8192) |
52 | 52 | ||
53 | /* Type: decimal. | 53 | /* Type: decimal. |
54 | * Specifies the internal structure of the prime modulus. | 54 | * Specifies the internal structure of the prime modulus. |
55 | */ | 55 | */ |
56 | #define QTYPE_UNKNOWN (0) | 56 | #define QTYPE_UNKNOWN (0) |
57 | #define QTYPE_UNSTRUCTURED (1) | 57 | #define QTYPE_UNSTRUCTURED (1) |
58 | #define QTYPE_SAFE (2) | 58 | #define QTYPE_SAFE (2) |
59 | #define QTYPE_SCHNOOR (3) | 59 | #define QTYPE_SCHNOOR (3) |
60 | #define QTYPE_SOPHIE_GERMAIN (4) | 60 | #define QTYPE_SOPHIE_GERMAIN (4) |
61 | #define QTYPE_STRONG (5) | 61 | #define QTYPE_STRONG (5) |
62 | 62 | ||
63 | /* Tests: decimal (bit field). | 63 | /* Tests: decimal (bit field). |
64 | * Specifies the methods used in checking for primality. | 64 | * Specifies the methods used in checking for primality. |
65 | * Usually, more than one test is used. | 65 | * Usually, more than one test is used. |
66 | */ | 66 | */ |
67 | #define QTEST_UNTESTED (0x00) | 67 | #define QTEST_UNTESTED (0x00) |
68 | #define QTEST_COMPOSITE (0x01) | 68 | #define QTEST_COMPOSITE (0x01) |
69 | #define QTEST_SIEVE (0x02) | 69 | #define QTEST_SIEVE (0x02) |
70 | #define QTEST_MILLER_RABIN (0x04) | 70 | #define QTEST_MILLER_RABIN (0x04) |
71 | #define QTEST_JACOBI (0x08) | 71 | #define QTEST_JACOBI (0x08) |
72 | #define QTEST_ELLIPTIC (0x10) | 72 | #define QTEST_ELLIPTIC (0x10) |
73 | 73 | ||
74 | /* | 74 | /* |
75 | * Size: decimal. | 75 | * Size: decimal. |
76 | * Specifies the number of the most significant bit (0 to M). | 76 | * Specifies the number of the most significant bit (0 to M). |
77 | * WARNING: internally, usually 1 to N. | 77 | * WARNING: internally, usually 1 to N. |
78 | */ | 78 | */ |
79 | #define QSIZE_MINIMUM (511) | 79 | #define QSIZE_MINIMUM (511) |
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Prime sieving defines | 82 | * Prime sieving defines |
83 | */ | 83 | */ |
84 | 84 | ||
85 | /* Constant: assuming 8 bit bytes and 32 bit words */ | 85 | /* Constant: assuming 8 bit bytes and 32 bit words */ |
86 | #define SHIFT_BIT (3) | 86 | #define SHIFT_BIT (3) |
87 | #define SHIFT_BYTE (2) | 87 | #define SHIFT_BYTE (2) |
88 | #define SHIFT_WORD (SHIFT_BIT+SHIFT_BYTE) | 88 | #define SHIFT_WORD (SHIFT_BIT+SHIFT_BYTE) |
89 | #define SHIFT_MEGABYTE (20) | 89 | #define SHIFT_MEGABYTE (20) |
90 | #define SHIFT_MEGAWORD (SHIFT_MEGABYTE-SHIFT_BYTE) | 90 | #define SHIFT_MEGAWORD (SHIFT_MEGABYTE-SHIFT_BYTE) |
91 | 91 | ||
92 | /* | 92 | /* |
93 | * Using virtual memory can cause thrashing. This should be the largest | 93 | * Using virtual memory can cause thrashing. This should be the largest |
94 | * number that is supported without a large amount of disk activity -- | 94 | * number that is supported without a large amount of disk activity -- |
95 | * that would increase the run time from hours to days or weeks! | 95 | * that would increase the run time from hours to days or weeks! |
96 | */ | 96 | */ |
97 | #define LARGE_MINIMUM (8UL) /* megabytes */ | 97 | #define LARGE_MINIMUM (8UL) /* megabytes */ |
98 | 98 | ||
99 | /* | 99 | /* |
100 | * Do not increase this number beyond the unsigned integer bit size. | 100 | * Do not increase this number beyond the unsigned integer bit size. |
101 | * Due to a multiple of 4, it must be LESS than 128 (yielding 2**30 bits). | 101 | * Due to a multiple of 4, it must be LESS than 128 (yielding 2**30 bits). |
102 | */ | 102 | */ |
103 | #define LARGE_MAXIMUM (127UL) /* megabytes */ | 103 | #define LARGE_MAXIMUM (127UL) /* megabytes */ |
104 | 104 | ||
105 | /* | 105 | /* |
106 | * Constant: when used with 32-bit integers, the largest sieve prime | 106 | * Constant: when used with 32-bit integers, the largest sieve prime |
107 | * has to be less than 2**32. | 107 | * has to be less than 2**32. |
108 | */ | 108 | */ |
109 | #define SMALL_MAXIMUM (0xffffffffUL) | 109 | #define SMALL_MAXIMUM (0xffffffffUL) |
110 | 110 | ||
111 | /* Constant: can sieve all primes less than 2**32, as 65537**2 > 2**32-1. */ | 111 | /* Constant: can sieve all primes less than 2**32, as 65537**2 > 2**32-1. */ |
112 | #define TINY_NUMBER (1UL<<16) | 112 | #define TINY_NUMBER (1UL<<16) |
113 | 113 | ||
114 | /* Ensure enough bit space for testing 2*q. */ | 114 | /* Ensure enough bit space for testing 2*q. */ |
115 | #define TEST_MAXIMUM (1UL<<16) | 115 | #define TEST_MAXIMUM (1UL<<16) |