I have C application that has to generate elliptic curve private key and export it for Java application that uses Spongycastle. I need that my application produces completely the same keys as Spongycastle, so I use in OpenSSL the same format as Spongycastle
is supposed to use for private key export, but for any reason resulted key bytes are different. Spongycastle ECPrivateKey
.getEncoded
method is supposed to return PKCS8 PrivateKeyInfo in DER encoding. I really can import it in OpenSSL. However, when I export it back, the key file size becames 2 times less.
Example key file is http://www.fileconvoy.com/dfl.php?id=g90dd3019881e526c999568884712f1e3c7d48d7cc
I use following command line:
openssl pkcs8 -topk8 -inform DER -in "ec.key" -nocrypt -outform DER -out "ec.p8"
This command line is supposed to import PKCS8 elliptic curve private key and export it in the same format. However, ec.key
file is 591 bytes, and ec.p8
file is 295 bytes, so imported and exported key or its format is obviously different. Why?