You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Substituting .sign(privateKey); for .sign(reencoded); doesn't error. reencoded differs from the original privateKey in an additional null component, which comes from this line in the parse-asn1AlgorithmIdentifier definition. Because the none component is optional, asn1.js decodes the original privateKey with or without it, but OpenSSL will only decode it without.
If I change asn1.js/lib/asn1/base/node.js line 534 from return child._encode(null, reporter, data); to return child._encode(undefined, reporter, data); then asn1.js no longer outputs the optional null component and OpenSSL accepts the output.
Should asn1.js encode the optional null component?
In actuality I have private keys that aren't ASN.1, e.g. RFC 6605 Section 6.1 P-256 Example and I'm trying to adapt them to crypto.createSign().
I looked around for a standard to see if the parse-asn1AlgorithmIdentifier definition or OpenSSL implementation are correct. I found lots of them, covering PrivateKeyInfo and AlgorithmIdentifier, but failed to find the definitive ASN.1 for elliptic curves.
The text was updated successfully, but these errors were encountered:
This outputs this key, which is not parseable by OpenSSL or Java BouncyCastle because of the null:
-----BEGIN PUBLIC KEY-----
MFswFQYHKoZIzj0CAQUABggqhkjOPQMBBwNCAAQI3VNUDfvSfmBFXvv51GUeReGR
KOsqf5HAS4GsDgViqOzf0Jjh3Xt4Vyh95bpcaqyBG1K5PJjvEz0xwg7wEnQ1
-----END PUBLIC KEY-----
java.lang.Exception: Error Performing Parsing java.lang.Exception: java.lang.IllegalArgumentException: Bad sequence size: 3
This generates exactly the same key even if the field 'none' is specified as undefined:
Should the following output
30020500
or3000
?OpenSSL (on my machine) chokes on the following:
Substituting
.sign(privateKey);
for.sign(reencoded);
doesn't error.reencoded
differs from the originalprivateKey
in an additionalnull
component, which comes from this line in theparse-asn1
AlgorithmIdentifier
definition. Because thenone
component is optional,asn1.js
decodes the originalprivateKey
with or without it, but OpenSSL will only decode it without.If I change
asn1.js/lib/asn1/base/node.js
line 534 fromreturn child._encode(null, reporter, data);
toreturn child._encode(undefined, reporter, data);
thenasn1.js
no longer outputs the optionalnull
component and OpenSSL accepts the output.Should
asn1.js
encode the optionalnull
component?In actuality I have private keys that aren't ASN.1, e.g. RFC 6605 Section 6.1 P-256 Example and I'm trying to adapt them to
crypto.createSign()
.Probably Irrelevant
I think the OpenSSL elliptic curve
AlgorithmIdentifier
encoding/decoding takes place ineckey_priv_encode()
/eckey_priv_decode()
/eckey_param2type()
/eckey_type2param()
.I looked around for a standard to see if the
parse-asn1
AlgorithmIdentifier
definition or OpenSSL implementation are correct. I found lots of them, coveringPrivateKeyInfo
andAlgorithmIdentifier
, but failed to find the definitive ASN.1 for elliptic curves.The text was updated successfully, but these errors were encountered: