ECDsa signature not a valid DER sequence
See original GitHub issueI am developing my own custom U2F for webauthn. It’s working with other demo websites but getting an error while registering with https://www.passwordless.dev/. The error I’m getting is “ECDsa signature not a valid DER sequence”. I’m using window crypto API for signing.
I have been trying to encode it properly that can be verified by OpenSSL properly but couldn’t get it done. Is it feasible to interoperate between windows crypto API and OpenSSL?
Signing code I’m using:
public async sign(data: Uint8Array): Promise<any> {
if (!this.privateKey) {
throw new Error('no private key available for signing');
}
return window.crypto.subtle.sign(
this.getKeyParams(),
this.privateKey,
data, //new TextEncoder().encode(data),
);
}
private getKeyParams(): EcdsaParams {
return { name: 'ECDSA', hash: coseEllipticCurveNames[ECDSA.ellipticCurveKeys[this.algorithm]] };
}
private async toCOSE(key: CryptoKey): Promise<Map<number, any>> {
const exportedKey = await window.crypto.subtle.exportKey('jwk', key);
const attData = new Map();
attData.set(1, 2); // EC2 key type
attData.set(3, this.algorithm);
attData.set(-1, ECDSA.ellipticCurveKeys[this.algorithm]);
attData.set(-2, base64ToByteArray(exportedKey.x, true));
attData.set(-3, base64ToByteArray(exportedKey.y, true));
return attData;
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
ASN1 encoding routines errors when verifying ECDSA ...
A raw ECDSA signature is comprised of two integers "r" and "s". OpenSSL expects them to be wrapped up inside a DER encoded...
Read more >Verifying DER encoded DSA/ECDSA signature with extra ...
Having a DSA/ECDSA signature which is supposed to be DER encoded as an ASN.1 sequence of r and s (as described in the...
Read more >JWS ECDSA signatures should not be ASN.1 DER formatted
JWS ECDSA signatures should not be ASN.1 DER formatted #125 ... appending data to an ECDSA signature before validation isn't a valid test....
Read more >Does the ECDSA signature value (of an OCSP response) ...
but this only requires the BIT STRING signature to be DER encoded, not any data encapsulated in it. TR-03111 (Technical Guideline on Elliptic ......
Read more >ASN.1: DER for Digital Signatures - Reading (r,s)
the most common digital signature is ECDSA (Elliptic Curve Digital Signature Algorithm). It takes a message (M), a private key (sk) and a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for helping through. It’s working now. There was some issue the way I was returning the signature form ‘then’.