1
$\begingroup$

I've been implementing RSA as a learning exercise and am at a point now where I'd like to try serializing my key to a file using some standard format. I've implemented it without using the Chinese Remainder Theorem, so my private key is composed only of my modulus $n=pq$ and my modular inverse exponent $d$. I've seen that PKCS1 & PKCS8 expect the use of the Chinese Remainder theorem. I know that I could simply derive these values, but is there any standard format where I can encode only my $n$ and $d$ without deriving the values for CRT implementations?

$\endgroup$

1 Answer 1

1
$\begingroup$

is there any standard format where I can encode only my n and d without deriving the values for CRT implementations?

Actually, for the standard PKCS #1 private key format, the CRT parameters are optional. As you can read in the linked text, one of the options is that the private key just stores $n$ and $d$.

$\endgroup$
2
  • 1
    $\begingroup$ 3.2 defines abstract representation(s) not directly serializable; A.1.2 defines ASN.1 that is serializable and requires CRT (except the 'multi-prime' part is optional). OTOH JOSE/JWK makes the CRT fields 'should' -- recommended but not required. OpenPGP contains p,q but not dp,dq and pinv instead of qinv -- always. PKCS11 transfers each field separately on the API but the supported and required fields (beyond n,e,d) are up to the 'token' i.e. device or instance. $\endgroup$ Dec 21, 2022 at 0:56
  • $\begingroup$ @dave_thompson_085: I remember a version of the PKCS #1 private key format with only the n, e, d fields (just omitting the others). However, all the references I now check have the CRT parameters mandatory... $\endgroup$
    – poncho
    Dec 21, 2022 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.