@simplewebauthn/server 14.0.0 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
- package/esm/authentication/verifyAuthenticationResponse.js +12 -0
- package/esm/errors/index.d.ts +17 -0
- package/esm/errors/index.d.ts.map +1 -0
- package/esm/errors/index.js +24 -0
- package/esm/helpers/convertX509PublicKeyToCOSE.d.ts +1 -1
- package/esm/helpers/convertX509PublicKeyToCOSE.d.ts.map +1 -1
- package/esm/helpers/convertX509PublicKeyToCOSE.js +22 -6
- package/esm/helpers/cose.d.ts +1 -0
- package/esm/helpers/cose.d.ts.map +1 -1
- package/esm/helpers/cose.js +3 -0
- package/esm/helpers/isCertRevoked.d.ts +2 -1
- package/esm/helpers/isCertRevoked.d.ts.map +1 -1
- package/esm/helpers/isCertRevoked.js +91 -70
- package/esm/helpers/iso/isoCrypto/verifyAKP.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verifyAKP.js +2 -1
- package/esm/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +0 -3
- package/esm/helpers/mapX509SignatureAlgToCOSEAlg.d.ts.map +1 -1
- package/esm/helpers/mapX509SignatureAlgToCOSEAlg.js +19 -10
- package/esm/helpers/validateCertificatePath.d.ts +1 -0
- package/esm/helpers/validateCertificatePath.d.ts.map +1 -1
- package/esm/helpers/validateCertificatePath.js +94 -52
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/metadata/verifyAttestationWithMetadata.d.ts.map +1 -1
- package/esm/metadata/verifyAttestationWithMetadata.js +1 -7
- package/esm/registration/verifications/verifyAttestationPacked.js +1 -1
- package/esm/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/esm/registration/verifyRegistrationResponse.js +19 -8
- package/package.json +4 -2
- package/script/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
- package/script/authentication/verifyAuthenticationResponse.js +12 -0
- package/script/errors/index.d.ts +17 -0
- package/script/errors/index.d.ts.map +1 -0
- package/script/errors/index.js +29 -0
- package/script/helpers/convertX509PublicKeyToCOSE.d.ts +1 -1
- package/script/helpers/convertX509PublicKeyToCOSE.d.ts.map +1 -1
- package/script/helpers/convertX509PublicKeyToCOSE.js +21 -5
- package/script/helpers/cose.d.ts +1 -0
- package/script/helpers/cose.d.ts.map +1 -1
- package/script/helpers/cose.js +4 -0
- package/script/helpers/isCertRevoked.d.ts +2 -1
- package/script/helpers/isCertRevoked.d.ts.map +1 -1
- package/script/helpers/isCertRevoked.js +91 -70
- package/script/helpers/iso/isoCrypto/verifyAKP.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verifyAKP.js +2 -1
- package/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +0 -3
- package/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts.map +1 -1
- package/script/helpers/mapX509SignatureAlgToCOSEAlg.js +19 -10
- package/script/helpers/validateCertificatePath.d.ts +1 -0
- package/script/helpers/validateCertificatePath.d.ts.map +1 -1
- package/script/helpers/validateCertificatePath.js +94 -52
- package/script/index.d.ts +1 -0
- package/script/index.d.ts.map +1 -1
- package/script/index.js +1 -0
- package/script/metadata/verifyAttestationWithMetadata.d.ts.map +1 -1
- package/script/metadata/verifyAttestationWithMetadata.js +1 -7
- package/script/registration/verifications/verifyAttestationPacked.js +1 -1
- package/script/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/script/registration/verifyRegistrationResponse.js +22 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyAuthenticationResponse.d.ts","sourceRoot":"","sources":["../../src/authentication/verifyAuthenticationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"verifyAuthenticationResponse.d.ts","sourceRoot":"","sources":["../../src/authentication/verifyAuthenticationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,6CAA6C,CAAC;AAQhH;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAAC,CAAC,CAAC;AAElG;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE;IACP,QAAQ,EAAE,0BAA0B,CAAC;IACrC,iBAAiB,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAChF,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,kBAAkB,CAAC,EAAE;QACnB,gBAAgB,CAAC,EAAE,2BAA2B,CAAC;KAChD,CAAC;CACH,GACA,OAAO,CAAC,8BAA8B,CAAC,CA6QzC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE;QAClB,YAAY,EAAE,eAAe,CAAC;QAC9B,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,OAAO,CAAC;QACtB,oBAAoB,EAAE,oBAAoB,CAAC;QAC3C,kBAAkB,EAAE,OAAO,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,6BAA6B,CAAC,EAAE,4CAA4C,CAAC;KAC9E,CAAC;CACH,CAAC"}
|
|
@@ -5,6 +5,10 @@ import { parseAuthenticatorData } from '../helpers/parseAuthenticatorData.js';
|
|
|
5
5
|
import { parseBackupFlags } from '../helpers/parseBackupFlags.js';
|
|
6
6
|
import { matchExpectedRPID } from '../helpers/matchExpectedRPID.js';
|
|
7
7
|
import { isoBase64URL, isoUint8Array } from '../helpers/iso/index.js';
|
|
8
|
+
import { decodeCredentialPublicKey } from '../helpers/decodeCredentialPublicKey.js';
|
|
9
|
+
import { COSEKEYS, isPQCCOSEAlg } from '../helpers/cose.js';
|
|
10
|
+
import { SettingsService } from '../services/settingsService.js';
|
|
11
|
+
import { PQCNotSupportedError } from '../errors/index.js';
|
|
8
12
|
/**
|
|
9
13
|
* Verify that the user has legitimately completed the authentication process
|
|
10
14
|
*
|
|
@@ -187,6 +191,14 @@ export async function verifyAuthenticationResponse(options) {
|
|
|
187
191
|
// on the device without going through this site
|
|
188
192
|
throw new Error(`Response counter value ${counter} was lower than expected ${credential.counter}`);
|
|
189
193
|
}
|
|
194
|
+
const decodedPublicKey = decodeCredentialPublicKey(credential.publicKey);
|
|
195
|
+
const pubKeyAlg = decodedPublicKey.get(COSEKEYS.alg);
|
|
196
|
+
if (typeof pubKeyAlg !== 'number') {
|
|
197
|
+
throw new Error('Credential public key was missing numeric alg');
|
|
198
|
+
}
|
|
199
|
+
if (isPQCCOSEAlg(pubKeyAlg) && !SettingsService.runtimeSupportsPQC()) {
|
|
200
|
+
throw new PQCNotSupportedError(pubKeyAlg);
|
|
201
|
+
}
|
|
190
202
|
const { credentialDeviceType, credentialBackedUp } = parseBackupFlags(flags);
|
|
191
203
|
const toReturn = {
|
|
192
204
|
verified: await verifySignature({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { COSEALG } from '../helpers/cose.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base error class that helps disambiguate SimpleWebAuthn library errors from other library errors
|
|
4
|
+
*/
|
|
5
|
+
export declare class SimpleWebAuthnError extends Error {
|
|
6
|
+
code: SimpleWebAuthnErrorCode;
|
|
7
|
+
constructor({ message, code, cause }: {
|
|
8
|
+
message: string;
|
|
9
|
+
code: SimpleWebAuthnErrorCode;
|
|
10
|
+
cause?: Error;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export declare class PQCNotSupportedError extends SimpleWebAuthnError {
|
|
14
|
+
constructor(alg: COSEALG);
|
|
15
|
+
}
|
|
16
|
+
export type SimpleWebAuthnErrorCode = 'RUNTIME_NO_PQC_SUPPORT' | 'CERTIFICATE_PATH_VERIFICATION_FAILED';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,IAAI,EAAE,uBAAuB,CAAC;gBAElB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpC,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,uBAAuB,CAAC;QAC9B,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAKF;AAED,qBAAa,oBAAqB,SAAQ,mBAAmB;gBAC/C,GAAG,EAAE,OAAO;CAKzB;AAED,MAAM,MAAM,uBAAuB,GAC/B,wBAAwB,GACxB,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mapCoseAlgToWebCryptoKeyAlgName } from '../helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base error class that helps disambiguate SimpleWebAuthn library errors from other library errors
|
|
4
|
+
*/
|
|
5
|
+
export class SimpleWebAuthnError extends Error {
|
|
6
|
+
constructor({ message, code, cause }) {
|
|
7
|
+
super(message, { cause });
|
|
8
|
+
Object.defineProperty(this, "code", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
this.name = 'SimpleWebAuthnError';
|
|
15
|
+
this.code = code;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class PQCNotSupportedError extends SimpleWebAuthnError {
|
|
19
|
+
constructor(alg) {
|
|
20
|
+
const webCryptoAlg = mapCoseAlgToWebCryptoKeyAlgName(alg);
|
|
21
|
+
const message = `This runtime's WebCrypto.subtle does not support use of ${webCryptoAlg}`;
|
|
22
|
+
super({ message, code: 'RUNTIME_NO_PQC_SUPPORT' });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COSEPublicKey } from './cose.js';
|
|
1
|
+
import { type COSEPublicKey } from './cose.js';
|
|
2
2
|
import type { Uint8Array_ } from '../types/index.js';
|
|
3
3
|
export declare function convertX509PublicKeyToCOSE(x509Certificate: Uint8Array_): COSEPublicKey;
|
|
4
4
|
//# sourceMappingURL=convertX509PublicKeyToCOSE.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertX509PublicKeyToCOSE.d.ts","sourceRoot":"","sources":["../../src/helpers/convertX509PublicKeyToCOSE.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convertX509PublicKeyToCOSE.d.ts","sourceRoot":"","sources":["../../src/helpers/convertX509PublicKeyToCOSE.ts"],"names":[],"mappings":"AAMA,OAAO,EAKL,KAAK,aAAa,EAInB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,WAAW,GAC3B,aAAa,CAsGf"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AsnParser } from '@peculiar/asn1-schema';
|
|
2
2
|
import { Certificate } from '@peculiar/asn1-x509';
|
|
3
3
|
import { ECParameters, id_ecPublicKey, id_secp256r1, id_secp384r1 } from '@peculiar/asn1-ecc';
|
|
4
|
+
import { id_ml_dsa_44, id_ml_dsa_65, id_ml_dsa_87 } from '@peculiar/asn1-x509-post-quantum';
|
|
4
5
|
import { id_rsaEncryption, RSAPublicKey } from '@peculiar/asn1-rsa';
|
|
5
|
-
import { COSECRV, COSEKEYS, COSEKTY, } from './cose.js';
|
|
6
|
+
import { COSEALG, COSECRV, COSEKEYS, COSEKTY, } from './cose.js';
|
|
6
7
|
import { mapX509SignatureAlgToCOSEAlg } from './mapX509SignatureAlgToCOSEAlg.js';
|
|
7
8
|
export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
8
9
|
let cosePublicKey = new Map();
|
|
@@ -11,8 +12,7 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
11
12
|
*/
|
|
12
13
|
const x509 = AsnParser.parse(x509Certificate, Certificate);
|
|
13
14
|
const { tbsCertificate } = x509;
|
|
14
|
-
const { subjectPublicKeyInfo
|
|
15
|
-
const signatureAlgorithm = _tbsSignature.algorithm;
|
|
15
|
+
const { subjectPublicKeyInfo } = tbsCertificate;
|
|
16
16
|
const publicKeyAlgorithmID = subjectPublicKeyInfo.algorithm.algorithm;
|
|
17
17
|
if (publicKeyAlgorithmID === id_ecPublicKey) {
|
|
18
18
|
/**
|
|
@@ -22,12 +22,15 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
22
22
|
throw new Error('Certificate public key was missing parameters (EC2)');
|
|
23
23
|
}
|
|
24
24
|
const ecParameters = AsnParser.parse(new Uint8Array(subjectPublicKeyInfo.algorithm.parameters), ECParameters);
|
|
25
|
-
let
|
|
25
|
+
let alg;
|
|
26
|
+
let crv;
|
|
26
27
|
const { namedCurve } = ecParameters;
|
|
27
28
|
if (namedCurve === id_secp256r1) {
|
|
29
|
+
alg = COSEALG.ES256;
|
|
28
30
|
crv = COSECRV.P256;
|
|
29
31
|
}
|
|
30
32
|
else if (namedCurve === id_secp384r1) {
|
|
33
|
+
alg = COSEALG.ES384;
|
|
31
34
|
crv = COSECRV.P384;
|
|
32
35
|
}
|
|
33
36
|
else {
|
|
@@ -48,7 +51,7 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
48
51
|
}
|
|
49
52
|
const coseEC2PubKey = new Map();
|
|
50
53
|
coseEC2PubKey.set(COSEKEYS.kty, COSEKTY.EC2);
|
|
51
|
-
coseEC2PubKey.set(COSEKEYS.alg,
|
|
54
|
+
coseEC2PubKey.set(COSEKEYS.alg, alg);
|
|
52
55
|
coseEC2PubKey.set(COSEKEYS.crv, crv);
|
|
53
56
|
coseEC2PubKey.set(COSEKEYS.x, x);
|
|
54
57
|
coseEC2PubKey.set(COSEKEYS.y, y);
|
|
@@ -61,11 +64,24 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
61
64
|
const rsaPublicKey = AsnParser.parse(subjectPublicKeyInfo.subjectPublicKey, RSAPublicKey);
|
|
62
65
|
const coseRSAPubKey = new Map();
|
|
63
66
|
coseRSAPubKey.set(COSEKEYS.kty, COSEKTY.RSA);
|
|
64
|
-
|
|
67
|
+
/**
|
|
68
|
+
* The algorithm ID is too ambiguous to know what this alg should really be. But practically
|
|
69
|
+
* speaking `shaHashOverride` is always specified when verifying signatures with RSA public keys
|
|
70
|
+
* which ultimately overrides this sensible default. Using RS256 also gets the correct WebCrypto
|
|
71
|
+
* alg name later on in verifyRSA.ts
|
|
72
|
+
*/
|
|
73
|
+
coseRSAPubKey.set(COSEKEYS.alg, COSEALG.RS256);
|
|
65
74
|
coseRSAPubKey.set(COSEKEYS.n, new Uint8Array(rsaPublicKey.modulus));
|
|
66
75
|
coseRSAPubKey.set(COSEKEYS.e, new Uint8Array(rsaPublicKey.publicExponent));
|
|
67
76
|
cosePublicKey = coseRSAPubKey;
|
|
68
77
|
}
|
|
78
|
+
else if ([id_ml_dsa_44, id_ml_dsa_65, id_ml_dsa_87].indexOf(publicKeyAlgorithmID) >= 0) {
|
|
79
|
+
const coseAKPPubKey = new Map();
|
|
80
|
+
coseAKPPubKey.set(COSEKEYS.kty, COSEKTY.AKP);
|
|
81
|
+
coseAKPPubKey.set(COSEKEYS.alg, mapX509SignatureAlgToCOSEAlg(publicKeyAlgorithmID));
|
|
82
|
+
coseAKPPubKey.set(COSEKEYS.pub, new Uint8Array(subjectPublicKeyInfo.subjectPublicKey));
|
|
83
|
+
cosePublicKey = coseAKPPubKey;
|
|
84
|
+
}
|
|
69
85
|
else {
|
|
70
86
|
throw new Error(`Certificate public key contained unexpected algorithm ID ${publicKeyAlgorithmID}`);
|
|
71
87
|
}
|
package/esm/helpers/cose.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cose.d.ts","sourceRoot":"","sources":["../../src/helpers/cose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAE1B,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,GAAG,SAAS,CAAC;IAC5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,GAAG,SAAS,CAAC;IAE5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C,CAAC;AAEF;;G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ED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,KAAK,KAAK;IACV,KAAK,KAAK;IACV,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,MAAM;IACX,MAAM,MAAM;IACZ,SAAS,MAAM;IACf,SAAS,MAAM;IACf,SAAS,MAAM;IACf,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,GAAG,SAAS;CACb;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,IAAI,OAAO,CAEjE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAElD"}
|
package/esm/helpers/cose.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
1
2
|
import { type X509Certificate } from '@peculiar/x509';
|
|
2
3
|
/**
|
|
3
4
|
* A method to pull a CRL from a certificate and compare its serial number to the list of revoked
|
|
@@ -5,5 +6,5 @@ import { type X509Certificate } from '@peculiar/x509';
|
|
|
5
6
|
*
|
|
6
7
|
* CRL certificate structure referenced from https://tools.ietf.org/html/rfc5280#page-117
|
|
7
8
|
*/
|
|
8
|
-
export declare function isCertRevoked(
|
|
9
|
+
export declare function isCertRevoked(certificate: X509Certificate, issuer?: X509Certificate): Promise<boolean>;
|
|
9
10
|
//# sourceMappingURL=isCertRevoked.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isCertRevoked.d.ts","sourceRoot":"","sources":["../../src/helpers/isCertRevoked.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAexB;;;;;GAKG;AACH,wBAAsB,aAAa,
|
|
1
|
+
{"version":3,"file":"isCertRevoked.d.ts","sourceRoot":"","sources":["../../src/helpers/isCertRevoked.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAexB;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,eAAe,EAC5B,MAAM,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,OAAO,CAAC,CA0HlB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
1
2
|
import { AuthorityKeyIdentifierExtension, CRLDistributionPointsExtension, SubjectKeyIdentifierExtension, X509Crl, } from '@peculiar/x509';
|
|
2
3
|
import { fetch } from './fetch.js';
|
|
3
4
|
const cacheRevokedCerts = {};
|
|
@@ -7,90 +8,110 @@ const cacheRevokedCerts = {};
|
|
|
7
8
|
*
|
|
8
9
|
* CRL certificate structure referenced from https://tools.ietf.org/html/rfc5280#page-117
|
|
9
10
|
*/
|
|
10
|
-
export async function isCertRevoked(
|
|
11
|
-
|
|
11
|
+
export async function isCertRevoked(certificate, issuer) {
|
|
12
|
+
if (!issuer) {
|
|
13
|
+
// We don't have a public key to verify any CRL signature so don't bother continuing
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const { extensions } = certificate;
|
|
12
17
|
if (!extensions) {
|
|
13
18
|
return false;
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
else if (ext instanceof CRLDistributionPointsExtension) {
|
|
26
|
-
extCRLDistributionPoints = ext;
|
|
27
|
-
}
|
|
20
|
+
const extCRLDistributionPoints = extensions.find((ext) => ext instanceof CRLDistributionPointsExtension);
|
|
21
|
+
// Get all CRL URLs from within the certificate
|
|
22
|
+
const crlURLs = [];
|
|
23
|
+
extCRLDistributionPoints?.distributionPoints?.forEach((dPoint) => {
|
|
24
|
+
dPoint.distributionPoint?.fullName?.forEach((fullName) => {
|
|
25
|
+
if (fullName.uniformResourceIdentifier) {
|
|
26
|
+
crlURLs.push(fullName.uniformResourceIdentifier);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
28
29
|
});
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
keyIdentifier = extAuthorityKeyID.keyId;
|
|
30
|
+
// If no URL(s) is provided then we have nothing to check
|
|
31
|
+
if (!(crlURLs.length > 0)) {
|
|
32
|
+
return false;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
// Get the issuer's key identifier for part of the cache key and to check against the
|
|
35
|
+
// certificate's and CRL's AuthorityKeyIdentifier extension
|
|
36
|
+
const { keyIdentifier: issuerKeyIdentifier, fromExtension: issuerKeyIdentifierFromExtension, } = await getIssuerKeyIdentifier(issuer);
|
|
37
|
+
const certificateExtAuthorityKeyID = certificate.extensions.find((ext) => ext instanceof AuthorityKeyIdentifierExtension);
|
|
38
|
+
// When present, assert that certificates's AuthorityKeyIdentifier mirrors
|
|
39
|
+
// the issuer's SubjectKeyIdentifier
|
|
40
|
+
if (issuerKeyIdentifierFromExtension &&
|
|
41
|
+
certificateExtAuthorityKeyID?.keyId &&
|
|
42
|
+
certificateExtAuthorityKeyID.keyId !== issuerKeyIdentifier) {
|
|
43
|
+
throw new Error(`Certificate's AuthorityKeyIdentifier did not match issuer's SubjectKeyIdentifier "${issuerKeyIdentifier}"`);
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
for (const crlURL of crlURLs) {
|
|
46
|
+
// Key off of issuer public key and CRL URL in case multiple CRLs are specified
|
|
47
|
+
const cacheKey = `${issuerKeyIdentifier}|${crlURL}`;
|
|
48
|
+
const cached = cacheRevokedCerts[cacheKey];
|
|
43
49
|
if (cached) {
|
|
44
50
|
const now = new Date();
|
|
45
51
|
// If there's a nextUpdate then make sure we're before it
|
|
46
52
|
if (!cached.nextUpdate || cached.nextUpdate > now) {
|
|
47
|
-
return cached.revokedCerts.indexOf(
|
|
53
|
+
return cached.revokedCerts.indexOf(certificate.serialNumber) >= 0;
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// Something was malformed with the CRL, so pass
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
const newCached = {
|
|
75
|
-
revokedCerts: [],
|
|
76
|
-
nextUpdate: undefined,
|
|
77
|
-
};
|
|
78
|
-
// nextUpdate
|
|
79
|
-
if (data.nextUpdate) {
|
|
80
|
-
newCached.nextUpdate = data.nextUpdate;
|
|
81
|
-
}
|
|
82
|
-
// revokedCertificates
|
|
83
|
-
const revokedCerts = data.entries;
|
|
84
|
-
if (revokedCerts) {
|
|
85
|
-
for (const cert of revokedCerts) {
|
|
86
|
-
const revokedHex = cert.serialNumber;
|
|
87
|
-
newCached.revokedCerts.push(revokedHex);
|
|
56
|
+
// Download and read the CRL
|
|
57
|
+
let crlBytes;
|
|
58
|
+
try {
|
|
59
|
+
const respCRL = await fetch(crlURL);
|
|
60
|
+
crlBytes = await respCRL.arrayBuffer();
|
|
61
|
+
}
|
|
62
|
+
catch (_err) {
|
|
63
|
+
// Some kind of network error occurred so try the next URL
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
let certCRL;
|
|
67
|
+
try {
|
|
68
|
+
certCRL = new X509Crl(crlBytes);
|
|
69
|
+
}
|
|
70
|
+
catch (_err) {
|
|
71
|
+
// Something was malformed with the CRL so try the next URL
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const certCRLVerified = await certCRL.verify({ publicKey: issuer.publicKey });
|
|
75
|
+
if (!certCRLVerified) {
|
|
76
|
+
throw new Error(`CRL from ${crlURL} failed signature verification against issuer "${issuer.subject}"`);
|
|
88
77
|
}
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
// When present, assert that the CRL's AuthorityKeyIdentifier mirrors
|
|
79
|
+
// the issuer's SubjectKeyIdentifier
|
|
80
|
+
const crlAKI = certCRL.getExtension(AuthorityKeyIdentifierExtension);
|
|
81
|
+
if (issuerKeyIdentifierFromExtension &&
|
|
82
|
+
crlAKI?.keyId &&
|
|
83
|
+
crlAKI.keyId !== issuerKeyIdentifier) {
|
|
84
|
+
throw new Error(`CRL from ${crlURL} contained an AuthorityKeyIdentifier that did not match issuer's SubjectKeyIdentifier "${issuerKeyIdentifier}"`);
|
|
85
|
+
}
|
|
86
|
+
// Cache the CRL only if a nextUpdate has been provided
|
|
87
|
+
if (certCRL.nextUpdate) {
|
|
88
|
+
cacheRevokedCerts[cacheKey] = {
|
|
89
|
+
revokedCerts: certCRL.entries.map((entry) => entry.serialNumber),
|
|
90
|
+
nextUpdate: certCRL.nextUpdate,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// Finally, check entries for revocation status
|
|
94
|
+
const revoked = certCRL.findRevoked(certificate);
|
|
95
|
+
if (revoked) {
|
|
96
|
+
return true;
|
|
92
97
|
}
|
|
93
|
-
return newCached.revokedCerts.indexOf(cert.serialNumber) >= 0;
|
|
94
98
|
}
|
|
95
99
|
return false;
|
|
96
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Determine a unique key ID for the issuer certificate, based either on its
|
|
103
|
+
* SubjectKeyIdentifierExtension or by generating the same value using the issuer's public key
|
|
104
|
+
*/
|
|
105
|
+
async function getIssuerKeyIdentifier(issuer) {
|
|
106
|
+
const issuerSKI = issuer.extensions?.find((ext) => ext instanceof SubjectKeyIdentifierExtension);
|
|
107
|
+
if (issuerSKI?.keyId) {
|
|
108
|
+
return { keyIdentifier: issuerSKI.keyId, fromExtension: true };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The issuer carries no SubjectKeyIdentifier extension, so derive one from its public key
|
|
112
|
+
* (RFC 5280, method 1). This is good enough to keep unrelated CAs from colliding when computing
|
|
113
|
+
* the revocation cache key, but it's not authoritative enough to reject a certificate over.
|
|
114
|
+
*/
|
|
115
|
+
const computed = await SubjectKeyIdentifierExtension.create(issuer.publicKey);
|
|
116
|
+
return { keyIdentifier: computed.keyId, fromExtension: false };
|
|
117
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyAKP.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyAKP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"verifyAKP.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyAKP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAM3E,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE5E,wBAAwB;AACxB,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,OAAO,CAAC,OAAO,CAAC,CA+CnB"}
|
|
@@ -3,6 +3,7 @@ import { isoBase64URL } from '../../index.js';
|
|
|
3
3
|
import { importJWKKey } from './importJWKKey.js';
|
|
4
4
|
import { getWebCrypto } from './getWebCrypto.js';
|
|
5
5
|
import { mapCoseAlgToWebCryptoKeyAlgName } from './mapCoseAlgToWebCryptoKeyAlgName.js';
|
|
6
|
+
import { PQCNotSupportedError } from '../../../errors/index.js';
|
|
6
7
|
/** AKP, a.k.a ML-DSA */
|
|
7
8
|
export async function verifyAKP(opts) {
|
|
8
9
|
const { cosePublicKey, signature, data } = opts;
|
|
@@ -37,7 +38,7 @@ export async function verifyAKP(opts) {
|
|
|
37
38
|
catch (err) {
|
|
38
39
|
const _err = err;
|
|
39
40
|
if (_err.name === 'NotSupportedError') {
|
|
40
|
-
throw new
|
|
41
|
+
throw new PQCNotSupportedError(alg);
|
|
41
42
|
}
|
|
42
43
|
else {
|
|
43
44
|
throw err;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { COSEALG } from './cose.js';
|
|
2
2
|
/**
|
|
3
3
|
* Map X.509 signature algorithm OIDs to COSE algorithm IDs
|
|
4
|
-
*
|
|
5
|
-
* - EC2 OIDs: https://oidref.com/1.2.840.10045.4.3
|
|
6
|
-
* - RSA OIDs: https://oidref.com/1.2.840.113549.1.1
|
|
7
4
|
*/
|
|
8
5
|
export declare function mapX509SignatureAlgToCOSEAlg(signatureAlgorithm: string): COSEALG;
|
|
9
6
|
//# sourceMappingURL=mapX509SignatureAlgToCOSEAlg.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapX509SignatureAlgToCOSEAlg.d.ts","sourceRoot":"","sources":["../../src/helpers/mapX509SignatureAlgToCOSEAlg.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapX509SignatureAlgToCOSEAlg.d.ts","sourceRoot":"","sources":["../../src/helpers/mapX509SignatureAlgToCOSEAlg.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,kBAAkB,EAAE,MAAM,GACzB,OAAO,CA8BT"}
|
|
@@ -1,33 +1,42 @@
|
|
|
1
|
+
import { id_ecdsaWithSHA256, id_ecdsaWithSHA384, id_ecdsaWithSHA512 } from '@peculiar/asn1-ecc';
|
|
2
|
+
import { id_sha1WithRSAEncryption, id_sha256WithRSAEncryption, id_sha384WithRSAEncryption, id_sha512WithRSAEncryption, } from '@peculiar/asn1-rsa';
|
|
3
|
+
import { id_ml_dsa_44, id_ml_dsa_65, id_ml_dsa_87 } from '@peculiar/asn1-x509-post-quantum';
|
|
1
4
|
import { COSEALG } from './cose.js';
|
|
2
5
|
/**
|
|
3
6
|
* Map X.509 signature algorithm OIDs to COSE algorithm IDs
|
|
4
|
-
*
|
|
5
|
-
* - EC2 OIDs: https://oidref.com/1.2.840.10045.4.3
|
|
6
|
-
* - RSA OIDs: https://oidref.com/1.2.840.113549.1.1
|
|
7
7
|
*/
|
|
8
8
|
export function mapX509SignatureAlgToCOSEAlg(signatureAlgorithm) {
|
|
9
9
|
let alg;
|
|
10
|
-
if (signatureAlgorithm ===
|
|
10
|
+
if (signatureAlgorithm === id_ecdsaWithSHA256) {
|
|
11
11
|
alg = COSEALG.ES256;
|
|
12
12
|
}
|
|
13
|
-
else if (signatureAlgorithm ===
|
|
13
|
+
else if (signatureAlgorithm === id_ecdsaWithSHA384) {
|
|
14
14
|
alg = COSEALG.ES384;
|
|
15
15
|
}
|
|
16
|
-
else if (signatureAlgorithm ===
|
|
16
|
+
else if (signatureAlgorithm === id_ecdsaWithSHA512) {
|
|
17
17
|
alg = COSEALG.ES512;
|
|
18
18
|
}
|
|
19
|
-
else if (signatureAlgorithm ===
|
|
19
|
+
else if (signatureAlgorithm === id_sha256WithRSAEncryption) {
|
|
20
20
|
alg = COSEALG.RS256;
|
|
21
21
|
}
|
|
22
|
-
else if (signatureAlgorithm ===
|
|
22
|
+
else if (signatureAlgorithm === id_sha384WithRSAEncryption) {
|
|
23
23
|
alg = COSEALG.RS384;
|
|
24
24
|
}
|
|
25
|
-
else if (signatureAlgorithm ===
|
|
25
|
+
else if (signatureAlgorithm === id_sha512WithRSAEncryption) {
|
|
26
26
|
alg = COSEALG.RS512;
|
|
27
27
|
}
|
|
28
|
-
else if (signatureAlgorithm ===
|
|
28
|
+
else if (signatureAlgorithm === id_sha1WithRSAEncryption) {
|
|
29
29
|
alg = COSEALG.RS1;
|
|
30
30
|
}
|
|
31
|
+
else if (signatureAlgorithm === id_ml_dsa_44) {
|
|
32
|
+
alg = COSEALG.ML_DSA_44;
|
|
33
|
+
}
|
|
34
|
+
else if (signatureAlgorithm === id_ml_dsa_65) {
|
|
35
|
+
alg = COSEALG.ML_DSA_65;
|
|
36
|
+
}
|
|
37
|
+
else if (signatureAlgorithm === id_ml_dsa_87) {
|
|
38
|
+
alg = COSEALG.ML_DSA_87;
|
|
39
|
+
}
|
|
31
40
|
else {
|
|
32
41
|
throw new Error(`Unable to map X.509 signature algorithm ${signatureAlgorithm} to a COSE algorithm`);
|
|
33
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateCertificatePath.d.ts","sourceRoot":"","sources":["../../src/helpers/validateCertificatePath.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateCertificatePath.d.ts","sourceRoot":"","sources":["../../src/helpers/validateCertificatePath.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAM1B;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EAAE,EACrB,eAAe,GAAE,MAAM,EAAO,GAC7B,OAAO,CAAC,OAAO,CAAC,CAiLlB"}
|