This outputs the key in PKCS1v2 format.
RSAPrivateKey ::= SEQUENCE {
version Version,
modulus INTEGER, -- n
publicExponent INTEGER, -- e
privateExponent INTEGER, -- d
prime1 INTEGER, -- p
prime2 INTEGER, -- q
exponent1 INTEGER, -- d mod (p-1)
exponent2 INTEGER, -- d mod (q-1)
coefficient INTEGER -- (inverse of q) mod p
}
Version ::= INTEGER
This routine is written to output PKCS1 version 0, private keys.
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DERInteger(0)); // version
v.add(new DERInteger(getModulus()));
v.add(new DERInteger(getPublicExponent()));
v.add(new DERInteger(getPrivateExponent()));
v.add(new DERInteger(getPrime1()));
v.add(new DERInteger(getPrime2()));
v.add(new DERInteger(getExponent1()));
v.add(new DERInteger(getExponent2()));
v.add(new DERInteger(getCoefficient()));
return new DERSequence(v);