Next: , Up: Used S-expressions   [Contents][Index]


6.2.1 RSA key parameters

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)))
n-mpi

RSA public modulus n.

e-mpi

RSA public exponent e.

d-mpi

RSA secret exponent d = e^{-1} \bmod (p-1)(q-1).

p-mpi

RSA secret prime p.

q-mpi

RSA secret prime q with p < q.

u-mpi

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);
    }