micro509 0.13.0 → 0.14.0
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/README.md +78 -30
- package/dist/crypto/crypto.d.ts +73 -0
- package/dist/crypto/crypto.js +74 -0
- package/dist/crypto/crypto.js.map +1 -0
- package/dist/crypto.d.ts +4 -0
- package/dist/crypto.js +2 -0
- package/dist/der/der.d.ts +1 -1
- package/dist/index.d.ts +13 -9
- package/dist/index.js +17 -15
- package/dist/internal/asn1/asn1.js +21 -10
- package/dist/internal/asn1/asn1.js.map +1 -1
- package/dist/internal/asn1/der.d.ts +4 -2
- package/dist/internal/asn1/der.js +18 -5
- package/dist/internal/asn1/der.js.map +1 -1
- package/dist/internal/asn1/oids.js +7 -1
- package/dist/internal/crypto/algorithm-names.js +4 -0
- package/dist/internal/crypto/algorithm-names.js.map +1 -1
- package/dist/internal/crypto/pbes2.d.ts +38 -0
- package/dist/internal/crypto/pbes2.js +9 -10
- package/dist/internal/crypto/pbes2.js.map +1 -1
- package/dist/internal/crypto/rsa-pss.js +2 -0
- package/dist/internal/crypto/rsa-pss.js.map +1 -1
- package/dist/internal/crypto/sig-verify.d.ts +31 -0
- package/dist/internal/crypto/sig-verify.js +10 -8
- package/dist/internal/crypto/sig-verify.js.map +1 -1
- package/dist/internal/shared/base64.js +7 -1
- package/dist/internal/shared/base64.js.map +1 -1
- package/dist/internal/shared/dn.d.ts +16 -0
- package/dist/internal/shared/dn.js +13 -6
- package/dist/internal/shared/dn.js.map +1 -1
- package/dist/internal/shared/ip.d.ts +69 -0
- package/dist/internal/shared/ip.js +18 -1
- package/dist/internal/shared/ip.js.map +1 -1
- package/dist/internal/verify/verify-path.d.ts +7 -0
- package/dist/internal/verify/verify-path.js +36 -36
- package/dist/internal/x509/directory-name.js +24 -0
- package/dist/internal/x509/directory-name.js.map +1 -0
- package/dist/internal/x509/extension-bits.js +13 -10
- package/dist/internal/x509/extension-bits.js.map +1 -1
- package/dist/internal/x509/extension-errors.d.ts +6 -0
- package/dist/internal/x509/extension-errors.js +20 -0
- package/dist/internal/x509/extension-errors.js.map +1 -0
- package/dist/internal/x509/extension-registry.js +113 -55
- package/dist/internal/x509/extension-registry.js.map +1 -1
- package/dist/internal/x509/general-name-tags.js +28 -0
- package/dist/internal/x509/general-name-tags.js.map +1 -0
- package/dist/internal/x509/general-name.js +97 -0
- package/dist/internal/x509/general-name.js.map +1 -0
- package/dist/internal/x509/name-fields.js +20 -10
- package/dist/internal/x509/name-fields.js.map +1 -1
- package/dist/keys/keys.d.ts +16 -2
- package/dist/keys/keys.js +311 -170
- package/dist/keys/keys.js.map +1 -1
- package/dist/keys.d.ts +3 -2
- package/dist/keys.js +3 -2
- package/dist/pem/pem.d.ts +3 -2
- package/dist/pem/pem.js +112 -30
- package/dist/pem/pem.js.map +1 -1
- package/dist/pkcs/pkcs12-mac.js +3 -3
- package/dist/pkcs/pkcs12-mac.js.map +1 -1
- package/dist/pkcs/pkcs7.d.ts +85 -21
- package/dist/pkcs/pkcs7.js +261 -186
- package/dist/pkcs/pkcs7.js.map +1 -1
- package/dist/pkcs.d.ts +2 -2
- package/dist/result/result.d.ts +18 -10
- package/dist/result/result.js +20 -12
- package/dist/result/result.js.map +1 -1
- package/dist/result.d.ts +2 -2
- package/dist/result.js +2 -2
- package/dist/revocation/chain.js +77 -81
- package/dist/revocation/chain.js.map +1 -1
- package/dist/revocation/crl.d.ts +13 -2
- package/dist/revocation/crl.js +415 -236
- package/dist/revocation/crl.js.map +1 -1
- package/dist/revocation/ocsp.d.ts +58 -17
- package/dist/revocation/ocsp.js +185 -173
- package/dist/revocation/ocsp.js.map +1 -1
- package/dist/revocation/revocation.d.ts +4 -4
- package/dist/revocation/revocation.js +48 -30
- package/dist/revocation/revocation.js.map +1 -1
- package/dist/revocation.d.ts +4 -4
- package/dist/revocation.js +5 -5
- package/dist/verify/identity.d.ts +2 -1
- package/dist/verify/identity.js +2 -1
- package/dist/verify/identity.js.map +1 -1
- package/dist/verify/policy.d.ts +6 -1
- package/dist/verify/verify.d.ts +4 -2
- package/dist/verify/verify.js +32 -14
- package/dist/verify/verify.js.map +1 -1
- package/dist/verify.d.ts +2 -1
- package/dist/verify.js +4 -3
- package/dist/x509/certificate.d.ts +36 -13
- package/dist/x509/certificate.js +36 -19
- package/dist/x509/certificate.js.map +1 -1
- package/dist/x509/csr.d.ts +6 -3
- package/dist/x509/extensions.d.ts +58 -21
- package/dist/x509/extensions.js +384 -117
- package/dist/x509/extensions.js.map +1 -1
- package/dist/x509/name-text.js +2 -0
- package/dist/x509/name-text.js.map +1 -1
- package/dist/x509/name.d.ts +8 -5
- package/dist/x509/name.js +17 -12
- package/dist/x509/name.js.map +1 -1
- package/dist/x509/parse.d.ts +104 -18
- package/dist/x509/parse.js +127 -163
- package/dist/x509/parse.js.map +1 -1
- package/dist/x509.d.ts +8 -5
- package/dist/x509.js +10 -8
- package/package.json +28 -20
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//#region src/internal/shared/ip.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes an IP address string for comparison.\
|
|
4
|
+
* IPv4 addresses pass through unchanged; IPv6 addresses expand to 8
|
|
5
|
+
* colon-separated zero-padded groups.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* normalizeIpAddress('::1');
|
|
10
|
+
* // '0000:0000:0000:0000:0000:0000:0000:0001'
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param value IPv4 or IPv6 address string to normalize.
|
|
14
|
+
* @returns The normalized address string.
|
|
15
|
+
*/
|
|
16
|
+
declare function normalizeIpAddress(value: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Parses an IPv4 or IPv6 address string into raw bytes.\
|
|
19
|
+
* Returns 4 bytes for IPv4 and 16 bytes for IPv6.
|
|
20
|
+
*
|
|
21
|
+
* Suitable for encoding into SAN iPAddress octets or name-constraint ranges.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* Array.from(parseIpAddressToBytes('127.0.0.1'));
|
|
26
|
+
* // [127, 0, 0, 1]
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param value IPv4 or IPv6 address string to parse.
|
|
30
|
+
* @returns The raw address bytes.
|
|
31
|
+
*/
|
|
32
|
+
declare function parseIpAddressToBytes(value: string): Uint8Array;
|
|
33
|
+
/**
|
|
34
|
+
* Converts raw IP address bytes back to a human-readable string.\
|
|
35
|
+
* Returns dotted-decimal IPv4 for 4-byte input and colon-separated hex
|
|
36
|
+
* IPv6 for 16-byte input.
|
|
37
|
+
*
|
|
38
|
+
* Throws on any other length.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* decodeIpAddress(Uint8Array.of(127, 0, 0, 1));
|
|
43
|
+
* // '127.0.0.1'
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param bytes Raw IPv4 or IPv6 address bytes.
|
|
47
|
+
* @returns The decoded address string.
|
|
48
|
+
*/
|
|
49
|
+
declare function decodeIpAddress(bytes: Uint8Array): string;
|
|
50
|
+
/**
|
|
51
|
+
* Returns an all-ones (`0xff`) mask of the appropriate length for the
|
|
52
|
+
* given IP address string.\
|
|
53
|
+
* Returns 4 bytes for IPv4 and 16 bytes for IPv6.
|
|
54
|
+
*
|
|
55
|
+
* Used to build name-constraint subnet masks that match a single host.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* Array.from(allOnesMaskForIpAddress('127.0.0.1'));
|
|
60
|
+
* // [255, 255, 255, 255]
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @param value IPv4 or IPv6 address string used to choose mask length.
|
|
64
|
+
* @returns An all-ones mask for the same address family.
|
|
65
|
+
*/
|
|
66
|
+
declare function allOnesMaskForIpAddress(value: string): Uint8Array;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { allOnesMaskForIpAddress, decodeIpAddress, normalizeIpAddress, parseIpAddressToBytes };
|
|
69
|
+
//# sourceMappingURL=ip.d.ts.map
|
|
@@ -37,6 +37,23 @@
|
|
|
37
37
|
/** Matches a single valid IPv6 hex segment (1–4 hex digits). */
|
|
38
38
|
const e = /^[0-9a-f]{1,4}$/;
|
|
39
39
|
/**
|
|
40
|
+
* Normalizes an IP address string for comparison.\
|
|
41
|
+
* IPv4 addresses pass through unchanged; IPv6 addresses expand to 8
|
|
42
|
+
* colon-separated zero-padded groups.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* normalizeIpAddress('::1');
|
|
47
|
+
* // '0000:0000:0000:0000:0000:0000:0000:0001'
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param value IPv4 or IPv6 address string to normalize.
|
|
51
|
+
* @returns The normalized address string.
|
|
52
|
+
*/
|
|
53
|
+
function normalizeIpAddress(e) {
|
|
54
|
+
return e.includes(":") ? expandIpv6(e).join(":") : e;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
40
57
|
* Expands an IPv6 address, including `::` shorthand, into exactly 8
|
|
41
58
|
* zero-padded four-character hex segments.\
|
|
42
59
|
* Throws on malformed input.
|
|
@@ -149,6 +166,6 @@ function parseIpv6ToBytes(e) {
|
|
|
149
166
|
}), n;
|
|
150
167
|
}
|
|
151
168
|
//#endregion
|
|
152
|
-
export { allOnesMaskForIpAddress, decodeIpAddress, expandIpv6, parseIpAddressToBytes };
|
|
169
|
+
export { allOnesMaskForIpAddress, decodeIpAddress, expandIpv6, normalizeIpAddress, parseIpAddressToBytes };
|
|
153
170
|
|
|
154
171
|
//# sourceMappingURL=ip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ip.js","names":[],"sources":["../../../src/internal/shared/ip.ts"],"sourcesContent":["/**\n * IP address parsing and normalization helpers shared by parsing,\n * validation, and identity matching flows.\n *\n * These utilities keep IPv4 and IPv6 handling consistent for SAN\n * matching and name constraint evaluation.\n *\n * @example\n * ```ts\n * import {\n * \tallOnesMaskForIpAddress,\n * \tdecodeIpAddress,\n * \texpandIpv6,\n * \tnormalizeIpAddress,\n * \tparseIpAddressToBytes,\n * } from './ip.ts';\n *\n * normalizeIpAddress('::1');\n * // '0000:0000:0000:0000:0000:0000:0000:0001'\n *\n * expandIpv6('2001:db8::1');\n * // ['2001', '0db8', '0000', '0000', '0000', '0000', '0000', '0001']\n *\n * Array.from(parseIpAddressToBytes('127.0.0.1'));\n * // [127, 0, 0, 1]\n *\n * decodeIpAddress(Uint8Array.of(127, 0, 0, 1));\n * // '127.0.0.1'\n *\n * Array.from(allOnesMaskForIpAddress('127.0.0.1'));\n * // [255, 255, 255, 255]\n * ```\n *\n * @module\n */\n\n/** Matches a single valid IPv6 hex segment (1–4 hex digits). */\nconst IPV6_SEGMENT = /^[0-9a-f]{1,4}$/;\n\n/**\n * Normalizes an IP address string for comparison.\\\n * IPv4 addresses pass through unchanged; IPv6 addresses expand to 8\n * colon-separated zero-padded groups.\n *\n * @example\n * ```ts\n * normalizeIpAddress('::1');\n * // '0000:0000:0000:0000:0000:0000:0000:0001'\n * ```\n *\n * @param value IPv4 or IPv6 address string to normalize.\n * @returns The normalized address string.\n */\nexport function normalizeIpAddress(value: string): string {\n\tif (!value.includes(':')) {\n\t\treturn value;\n\t}\n\treturn expandIpv6(value).join(':');\n}\n\n/**\n * Expands an IPv6 address, including `::` shorthand, into exactly 8\n * zero-padded four-character hex segments.\\\n * Throws on malformed input.\n *\n * @example\n * ```ts\n * expandIpv6('2001:db8::1');\n * // ['2001', '0db8', '0000', '0000', '0000', '0000', '0000', '0001']\n * ```\n *\n * @param value IPv6 address string to expand.\n * @returns The 8 normalized IPv6 segments.\n */\nexport function expandIpv6(value: string): readonly string[] {\n\tconst normalized = value.toLowerCase();\n\tconst pieces = normalized.split('::');\n\tconst head = pieces[0] ?? '';\n\tconst tail = pieces[1];\n\tif (tail !== undefined && normalized.indexOf('::') !== normalized.lastIndexOf('::')) {\n\t\tthrow new Error(`Invalid IPv6 address: ${value}`);\n\t}\n\tconst headParts = head.length > 0 ? head.split(':') : [];\n\tconst tailParts = tail !== undefined && tail.length > 0 ? tail.split(':') : [];\n\tconst missing = 8 - (headParts.length + tailParts.length);\n\tif ((tail === undefined && headParts.length !== 8) || missing < 0) {\n\t\tthrow new Error(`Invalid IPv6 address: ${value}`);\n\t}\n\tconst zeroes = Array.from({ length: missing }, () => '0');\n\tconst parts = tail === undefined ? headParts : [...headParts, ...zeroes, ...tailParts];\n\tif (parts.length !== 8) {\n\t\tthrow new Error(`Invalid IPv6 address: ${value}`);\n\t}\n\treturn parts.map((segment) => {\n\t\tif (!IPV6_SEGMENT.test(segment)) {\n\t\t\tthrow new Error(`Invalid IPv6 address: ${value}`);\n\t\t}\n\t\treturn segment.padStart(4, '0');\n\t});\n}\n\n/**\n * Parses an IPv4 or IPv6 address string into raw bytes.\\\n * Returns 4 bytes for IPv4 and 16 bytes for IPv6.\n *\n * Suitable for encoding into SAN iPAddress octets or name-constraint ranges.\n *\n * @example\n * ```ts\n * Array.from(parseIpAddressToBytes('127.0.0.1'));\n * // [127, 0, 0, 1]\n * ```\n *\n * @param value IPv4 or IPv6 address string to parse.\n * @returns The raw address bytes.\n */\nexport function parseIpAddressToBytes(value: string): Uint8Array {\n\tif (value.includes(':')) {\n\t\treturn parseIpv6ToBytes(value);\n\t}\n\tconst segments = value.split('.');\n\tif (segments.length !== 4) {\n\t\tthrow new Error(`Invalid IPv4 address: ${value}`);\n\t}\n\treturn Uint8Array.from(\n\t\tsegments.map((segment) => {\n\t\t\tif (segment.length === 0) {\n\t\t\t\tthrow new Error(`Invalid IPv4 address: ${value}`);\n\t\t\t}\n\t\t\tconst parsed = Number(segment);\n\t\t\tif (!Number.isInteger(parsed) || parsed < 0 || parsed > 255) {\n\t\t\t\tthrow new Error(`Invalid IPv4 address: ${value}`);\n\t\t\t}\n\t\t\treturn parsed;\n\t\t}),\n\t);\n}\n\n/**\n * Converts raw IP address bytes back to a human-readable string.\\\n * Returns dotted-decimal IPv4 for 4-byte input and colon-separated hex\n * IPv6 for 16-byte input.\n *\n * Throws on any other length.\n *\n * @example\n * ```ts\n * decodeIpAddress(Uint8Array.of(127, 0, 0, 1));\n * // '127.0.0.1'\n * ```\n *\n * @param bytes Raw IPv4 or IPv6 address bytes.\n * @returns The decoded address string.\n */\nexport function decodeIpAddress(bytes: Uint8Array): string {\n\tif (bytes.length === 4) {\n\t\treturn Array.from(bytes, (value) => String(value)).join('.');\n\t}\n\tif (bytes.length === 16) {\n\t\tconst groups: string[] = [];\n\t\tfor (let index = 0; index < bytes.length; index += 2) {\n\t\t\tconst left = bytes[index] ?? 0;\n\t\t\tconst right = bytes[index + 1] ?? 0;\n\t\t\tgroups.push(((left << 8) | right).toString(16));\n\t\t}\n\t\treturn groups.join(':');\n\t}\n\tthrow new Error(`Unsupported IP address length: ${bytes.length}`);\n}\n\n/**\n * Returns an all-ones (`0xff`) mask of the appropriate length for the\n * given IP address string.\\\n * Returns 4 bytes for IPv4 and 16 bytes for IPv6.\n *\n * Used to build name-constraint subnet masks that match a single host.\n *\n * @example\n * ```ts\n * Array.from(allOnesMaskForIpAddress('127.0.0.1'));\n * // [255, 255, 255, 255]\n * ```\n *\n * @param value IPv4 or IPv6 address string used to choose mask length.\n * @returns An all-ones mask for the same address family.\n */\nexport function allOnesMaskForIpAddress(value: string): Uint8Array {\n\t// Validate and parse the IP address to determine its type\n\tconst parsed = parseIpAddressToBytes(value);\n\tconst mask = new Uint8Array(parsed.length);\n\tmask.fill(0xff);\n\treturn mask;\n}\n\n/** Parses an IPv6 address string into a 16-byte `Uint8Array`. */\nfunction parseIpv6ToBytes(value: string): Uint8Array {\n\tconst expanded = expandIpv6(value);\n\tconst bytes = new Uint8Array(16);\n\texpanded.forEach((segment, index) => {\n\t\tconst parsed = Number.parseInt(segment, 16);\n\t\tbytes[index * 2] = parsed >> 8;\n\t\tbytes[index * 2 + 1] = parsed & 0xff;\n\t});\n\treturn bytes;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,IAAe;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ip.js","names":[],"sources":["../../../src/internal/shared/ip.ts"],"sourcesContent":["/**\n * IP address parsing and normalization helpers shared by parsing,\n * validation, and identity matching flows.\n *\n * These utilities keep IPv4 and IPv6 handling consistent for SAN\n * matching and name constraint evaluation.\n *\n * @example\n * ```ts\n * import {\n * \tallOnesMaskForIpAddress,\n * \tdecodeIpAddress,\n * \texpandIpv6,\n * \tnormalizeIpAddress,\n * \tparseIpAddressToBytes,\n * } from './ip.ts';\n *\n * normalizeIpAddress('::1');\n * // '0000:0000:0000:0000:0000:0000:0000:0001'\n *\n * expandIpv6('2001:db8::1');\n * // ['2001', '0db8', '0000', '0000', '0000', '0000', '0000', '0001']\n *\n * Array.from(parseIpAddressToBytes('127.0.0.1'));\n * // [127, 0, 0, 1]\n *\n * decodeIpAddress(Uint8Array.of(127, 0, 0, 1));\n * // '127.0.0.1'\n *\n * Array.from(allOnesMaskForIpAddress('127.0.0.1'));\n * // [255, 255, 255, 255]\n * ```\n *\n * @module\n */\n\n/** Matches a single valid IPv6 hex segment (1–4 hex digits). */\nconst IPV6_SEGMENT = /^[0-9a-f]{1,4}$/;\n\n/**\n * Normalizes an IP address string for comparison.\\\n * IPv4 addresses pass through unchanged; IPv6 addresses expand to 8\n * colon-separated zero-padded groups.\n *\n * @example\n * ```ts\n * normalizeIpAddress('::1');\n * // '0000:0000:0000:0000:0000:0000:0000:0001'\n * ```\n *\n * @param value IPv4 or IPv6 address string to normalize.\n * @returns The normalized address string.\n */\nexport function normalizeIpAddress(value: string): string {\n\tif (!value.includes(':')) {\n\t\treturn value;\n\t}\n\treturn expandIpv6(value).join(':');\n}\n\n/**\n * Expands an IPv6 address, including `::` shorthand, into exactly 8\n * zero-padded four-character hex segments.\\\n * Throws on malformed input.\n *\n * @example\n * ```ts\n * expandIpv6('2001:db8::1');\n * // ['2001', '0db8', '0000', '0000', '0000', '0000', '0000', '0001']\n * ```\n *\n * @param value IPv6 address string to expand.\n * @returns The 8 normalized IPv6 segments.\n */\nexport function expandIpv6(value: string): readonly string[] {\n\tconst normalized = value.toLowerCase();\n\tconst pieces = normalized.split('::');\n\tconst head = pieces[0] ?? '';\n\tconst tail = pieces[1];\n\tif (tail !== undefined && normalized.indexOf('::') !== normalized.lastIndexOf('::')) {\n\t\tthrow new Error(`Invalid IPv6 address: ${value}`);\n\t}\n\tconst headParts = head.length > 0 ? head.split(':') : [];\n\tconst tailParts = tail !== undefined && tail.length > 0 ? tail.split(':') : [];\n\tconst missing = 8 - (headParts.length + tailParts.length);\n\tif ((tail === undefined && headParts.length !== 8) || missing < 0) {\n\t\tthrow new Error(`Invalid IPv6 address: ${value}`);\n\t}\n\tconst zeroes = Array.from({ length: missing }, () => '0');\n\tconst parts = tail === undefined ? headParts : [...headParts, ...zeroes, ...tailParts];\n\tif (parts.length !== 8) {\n\t\tthrow new Error(`Invalid IPv6 address: ${value}`);\n\t}\n\treturn parts.map((segment) => {\n\t\tif (!IPV6_SEGMENT.test(segment)) {\n\t\t\tthrow new Error(`Invalid IPv6 address: ${value}`);\n\t\t}\n\t\treturn segment.padStart(4, '0');\n\t});\n}\n\n/**\n * Parses an IPv4 or IPv6 address string into raw bytes.\\\n * Returns 4 bytes for IPv4 and 16 bytes for IPv6.\n *\n * Suitable for encoding into SAN iPAddress octets or name-constraint ranges.\n *\n * @example\n * ```ts\n * Array.from(parseIpAddressToBytes('127.0.0.1'));\n * // [127, 0, 0, 1]\n * ```\n *\n * @param value IPv4 or IPv6 address string to parse.\n * @returns The raw address bytes.\n */\nexport function parseIpAddressToBytes(value: string): Uint8Array {\n\tif (value.includes(':')) {\n\t\treturn parseIpv6ToBytes(value);\n\t}\n\tconst segments = value.split('.');\n\tif (segments.length !== 4) {\n\t\tthrow new Error(`Invalid IPv4 address: ${value}`);\n\t}\n\treturn Uint8Array.from(\n\t\tsegments.map((segment) => {\n\t\t\tif (segment.length === 0) {\n\t\t\t\tthrow new Error(`Invalid IPv4 address: ${value}`);\n\t\t\t}\n\t\t\tconst parsed = Number(segment);\n\t\t\tif (!Number.isInteger(parsed) || parsed < 0 || parsed > 255) {\n\t\t\t\tthrow new Error(`Invalid IPv4 address: ${value}`);\n\t\t\t}\n\t\t\treturn parsed;\n\t\t}),\n\t);\n}\n\n/**\n * Converts raw IP address bytes back to a human-readable string.\\\n * Returns dotted-decimal IPv4 for 4-byte input and colon-separated hex\n * IPv6 for 16-byte input.\n *\n * Throws on any other length.\n *\n * @example\n * ```ts\n * decodeIpAddress(Uint8Array.of(127, 0, 0, 1));\n * // '127.0.0.1'\n * ```\n *\n * @param bytes Raw IPv4 or IPv6 address bytes.\n * @returns The decoded address string.\n */\nexport function decodeIpAddress(bytes: Uint8Array): string {\n\tif (bytes.length === 4) {\n\t\treturn Array.from(bytes, (value) => String(value)).join('.');\n\t}\n\tif (bytes.length === 16) {\n\t\tconst groups: string[] = [];\n\t\tfor (let index = 0; index < bytes.length; index += 2) {\n\t\t\tconst left = bytes[index] ?? 0;\n\t\t\tconst right = bytes[index + 1] ?? 0;\n\t\t\tgroups.push(((left << 8) | right).toString(16));\n\t\t}\n\t\treturn groups.join(':');\n\t}\n\tthrow new Error(`Unsupported IP address length: ${bytes.length}`);\n}\n\n/**\n * Returns an all-ones (`0xff`) mask of the appropriate length for the\n * given IP address string.\\\n * Returns 4 bytes for IPv4 and 16 bytes for IPv6.\n *\n * Used to build name-constraint subnet masks that match a single host.\n *\n * @example\n * ```ts\n * Array.from(allOnesMaskForIpAddress('127.0.0.1'));\n * // [255, 255, 255, 255]\n * ```\n *\n * @param value IPv4 or IPv6 address string used to choose mask length.\n * @returns An all-ones mask for the same address family.\n */\nexport function allOnesMaskForIpAddress(value: string): Uint8Array {\n\t// Validate and parse the IP address to determine its type\n\tconst parsed = parseIpAddressToBytes(value);\n\tconst mask = new Uint8Array(parsed.length);\n\tmask.fill(0xff);\n\treturn mask;\n}\n\n/** Parses an IPv6 address string into a 16-byte `Uint8Array`. */\nfunction parseIpv6ToBytes(value: string): Uint8Array {\n\tconst expanded = expandIpv6(value);\n\tconst bytes = new Uint8Array(16);\n\texpanded.forEach((segment, index) => {\n\t\tconst parsed = Number.parseInt(segment, 16);\n\t\tbytes[index * 2] = parsed >> 8;\n\t\tbytes[index * 2 + 1] = parsed & 0xff;\n\t});\n\treturn bytes;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ParsedCertificate } from "../../x509/parse.js";
|
|
2
|
+
//#region src/internal/verify/verify-path.d.ts
|
|
3
|
+
/** Returns `true` if the certificate's subject and issuer DNs are semantically equal (RFC 5280 §7.1). */
|
|
4
|
+
declare function isSelfIssued(certificate: ParsedCertificate): boolean;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { isSelfIssued };
|
|
7
|
+
//# sourceMappingURL=verify-path.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toHex as e } from "../asn1/asn1.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { canonicalDnKey as t, compareDistinguishedNames as n } from "../shared/dn.js";
|
|
3
|
+
import { parseCertificatesFromSource as r } from "../../x509/parse.js";
|
|
4
|
+
import { verifySignedDataDetailed as i } from "../crypto/sig-verify.js";
|
|
5
5
|
//#region src/internal/verify/verify-path.ts
|
|
6
6
|
/**
|
|
7
7
|
* Internal certificate path-building and signature-check helpers.
|
|
@@ -18,7 +18,7 @@ function isWithinValidity(e, t) {
|
|
|
18
18
|
}
|
|
19
19
|
/** Returns `true` if the certificate's subject and issuer DNs are semantically equal (RFC 5280 §7.1). */
|
|
20
20
|
function isSelfIssued(e) {
|
|
21
|
-
return
|
|
21
|
+
return n(e.subject, e.issuer);
|
|
22
22
|
}
|
|
23
23
|
/** Counts non-self-issued CA certificates in positions 0..(index-1) for pathLength checking. */
|
|
24
24
|
function countCaCertificatesBelowParsed(e, t) {
|
|
@@ -44,12 +44,12 @@ function loadSingleCertificate(e) {
|
|
|
44
44
|
}
|
|
45
45
|
/** Verifies that `certificate` was signed by `issuer`'s public key. */
|
|
46
46
|
async function verifyCertificateSignature(e, t) {
|
|
47
|
-
let
|
|
48
|
-
return !
|
|
47
|
+
let n = await i(e.signatureAlgorithmOid, e.signatureAlgorithmParametersDer, t.publicKeyAlgorithmOid, t.publicKeyParametersOid, t.subjectPublicKeyInfoDer, e.signatureValue, e.tbsCertificateDer);
|
|
48
|
+
return !n.ok && n.code === "verification_error" ? {
|
|
49
49
|
ok: !1,
|
|
50
50
|
code: "signature_invalid",
|
|
51
|
-
reason:
|
|
52
|
-
} :
|
|
51
|
+
reason: n.reason
|
|
52
|
+
} : n;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Depth-first chain search from leaf to root. Tries all issuer candidates,
|
|
@@ -57,16 +57,16 @@ async function verifyCertificateSignature(e, t) {
|
|
|
57
57
|
* step. Returns the first fully anchored path or the deepest partial path
|
|
58
58
|
* with the best failure encountered.
|
|
59
59
|
*/
|
|
60
|
-
async function buildChainInternal(e,
|
|
61
|
-
let s = [...
|
|
60
|
+
async function buildChainInternal(e, n, r, i, a, o) {
|
|
61
|
+
let s = [...n, ...r], c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = new Set(r.map((e) => fingerprint(e))), d = /* @__PURE__ */ new Map();
|
|
62
62
|
for (let e of i) {
|
|
63
|
-
let
|
|
64
|
-
|
|
63
|
+
let n = t(e.subject), r = d.get(n);
|
|
64
|
+
r === void 0 ? d.set(n, [e]) : r.push(e);
|
|
65
65
|
}
|
|
66
66
|
let f = !1, p = [e], m, h, g = /* @__PURE__ */ new Set();
|
|
67
|
-
s.forEach((e,
|
|
68
|
-
let
|
|
69
|
-
i === void 0 ? c.set(
|
|
67
|
+
s.forEach((e, n) => {
|
|
68
|
+
let r = t(e.subject), i = c.get(r);
|
|
69
|
+
i === void 0 ? c.set(r, [e]) : i.push(e), l.set(fingerprint(e), n);
|
|
70
70
|
});
|
|
71
71
|
let _ = s.length + 1, v = fingerprint(e), y = await search(e, [e], /* @__PURE__ */ new Set([v]), 0);
|
|
72
72
|
if (y !== void 0) {
|
|
@@ -94,21 +94,21 @@ async function buildChainInternal(e, t, n, i, a, o) {
|
|
|
94
94
|
foundTrustedRoot: !1,
|
|
95
95
|
missingIssuerAt: m
|
|
96
96
|
};
|
|
97
|
-
async function search(e,
|
|
98
|
-
if (u.has(fingerprint(e))) return
|
|
99
|
-
let a = await matchTrustAnchor(e, d, o,
|
|
100
|
-
if (a.failure !== void 0 && recordFailure(a.failure,
|
|
101
|
-
if (
|
|
102
|
-
let s = [...
|
|
97
|
+
async function search(e, n, r, i) {
|
|
98
|
+
if (u.has(fingerprint(e))) return n;
|
|
99
|
+
let a = await matchTrustAnchor(e, d, o, n.length - 1);
|
|
100
|
+
if (a.failure !== void 0 && recordFailure(a.failure, n), a.matched) return n;
|
|
101
|
+
if (n.length > _) return;
|
|
102
|
+
let s = [...r].sort().join(","), f = `${fingerprint(e)}:${i}:${s}`;
|
|
103
103
|
if (g.has(f)) return;
|
|
104
|
-
let p = rankIssuerCandidates(e, c.get(
|
|
104
|
+
let p = rankIssuerCandidates(e, c.get(t(e.issuer)) ?? [], l, u);
|
|
105
105
|
if (p.length === 0) {
|
|
106
|
-
recordMissingIssuers(e,
|
|
106
|
+
recordMissingIssuers(e, n), g.add(f);
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
let m = await searchIssuerCandidates(e, p,
|
|
109
|
+
let m = await searchIssuerCandidates(e, p, n, r, i);
|
|
110
110
|
if (m !== void 0) return m;
|
|
111
|
-
g.add(f), updateDeepest(
|
|
111
|
+
g.add(f), updateDeepest(n);
|
|
112
112
|
}
|
|
113
113
|
function recordMissingIssuers(e, t) {
|
|
114
114
|
isSelfIssued(e) ? (updateDeepest(t), f = !0) : updateDeepest(t) && (m = t.length - 1);
|
|
@@ -203,7 +203,7 @@ function authorityKeyIdentifierMismatch(e, t) {
|
|
|
203
203
|
}
|
|
204
204
|
/** Expands a PEM (possibly multi-block) or DER source into parsed certificates. */
|
|
205
205
|
function expandSource(e) {
|
|
206
|
-
return
|
|
206
|
+
return r(e);
|
|
207
207
|
}
|
|
208
208
|
/** Filters and sorts issuer candidates: AKI match first, then roots, then input order. */
|
|
209
209
|
function rankIssuerCandidates(e, t, n, r) {
|
|
@@ -226,25 +226,25 @@ function compareBooleans(e, t) {
|
|
|
226
226
|
}
|
|
227
227
|
/** Returns `true` if `issuer`'s subject DN semantically matches `child`'s issuer DN (RFC 5280 §7.1). */
|
|
228
228
|
function isIssuerOf(e, t) {
|
|
229
|
-
return
|
|
229
|
+
return n(t.issuer, e.subject);
|
|
230
230
|
}
|
|
231
231
|
/** Attempts to verify `certificate` against each bare trust anchor whose subject DN matches. */
|
|
232
|
-
async function matchTrustAnchor(e,
|
|
233
|
-
let o =
|
|
232
|
+
async function matchTrustAnchor(e, r, i, a) {
|
|
233
|
+
let o = r.get(t(e.issuer));
|
|
234
234
|
if (o === void 0) return { matched: !1 };
|
|
235
235
|
let s;
|
|
236
236
|
for (let t of o) {
|
|
237
|
-
if (trustAnchorAkiMismatch(e, t) || !
|
|
237
|
+
if (trustAnchorAkiMismatch(e, t) || !n(e.issuer, t.subject)) continue;
|
|
238
238
|
let r = await verifyTrustAnchorSignature(e, t);
|
|
239
239
|
if (!r.ok) {
|
|
240
|
-
s === void 0 && (s =
|
|
240
|
+
s === void 0 && (s = i.failure(r.code, r.reason, a, i.detail({
|
|
241
241
|
subjectCommonName: e.subject.values.commonName,
|
|
242
242
|
actual: r.reason
|
|
243
243
|
})));
|
|
244
244
|
continue;
|
|
245
245
|
}
|
|
246
246
|
if (!r.valid) {
|
|
247
|
-
s === void 0 && (s =
|
|
247
|
+
s === void 0 && (s = i.failure("signature_invalid", "certificate signature does not verify", a, i.detail({
|
|
248
248
|
subjectCommonName: e.subject.values.commonName,
|
|
249
249
|
actual: "certificate signature does not verify"
|
|
250
250
|
})));
|
|
@@ -261,12 +261,12 @@ function trustAnchorAkiMismatch(e, t) {
|
|
|
261
261
|
return t.subjectKeyIdentifier !== void 0 && e.authorityKeyIdentifier !== void 0 && t.subjectKeyIdentifier !== e.authorityKeyIdentifier;
|
|
262
262
|
}
|
|
263
263
|
async function verifyTrustAnchorSignature(e, t) {
|
|
264
|
-
let
|
|
265
|
-
return !
|
|
264
|
+
let n = await i(e.signatureAlgorithmOid, e.signatureAlgorithmParametersDer, t.publicKeyAlgorithmOid, t.publicKeyParametersOid, t.subjectPublicKeyInfoDer, e.signatureValue, e.tbsCertificateDer);
|
|
265
|
+
return !n.ok && n.code === "verification_error" ? {
|
|
266
266
|
ok: !1,
|
|
267
267
|
code: "signature_invalid",
|
|
268
|
-
reason:
|
|
269
|
-
} :
|
|
268
|
+
reason: n.reason
|
|
269
|
+
} : n;
|
|
270
270
|
}
|
|
271
271
|
function describeDateTime(e) {
|
|
272
272
|
return Number.isNaN(e.getTime()) ? "<invalid date>" : e.toISOString();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readRootElement as e } from "../asn1/der.js";
|
|
2
|
+
import { childrenOf as t, decodeObjectIdentifier as n, requireElement as r } from "../asn1/asn1.js";
|
|
3
|
+
//#region src/internal/x509/directory-name.ts
|
|
4
|
+
/** Read and validate the explicit X.501 Name carried by directoryName [4]. */
|
|
5
|
+
function readDirectoryNameTlv(i) {
|
|
6
|
+
let a = new Uint8Array(i.value), o = r(e(a, { maxDepth: 64 }), "directoryName Name");
|
|
7
|
+
if (o.tag !== 48) throw Error("directoryName must wrap a Name SEQUENCE");
|
|
8
|
+
for (let e of t(a, o)) {
|
|
9
|
+
if (e.tag !== 49) throw Error("directoryName RDN must use SET");
|
|
10
|
+
let r = t(a, e);
|
|
11
|
+
if (r.length === 0) throw Error("directoryName RDN must not be empty");
|
|
12
|
+
for (let e of r) {
|
|
13
|
+
if (e.tag !== 48) throw Error("directoryName attribute must use SEQUENCE");
|
|
14
|
+
let r = t(a, e), i = r[0];
|
|
15
|
+
if (r.length !== 2 || i === void 0 || i.tag !== 6) throw Error("directoryName attribute must contain an OID and value");
|
|
16
|
+
n(i.value);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { readDirectoryNameTlv };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=directory-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-name.js","names":[],"sources":["../../../src/internal/x509/directory-name.ts"],"sourcesContent":["import { childrenOf, decodeObjectIdentifier, requireElement } from '#micro509/internal/asn1/asn1';\nimport type { DerElement } from '#micro509/internal/asn1/der';\nimport { DEFAULT_MAX_DER_DEPTH, readRootElement } from '#micro509/internal/asn1/der';\n\n/** Read and validate the explicit X.501 Name carried by directoryName [4]. */\nexport function readDirectoryNameTlv(element: DerElement): Uint8Array {\n\tconst nameDer = new Uint8Array(element.value);\n\tconst name = requireElement(\n\t\treadRootElement(nameDer, { maxDepth: DEFAULT_MAX_DER_DEPTH }),\n\t\t'directoryName Name',\n\t);\n\tif (name.tag !== 0x30) {\n\t\tthrow new Error('directoryName must wrap a Name SEQUENCE');\n\t}\n\tfor (const rdn of childrenOf(nameDer, name)) {\n\t\tif (rdn.tag !== 0x31) {\n\t\t\tthrow new Error('directoryName RDN must use SET');\n\t\t}\n\t\tconst attributes = childrenOf(nameDer, rdn);\n\t\tif (attributes.length === 0) {\n\t\t\tthrow new Error('directoryName RDN must not be empty');\n\t\t}\n\t\tfor (const attribute of attributes) {\n\t\t\tif (attribute.tag !== 0x30) {\n\t\t\t\tthrow new Error('directoryName attribute must use SEQUENCE');\n\t\t\t}\n\t\t\tconst parts = childrenOf(nameDer, attribute);\n\t\t\tconst type = parts[0];\n\t\t\tif (parts.length !== 2 || type === undefined || type.tag !== 0x06) {\n\t\t\t\tthrow new Error('directoryName attribute must contain an OID and value');\n\t\t\t}\n\t\t\tdecodeObjectIdentifier(type.value);\n\t\t}\n\t}\n\treturn nameDer;\n}\n"],"mappings":";;;;AAKA,SAAgB,qBAAqB,GAAiC;CACrE,IAAM,IAAU,IAAI,WAAW,EAAQ,KAAK,GACtC,IAAO,EACZ,EAAgB,GAAS,EAAE,UAAA,GAAgC,CAAC,GAC5D,oBACD;CACA,IAAI,EAAK,QAAQ,IAChB,MAAU,MAAM,yCAAyC;CAE1D,KAAK,IAAM,KAAO,EAAW,GAAS,CAAI,GAAG;EAC5C,IAAI,EAAI,QAAQ,IACf,MAAU,MAAM,gCAAgC;EAEjD,IAAM,IAAa,EAAW,GAAS,CAAG;EAC1C,IAAI,EAAW,WAAW,GACzB,MAAU,MAAM,qCAAqC;EAEtD,KAAK,IAAM,KAAa,GAAY;GACnC,IAAI,EAAU,QAAQ,IACrB,MAAU,MAAM,2CAA2C;GAE5D,IAAM,IAAQ,EAAW,GAAS,CAAS,GACrC,IAAO,EAAM;GACnB,IAAI,EAAM,WAAW,KAAK,MAAS,KAAA,KAAa,EAAK,QAAQ,GAC5D,MAAU,MAAM,uDAAuD;GAExE,EAAuB,EAAK,KAAK;EAClC;CACD;CACA,OAAO;AACR"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { bitString as e, readRootElement as t } from "../asn1/der.js";
|
|
2
|
+
import { throwExtensionEncoderError as n } from "./extension-errors.js";
|
|
2
3
|
//#region src/internal/x509/extension-bits.ts
|
|
3
4
|
/**
|
|
4
5
|
* BIT STRING helpers for {@linkcode KeyUsage} and {@linkcode DistributionPointReason} flags.
|
|
@@ -14,10 +15,11 @@ import { bitString as e, readRootElement as t } from "../asn1/der.js";
|
|
|
14
15
|
* `flags` contains the recognized flag values with any non-zero padding bits
|
|
15
16
|
* masked out. `nonZeroPadding` is `true` when the original BIT STRING encoding
|
|
16
17
|
* had non-zero bits in positions that DER ({@linkcode https://www.itu.int/rec/T-REC-X.690-202102-I/en | X.690 §11.2.1}) requires to be zero.
|
|
17
|
-
*
|
|
18
|
+
* `requireCanonicalBitFlags` rejects such encodings before they reach parsed
|
|
19
|
+
* extension values.
|
|
18
20
|
*/
|
|
19
21
|
/** Canonical bit-position order for Key Usage flags (RFC 5280 §4.2.1.3). */
|
|
20
|
-
const
|
|
22
|
+
const r = [
|
|
21
23
|
"digitalSignature",
|
|
22
24
|
"nonRepudiation",
|
|
23
25
|
"keyEncipherment",
|
|
@@ -27,7 +29,7 @@ const n = [
|
|
|
27
29
|
"cRLSign",
|
|
28
30
|
"encipherOnly",
|
|
29
31
|
"decipherOnly"
|
|
30
|
-
],
|
|
32
|
+
], i = [
|
|
31
33
|
"keyCompromise",
|
|
32
34
|
"cACompromise",
|
|
33
35
|
"affiliationChanged",
|
|
@@ -43,8 +45,9 @@ const n = [
|
|
|
43
45
|
* @param usages Flags to set. Bit positions follow RFC 5280 §4.2.1.3 order.
|
|
44
46
|
*/
|
|
45
47
|
function encodeKeyUsageExtension(t) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
t.length === 0 && n("key_usage_empty", "keyUsage must set at least one bit");
|
|
49
|
+
let i = encodeBitFlags(t, (e) => indexInOrder(r, e, "key usage"));
|
|
50
|
+
return e(i.bytes, i.unusedBits);
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
50
53
|
* Decode a DER-encoded Key Usage BIT STRING into an array of {@linkcode KeyUsage} flags.
|
|
@@ -52,9 +55,9 @@ function encodeKeyUsageExtension(t) {
|
|
|
52
55
|
* @param bytes DER of the keyUsage extension value (BIT STRING).
|
|
53
56
|
*/
|
|
54
57
|
function parseKeyUsageExtension(e) {
|
|
55
|
-
let
|
|
56
|
-
if (
|
|
57
|
-
return requireCanonicalBitFlags(decodeBitFlags(
|
|
58
|
+
let n = t(e, { maxDepth: 64 });
|
|
59
|
+
if (n.tag !== 3) throw Error("keyUsage must be a BIT STRING");
|
|
60
|
+
return requireCanonicalBitFlags(decodeBitFlags(n.value, r, 0), "keyUsage");
|
|
58
61
|
}
|
|
59
62
|
/**
|
|
60
63
|
* Encode {@linkcode DistributionPointReason} flags as BIT STRING content bytes
|
|
@@ -63,7 +66,7 @@ function parseKeyUsageExtension(e) {
|
|
|
63
66
|
* @param reasons Reason flags to encode.
|
|
64
67
|
*/
|
|
65
68
|
function encodeDistributionPointReasonFlagsContent(e) {
|
|
66
|
-
let t = encodeBitFlags(e, (e) => indexInOrder(
|
|
69
|
+
let t = encodeBitFlags(e, (e) => indexInOrder(i, e, "distribution point reason") + 1);
|
|
67
70
|
return Uint8Array.of(t.unusedBits, ...t.bytes);
|
|
68
71
|
}
|
|
69
72
|
/**
|
|
@@ -73,7 +76,7 @@ function encodeDistributionPointReasonFlagsContent(e) {
|
|
|
73
76
|
* @returns Decoded reason flags, preserving empty-but-present values and padding metadata.
|
|
74
77
|
*/
|
|
75
78
|
function parseDistributionPointReasonFlagsContent(e) {
|
|
76
|
-
return requireCanonicalBitFlags(decodeBitFlags(e,
|
|
79
|
+
return requireCanonicalBitFlags(decodeBitFlags(e, i, 1), "DistributionPoint reasons");
|
|
77
80
|
}
|
|
78
81
|
/** Pack named flags into a minimal byte array with DER BIT STRING unused-bits count. */
|
|
79
82
|
function encodeBitFlags(e, t) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-bits.js","names":[],"sources":["../../../src/internal/x509/extension-bits.ts"],"sourcesContent":["/**\n * BIT STRING helpers for {@linkcode KeyUsage} and {@linkcode DistributionPointReason} flags.\n *\n * Centralizes the bit-position ordering so certificate builders and parsers\n * produce identical wire encodings.\n *\n * @module\n */\n\n/**\n * Decoded BIT STRING flags with DER conformance metadata.\n *\n * `flags` contains the recognized flag values with any non-zero padding bits\n * masked out. `nonZeroPadding` is `true` when the original BIT STRING encoding\n * had non-zero bits in positions that DER ({@linkcode https://www.itu.int/rec/T-REC-X.690-202102-I/en | X.690 §11.2.1}) requires to be zero.\n *
|
|
1
|
+
{"version":3,"file":"extension-bits.js","names":[],"sources":["../../../src/internal/x509/extension-bits.ts"],"sourcesContent":["/**\n * BIT STRING helpers for {@linkcode KeyUsage} and {@linkcode DistributionPointReason} flags.\n *\n * Centralizes the bit-position ordering so certificate builders and parsers\n * produce identical wire encodings.\n *\n * @module\n */\n\n/**\n * Decoded BIT STRING flags with DER conformance metadata.\n *\n * `flags` contains the recognized flag values with any non-zero padding bits\n * masked out. `nonZeroPadding` is `true` when the original BIT STRING encoding\n * had non-zero bits in positions that DER ({@linkcode https://www.itu.int/rec/T-REC-X.690-202102-I/en | X.690 §11.2.1}) requires to be zero.\n * `requireCanonicalBitFlags` rejects such encodings before they reach parsed\n * extension values.\n */\nimport { bitString, DEFAULT_MAX_DER_DEPTH, readRootElement } from '#micro509/internal/asn1/der';\nimport { throwExtensionEncoderError } from '#micro509/internal/x509/extension-errors';\nimport type { DistributionPointReason, KeyUsage, ParsedBitFlags } from '#micro509/x509/extensions';\n\nexport type { ParsedBitFlags };\n\n/** Canonical bit-position order for Key Usage flags (RFC 5280 §4.2.1.3). */\nconst KEY_USAGE_ORDER = [\n\t'digitalSignature',\n\t'nonRepudiation',\n\t'keyEncipherment',\n\t'dataEncipherment',\n\t'keyAgreement',\n\t'keyCertSign',\n\t'cRLSign',\n\t'encipherOnly',\n\t'decipherOnly',\n] as const satisfies readonly KeyUsage[];\n\n/** Canonical bit-position order for DistributionPoint reason flags (RFC 5280 §4.2.1.13). */\nconst DISTRIBUTION_POINT_REASON_ORDER = [\n\t'keyCompromise',\n\t'cACompromise',\n\t'affiliationChanged',\n\t'superseded',\n\t'cessationOfOperation',\n\t'certificateHold',\n\t'privilegeWithdrawn',\n\t'aACompromise',\n] as const satisfies readonly DistributionPointReason[];\n\n/**\n * Encode an array of {@linkcode KeyUsage} flags into a DER BIT STRING.\n *\n * @param usages Flags to set. Bit positions follow RFC 5280 §4.2.1.3 order.\n */\nexport function encodeKeyUsageExtension(usages: readonly KeyUsage[]): Uint8Array {\n\tif (usages.length === 0) {\n\t\tthrowExtensionEncoderError('key_usage_empty', 'keyUsage must set at least one bit');\n\t}\n\tconst encoded = encodeBitFlags(usages, (usage) =>\n\t\tindexInOrder(KEY_USAGE_ORDER, usage, 'key usage'),\n\t);\n\treturn bitString(encoded.bytes, encoded.unusedBits);\n}\n\n/**\n * Decode a DER-encoded Key Usage BIT STRING into an array of {@linkcode KeyUsage} flags.\n *\n * @param bytes DER of the keyUsage extension value (BIT STRING).\n */\nexport function parseKeyUsageExtension(bytes: Uint8Array): ParsedBitFlags<KeyUsage> {\n\tconst bitStringElement = readRootElement(bytes, { maxDepth: DEFAULT_MAX_DER_DEPTH });\n\tif (bitStringElement.tag !== 0x03) {\n\t\tthrow new Error('keyUsage must be a BIT STRING');\n\t}\n\treturn requireCanonicalBitFlags(\n\t\tdecodeBitFlags(bitStringElement.value, KEY_USAGE_ORDER, 0),\n\t\t'keyUsage',\n\t);\n}\n\n/**\n * Encode {@linkcode DistributionPointReason} flags as BIT STRING content bytes\n * (unusedBits prefix + flag bytes), suitable for wrapping in an implicit context tag.\n *\n * @param reasons Reason flags to encode.\n */\nexport function encodeDistributionPointReasonFlagsContent(\n\treasons: readonly DistributionPointReason[],\n): Uint8Array {\n\tconst encoded = encodeBitFlags(\n\t\treasons,\n\t\t(reason) =>\n\t\t\tindexInOrder(DISTRIBUTION_POINT_REASON_ORDER, reason, 'distribution point reason') + 1,\n\t);\n\treturn Uint8Array.of(encoded.unusedBits, ...encoded.bytes);\n}\n\n/**\n * Decode BIT STRING content bytes into {@linkcode DistributionPointReason} flags.\n *\n * @param value Raw content bytes (unusedBits prefix + flag bytes).\n * @returns Decoded reason flags, preserving empty-but-present values and padding metadata.\n */\nexport function parseDistributionPointReasonFlagsContent(\n\tvalue: Uint8Array,\n): ParsedBitFlags<DistributionPointReason> {\n\treturn requireCanonicalBitFlags(\n\t\tdecodeBitFlags(value, DISTRIBUTION_POINT_REASON_ORDER, 1),\n\t\t'DistributionPoint reasons',\n\t);\n}\n\n/** Pack named flags into a minimal byte array with DER BIT STRING unused-bits count. */\nfunction encodeBitFlags<T extends string>(\n\tvalues: readonly T[],\n\tbitForValue: (value: T) => number,\n): {\n\treadonly bytes: Uint8Array;\n\treadonly unusedBits: number;\n} {\n\tif (values.length === 0) {\n\t\treturn { bytes: new Uint8Array(0), unusedBits: 0 };\n\t}\n\tlet highestBit = -1;\n\tconst bits: number[] = [];\n\tfor (const value of values) {\n\t\tconst bit = bitForValue(value);\n\t\tbits.push(bit);\n\t\tif (bit > highestBit) {\n\t\t\thighestBit = bit;\n\t\t}\n\t}\n\tconst byteLength = Math.floor(highestBit / 8) + 1;\n\tconst bytes = new Uint8Array(byteLength);\n\tfor (const bit of bits) {\n\t\tconst byteIndex = Math.floor(bit / 8);\n\t\tconst bitIndex = bit % 8;\n\t\tconst current = bytes[byteIndex] ?? 0;\n\t\tbytes[byteIndex] = current | (1 << (7 - bitIndex));\n\t}\n\tconst totalBits = highestBit + 1;\n\tconst unusedBits = (8 - (totalBits % 8)) % 8;\n\treturn {\n\t\tbytes,\n\t\tunusedBits,\n\t};\n}\n\n/** Unpack set bits from a BIT STRING content into named flags from a candidate list. */\nfunction decodeBitFlags<T extends string>(\n\tvalue: Uint8Array,\n\tcandidates: readonly T[],\n\tbitOffset: number,\n): ParsedBitFlags<T> {\n\tif (value.length === 0) {\n\t\tthrow new Error('Empty BIT STRING');\n\t}\n\tconst unusedBits = value[0] ?? 0;\n\tif (unusedBits > 7) {\n\t\tthrow new Error('Invalid BIT STRING');\n\t}\n\tconst bytes = value.slice(1);\n\tif (bytes.length === 0 && unusedBits !== 0) {\n\t\tthrow new Error('Invalid BIT STRING');\n\t}\n\tlet nonZeroPadding = false;\n\tif (unusedBits > 0 && bytes.length > 0) {\n\t\tconst lastByte = bytes[bytes.length - 1] ?? 0;\n\t\tconst paddingMask = (1 << unusedBits) - 1;\n\t\tnonZeroPadding = (lastByte & paddingMask) !== 0;\n\t}\n\tconst flags: T[] = [];\n\tfor (let index = 0; index < candidates.length; index += 1) {\n\t\tconst bit = index + bitOffset;\n\t\tconst byteIndex = Math.floor(bit / 8);\n\t\tif (byteIndex >= bytes.length) {\n\t\t\tbreak;\n\t\t}\n\t\tconst byte = bytes[byteIndex] ?? 0;\n\t\tconst bitIndex = bit % 8;\n\t\tif ((byte & (1 << (7 - bitIndex))) !== 0) {\n\t\t\tconst candidate = candidates[index];\n\t\t\tif (candidate !== undefined) {\n\t\t\t\tflags.push(candidate);\n\t\t\t}\n\t\t}\n\t}\n\treturn { flags, nonZeroPadding };\n}\n\nfunction requireCanonicalBitFlags<T extends string>(\n\tparsed: ParsedBitFlags<T>,\n\tlabel: string,\n): ParsedBitFlags<T> {\n\tif (parsed.nonZeroPadding) {\n\t\tthrow new Error(`${label} BIT STRING must not set padding bits`);\n\t}\n\treturn parsed;\n}\n\n/** Look up the bit position of a flag in its canonical order array. Throws on unknown flags. */\nfunction indexInOrder<T extends string>(order: readonly T[], value: T, label: string): number {\n\tconst index = order.indexOf(value);\n\tif (index < 0) {\n\t\tthrow new Error(`Unsupported ${label}: ${value}`);\n\t}\n\treturn index;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/internal/x509/extension-errors.d.ts
|
|
2
|
+
/** Machine-readable reason an extension encoder rejected its construction input. */
|
|
3
|
+
type ExtensionEncoderErrorCode = "authority_info_access_empty" | "authority_info_access_ocsp_not_uri" | "certificate_policies_empty" | "crl_distribution_points_empty" | "directory_name_not_sequence" | "display_text_out_of_range" | "distribution_point_crl_issuer_empty" | "distribution_point_crl_issuer_not_directory_name" | "distribution_point_empty" | "distribution_point_full_name_empty" | "distribution_point_relative_name_multiple_crl_issuers" | "duplicate_extension_oid" | "duplicate_policy_oid" | "edwards_key_usage_forbids_agreement_bit" | "edwards_key_usage_forbids_key_cert_sign" | "edwards_key_usage_requires_key_cert_sign" | "edwards_key_usage_requires_signing_bit" | "empty_general_name_value" | "empty_subject_requires_subject_alt_name" | "extended_key_usage_empty" | "extension_must_be_critical" | "extension_must_be_non_critical" | "extension_not_supported_in_context" | "invalid_general_name_tag" | "invalid_ia5_string" | "invalid_ip_name_constraint" | "invalid_oid" | "key_usage_empty" | "malformed_known_extension_value" | "montgomery_key_usage_forbids_both_cipher_bits" | "montgomery_key_usage_forbids_signature_bit" | "montgomery_key_usage_requires_key_agreement" | "name_constraints_empty" | "path_length_requires_ca" | "path_length_requires_key_cert_sign" | "policy_constraints_empty" | "policy_mappings_any_policy" | "policy_mappings_empty" | "reserved_policy_qualifier_oid";
|
|
4
|
+
//#endregion
|
|
5
|
+
export { ExtensionEncoderErrorCode };
|
|
6
|
+
//# sourceMappingURL=extension-errors.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { throwMicro509Error as e } from "../../result/result.js";
|
|
2
|
+
//#region src/internal/x509/extension-errors.ts
|
|
3
|
+
/**
|
|
4
|
+
* Stable error codes for X.509 extension encoder input validation.
|
|
5
|
+
*
|
|
6
|
+
* The extension builders throw on invalid construction input (an empty
|
|
7
|
+
* collection, a duplicate OID, an out-of-range value). Each failure carries one
|
|
8
|
+
* of these codes on a {@link ResultError}, so callers branch on `error.code` via
|
|
9
|
+
* `isResultError` instead of matching message strings.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
/** Throws a {@link ResultError} for an extension encoder input-validation failure. */
|
|
14
|
+
function throwExtensionEncoderError(t, n) {
|
|
15
|
+
e(t, n);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { throwExtensionEncoderError };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=extension-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-errors.js","names":[],"sources":["../../../src/internal/x509/extension-errors.ts"],"sourcesContent":["/**\n * Stable error codes for X.509 extension encoder input validation.\n *\n * The extension builders throw on invalid construction input (an empty\n * collection, a duplicate OID, an out-of-range value). Each failure carries one\n * of these codes on a {@link ResultError}, so callers branch on `error.code` via\n * `isResultError` instead of matching message strings.\n *\n * @module\n */\n\nimport { throwMicro509Error } from '#micro509/result/result';\n\n/** Machine-readable reason an extension encoder rejected its construction input. */\nexport type ExtensionEncoderErrorCode =\n\t| 'authority_info_access_empty'\n\t| 'authority_info_access_ocsp_not_uri'\n\t| 'certificate_policies_empty'\n\t| 'crl_distribution_points_empty'\n\t| 'directory_name_not_sequence'\n\t| 'display_text_out_of_range'\n\t| 'distribution_point_crl_issuer_empty'\n\t| 'distribution_point_crl_issuer_not_directory_name'\n\t| 'distribution_point_empty'\n\t| 'distribution_point_full_name_empty'\n\t| 'distribution_point_relative_name_multiple_crl_issuers'\n\t| 'duplicate_extension_oid'\n\t| 'duplicate_policy_oid'\n\t| 'edwards_key_usage_forbids_agreement_bit'\n\t| 'edwards_key_usage_forbids_key_cert_sign'\n\t| 'edwards_key_usage_requires_key_cert_sign'\n\t| 'edwards_key_usage_requires_signing_bit'\n\t| 'empty_general_name_value'\n\t| 'empty_subject_requires_subject_alt_name'\n\t| 'extended_key_usage_empty'\n\t| 'extension_must_be_critical'\n\t| 'extension_must_be_non_critical'\n\t| 'extension_not_supported_in_context'\n\t| 'invalid_general_name_tag'\n\t| 'invalid_ia5_string'\n\t| 'invalid_ip_name_constraint'\n\t| 'invalid_oid'\n\t| 'key_usage_empty'\n\t| 'malformed_known_extension_value'\n\t| 'montgomery_key_usage_forbids_both_cipher_bits'\n\t| 'montgomery_key_usage_forbids_signature_bit'\n\t| 'montgomery_key_usage_requires_key_agreement'\n\t| 'name_constraints_empty'\n\t| 'path_length_requires_ca'\n\t| 'path_length_requires_key_cert_sign'\n\t| 'policy_constraints_empty'\n\t| 'policy_mappings_any_policy'\n\t| 'policy_mappings_empty'\n\t| 'reserved_policy_qualifier_oid';\n\n/** Throws a {@link ResultError} for an extension encoder input-validation failure. */\nexport function throwExtensionEncoderError(\n\tcode: ExtensionEncoderErrorCode,\n\tmessage: string,\n): never {\n\tthrowMicro509Error(code, message);\n}\n"],"mappings":";;;;;;;;;;;;;AAwDA,SAAgB,2BACf,GACA,GACQ;CACR,EAAmB,GAAM,CAAO;AACjC"}
|