@ac-kit/format-asn1 0.3.0 → 0.4.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.
Files changed (105) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +132 -4
  3. package/dist/_encoding/constants.d.ts +2 -0
  4. package/dist/_encoding/constants.d.ts.map +1 -1
  5. package/dist/_encoding/constants.js +7 -0
  6. package/dist/_encoding/constants.js.map +1 -1
  7. package/dist/_encoding/decode-primitive.d.ts +39 -0
  8. package/dist/_encoding/decode-primitive.d.ts.map +1 -0
  9. package/dist/_encoding/decode-primitive.js +144 -0
  10. package/dist/_encoding/decode-primitive.js.map +1 -0
  11. package/dist/_encoding/def-tags.d.ts +36 -3
  12. package/dist/_encoding/def-tags.d.ts.map +1 -1
  13. package/dist/_encoding/def-tags.js +88 -3
  14. package/dist/_encoding/def-tags.js.map +1 -1
  15. package/dist/_encoding/encoded-tag-sort-key.d.ts +7 -0
  16. package/dist/_encoding/encoded-tag-sort-key.d.ts.map +1 -0
  17. package/dist/_encoding/encoded-tag-sort-key.js +13 -0
  18. package/dist/_encoding/encoded-tag-sort-key.js.map +1 -0
  19. package/dist/_encoding/tag.d.ts +1 -6
  20. package/dist/_encoding/tag.d.ts.map +1 -1
  21. package/dist/_encoding/tag.js +5 -43
  22. package/dist/_encoding/tag.js.map +1 -1
  23. package/dist/_encoding/tlv.d.ts +4 -25
  24. package/dist/_encoding/tlv.d.ts.map +1 -1
  25. package/dist/_encoding/tlv.js +12 -48
  26. package/dist/_encoding/tlv.js.map +1 -1
  27. package/dist/_encoding/values.d.ts.map +1 -1
  28. package/dist/_encoding/values.js +31 -19
  29. package/dist/_encoding/values.js.map +1 -1
  30. package/dist/_encoding/vlq.d.ts.map +1 -1
  31. package/dist/_encoding/vlq.js +2 -2
  32. package/dist/_encoding/vlq.js.map +1 -1
  33. package/dist/_encoding/with-offset.d.ts +12 -0
  34. package/dist/_encoding/with-offset.d.ts.map +1 -0
  35. package/dist/_encoding/with-offset.js +22 -0
  36. package/dist/_encoding/with-offset.js.map +1 -0
  37. package/dist/ber/_decode.d.ts +25 -0
  38. package/dist/ber/_decode.d.ts.map +1 -0
  39. package/dist/ber/_decode.js +409 -0
  40. package/dist/ber/_decode.js.map +1 -0
  41. package/dist/ber/codec.d.ts +3 -2
  42. package/dist/ber/codec.d.ts.map +1 -1
  43. package/dist/ber/codec.js +45 -16
  44. package/dist/ber/codec.js.map +1 -1
  45. package/dist/ber/decode.d.ts +30 -1
  46. package/dist/ber/decode.d.ts.map +1 -1
  47. package/dist/ber/decode.js +31 -221
  48. package/dist/ber/decode.js.map +1 -1
  49. package/dist/ber/encode.d.ts +7 -1
  50. package/dist/ber/encode.d.ts.map +1 -1
  51. package/dist/ber/encode.js +46 -53
  52. package/dist/ber/encode.js.map +1 -1
  53. package/dist/cer/decode.d.ts +20 -1
  54. package/dist/cer/decode.d.ts.map +1 -1
  55. package/dist/cer/decode.js +27 -221
  56. package/dist/cer/decode.js.map +1 -1
  57. package/dist/cer/encode.d.ts +22 -6
  58. package/dist/cer/encode.d.ts.map +1 -1
  59. package/dist/cer/encode.js +147 -136
  60. package/dist/cer/encode.js.map +1 -1
  61. package/dist/der/decode.d.ts +27 -21
  62. package/dist/der/decode.d.ts.map +1 -1
  63. package/dist/der/decode.js +323 -398
  64. package/dist/der/decode.js.map +1 -1
  65. package/dist/der/encode.js +5 -8
  66. package/dist/der/encode.js.map +1 -1
  67. package/dist/errors.d.ts +56 -0
  68. package/dist/errors.d.ts.map +1 -0
  69. package/dist/errors.js +31 -0
  70. package/dist/errors.js.map +1 -0
  71. package/dist/index.d.ts +4 -0
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +4 -0
  74. package/dist/index.js.map +1 -1
  75. package/dist/per/decode.d.ts +9 -0
  76. package/dist/per/decode.d.ts.map +1 -1
  77. package/dist/per/decode.js +114 -32
  78. package/dist/per/decode.js.map +1 -1
  79. package/dist/per/encode.js +1 -1
  80. package/dist/per/encode.js.map +1 -1
  81. package/dist/reader/_framing.d.ts +38 -0
  82. package/dist/reader/_framing.d.ts.map +1 -0
  83. package/dist/reader/_framing.js +144 -0
  84. package/dist/reader/_framing.js.map +1 -0
  85. package/dist/reader/_header.d.ts +49 -0
  86. package/dist/reader/_header.d.ts.map +1 -0
  87. package/dist/reader/_header.js +130 -0
  88. package/dist/reader/_header.js.map +1 -0
  89. package/dist/reader/ber-reader.d.ts +240 -0
  90. package/dist/reader/ber-reader.d.ts.map +1 -0
  91. package/dist/reader/ber-reader.js +567 -0
  92. package/dist/reader/ber-reader.js.map +1 -0
  93. package/dist/reader/inspect.d.ts +68 -0
  94. package/dist/reader/inspect.d.ts.map +1 -0
  95. package/dist/reader/inspect.js +104 -0
  96. package/dist/reader/inspect.js.map +1 -0
  97. package/dist/schema/universal-tag-name.d.ts +26 -0
  98. package/dist/schema/universal-tag-name.d.ts.map +1 -0
  99. package/dist/schema/universal-tag-name.js +74 -0
  100. package/dist/schema/universal-tag-name.js.map +1 -0
  101. package/package.json +9 -8
  102. package/dist/_encoding/errors.d.ts +0 -8
  103. package/dist/_encoding/errors.d.ts.map +0 -1
  104. package/dist/_encoding/errors.js +0 -15
  105. package/dist/_encoding/errors.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,86 @@
1
1
  # @ac-kit/format-asn1
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 34e8cfa: `universalTagName(tag)` gives the type name X.680 §8.6 assigns a universal tag,
8
+ spelled as in ASN.1 notation (`"BOOLEAN"`, `"BIT STRING"`, `"UTF8String"` …
9
+ `"RELATIVE-OID-IRI"`, with `ObjectDescriptor`, `UTCTime` and `GeneralizedTime`),
10
+ so an explorer labels `berInspect` elements without its own table. It takes any
11
+ `{ tagClass, tagNumber }`, a `BerElement` with its `bigint` number included, and
12
+ returns `undefined` for another class or a reserved number (0, 15, 37 and
13
+ above). The named numbers are exactly the members of `UniversalTagNumber`.
14
+ - 34e8cfa: BER framing is readable and inspectable on its own, and decoding errors are
15
+ typed.
16
+
17
+ - New `BerReader`, a pull reader over BER, CER or DER bytes: `new BerReader(bytes, rules, { maxTagOctets?, onNonCanonical? })`, `rules` `"ber"`, `"cer"` or `"der"`.
18
+ - `peekHeader()` reads the next element's identifier and length octets without consuming it: `tagClass`, `tagNumber` (`null` above `Number.MAX_SAFE_INTEGER`; `bigTagNumber()` is exact), `constructed`, `contentsOffset` and `contentsLength` (`null` for the indefinite form). It allocates nothing for a tag number below 31.
19
+ - `readContents()`, `readElement()` and `skip()` consume the element; the first two return views of the input. For an indefinite-length element they take time linear in its size and constant memory.
20
+ - `enter()` returns a reader over a constructed element's contents; the parent cannot be used until that reader's `finish()`, which checks nothing is left and moves the parent past the element. `finish()` on the reader the constructor returns checks the whole view was read.
21
+ - `readOctetStringContents()` and `readBitStringContents()` return the contents of a string's primitive form, joining the segments of a constructed one, nested at most 512 levels deep (`limit-exceeded`). A BIT STRING segment with unused bits must be the last one, at every level.
22
+ - Offsets are relative to the view given to the constructor, which must not change while a reader of it is in use. End-of-contents octets are recognised only where an indefinite-length element ends; one that is missing or cut short is `truncated` or `overrun`, never `trailing-data`.
23
+ - Every rule set refuses a high tag number form for a number below 31 or with a leading `0x80` octet, identifiers longer than `maxTagOctets` octets after the first (default 16), a `0xFF` length octet, a length beyond `Number.MAX_SAFE_INTEGER` (`limit-exceeded`) and an indefinite-length primitive. `"der"` also refuses the indefinite form, lengths not in the fewest octets and constructed strings; `"cer"` refuses constructed encodings with a definite length, primitive lengths not in the fewest octets and strings not fragmented as X.690 §9.2 requires. `onNonCanonical` receives these DER and CER violations instead, and reading continues as BER; it must not call the reader, which throws `TypeError` for a call made from it.
24
+ - A method that throws, a `DecodingError` or what `onNonCanonical` throws, consumes nothing: the reader stays open at the same offset with no child open, so the element can be read again or the level ended with `finish()`.
25
+ - New `berInspect(bytes, { rules, maxDepth, maxElements, maxTagOctets? })`, a schema-free view of the framing: it returns `{ roots, error }`, the elements in wire order with their tag, exact `bigint` tag number, form, byte ranges and the `rules` violations of their header (`issues`), and the `DecodingError` that stopped reading, if any. After an error, the tree holds what was read before it; an indefinite-length element still open has `contentsEnd` and `end` `undefined`. It throws only `RangeError`, for limits that are not positive safe integers.
26
+ - `DecodingError` and `EncodingError` are exported. `DecodingError` now extends `SyntaxError` and carries `offset` and `code`: `"truncated"`, `"overrun"`, `"limit-exceeded"`, `"invalid-tag"`, `"invalid-length"`, `"invalid-end-of-contents"`, `"missing-element"`, `"trailing-data"`, `"non-canonical"`, `"unexpected-element"` or `"invalid-contents"`. Every BER, CER, DER and PER decoder throws it, and only it, for anything wrong with its input, including invalid UTF-8 (a `TypeError` before), a PER input that ends early (a `RangeError` before) and nesting deeper than 512 elements (a possible stack overflow before). An error in text is placed on the first invalid octet, and one in a constructed string on the octet of the input it concerns, not on the start of the contents. For `perDecode`, `offset` is the byte holding the next unread bit.
27
+ - `berDecode` and `cerDecode` decode indefinite-length values whose contents hold `00 00`, and nested indefinite-length values, which they used to refuse, cut short or decode with elements missing.
28
+ - `cerEncode` writes every constructed encoding in the indefinite-length form (X.690 §9.1). Earlier versions wrote a definite length up to 1000 contents octets, so the output changes for every SEQUENCE, SET, SEQUENCE OF, SET OF and EXPLICIT tag of that size. It also fragments BIT STRINGs and IMPLICIT-tagged strings above 1000 octets as it does other strings (they were primitive), writing the fragments of a character string as OCTET STRINGs (X.690 §8.23; they carried the string's own tag). A long OCTET STRING is written as before. BIT STRING padding bits are cleared and, for a type with named bits, trailing zero bits removed (§11.2), as in DER; SET components are ordered by their whole tag (tags of 31 and above sorted wrongly) and an untagged CHOICE component as its smallest tag, whichever alternative it holds (§9.3).
29
+ - `cerDecode` refuses input that is not CER framing: a constructed encoding with a definite length, a primitive length not in the fewest octets, a string not fragmented as X.690 §9.2 requires, SET components out of the order of §9.3. Migration for stored output of earlier `cerEncode` versions: `berDecode` reads all of it except a character string above 1000 octets, whose fragments carry the string's own tag and are refused (`unexpected-element`); decode those with the previous version and write them again with `cerEncode`.
30
+ - `berDecode` and `cerDecode` join the segments of a constructed string before decoding it, so a character split across segments decodes; refuse the contents `derDecode` refuses in either mode (a BOOLEAN that is not one octet, an INTEGER or ENUMERATED that is empty or has a redundant leading octet, a BIT STRING without its initial octet or with unused bits it cannot have, a non-empty NULL, a BMPString or UniversalString of a length that is no multiple of its code unit); refuse BOOLEAN, INTEGER, ENUMERATED, NULL, REAL, the object identifier types, the OID-IRI types, TIME, DATE, TIME-OF-DAY, DATE-TIME and DURATION in the constructed form (X.690 §8.26; `cerEncode` no longer fragments the last five); refuse an element after the last component of a SEQUENCE or SET with no extension marker, and a second element inside an EXPLICIT tag; read SET components by tag in any order (`cerDecode`: in the order of §9.3); skip unknown extension additions before the root components that follow a second `...`; return ANY values with their original bytes, as `derDecode` does; and apply a transform under an IMPLICIT tag.
31
+ - `berEncode` writes the tags as `derEncode` and `cerEncode` do: an IMPLICIT tag over a `lazy` or parameterized type takes the form of the type underneath (a lazy SEQUENCE was written primitive, a parameterized one threw), over a CHOICE or ANY it is EXPLICIT (X.680 §31.2.7), and over another tag it no longer throws.
32
+ - Every BER, CER and DER decoder refuses a tag number below 31 in the high-tag form. `derDecode` accepts tag numbers above `Number.MAX_SAFE_INTEGER` inside ANY values, up to 16 identifier octets after the first, limits IMPLICIT tag nesting to 512 levels in `derDecodeContents` as in `derDecode`, and reports a UTCTime or GeneralizedTime that BER refuses as `invalid-contents`, not `non-canonical`.
33
+ - BER, CER and DER decoding read a length field of 2³¹ or more exactly, where it used to wrap to a wrong value, and refuse a length longer than the input. Encoding writes the length of contents of 4 GiB or more correctly.
34
+ - The BER `Decoder` from `createBerDecoder` reports, at the end of input, the bytes an indefinite-length value used rather than the whole buffer, and is fatal (`limit-exceeded`), instead of waiting for more input or returning a size hint beyond the safe integers, for a length beyond `Number.MAX_SAFE_INTEGER`, a header and length together longer than that, or identifier octets past the limit.
35
+ - `perDecode` refuses nesting deeper than 512 values, keeps a leading U+FEFF of a UTF8String (it was dropped), refuses a BMPString with a lone surrogate or an odd length (it came back with U+FFFD), and places the errors of OBJECT IDENTIFIER, REAL and text contents on the offset in the input, across fragments too (they were relative to the contents).
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies [34e8cfa]
40
+ - Updated dependencies [34e8cfa]
41
+ - Updated dependencies [34e8cfa]
42
+ - Updated dependencies [34e8cfa]
43
+ - Updated dependencies [34e8cfa]
44
+ - Updated dependencies [34e8cfa]
45
+ - Updated dependencies [34e8cfa]
46
+ - Updated dependencies [34e8cfa]
47
+ - Updated dependencies [34e8cfa]
48
+ - Updated dependencies [34e8cfa]
49
+ - Updated dependencies [34e8cfa]
50
+ - Updated dependencies [34e8cfa]
51
+ - Updated dependencies [34e8cfa]
52
+ - Updated dependencies [34e8cfa]
53
+ - Updated dependencies [34e8cfa]
54
+ - Updated dependencies [34e8cfa]
55
+ - Updated dependencies [34e8cfa]
56
+ - Updated dependencies [34e8cfa]
57
+ - Updated dependencies [34e8cfa]
58
+ - Updated dependencies [34e8cfa]
59
+ - Updated dependencies [34e8cfa]
60
+ - Updated dependencies [34e8cfa]
61
+ - Updated dependencies [34e8cfa]
62
+ - Updated dependencies [34e8cfa]
63
+ - Updated dependencies [34e8cfa]
64
+ - @ac-kit/algo@0.5.0
65
+ - @ac-kit/core@0.12.0
66
+ - @ac-kit/math-numbers@0.2.9
67
+ - @ac-kit/format-varint@0.2.7
68
+ - @ac-kit/format-oid@0.2.0
69
+ - @ac-kit/format-core@0.4.2
70
+
71
+ ## 0.3.1
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies [065cf8d]
76
+ - Updated dependencies [065cf8d]
77
+ - Updated dependencies [065cf8d]
78
+ - @ac-kit/core@0.11.0
79
+ - @ac-kit/algo@0.4.1
80
+ - @ac-kit/format-core@0.4.1
81
+ - @ac-kit/format-varint@0.2.6
82
+ - @ac-kit/math-numbers@0.2.8
83
+
3
84
  ## 0.3.0
4
85
 
5
86
  ### Minor Changes
package/README.md CHANGED
@@ -50,16 +50,144 @@ with `Z`. Contents whose type the schema does not give (ANY, open types, unknown
50
50
  extensions) are checked for framing only, since their contents rules depend on
51
51
  a type the decoder does not know. Not yet checked: the REAL canonical form
52
52
  (§11.3), GeneralString escape sequences (§11.4), the TIME family (§11.9) and
53
- the character repertoires of restricted string types (X.680 §41). Anything else throws `DecodingError`. Pass `false` as the third
54
- argument to accept the canonical-form violations from legacy encoders;
55
- malformed framing is refused either way. Verify signatures over the original
56
- bytes, never over a re-encoding.
53
+ the character repertoires of restricted string types (X.680 §41). Anything else
54
+ throws [`DecodingError`](#errors). The framing is the one
55
+ [`BerReader`](#read-ber-cer-and-der-with-a-cursor) reads with `"der"`. Pass
56
+ `false` as the third argument to accept the canonical-form violations from
57
+ legacy encoders; malformed framing and the indefinite length form are refused
58
+ either way. Verify signatures over the original bytes, never over a
59
+ re-encoding.
57
60
 
58
61
  `derEncode` converts times to UTC and omits known wire DEFAULTs. An
59
62
  OPTIONAL component whose type is an untagged ANY has no tag to recognise it by,
60
63
  so it is taken as present whenever an element remains: give it a tag or keep it
61
64
  last in its SEQUENCE.
62
65
 
66
+ `cerEncode` writes every constructed value in the indefinite-length form, a
67
+ string of more than 1000 octets in 1000-octet segments (OCTET STRING segments
68
+ for the character strings), and SET components in the order X.690 §9.3 gives
69
+ (an untagged CHOICE counts as its smallest tag, where DER orders it by the
70
+ alternative it holds). `cerDecode` refuses input that is not CER framing — read
71
+ such input with `berDecode`. `berDecode` and `cerDecode` refuse malformed
72
+ contents exactly as `derDecode` does in either mode (a BOOLEAN that is not one
73
+ octet, a non-minimal INTEGER, a BIT STRING with unused bits it cannot have, a
74
+ BMPString of an odd length, invalid text, …); the canonical-form rules stay
75
+ `derDecode`'s, `berDecode`'s `strict` only asking BOOLEAN TRUE to be `0xFF`.
76
+
77
+ ## Read BER, CER and DER with a cursor
78
+
79
+ ```ts
80
+ import { BerReader } from "@ac-kit/format-asn1";
81
+
82
+ declare const der: Uint8Array;
83
+
84
+ // The bytes a certificate's signature covers, as received.
85
+ const certificate = new BerReader(der, "der").enter();
86
+ const tbsCertificate = certificate.readElement();
87
+ ```
88
+
89
+ `BerReader` reads one element at a time. `peekHeader()` reads the next
90
+ identifier and length octets without consuming the element (`tagClass`,
91
+ `tagNumber`, `constructed`, `contentsOffset`, `contentsLength`, `null` for the
92
+ indefinite form); `readContents()`, `readElement()` and `skip()` consume it and
93
+ return views of the input; `enter()` returns a reader over a constructed
94
+ element, and its `finish()` checks nothing is left and hands control back to the
95
+ parent. `readOctetStringContents()` and `readBitStringContents()` join the
96
+ segments of a constructed string, nested at most 512 levels deep. Offsets are
97
+ relative to the view given to the constructor, which must not change while a
98
+ reader of it is in use. `"der"` refuses the indefinite form and non-minimal
99
+ lengths; `"cer"` refuses definite-length constructed encodings and strings not
100
+ fragmented as X.690 §9.2 requires; `onNonCanonical` collects those violations
101
+ instead and reads on as BER, and must not call the reader (a call from it
102
+ throws `TypeError`). A method that throws consumes nothing: the reader stays
103
+ open at the same offset, with no child open, so the element can be read again
104
+ or the level ended with `finish()`. End-of-contents octets are recognised only
105
+ where an
106
+ indefinite-length element ends, so contents holding `00 00` and nested
107
+ indefinite-length elements read correctly, in time linear in their size.
108
+
109
+ ## Inspect framing without a schema
110
+
111
+ ```ts
112
+ import { berInspect } from "@ac-kit/format-asn1";
113
+
114
+ const bytes = Uint8Array.of(0x30, 0x80, 0x05, 0x00, 0x00, 0x00);
115
+ const { roots, error } = berInspect(bytes, {
116
+ rules: "der",
117
+ maxDepth: 8,
118
+ maxElements: 100,
119
+ });
120
+ // error: undefined
121
+ // roots[0]: start 0, contentsStart 2, contentsEnd 4, end 6, indefinite;
122
+ // roots[0].issues: one, at offset 1 — DER forbids the indefinite form.
123
+ ```
124
+
125
+ `berInspect` returns the roots in wire order (none for an empty view). Each
126
+ element reports its tag class, exact `bigint` tag number, whether it is
127
+ constructed or indefinite, its immediate children, and the violations of
128
+ `rules` in its header (`issues`), which do not stop reading. Offsets are
129
+ relative to the supplied view: `[start, end)` covers the whole element and
130
+ `[contentsStart, contentsEnd)` excludes the header and any end-of-contents
131
+ octets. Primitive contents are not interpreted and types are not checked.
132
+
133
+ It never throws for the input: a framing error or an exceeded limit ends
134
+ reading and is returned as `error`, with the elements read before it (an
135
+ indefinite-length element still open has `contentsEnd` and `end` `undefined`).
136
+ Limits must be positive safe integers (`RangeError` otherwise). Root depth is 1,
137
+ the element limit counts across all roots (not counting end-of-contents octets),
138
+ and `maxTagOctets` defaults to 16 identifier octets after the first; exceeding a
139
+ limit is an `error` with the code `limit-exceeded`.
140
+
141
+ ### Name universal tags
142
+
143
+ ```ts
144
+ import { universalTagName } from "@ac-kit/format-asn1";
145
+
146
+ universalTagName(roots[0]); // "SEQUENCE"
147
+ universalTagName({ tagClass: "universal", tagNumber: 36n }); // "RELATIVE-OID-IRI"
148
+ universalTagName({ tagClass: "context", tagNumber: 0 }); // undefined
149
+ ```
150
+
151
+ `universalTagName` labels an element, or any `{ tagClass, tagNumber }` with a
152
+ `number` or `bigint` number, with the type name X.680 §8.6 assigns its
153
+ universal tag, spelled as in ASN.1 notation (`"BIT STRING"`, `"UTF8String"`,
154
+ `"TIME-OF-DAY"`), the useful types `ObjectDescriptor`, `UTCTime` and
155
+ `GeneralizedTime` included. A shared tag takes the first type's name:
156
+ `"SEQUENCE"` also stands for SEQUENCE OF, `"SET"` for SET OF, `"EXTERNAL"` for
157
+ INSTANCE OF. It returns `undefined` for another class and for the numbers
158
+ X.680 reserves (0, 15, 37 and above), so a caller falls back to its own label.
159
+ The named numbers are exactly the members of `UniversalTagNumber`.
160
+
161
+ ## Errors
162
+
163
+ The BER, CER and DER decoders (`berDecode`, `cerDecode`, `derDecode`,
164
+ `createBerDecoder`), `perDecode`, `BerReader` and `berInspect` report anything
165
+ wrong with their input as a `DecodingError`, and only that: a `RangeError` or
166
+ `TypeError` from them is a caller error, such as an invalid option or a reader
167
+ used out of turn. `DecodingError` extends `SyntaxError`; `offset` is the offset
168
+ of the offending octet, relative to the view the failing call was given (for
169
+ `perDecode`, of the byte holding the next unread bit), and `code` says what is
170
+ wrong:
171
+
172
+ - `truncated`: the input ends inside an element, before an element, or before
173
+ the end-of-contents octets of an indefinite-length element.
174
+ - `overrun`: an element extends past the end of the definite-length element
175
+ enclosing it.
176
+ - `limit-exceeded`: identifier octets, nesting depth or element count beyond a
177
+ limit, or a length beyond `Number.MAX_SAFE_INTEGER`.
178
+ - `invalid-tag`: identifier octets X.690 §8.1.2 forbids.
179
+ - `invalid-length`: length octets X.690 §8.1.3 forbids.
180
+ - `invalid-end-of-contents`: end-of-contents octets where no indefinite-length
181
+ element can end, or not exactly `00 00`.
182
+ - `missing-element`: an element is required and none is left.
183
+ - `trailing-data`: an element is left where the value must end.
184
+ - `non-canonical`: valid BER that the selected rules (DER, CER) forbid.
185
+ - `unexpected-element`: a well-framed element not allowed here: wrong tag, wrong
186
+ form for its type, no CHOICE alternative.
187
+ - `invalid-contents`: contents octets that are no valid encoding of their type.
188
+
189
+ `EncodingError` is what the encoders throw for a value they cannot write.
190
+
63
191
  ## DEFAULTs with decode transforms
64
192
 
65
193
  `.transform(fn)` is decode-only: encoders still take the original input type.
@@ -1,3 +1,5 @@
1
+ export declare const CER_STRING_SEGMENT_OCTETS = 1000;
2
+ export declare const MAX_DECODE_DEPTH = 512;
1
3
  export declare const TAG_CLASS_UNIVERSAL = 0;
2
4
  export declare const TAG_CLASS_APPLICATION = 64;
3
5
  export declare const TAG_CLASS_CONTEXT = 128;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/_encoding/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,mBAAmB,IAAO,CAAC;AACxC,eAAO,MAAM,qBAAqB,KAAO,CAAC;AAC1C,eAAO,MAAM,iBAAiB,MAAO,CAAC;AACtC,eAAO,MAAM,iBAAiB,MAAO,CAAC;AAGtC,eAAO,MAAM,eAAe,KAAO,CAAC;AACpC,eAAO,MAAM,aAAa,IAAO,CAAC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MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,8BAA8B,KAAK,CAAC;AACjD,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAChD,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,8BAA8B,KAAK,CAAC;AACjD,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,8BAA8B,KAAK,CAAC;AACjD,eAAO,MAAM,8BAA8B,KAAK,CAAC;AACjD,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAG3C,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAC5C,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,8BAA8B,KAAK,CAAC"}
@@ -1,3 +1,10 @@
1
+ // X.690 §9.2 — CER strings of more than this many contents octets are
2
+ // constructed, in segments of exactly this many octets but the last.
3
+ export const CER_STRING_SEGMENT_OCTETS = 1000;
4
+ // Deepest nesting of decoded values the BER, CER and DER decoders follow before
5
+ // refusing the input. Only a recursive (`lazy`) schema lets the input choose its
6
+ // depth; this keeps such input from exhausting the call stack.
7
+ export const MAX_DECODE_DEPTH = 512;
1
8
  // X.690 §8.1.2.2 — Identifier octets: tag class bits (7-6)
2
9
  export const TAG_CLASS_UNIVERSAL = 0x00;
3
10
  export const TAG_CLASS_APPLICATION = 0x40;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/_encoding/constants.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,CAAC,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from "../schema/types/any-def.js";
2
+ /** What differs between the rules the primitive contents are decoded for. */
3
+ export type PrimitivePolicy = {
4
+ /** Names the rules in messages. */
5
+ readonly label: "BER" | "CER" | "DER";
6
+ /**
7
+ * The canonical-form rules of X.690 §10 and §11: BIT STRING padding, the
8
+ * UTCTime and GeneralizedTime forms.
9
+ */
10
+ readonly canonical: boolean;
11
+ /** BOOLEAN TRUE must be `0xFF` (X.690 §11.1). */
12
+ readonly strictBoolean: boolean;
13
+ };
14
+ /** A fresh copy: `slice` on a Buffer would be a view of the input. */
15
+ export declare function copyBytes(view: Uint8Array): Uint8Array;
16
+ /**
17
+ * Decodes the contents octets of a primitive encoding of `def`, a def that is
18
+ * neither a wrapper nor a tag, nor constructed (X.690 §8.2–§8.26), refusing
19
+ * what is no valid encoding of the type under any rule set as
20
+ * `invalid-contents` and, when `policy.canonical`, what BER allows and CER and
21
+ * DER forbid as `non-canonical`. A string kind is decoded from its primitive
22
+ * contents; its segments were joined by the caller.
23
+ *
24
+ * @param at - Offset of `contents` in the input, which offsets in errors are
25
+ * relative to.
26
+ * @throws {DecodingError} For contents that are not valid.
27
+ */
28
+ export declare function decodePrimitiveContents(def: AnyAsn1TypeDef, contents: Uint8Array, at: number, policy: PrimitivePolicy): unknown;
29
+ /**
30
+ * Decodes Unicode text, refusing what is invalid at the first octet of the
31
+ * first invalid sequence. `ignoreBOM`: a leading U+FEFF is part of the value,
32
+ * not a mark.
33
+ *
34
+ * @param at - Offset of `contents` in the input, which the error's offset is
35
+ * relative to.
36
+ * @throws {DecodingError} `invalid-contents`.
37
+ */
38
+ export declare function decodeFatalText(contents: Uint8Array, encoding: "utf-8" | "utf-16be" | "utf-32be", at: number): string;
39
+ //# sourceMappingURL=decode-primitive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode-primitive.d.ts","sourceRoot":"","sources":["../../src/_encoding/decode-primitive.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAUjE,6EAA6E;AAC7E,MAAM,MAAM,eAAe,GAAG;IAC7B,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAEtD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,cAAc,EACnB,QAAQ,EAAE,UAAU,EACpB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,eAAe,GACrB,OAAO,CAkHT;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC9B,QAAQ,EAAE,UAAU,EACpB,QAAQ,EAAE,OAAO,GAAG,UAAU,GAAG,UAAU,EAC3C,EAAE,EAAE,MAAM,GACR,MAAM,CAYR"}
@@ -0,0 +1,144 @@
1
+ import { bigIntFromBytesBe, decodeText, indexOfInvalidText, } from "@ac-kit/core";
2
+ import { DecodingError } from "../errors.js";
3
+ import { decodeGeneralizedTime, decodeOid, decodeReal, decodeRelativeOid, decodeUtcTime, } from "./values.js";
4
+ import { withOffset } from "./with-offset.js";
5
+ /** A fresh copy: `slice` on a Buffer would be a view of the input. */
6
+ export function copyBytes(view) {
7
+ return new Uint8Array(view);
8
+ }
9
+ /**
10
+ * Decodes the contents octets of a primitive encoding of `def`, a def that is
11
+ * neither a wrapper nor a tag, nor constructed (X.690 §8.2–§8.26), refusing
12
+ * what is no valid encoding of the type under any rule set as
13
+ * `invalid-contents` and, when `policy.canonical`, what BER allows and CER and
14
+ * DER forbid as `non-canonical`. A string kind is decoded from its primitive
15
+ * contents; its segments were joined by the caller.
16
+ *
17
+ * @param at - Offset of `contents` in the input, which offsets in errors are
18
+ * relative to.
19
+ * @throws {DecodingError} For contents that are not valid.
20
+ */
21
+ export function decodePrimitiveContents(def, contents, at, policy) {
22
+ const label = policy.label;
23
+ switch (def.kind) {
24
+ case "boolean":
25
+ if (contents.length !== 1) {
26
+ throw new DecodingError(`${label}: BOOLEAN contents must be one octet (X.690 §8.2.1)`, at, "invalid-contents");
27
+ }
28
+ if (policy.strictBoolean &&
29
+ contents[0] !== 0x00 &&
30
+ contents[0] !== 0xff) {
31
+ throw new DecodingError(`${label}: BOOLEAN TRUE must be encoded as 0xFF (X.690 §11.1)`, at, "non-canonical");
32
+ }
33
+ return contents[0] !== 0x00;
34
+ case "integer":
35
+ case "enumerated":
36
+ if (contents.length === 0) {
37
+ throw new DecodingError(`${label}: INTEGER contents must not be empty (X.690 §8.3.1)`, at, "invalid-contents");
38
+ }
39
+ if (contents.length > 1 &&
40
+ ((contents[0] === 0x00 && (contents[1] & 0x80) === 0) ||
41
+ (contents[0] === 0xff && (contents[1] & 0x80) !== 0))) {
42
+ throw new DecodingError(`${label}: INTEGER with a redundant leading octet (X.690 §8.3.2)`, at, "invalid-contents");
43
+ }
44
+ // Linear: core parses long values from hex digits.
45
+ return bigIntFromBytesBe(contents);
46
+ case "bitString":
47
+ return decodeBitString(policy, def.namedBits !== undefined && def.namedBits.length > 0, contents, at);
48
+ case "octetString":
49
+ return copyBytes(contents);
50
+ case "null":
51
+ if (contents.length !== 0) {
52
+ throw new DecodingError(`${label}: NULL contents must be empty (X.690 §8.8.2)`, at, "invalid-contents");
53
+ }
54
+ return null;
55
+ case "objectIdentifier":
56
+ return withOffset(at, () => decodeOid(contents));
57
+ case "relativeOid":
58
+ return withOffset(at, () => decodeRelativeOid(contents));
59
+ case "oidIri":
60
+ case "relativeOidIri":
61
+ return decodeFatalText(contents, "utf-8", at);
62
+ case "real":
63
+ return withOffset(at, () => decodeReal(contents));
64
+ case "utf8String":
65
+ return decodeFatalText(contents, "utf-8", at);
66
+ case "numericString":
67
+ case "printableString":
68
+ case "teletexString":
69
+ case "videotexString":
70
+ case "ia5String":
71
+ case "graphicString":
72
+ case "visibleString":
73
+ case "generalString":
74
+ return decodeText(contents, "latin1");
75
+ case "universalString":
76
+ checkCodeUnitLength(label, contents, 4, "UniversalString", at);
77
+ return decodeFatalText(contents, "utf-32be", at);
78
+ case "bmpString":
79
+ checkCodeUnitLength(label, contents, 2, "BMPString", at);
80
+ return decodeFatalText(contents, "utf-16be", at);
81
+ case "utcTime":
82
+ return withOffset(at, () => decodeUtcTime(contents, policy.canonical));
83
+ case "generalizedTime":
84
+ return withOffset(at, () => decodeGeneralizedTime(contents, policy.canonical));
85
+ case "time":
86
+ case "date":
87
+ case "timeOfDay":
88
+ case "dateTime":
89
+ case "duration":
90
+ return decodeText(contents, "latin1");
91
+ default:
92
+ throw new DecodingError(`Cannot ${label}-decode def kind: ${def.kind}`, at, "unexpected-element");
93
+ }
94
+ }
95
+ /**
96
+ * Decodes Unicode text, refusing what is invalid at the first octet of the
97
+ * first invalid sequence. `ignoreBOM`: a leading U+FEFF is part of the value,
98
+ * not a mark.
99
+ *
100
+ * @param at - Offset of `contents` in the input, which the error's offset is
101
+ * relative to.
102
+ * @throws {DecodingError} `invalid-contents`.
103
+ */
104
+ export function decodeFatalText(contents, encoding, at) {
105
+ try {
106
+ return decodeText(contents, encoding, { fatal: true, ignoreBOM: true });
107
+ }
108
+ catch (cause) {
109
+ if (!(cause instanceof TypeError))
110
+ throw cause;
111
+ throw new DecodingError(cause.message, at + Math.max(0, indexOfInvalidText(contents, encoding)), "invalid-contents", { cause });
112
+ }
113
+ }
114
+ function checkCodeUnitLength(label, contents, unit, what, at) {
115
+ if (contents.length % unit !== 0) {
116
+ throw new DecodingError(`${label}: ${what} length ${contents.length} is not a multiple of ${unit}`, at, "invalid-contents");
117
+ }
118
+ }
119
+ function decodeBitString(policy, hasNamedBits, contents, at) {
120
+ const label = policy.label;
121
+ if (contents.length === 0) {
122
+ throw new DecodingError(`${label}: BIT STRING has no initial octet (X.690 §8.6.2)`, at, "invalid-contents");
123
+ }
124
+ const unusedBits = contents[0];
125
+ if (unusedBits > 7) {
126
+ throw new DecodingError(`${label}: BIT STRING with ${unusedBits} unused bits (X.690 §8.6.2.2)`, at, "invalid-contents");
127
+ }
128
+ if (contents.length === 1) {
129
+ if (unusedBits !== 0) {
130
+ throw new DecodingError(`${label}: empty BIT STRING with unused bits (X.690 §8.6.2.3)`, at, "invalid-contents");
131
+ }
132
+ }
133
+ else if (policy.canonical) {
134
+ const last = contents[contents.length - 1];
135
+ if ((last & ((1 << unusedBits) - 1)) !== 0) {
136
+ throw new DecodingError(`${label}: BIT STRING unused bits are not zero (X.690 §11.2.1)`, at, "non-canonical");
137
+ }
138
+ if (hasNamedBits && ((last >> unusedBits) & 1) === 0) {
139
+ throw new DecodingError(`${label}: BIT STRING with named bits ends in a zero bit (X.690 §11.2.2)`, at, "non-canonical");
140
+ }
141
+ }
142
+ return { bytes: copyBytes(contents.subarray(1)), unusedBits };
143
+ }
144
+ //# sourceMappingURL=decode-primitive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode-primitive.js","sourceRoot":"","sources":["../../src/_encoding/decode-primitive.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,UAAU,EACV,kBAAkB,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EACN,qBAAqB,EACrB,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,aAAa,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAe9C,sEAAsE;AACtE,MAAM,UAAU,SAAS,CAAC,IAAgB;IACzC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CACtC,GAAmB,EACnB,QAAoB,EACpB,EAAU,EACV,MAAuB;IAEvB,MAAM,KA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,CAAC;QAC7B,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,aAAa,CACtB,GAAG,KAAK,uDAAuD,EAC/D,EAAE,EACF,eAAe,CACf,CAAC;QACH,CAAC;QACD,IAAI,YAAY,IAAI,CAAC,CAAC,IAAI,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,aAAa,CACtB,GAAG,KAAK,iEAAiE,EACzE,EAAE,EACF,eAAe,CACf,CAAC;QACH,CAAC;IACF,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;AAC/D,CAAC"}
@@ -1,7 +1,10 @@
1
- import type { Tag } from "../schema/metadata.js";
1
+ import type { Tag, TagClass } from "../schema/metadata.js";
2
2
  import type { AnyAsn1TypeDef } from "../schema/types/any-def.js";
3
3
  import type { Asn1TaggedTypeDef } from "../schema/types/base.js";
4
4
  import type { Asn1ChoiceTypeDef } from "../schema/types/constructed/choice.js";
5
+ import type { Asn1ComponentDef, Asn1SequenceComponentDescriptorDef } from "../schema/types/constructed/component.js";
6
+ import type { Asn1SequenceTypeDef } from "../schema/types/constructed/sequence.js";
7
+ import type { Asn1SetTypeDef } from "../schema/types/constructed/set.js";
5
8
  /**
6
9
  * Strips the wrappers that never appear on the wire (`lazy`, `transform`, a
7
10
  * parameterized-type instance) until a def that encodes itself is reached.
@@ -64,6 +67,36 @@ export declare function tagKey(tag: Tag): string;
64
67
  * afterwards.
65
68
  */
66
69
  export declare function outerTagSet(def: AnyAsn1TypeDef, fail: (message: string) => Error): OuterTagSet;
67
- /** Whether `tag` may start an encoding of a def whose outer set is `set`. */
68
- export declare function outerTagSetHas(set: OuterTagSet, tag: Tag): boolean;
70
+ /**
71
+ * Whether a tag of this class and number may start an encoding of a def whose
72
+ * outer set is `set`. A tag number above `Number.MAX_SAFE_INTEGER` (`null`)
73
+ * matches no schema tag.
74
+ */
75
+ export declare function outerTagSetHas(set: OuterTagSet, tagClass: TagClass, tagNumber: number | null): boolean;
76
+ /**
77
+ * Whether a def of this kind is encoded like an OCTET STRING: its contents are
78
+ * bytes that BER and CER may send as the segments of a constructed encoding
79
+ * (X.690 §8.7.3, §8.23, §8.25) and CER fragments above 1000 octets (§9.2). BIT
80
+ * STRING is encoded alike but its segments carry an unused-bits octet, so it is
81
+ * not one; TIME, DATE, TIME-OF-DAY, DATE-TIME and DURATION are primitive only
82
+ * (§8.26), so they are not either.
83
+ */
84
+ export declare function isStringKind(kind: string): boolean;
85
+ /** The components of a SEQUENCE or SET, extension addition groups flattened. */
86
+ export declare function componentList(items: readonly Asn1SequenceComponentDescriptorDef[]): Asn1ComponentDef[];
87
+ /** Whether a SEQUENCE or SET has an extension marker. */
88
+ export declare function isExtensible(def: Asn1SequenceTypeDef | Asn1SetTypeDef): boolean;
89
+ /**
90
+ * The component of a SET an element with this tag belongs to: the first whose
91
+ * type may start with the tag, else the first not yet `present` whose type has
92
+ * no finite tag set (ANY, open type); -1 when none.
93
+ */
94
+ export declare function findSetComponent(components: readonly Asn1ComponentDef[], tagSets: readonly OuterTagSet[], present: ReadonlySet<Asn1ComponentDef>, tagClass: TagClass, tagNumber: number | null): number;
95
+ /**
96
+ * The sort key of the smallest tag a def may start with, which orders a SET
97
+ * component in CER (X.690 §9.3): an untagged CHOICE counts as its smallest tag,
98
+ * those of the untagged CHOICEs nested in it included. `undefined` when the def
99
+ * has no finite tag set (ANY, open type): the tag of the element decides.
100
+ */
101
+ export declare function smallestTagSortKey(def: AnyAsn1TypeDef, fail: (message: string) => Error): bigint | undefined;
69
102
  //# sourceMappingURL=def-tags.d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