I'm trying to create this gimmicky public-private RSA key pair where p and q are the same number. I would want to use the asn1 parser in OpenSSL, but I'm required to specify the coeff parameter, the multiplicative inverse for q with modulo p. This number does not exist when p and q are equal. Is there a way I could make OpenSSL generate the key for me without specifying this undefinable parameter?

pubExp=INTEGER:[some public exponent]
coeff=INTEGER:[this number does not exist]
  • I’m not sure if you mean it’s undefinable because it’s incalculable or you just don’t know how to calculate it. I’m not really familiar with the math except that the functions are implemented in the plumbing code for OpenSSL. If it’s incalculable you won’t be able to generate a key because you can’t calculate the value. – nbering Jan 30 '19 at 22:50
  • I think the RSA operations are mathematically sound and the q^-1 (mod p) is incalculable at the same time in this very special case when p equals q. I don't see why they wouldn't be. – Magnus Jan 30 '19 at 22:54
  • If the math checks out for the RSA algorithm bug the coefficient field is still incalculable, then you can’t generate a standards-compliant PKCS#1 Private Key file. tools.ietf.org/html/rfc8017#appendix-A.1.2 Interestingly... you may still be able to generate a PGP key file. tools.ietf.org/html/rfc4880#section-5.5.3 – nbering Jan 30 '19 at 23:07
  • If you'll take Java instead, it can handle(?) RSA with bogus n and no CRT; see my answer at crypto.stackexchange.com/questions/66258/… for single-prime whereas you want a prime squared so adjust the mod for e^-1 accordingly. @nbering: PGP doesn't store d mod p and d mod q, but p^-1 mod q has exactly the same problem in this (bogus) case as q^-1 mod p. – dave_thompson_085 Jan 31 '19 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.