rsatool calculates RSA (p, q, n, d, e) and RSA-CRT (dP, dQ, qInv) parameters given either two primes (p, q) or modulus and private exponent (n, d).
The resulting parameters are displayed and can be written as an OpenSSL-compatible DER or PEM-encoded RSA private key.
Source code and additional information may be found here: https://github.com/ius/rsatool