Next: DSA key parameters, Up: Used S-expressions [Contents][Index]
An RSA private key is described by this S-expression:
(private-key (rsa (n n-mpi) (e e-mpi) (d d-mpi) (p p-mpi) (q q-mpi) (u u-mpi)))
An RSA public key is described by this S-expression:
(public-key (rsa (n n-mpi) (e e-mpi)))
RSA public modulus n.
RSA public exponent e.
RSA secret exponent d = e^{-1} \bmod (p-1)(q-1).
RSA secret prime p.
RSA secret prime q with p < q.
Multiplicative inverse u = p^{-1} \bmod q.
For signing and decryption the parameters (p, q, u) are optional but greatly improve the performance. Either all of these optional parameters must be given or none of them. They are mandatory for gcry_pk_testkey.
Note that OpenSSL uses slighly different parameters: q < p and u = q^{-1} \bmod p. To use these parameters you will need to swap the values and recompute u. Here is example code to do this:
if (gcry_mpi_cmp (p, q) > 0) { gcry_mpi_swap (p, q); gcry_mpi_invm (u, p, q); }