Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
AJ ONeal | b22f957124 | |
AJ ONeal | 48bee9204d |
14
keypairs.js
14
keypairs.js
|
@ -240,7 +240,7 @@ Keypairs.signJws = function (opts) {
|
||||||
if ('EC' === opts.jwk.kty) {
|
if ('EC' === opts.jwk.kty) {
|
||||||
// ECDSA JWT signatures differ from "normal" ECDSA signatures
|
// ECDSA JWT signatures differ from "normal" ECDSA signatures
|
||||||
// https://tools.ietf.org/html/rfc7518#section-3.4
|
// https://tools.ietf.org/html/rfc7518#section-3.4
|
||||||
binsig = convertIfEcdsa(binsig);
|
binsig = ecdsaAsn1SigToJoseSig(binsig);
|
||||||
}
|
}
|
||||||
|
|
||||||
var sig = binsig.toString('base64')
|
var sig = binsig.toString('base64')
|
||||||
|
@ -257,7 +257,7 @@ Keypairs.signJws = function (opts) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertIfEcdsa(binsig) {
|
function ecdsaAsn1SigToJoseSig(binsig) {
|
||||||
// should have asn1 sequence header of 0x30
|
// should have asn1 sequence header of 0x30
|
||||||
if (0x30 !== binsig[0]) { throw new Error("Impossible EC SHA head marker"); }
|
if (0x30 !== binsig[0]) { throw new Error("Impossible EC SHA head marker"); }
|
||||||
var index = 2; // first ecdsa "R" header byte
|
var index = 2; // first ecdsa "R" header byte
|
||||||
|
@ -346,10 +346,14 @@ Enc.bufToUrlBase64 = function (buf) {
|
||||||
// For 'rsa-compat' module only
|
// For 'rsa-compat' module only
|
||||||
// PLEASE do not use these sync methods, they are deprecated
|
// PLEASE do not use these sync methods, they are deprecated
|
||||||
Keypairs._importSync = function (opts) {
|
Keypairs._importSync = function (opts) {
|
||||||
if ('RSA' === opts.jwk.kty) {
|
try {
|
||||||
return Rasha.importSync(opts);
|
|
||||||
} else {
|
|
||||||
return Eckles.importSync(opts);
|
return Eckles.importSync(opts);
|
||||||
|
} catch(e) {
|
||||||
|
try {
|
||||||
|
return Rasha.importSync(opts);
|
||||||
|
} catch(e) {
|
||||||
|
console.error("options.pem does not appear to be a valid RSA or ECDSA public or private key");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// PLEASE do not use these, they are deprecated
|
// PLEASE do not use these, they are deprecated
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "keypairs",
|
"name": "keypairs",
|
||||||
"version": "1.2.13",
|
"version": "1.2.14",
|
||||||
"description": "Lightweight RSA/ECDSA keypair generation and JWK <-> PEM using node's native RSA and ECDSA support",
|
"description": "Lightweight RSA/ECDSA keypair generation and JWK <-> PEM using node's native RSA and ECDSA support",
|
||||||
"main": "keypairs.js",
|
"main": "keypairs.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
|
Loading…
Reference in New Issue