@@ -75,11 +75,23 @@ static int dsa_make_params(prng_state *prng, int wprng, int group_size, int modu
7575 L = modulus_size * 8 ;
7676 N = group_size * 8 ;
7777
78+ /* XXX-TODO no Lucas test */
79+ #ifdef LTC_MPI_HAS_LUCAS_TEST
7880 /* M-R tests (when followed by one Lucas test) according FIPS-186-4 - Appendix C.3 - table C.1 */
7981 mr_tests_p = (L <= 2048 ) ? 3 : 2 ;
8082 if (N <= 160 ) { mr_tests_q = 19 ; }
8183 else if (N <= 224 ) { mr_tests_q = 24 ; }
8284 else { mr_tests_q = 27 ; }
85+ #else
86+ /* M-R tests (without Lucas test) according FIPS-186-4 - Appendix C.3 - table C.1 */
87+ if (L <= 1024 ) { mr_tests_p = 40 ; }
88+ else if (L <= 2048 ) { mr_tests_p = 56 ; }
89+ else { mr_tests_p = 64 ; }
90+
91+ if (N <= 160 ) { mr_tests_q = 40 ; }
92+ else if (N <= 224 ) { mr_tests_q = 56 ; }
93+ else { mr_tests_q = 64 ; }
94+ #endif
8395
8496 if (N <= 256 ) {
8597 hash = register_hash (& sha256_desc );
@@ -122,7 +134,7 @@ static int dsa_make_params(prng_state *prng, int wprng, int group_size, int modu
122134 if ((err = mp_mod (U , t2N1 , U )) != CRYPT_OK ) { goto cleanup ; }
123135 if ((err = mp_add (t2N1 , U , q )) != CRYPT_OK ) { goto cleanup ; }
124136 if (!mp_isodd (q )) mp_add_d (q , 1 , q );
125- if ((err = mp_prime_is_prime (q , mr_tests_q , & res )) != CRYPT_OK ) { goto cleanup ; } /* XXX-TODO rounds are ignored; no Lucas test */
137+ if ((err = mp_prime_is_prime (q , mr_tests_q , & res )) != CRYPT_OK ) { goto cleanup ; }
126138 if (res == LTC_MP_YES ) found_q = 1 ;
127139 }
128140
@@ -149,7 +161,7 @@ static int dsa_make_params(prng_state *prng, int wprng, int group_size, int modu
149161 if ((err = mp_sub (X , p , p )) != CRYPT_OK ) { goto cleanup ; }
150162 if (mp_cmp (p , t2L1 ) != LTC_MP_LT ) {
151163 /* p >= 2^(L-1) */
152- if ((err = mp_prime_is_prime (p , mr_tests_p , & res )) != CRYPT_OK ) { goto cleanup ; } /* XXX-TODO rounds are ignored; no Lucas test */
164+ if ((err = mp_prime_is_prime (p , mr_tests_p , & res )) != CRYPT_OK ) { goto cleanup ; }
153165 if (res == LTC_MP_YES ) {
154166 found_p = 1 ;
155167 }
0 commit comments