- /* Test that the modulus is really prime */
- if (mpz_probab_prime_p(&st->p,5)==0) {
- cfgfatal(loc,"diffie-hellman","modulus must be a prime\n");
+ i=list_elem(args,2);
+ if (i && i->type==t_bool && i->data.bool==False) {
+ Message(M_INFO,"diffie-hellman (%s:%d): skipping modulus "
+ "primality check\n",loc.file,loc.line);
+ } else {
+ /* Test that the modulus is really prime */
+ if (mpz_probab_prime_p(&st->p,5)==0) {
+ cfgfatal(loc,"diffie-hellman","modulus must be a prime\n");
+ }
+ }
+
+ size_t sz=mpz_sizeinbase(&st->p,2)/8;
+ if (sz>INT_MAX) {
+ cfgfatal(loc,"diffie-hellman","modulus far too large\n");
+ }
+ if (mpz_cmp(&st->g,&st->p) >= 0) {
+ cfgfatal(loc,"diffie-hellman","generator must be less than modulus\n");