cryptography - Get key parameters from imported Elliptic Curve key in ASN.1 format -
i need write code gets input elliptic curve key in asn.1 format.
the input byte array next:
308187020100301306072a8648ce3d020106082a8648ce3d030107046d306b0201010420e699203ac5bcfe36402ebd0ac9e8e21cc6fad5828a61297ea747468fff4dbb20a144034200047e05188a03ea81e853b9f6ac5f20dca1a1ca828fd7cd5d92161fb2120c35eac52eab079ed01a510123057c322ddff95e239d6063055bc90858d161d71de707f8
online parser shows me next structure:
to use key want need public value x
, public value y
, private value
structure, @ least think so. not know how.
i have searched information object identifier 1.2.840.10045.2.1
, object identifier 1.2.840.10045.3.1.7
. i've found this document. there no description of fields of asn.1 structure.
how can required parameters imported data?
it's commonly known pkcs#8 structure, "private-key information syntax specification". contains unencrypted part of pkcs#8 private key.
so in pkcs#8:
privatekeyinfo ::= sequence { version version, privatekeyalgorithm algorithmidentifier {{privatekeyalgorithms}}, privatekey privatekey, attributes [0] attributes optional }
the algorithmidentifier taken pkcs#5
algorithmidentifier { algorithm-identifier:infoobjectset } ::= sequence { algorithm algorithm-identifier.&id({infoobjectset}), parameters algorithm-identifier.&type({infoobjectset} {@algorithm}) optional }
the elliptic curve private key structure:
ecprivatekey ::= sequence { version integer { ecprivkeyver1(1) } (ecprivkeyver1), privatekey octet string, parameters [0] ecparameters {{ namedcurve }} optional, publickey [1] bit string optional }
oh, , encoded in der, distinguished encoding rules (study version) - may not able rule out ber completely, more loosely defined , therefore harder parse structure). pkcs#8 defines ber unfortunately.
oh, yeah, public key in uncompressed point format. don't forget strip away 00
bit string.
happy parsing.
Comments
Post a Comment