@lapo/asn1js 1.2.1 → 1.2.4

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/LICENSE CHANGED
@@ -1,4 +1,6 @@
1
- ASN.1 JavaScript decoder Copyright (c) 2008-2020 Lapo Luchini <lapo@lapo.it>
1
+ ISC License
2
+
3
+ Copyright (c) 2008-2022 Lapo Luchini <lapo@lapo.it>
2
4
 
3
5
  Permission to use, copy, modify, and/or distribute this software for any
4
6
  purpose with or without fee is hereby granted, provided that the above
@@ -11,4 +13,3 @@ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
13
  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
14
  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
15
  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
-
package/README.md CHANGED
@@ -32,10 +32,27 @@ const Hex = require('@lapo/asn1js/hex');
32
32
  import Hex from '@lapo/asn1js/hex';
33
33
  ```
34
34
 
35
+ Usage with RequireJS
36
+ --------------------
37
+
38
+ Can be [tested on JSFiddle](https://jsfiddle.net/lapo/tmdq35ug/).
39
+
40
+ ```html
41
+ <script type="text/javascript" src="https://unpkg.com/requirejs/require.js"></script>
42
+ <script>
43
+ require([
44
+ 'https://unpkg.com/@lapo/asn1js/asn1.js',
45
+ 'https://unpkg.com/@lapo/asn1js/hex.js'
46
+ ], function(ASN1, Hex) {
47
+ document.body.innerText = ASN1.decode(Hex.decode('06032B6570')).content();
48
+ });
49
+ </script>
50
+ ```
51
+
35
52
  ISC license
36
53
  -----------
37
54
 
38
- ASN.1 JavaScript decoder Copyright (c) 2008-2020 Lapo Luchini <lapo@lapo.it>
55
+ ASN.1 JavaScript decoder Copyright (c) 2008-2022 Lapo Luchini <lapo@lapo.it>
39
56
 
40
57
  Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
41
58
 
@@ -48,6 +65,7 @@ credits
48
65
  - BMPString support added by [Felipe Gasper](https://github.com/FGasper)
49
66
  - extended tag support added by [Péter Budai](https://www.peterbudai.eu/)
50
67
  - patches by [Gergely Nagy](https://github.com/ngg)
68
+ - Relative OID support added by [Mistial Developer](https://github.com/mistial-dev)
51
69
 
52
70
  links
53
71
  -----
package/asn1.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // ASN.1 JavaScript decoder
2
- // Copyright (c) 2008-2020 Lapo Luchini <lapo@lapo.it>
2
+ // Copyright (c) 2008-2022 Lapo Luchini <lapo@lapo.it>
3
3
 
4
4
  // Permission to use, copy, modify, and/or distribute this software for any
5
5
  // purpose with or without fee is hereby granted, provided that the above
@@ -22,8 +22,8 @@
22
22
  var Int10 = require('./int10'),
23
23
  oids = require('./oids'),
24
24
  ellipsis = "\u2026",
25
- reTimeS = /^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,
26
- reTimeL = /^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
25
+ reTimeS = /^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|(-(?:0\d|1[0-2])|[+](?:0\d|1[0-4]))([0-5]\d)?)?$/,
26
+ reTimeL = /^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|(-(?:0\d|1[0-2])|[+](?:0\d|1[0-4]))([0-5]\d)?)?$/;
27
27
 
28
28
  function stringCut(str, len) {
29
29
  if (str.length > len)
@@ -94,13 +94,52 @@ Stream.prototype.isASCII = function (start, end) {
94
94
  }
95
95
  return true;
96
96
  };
97
- Stream.prototype.parseStringISO = function (start, end) {
97
+ Stream.prototype.parseStringISO = function (start, end, maxLength) {
98
98
  var s = "";
99
99
  for (var i = start; i < end; ++i)
100
100
  s += String.fromCharCode(this.get(i));
101
- return s;
101
+ return { size: s.length, str: stringCut(s, maxLength) };
102
102
  };
103
- Stream.prototype.parseStringUTF = function (start, end) {
103
+ var tableT61 = [
104
+ ['', ''],
105
+ ['AEIOUaeiou', 'ÀÈÌÒÙàèìòù'], // Grave
106
+ ['ACEILNORSUYZacegilnorsuyz', 'ÁĆÉÍĹŃÓŔŚÚÝŹáćéģíĺńóŕśúýź'], // Acute
107
+ ['ACEGHIJOSUWYaceghijosuwy', 'ÂĈÊĜĤÎĴÔŜÛŴŶâĉêĝĥîĵôŝûŵŷ'], // Circumflex
108
+ ['AINOUainou', 'ÃĨÑÕŨãĩñõũ'], // Tilde
109
+ ['AEIOUaeiou', 'ĀĒĪŌŪāēīōū'], // Macron
110
+ ['AGUagu', 'ĂĞŬăğŭ'], // Breve
111
+ ['CEGIZcegz', 'ĊĖĠİŻċėġż'], // Dot
112
+ ['AEIOUYaeiouy', 'ÄËÏÖÜŸäëïöüÿ'], // Umlaut or diæresis
113
+ ['', ''],
114
+ ['AUau', 'ÅŮåů'], // Ring
115
+ ['CGKLNRSTcklnrst', 'ÇĢĶĻŅŖŞŢçķļņŗşţ'], // Cedilla
116
+ ['', ''],
117
+ ['OUou', 'ŐŰőű'], // Double Acute
118
+ ['AEIUaeiu', 'ĄĘĮŲąęįų'], // Ogonek
119
+ ['CDELNRSTZcdelnrstz', 'ČĎĚĽŇŘŠŤŽčďěľňřšťž'] // Caron
120
+ ];
121
+ Stream.prototype.parseStringT61 = function (start, end, maxLength) {
122
+ // warning: this code is not very well tested so far
123
+ function merge(c, d) {
124
+ var t = tableT61[c - 0xC0];
125
+ var i = t[0].indexOf(String.fromCharCode(d));
126
+ return (i < 0) ? '\0' : t[1].charAt(i);
127
+ }
128
+ var s = "", c;
129
+ for (var i = start; i < end; ++i) {
130
+ c = this.get(i);
131
+ if (c >= 0xA4 && c <= 0xBF)
132
+ s += '$¥#§¤\0\0«\0\0\0\0°±²³×µ¶·÷\0\0»¼½¾¿'.charAt(c - 0xA4);
133
+ else if (c >= 0xE0 && c <= 0xFF)
134
+ s += 'ΩÆÐªĦ\0IJĿŁØŒºÞŦŊʼnĸæđðħıijŀłøœßþŧŋ\0'.charAt(c - 0xE0);
135
+ else if (c >= 0xC0 && c <= 0xCF)
136
+ s += merge(c, this.get(++i));
137
+ else // using ISO 8859-1 for characters undefined (or equal) in T.61
138
+ s += String.fromCharCode(c);
139
+ }
140
+ return { size: s.length, str: stringCut(s, maxLength) };
141
+ };
142
+ Stream.prototype.parseStringUTF = function (start, end, maxLength) {
104
143
  function ex(c) { // must be 10xxxxxx
105
144
  if ((c < 0x80) || (c >= 0xC0))
106
145
  throw new Error('Invalid UTF-8 continuation byte: ' + c);
@@ -129,19 +168,19 @@ Stream.prototype.parseStringUTF = function (start, end) {
129
168
  else
130
169
  throw new Error('Invalid UTF-8 starting byte (since 2003 it is restricted to 4 bytes): ' + c);
131
170
  }
132
- return s;
171
+ return { size: s.length, str: stringCut(s, maxLength) };
133
172
  };
134
- Stream.prototype.parseStringBMP = function (start, end) {
135
- var str = "", hi, lo;
173
+ Stream.prototype.parseStringBMP = function (start, end, maxLength) {
174
+ var s = "", hi, lo;
136
175
  for (var i = start; i < end; ) {
137
176
  hi = this.get(i++);
138
177
  lo = this.get(i++);
139
- str += String.fromCharCode((hi << 8) | lo);
178
+ s += String.fromCharCode((hi << 8) | lo);
140
179
  }
141
- return str;
180
+ return { size: s.length, str: stringCut(s, maxLength) };
142
181
  };
143
182
  Stream.prototype.parseTime = function (start, end, shortYear) {
144
- var s = this.parseStringISO(start, end),
183
+ var s = this.parseStringISO(start, end).str,
145
184
  m = (shortYear ? reTimeS : reTimeL).exec(s);
146
185
  if (!m)
147
186
  return "Unrecognized time: " + s;
@@ -162,11 +201,8 @@ Stream.prototype.parseTime = function (start, end, shortYear) {
162
201
  }
163
202
  if (m[8]) {
164
203
  s += " UTC";
165
- if (m[8] != 'Z') {
166
- s += m[8];
167
- if (m[9])
168
- s += ":" + m[9];
169
- }
204
+ if (m[9])
205
+ s += m[9] + ":" + (m[10] || "00");
170
206
  }
171
207
  return s;
172
208
  };
@@ -215,18 +251,21 @@ Stream.prototype.parseBitString = function (start, end, maxLength) {
215
251
  }
216
252
  return { size: lenBit, str: s };
217
253
  };
254
+ function checkPrintable(s) {
255
+ var i, v;
256
+ for (i = 0; i < s.length; ++i) {
257
+ v = s.charCodeAt(i);
258
+ if (v < 32 && v != 9 && v != 10 && v != 13) // [\t\r\n] are (kinda) printable
259
+ throw new Error('Unprintable character at index ' + i + ' (code ' + s.str.charCodeAt(i) + ")");
260
+ }
261
+ }
218
262
  Stream.prototype.parseOctetString = function (start, end, maxLength) {
219
263
  var len = end - start,
220
264
  s;
221
265
  try {
222
- s = this.parseStringUTF(start, end);
223
- var v;
224
- for (i = 0; i < s.length; ++i) {
225
- v = s.charCodeAt(i);
226
- if (v < 32 && v != 9 && v != 10 && v != 13) // [\t\r\n] are (kinda) printable
227
- throw new Error('Unprintable character at index ' + i + ' (code ' + s.charCodeAt(i) + ")");
228
- }
229
- return { size: len, str: s };
266
+ s = this.parseStringUTF(start, end, maxLength);
267
+ checkPrintable(s.str);
268
+ return { size: end - start, str: s.str };
230
269
  } catch (e) {
231
270
  // ignore
232
271
  }
@@ -240,7 +279,7 @@ Stream.prototype.parseOctetString = function (start, end, maxLength) {
240
279
  s += ellipsis;
241
280
  return { size: len, str: s };
242
281
  };
243
- Stream.prototype.parseOID = function (start, end, maxLength) {
282
+ Stream.prototype.parseOID = function (start, end, maxLength, isRelative) {
244
283
  var s = '',
245
284
  n = new Int10(),
246
285
  bits = 0;
@@ -251,7 +290,9 @@ Stream.prototype.parseOID = function (start, end, maxLength) {
251
290
  if (!(v & 0x80)) { // finished
252
291
  if (s === '') {
253
292
  n = n.simplify();
254
- if (n instanceof Int10) {
293
+ if (isRelative) {
294
+ s = (n instanceof Int10) ? n.toString() : "" + n;
295
+ } else if (n instanceof Int10) {
255
296
  n.sub(80);
256
297
  s = "2." + n.toString();
257
298
  } else {
@@ -268,7 +309,7 @@ Stream.prototype.parseOID = function (start, end, maxLength) {
268
309
  }
269
310
  if (bits > 0)
270
311
  s += ".incomplete";
271
- if (typeof oids === 'object') {
312
+ if (typeof oids === 'object' && !isRelative) {
272
313
  var oid = oids[s];
273
314
  if (oid) {
274
315
  if (oid.d) s += "\n" + oid.d;
@@ -278,6 +319,9 @@ Stream.prototype.parseOID = function (start, end, maxLength) {
278
319
  }
279
320
  return s;
280
321
  };
322
+ Stream.prototype.parseRelativeOID = function (start, end, maxLength) {
323
+ return this.parseOID(start, end, maxLength, true);
324
+ };
281
325
 
282
326
  function ASN1(stream, header, length, tag, tagLen, sub) {
283
327
  if (!(tag instanceof ASN1Tag)) throw 'Invalid tag value.';
@@ -305,6 +349,7 @@ ASN1.prototype.typeName = function () {
305
349
  case 0x0A: return "ENUMERATED";
306
350
  case 0x0B: return "EMBEDDED_PDV";
307
351
  case 0x0C: return "UTF8String";
352
+ case 0x0D: return "RELATIVE_OID";
308
353
  case 0x10: return "SEQUENCE";
309
354
  case 0x11: return "SET";
310
355
  case 0x12: return "NumericString";
@@ -327,12 +372,15 @@ ASN1.prototype.typeName = function () {
327
372
  }
328
373
  };
329
374
  function recurse(el, parser, maxLength) {
330
- var differentTags = false;
331
- if (el.sub) el.sub.forEach(function (e1) {
332
- if (e1.tag.tagClass != el.tag.tagClass || e1.tag.tagNumber != el.tag.tagNumber)
333
- differentTags = true;
334
- });
335
- if (!el.sub || differentTags)
375
+ var avoidRecurse = true;
376
+ if (el.tag.tagConstructed && el.sub) {
377
+ avoidRecurse = false;
378
+ el.sub.forEach(function (e1) {
379
+ if (e1.tag.tagClass != el.tag.tagClass || e1.tag.tagNumber != el.tag.tagNumber)
380
+ avoidRecurse = true;
381
+ });
382
+ }
383
+ if (avoidRecurse)
336
384
  return el.stream[parser](el.posContent(), el.posContent() + Math.abs(el.length), maxLength);
337
385
  var d = { size: 0, str: '' };
338
386
  el.sub.forEach(function (el) {
@@ -376,6 +424,8 @@ ASN1.prototype.content = function (maxLength) {
376
424
  case 0x0A: // ENUMERATED
377
425
  return this.stream.parseInteger(content, content + len);
378
426
  //case 0x0B: // EMBEDDED_PDV
427
+ case 0x0D: // RELATIVE-OID
428
+ return this.stream.parseRelativeOID(content, content + len, maxLength);
379
429
  case 0x10: // SEQUENCE
380
430
  case 0x11: // SET
381
431
  if (this.sub !== null)
@@ -383,19 +433,20 @@ ASN1.prototype.content = function (maxLength) {
383
433
  else
384
434
  return "(no elem)";
385
435
  case 0x0C: // UTF8String
386
- return stringCut(this.stream.parseStringUTF(content, content + len), maxLength);
436
+ return recurse(this, 'parseStringUTF', maxLength).str;
437
+ case 0x14: // TeletexString
438
+ return recurse(this, 'parseStringT61', maxLength).str;
387
439
  case 0x12: // NumericString
388
440
  case 0x13: // PrintableString
389
- case 0x14: // TeletexString
390
441
  case 0x15: // VideotexString
391
442
  case 0x16: // IA5String
392
443
  case 0x1A: // VisibleString
393
444
  case 0x1B: // GeneralString
394
445
  //case 0x19: // GraphicString
395
446
  //case 0x1C: // UniversalString
396
- return stringCut(this.stream.parseStringISO(content, content + len), maxLength);
447
+ return recurse(this, 'parseStringISO', maxLength).str;
397
448
  case 0x1E: // BMPString
398
- return stringCut(this.stream.parseStringBMP(content, content + len), maxLength);
449
+ return recurse(this, 'parseStringBMP', maxLength).str;
399
450
  case 0x17: // UTCTime
400
451
  case 0x18: // GeneralizedTime
401
452
  return this.stream.parseTime(content, content + len, (this.tag.tagNumber == 0x17));
package/base64.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Base64 JavaScript decoder
2
- // Copyright (c) 2008-2020 Lapo Luchini <lapo@lapo.it>
2
+ // Copyright (c) 2008-2022 Lapo Luchini <lapo@lapo.it>
3
3
 
4
4
  // Permission to use, copy, modify, and/or distribute this software for any
5
5
  // purpose with or without fee is hereby granted, provided that the above
@@ -86,7 +86,7 @@ Base64.pretty = function (str) {
86
86
  return str.replace(/(.{80})/g, '$1\n');
87
87
  };
88
88
 
89
- Base64.re = /-----BEGIN [^-]+-----([A-Za-z0-9+/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+/=\s]+)====/;
89
+ Base64.re = /-----BEGIN [^-]+-----([A-Za-z0-9+/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+/=\s]+)====|^([A-Za-z0-9+/=\s]+)$/;
90
90
  Base64.unarmor = function (a) {
91
91
  var m = Base64.re.exec(a);
92
92
  if (m) {
@@ -94,6 +94,8 @@ Base64.unarmor = function (a) {
94
94
  a = m[1];
95
95
  else if (m[2])
96
96
  a = m[2];
97
+ else if (m[3])
98
+ a = m[3];
97
99
  else
98
100
  throw "RegExp out of sync";
99
101
  }
package/hex.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Hex JavaScript decoder
2
- // Copyright (c) 2008-2020 Lapo Luchini <lapo@lapo.it>
2
+ // Copyright (c) 2008-2022 Lapo Luchini <lapo@lapo.it>
3
3
 
4
4
  // Permission to use, copy, modify, and/or distribute this software for any
5
5
  // purpose with or without fee is hereby granted, provided that the above
package/int10.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Big integer base-10 printing library
2
- // Copyright (c) 2008-2020 Lapo Luchini <lapo@lapo.it>
2
+ // Copyright (c) 2008-2022 Lapo Luchini <lapo@lapo.it>
3
3
 
4
4
  // Permission to use, copy, modify, and/or distribute this software for any
5
5
  // purpose with or without fee is hereby granted, provided that the above
package/oids.js CHANGED
@@ -710,6 +710,7 @@ return {
710
710
  "1.2.840.113549.1.9.16.0.7": { "d": "id-mod-ets-eSigPolicy-88", "c": "S/MIME Modules" },
711
711
  "1.2.840.113549.1.9.16.0.8": { "d": "id-mod-ets-eSigPolicy-88", "c": "S/MIME Modules" },
712
712
  "1.2.840.113549.1.9.16.1": { "d": "contentType", "c": "S/MIME" },
713
+ "1.2.840.113549.1.9.16.1.0": { "d": "anyContentType", "c": "S/MIME Content Types" },
713
714
  "1.2.840.113549.1.9.16.1.1": { "d": "receipt", "c": "S/MIME Content Types" },
714
715
  "1.2.840.113549.1.9.16.1.2": { "d": "authData", "c": "S/MIME Content Types" },
715
716
  "1.2.840.113549.1.9.16.1.3": { "d": "publishCert", "c": "S/MIME Content Types" },
@@ -744,6 +745,19 @@ return {
744
745
  "1.2.840.113549.1.9.16.1.32": { "d": "asAdjacencyAttest", "c": "S/MIME Content Types", "w": true },
745
746
  "1.2.840.113549.1.9.16.1.33": { "d": "rpkiTrustAnchor", "c": "S/MIME Content Types" },
746
747
  "1.2.840.113549.1.9.16.1.34": { "d": "trustAnchorList", "c": "S/MIME Content Types" },
748
+ "1.2.840.113549.1.9.16.1.35": { "d": "rpkiGhostbusters", "c": "S/MIME Content Types" },
749
+ "1.2.840.113549.1.9.16.1.36": { "d": "resourceTaggedAttest", "c": "S/MIME Content Types" },
750
+ "1.2.840.113549.1.9.16.1.37": { "d": "utf8TextWithCRLF", "c": "S/MIME Content Types" },
751
+ "1.2.840.113549.1.9.16.1.38": { "d": "htmlWithCRLF", "c": "S/MIME Content Types" },
752
+ "1.2.840.113549.1.9.16.1.39": { "d": "epub", "c": "S/MIME Content Types" },
753
+ "1.2.840.113549.1.9.16.1.40": { "d": "animaJSONVoucher", "c": "S/MIME Content Types" },
754
+ "1.2.840.113549.1.9.16.1.41": { "d": "mudType", "c": "S/MIME Content Types" },
755
+ "1.2.840.113549.1.9.16.1.42": { "d": "sztpConveyedInfoXML", "c": "S/MIME Content Types" },
756
+ "1.2.840.113549.1.9.16.1.43": { "d": "sztpConveyedInfoJSON", "c": "S/MIME Content Types" },
757
+ "1.2.840.113549.1.9.16.1.44": { "d": "cbor", "c": "S/MIME Content Types" },
758
+ "1.2.840.113549.1.9.16.1.45": { "d": "cborSequence", "c": "S/MIME Content Types" },
759
+ "1.2.840.113549.1.9.16.1.46": { "d": "animaCBORVoucher", "c": "S/MIME Content Types", "w": true },
760
+ "1.2.840.113549.1.9.16.1.47": { "d": "geofeedCSVwithCRLF", "c": "S/MIME Content Types" },
747
761
  "1.2.840.113549.1.9.16.2": { "d": "authenticatedAttributes", "c": "S/MIME" },
748
762
  "1.2.840.113549.1.9.16.2.1": { "d": "receiptRequest", "c": "S/MIME Authenticated Attributes" },
749
763
  "1.2.840.113549.1.9.16.2.2": { "d": "securityLabel", "c": "S/MIME Authenticated Attributes" },
@@ -796,6 +810,13 @@ return {
796
810
  "1.2.840.113549.1.9.16.2.49": { "d": "erInternal", "c": "S/MIME Authenticated Attributes" },
797
811
  "1.2.840.113549.1.9.16.2.50": { "d": "erExternal", "c": "S/MIME Authenticated Attributes" },
798
812
  "1.2.840.113549.1.9.16.2.51": { "d": "multipleSignatures", "c": "S/MIME Authenticated Attributes" },
813
+ "1.2.840.113549.1.9.16.2.52": { "d": "cmsAlgorithmProtect", "c": "S/MIME Authenticated Attributes" },
814
+ "1.2.840.113549.1.9.16.2.53": { "d": "setKeyInformation", "c": "S/MIME Authenticated Attributes" },
815
+ "1.2.840.113549.1.9.16.2.54": { "d": "asymmDecryptKeyID", "c": "S/MIME Authenticated Attributes" },
816
+ "1.2.840.113549.1.9.16.2.55": { "d": "secureHeaderFieldsIdentifier", "c": "S/MIME Authenticated Attributes" },
817
+ "1.2.840.113549.1.9.16.2.56": { "d": "otpChallenge", "c": "S/MIME Authenticated Attributes" },
818
+ "1.2.840.113549.1.9.16.2.57": { "d": "revocationChallenge", "c": "S/MIME Authenticated Attributes" },
819
+ "1.2.840.113549.1.9.16.2.58": { "d": "estIdentityLinking", "c": "S/MIME Authenticated Attributes" },
799
820
  "1.2.840.113549.1.9.16.3.1": { "d": "esDHwith3DES", "c": "S/MIME Algorithms. Obsolete", "w": true },
800
821
  "1.2.840.113549.1.9.16.3.2": { "d": "esDHwithRC2", "c": "S/MIME Algorithms. Obsolete", "w": true },
801
822
  "1.2.840.113549.1.9.16.3.3": { "d": "3desWrap", "c": "S/MIME Algorithms. Obsolete", "w": true },
@@ -835,6 +856,10 @@ return {
835
856
  "1.2.840.113549.1.9.16.6.4": { "d": "proofOfSender", "c": "S/MIME Commitment Type Identifiers" },
836
857
  "1.2.840.113549.1.9.16.6.5": { "d": "proofOfApproval", "c": "S/MIME Commitment Type Identifiers" },
837
858
  "1.2.840.113549.1.9.16.6.6": { "d": "proofOfCreation", "c": "S/MIME Commitment Type Identifiers" },
859
+ "1.2.840.113549.1.9.16.7.1": { "d": "testAmoco", "c": "S/MIMETest Security Policies" },
860
+ "1.2.840.113549.1.9.16.7.2": { "d": "testCaterpillar", "c": "S/MIMETest Security Policies" },
861
+ "1.2.840.113549.1.9.16.7.3": { "d": "testWhirlpool", "c": "S/MIMETest Security Policies" },
862
+ "1.2.840.113549.1.9.16.7.4": { "d": "testWhirlpoolCategories", "c": "S/MIMETest Security Policies" },
838
863
  "1.2.840.113549.1.9.16.8.1": { "d": "glUseKEK", "c": "S/MIME Symmetric Key Distribution Attributes" },
839
864
  "1.2.840.113549.1.9.16.8.2": { "d": "glDelete", "c": "S/MIME Symmetric Key Distribution Attributes" },
840
865
  "1.2.840.113549.1.9.16.8.3": { "d": "glAddMember", "c": "S/MIME Symmetric Key Distribution Attributes" },
@@ -855,6 +880,13 @@ return {
855
880
  "1.2.840.113549.1.9.16.9.2": { "d": "domainSig", "c": "S/MIME Signature Type Identifier" },
856
881
  "1.2.840.113549.1.9.16.9.3": { "d": "additionalAttributesSig", "c": "S/MIME Signature Type Identifier" },
857
882
  "1.2.840.113549.1.9.16.9.4": { "d": "reviewSig", "c": "S/MIME Signature Type Identifier" },
883
+ "1.2.840.113549.1.9.16.10.1": { "d": "envelopedData", "c": "S/MIME X.400 Encoded Information Types" },
884
+ "1.2.840.113549.1.9.16.10.2": { "d": "signedData", "c": "S/MIME X.400 Encoded Information Types" },
885
+ "1.2.840.113549.1.9.16.10.3": { "d": "certsOnly", "c": "S/MIME X.400 Encoded Information Types" },
886
+ "1.2.840.113549.1.9.16.10.4": { "d": "signedReceipt", "c": "S/MIME X.400 Encoded Information Types" },
887
+ "1.2.840.113549.1.9.16.10.5": { "d": "envelopedX400", "c": "S/MIME X.400 Encoded Information Types" },
888
+ "1.2.840.113549.1.9.16.10.6": { "d": "signedX400", "c": "S/MIME X.400 Encoded Information Types" },
889
+ "1.2.840.113549.1.9.16.10.7": { "d": "compressedData", "c": "S/MIME X.400 Encoded Information Types" },
858
890
  "1.2.840.113549.1.9.16.11": { "d": "capabilities", "c": "S/MIME" },
859
891
  "1.2.840.113549.1.9.16.11.1": { "d": "preferBinaryInside", "c": "S/MIME Capability" },
860
892
  "1.2.840.113549.1.9.16.12": { "d": "pskcAttributes", "c": "S/MIME Portable Symmetric Key Container Attributes" },
@@ -885,6 +917,9 @@ return {
885
917
  "1.2.840.113549.1.9.16.12.25": { "d": "pskcPinpolicy", "c": "S/MIME Portable Symmetric Key Container Attributes" },
886
918
  "1.2.840.113549.1.9.16.12.26": { "d": "pskcDeviceuserid", "c": "S/MIME Portable Symmetric Key Container Attributes" },
887
919
  "1.2.840.113549.1.9.16.12.27": { "d": "pskcKeyuserid", "c": "S/MIME Portable Symmetric Key Container Attributes" },
920
+ "1.2.840.113549.1.9.16.13": { "d": "otherRecipientInfoIds", "c": "S/MIME Other Recipient Info Identifiers" },
921
+ "1.2.840.113549.1.9.16.13.1": { "d": "keyTransPSK", "c": "S/MIME Other Recipient Info Identifiers" },
922
+ "1.2.840.113549.1.9.16.13.2": { "d": "keyAgreePSK", "c": "S/MIME Other Recipient Info Identifiers" },
888
923
  "1.2.840.113549.1.9.20": { "d": "friendlyName (for PKCS #12)", "c": "PKCS #9 via PKCS #12" },
889
924
  "1.2.840.113549.1.9.21": { "d": "localKeyID (for PKCS #12)", "c": "PKCS #9 via PKCS #12" },
890
925
  "1.2.840.113549.1.9.22": { "d": "certTypes (for PKCS #12)", "c": "PKCS #9 via PKCS #12" },
@@ -1086,6 +1121,9 @@ return {
1086
1121
  "1.2.840.113635.100.6.1.1": { "d": "appleCertificateExtensionAppleSigning", "c": "Apple certificate extension" },
1087
1122
  "1.2.840.113635.100.6.1.2": { "d": "appleCertificateExtensionADCDeveloperSigning", "c": "Apple certificate extension" },
1088
1123
  "1.2.840.113635.100.6.1.3": { "d": "appleCertificateExtensionADCAppleSigning", "c": "Apple certificate extension" },
1124
+ "1.2.840.113635.100.15.1": { "d": "appleCustomCertificateExtension1", "c": "Apple custom certificate extension" },
1125
+ "1.2.840.113635.100.15.2": { "d": "appleCustomCertificateExtension2", "c": "Apple custom certificate extension" },
1126
+ "1.2.840.113635.100.15.3": { "d": "appleCustomCertificateExtension3", "c": "Apple custom certificate extension" },
1089
1127
  "1.3.6.1.4.1.311.2.1.4": { "d": "spcIndirectDataContext", "c": "Microsoft code signing" },
1090
1128
  "1.3.6.1.4.1.311.2.1.10": { "d": "spcAgencyInfo", "c": "Microsoft code signing. Also known as policyLink" },
1091
1129
  "1.3.6.1.4.1.311.2.1.11": { "d": "spcStatementType", "c": "Microsoft code signing" },
@@ -1192,6 +1230,7 @@ return {
1192
1230
  "1.3.6.1.4.1.311.60.2.1.1": { "d": "jurisdictionOfIncorporationL", "c": "Microsoft (???)" },
1193
1231
  "1.3.6.1.4.1.311.60.2.1.2": { "d": "jurisdictionOfIncorporationSP", "c": "Microsoft (???)" },
1194
1232
  "1.3.6.1.4.1.311.60.2.1.3": { "d": "jurisdictionOfIncorporationC", "c": "Microsoft (???)" },
1233
+ "1.3.6.1.4.1.311.76.509.1.1": { "d": "microsoftCPS", "c": "Microsoft PKI services" },
1195
1234
  "1.3.6.1.4.1.311.88": { "d": "capiCom", "c": "Microsoft attribute" },
1196
1235
  "1.3.6.1.4.1.311.88.1": { "d": "capiComVersion", "c": "Microsoft attribute" },
1197
1236
  "1.3.6.1.4.1.311.88.2": { "d": "capiComAttribute", "c": "Microsoft attribute" },
@@ -1269,7 +1308,7 @@ return {
1269
1308
  "1.3.6.1.4.1.8301.3.5.1": { "d": "validityModelChain", "c": "TU Darmstadt ValidityModel" },
1270
1309
  "1.3.6.1.4.1.8301.3.5.2": { "d": "validityModelShell", "c": "ValidityModel" },
1271
1310
  "1.3.6.1.4.1.8231.1": { "d": "rolUnicoNacional", "c": "Chilean Government national unique roll number" },
1272
- "1.3.6.1.4.1.11591": { "d": "gnu", "c": "GNU Project (see http://www.gnupg.org/oids.html)" },
1311
+ "1.3.6.1.4.1.11591": { "d": "gnu", "c": "GNU Project (see https://www.gnupg.org/oids.html)" },
1273
1312
  "1.3.6.1.4.1.11591.1": { "d": "gnuRadius", "c": "GNU Radius" },
1274
1313
  "1.3.6.1.4.1.11591.3": { "d": "gnuRadar", "c": "GNU Radar" },
1275
1314
  "1.3.6.1.4.1.11591.4.11": { "d": "scrypt", "c": "GNU Generic Security Service" },
@@ -1302,6 +1341,7 @@ return {
1302
1341
  "1.3.6.1.4.1.23629.1.4.2.1.3": { "d": "safenetStartDate", "c": "SafeNet" },
1303
1342
  "1.3.6.1.4.1.23629.1.4.2.1.4": { "d": "safenetAdminCert", "c": "SafeNet" },
1304
1343
  "1.3.6.1.4.1.23629.1.4.2.2.1": { "d": "safenetKeyDigest", "c": "SafeNet" },
1344
+ "1.3.6.1.4.1.51483.2.1": { "d": "hashOfRootKey", "c": "CTIA" },
1305
1345
  "1.3.6.1.5.2.3.1": { "d": "authData", "c": "Kerberos" },
1306
1346
  "1.3.6.1.5.2.3.2": { "d": "dHKeyData", "c": "Kerberos" },
1307
1347
  "1.3.6.1.5.2.3.3": { "d": "rkeyData", "c": "Kerberos" },
@@ -1341,10 +1381,13 @@ return {
1341
1381
  "1.3.6.1.5.5.7.1.29": { "d": "autonomousSysIdsV2", "c": "PKIX private extension" },
1342
1382
  "1.3.6.1.5.5.7.1.30": { "d": "manufacturerUsageDescriptionSigner", "c": "PKIX private extension" },
1343
1383
  "1.3.6.1.5.5.7.1.31": { "d": "acmeIdentifier", "c": "PKIX private extension" },
1384
+ "1.3.6.1.5.5.7.1.32": { "d": "masaURL", "c": "PKIX private extension" },
1344
1385
  "1.3.6.1.5.5.7.2": { "d": "policyQualifierIds", "c": "PKIX" },
1345
1386
  "1.3.6.1.5.5.7.2.1": { "d": "cps", "c": "PKIX policy qualifier" },
1346
1387
  "1.3.6.1.5.5.7.2.2": { "d": "unotice", "c": "PKIX policy qualifier" },
1347
1388
  "1.3.6.1.5.5.7.2.3": { "d": "textNotice", "c": "PKIX policy qualifier" },
1389
+ "1.3.6.1.5.5.7.2.4": { "d": "acps", "c": "PKIX policy qualifier" },
1390
+ "1.3.6.1.5.5.7.2.5": { "d": "acunotice", "c": "PKIX policy qualifier" },
1348
1391
  "1.3.6.1.5.5.7.3": { "d": "keyPurpose", "c": "PKIX" },
1349
1392
  "1.3.6.1.5.5.7.3.1": { "d": "serverAuth", "c": "PKIX key purpose" },
1350
1393
  "1.3.6.1.5.5.7.3.2": { "d": "clientAuth", "c": "PKIX key purpose" },
@@ -1376,6 +1419,10 @@ return {
1376
1419
  "1.3.6.1.5.5.7.3.28": { "d": "cmcRA", "c": "PKIX key purpose" },
1377
1420
  "1.3.6.1.5.5.7.3.29": { "d": "cmcArchive", "c": "PKIX key purpose" },
1378
1421
  "1.3.6.1.5.5.7.3.30": { "d": "bgpsecRouter", "c": "PKIX key purpose" },
1422
+ "1.3.6.1.5.5.7.3.31": { "d": "bimi", "c": "PKIX key purpose" },
1423
+ "1.3.6.1.5.5.7.3.32": { "d": "cmKGA", "c": "PKIX key purpose" },
1424
+ "1.3.6.1.5.5.7.3.33": { "d": "rpcTLSClient", "c": "PKIX key purpose" },
1425
+ "1.3.6.1.5.5.7.3.34": { "d": "rpcTLSServer", "c": "PKIX key purpose" },
1379
1426
  "1.3.6.1.5.5.7.4": { "d": "cmpInformationTypes", "c": "PKIX" },
1380
1427
  "1.3.6.1.5.5.7.4.1": { "d": "caProtEncCert", "c": "PKIX CMP information" },
1381
1428
  "1.3.6.1.5.5.7.4.2": { "d": "signKeyPairTypes", "c": "PKIX CMP information" },
@@ -1425,7 +1472,9 @@ return {
1425
1472
  "1.3.6.1.5.5.7.8": { "d": "otherNames", "c": "PKIX" },
1426
1473
  "1.3.6.1.5.5.7.8.1": { "d": "personalData", "c": "PKIX other name" },
1427
1474
  "1.3.6.1.5.5.7.8.2": { "d": "userGroup", "c": "PKIX other name" },
1475
+ "1.3.6.1.5.5.7.8.3": { "d": "permanentIdentifier", "c": "PKIX other name" },
1428
1476
  "1.3.6.1.5.5.7.8.5": { "d": "xmppAddr", "c": "PKIX other name" },
1477
+ "1.3.6.1.5.5.7.8.6": { "d": "SIM", "c": "PKIX other name" },
1429
1478
  "1.3.6.1.5.5.7.9": { "d": "personalData", "c": "PKIX qualified certificates" },
1430
1479
  "1.3.6.1.5.5.7.9.1": { "d": "dateOfBirth", "c": "PKIX personal data" },
1431
1480
  "1.3.6.1.5.5.7.9.2": { "d": "placeOfBirth", "c": "PKIX personal data" },
@@ -1441,6 +1490,10 @@ return {
1441
1490
  "1.3.6.1.5.5.7.10.6": { "d": "wlanSSID", "c": "PKIX attribute-certificate extension" },
1442
1491
  "1.3.6.1.5.5.7.11": { "d": "personalData", "c": "PKIX qualified certificates" },
1443
1492
  "1.3.6.1.5.5.7.11.1": { "d": "pkixQCSyntax-v1", "c": "PKIX qualified certificates" },
1493
+ "1.3.6.1.5.5.7.11.2": { "d": "pkixQCSyntax-v2", "c": "PKIX qualified certificates" },
1494
+ "1.3.6.1.5.5.7.12": { "d": "pkixCCT", "c": "PKIX CMC Content Types" },
1495
+ "1.3.6.1.5.5.7.12.2": { "d": "pkiData", "c": "PKIX CMC Content Types" },
1496
+ "1.3.6.1.5.5.7.12.3": { "d": "pkiResponse", "c": "PKIX CMC Content Types" },
1444
1497
  "1.3.6.1.5.5.7.14.2": { "d": "resourceCertificatePolicy", "c": "PKIX policies" },
1445
1498
  "1.3.6.1.5.5.7.20": { "d": "logo", "c": "PKIX qualified certificates" },
1446
1499
  "1.3.6.1.5.5.7.20.1": { "d": "logoLoyalty", "c": "PKIX" },
@@ -1875,7 +1928,36 @@ return {
1875
1928
  "2.5.4.74": { "d": "protPrivPolicy", "c": "X.520 DN component" },
1876
1929
  "2.5.4.75": { "d": "xMLPrivilegeInfo", "c": "X.520 DN component" },
1877
1930
  "2.5.4.76": { "d": "xmlPrivPolicy", "c": "X.520 DN component" },
1931
+ "2.5.4.77": { "d": "uuidpair", "c": "X.520 DN component" },
1932
+ "2.5.4.78": { "d": "tagOid", "c": "X.520 DN component" },
1933
+ "2.5.4.79": { "d": "uiiFormat", "c": "X.520 DN component" },
1934
+ "2.5.4.80": { "d": "uiiInUrh", "c": "X.520 DN component" },
1935
+ "2.5.4.81": { "d": "contentUrl", "c": "X.520 DN component" },
1878
1936
  "2.5.4.82": { "d": "permission", "c": "X.520 DN component" },
1937
+ "2.5.4.83": { "d": "uri", "c": "X.520 DN component" },
1938
+ "2.5.4.84": { "d": "pwdAttribute", "c": "X.520 DN component" },
1939
+ "2.5.4.85": { "d": "userPwd", "c": "X.520 DN component" },
1940
+ "2.5.4.86": { "d": "urn", "c": "X.520 DN component" },
1941
+ "2.5.4.87": { "d": "url", "c": "X.520 DN component" },
1942
+ "2.5.4.88": { "d": "utmCoordinates", "c": "X.520 DN component" },
1943
+ "2.5.4.89": { "d": "urnC", "c": "X.520 DN component" },
1944
+ "2.5.4.90": { "d": "uii", "c": "X.520 DN component" },
1945
+ "2.5.4.91": { "d": "epc", "c": "X.520 DN component" },
1946
+ "2.5.4.92": { "d": "tagAfi", "c": "X.520 DN component" },
1947
+ "2.5.4.93": { "d": "epcFormat", "c": "X.520 DN component" },
1948
+ "2.5.4.94": { "d": "epcInUrn", "c": "X.520 DN component" },
1949
+ "2.5.4.95": { "d": "ldapUrl", "c": "X.520 DN component" },
1950
+ "2.5.4.96": { "d": "tagLocation", "c": "X.520 DN component" },
1951
+ "2.5.4.97": { "d": "organizationIdentifier", "c": "X.520 DN component" },
1952
+ "2.5.4.98": { "d": "countryCode3c", "c": "X.520 DN component" },
1953
+ "2.5.4.99": { "d": "countryCode3n", "c": "X.520 DN component" },
1954
+ "2.5.4.100": { "d": "dnsName", "c": "X.520 DN component" },
1955
+ "2.5.4.101": { "d": "eepkCertificateRevocationList", "c": "X.520 DN component" },
1956
+ "2.5.4.102": { "d": "eeAttrCertificateRevocationList", "c": "X.520 DN component" },
1957
+ "2.5.4.103": { "d": "supportedPublicKeyAlgorithms", "c": "X.520 DN component" },
1958
+ "2.5.4.104": { "d": "intEmail", "c": "X.520 DN component" },
1959
+ "2.5.4.105": { "d": "jid", "c": "X.520 DN component" },
1960
+ "2.5.4.106": { "d": "objectIdentifier", "c": "X.520 DN component" },
1879
1961
  "2.5.6.0": { "d": "top", "c": "X.520 objectClass" },
1880
1962
  "2.5.6.1": { "d": "alias", "c": "X.520 objectClass" },
1881
1963
  "2.5.6.2": { "d": "country", "c": "X.520 objectClass" },
@@ -2175,6 +2257,7 @@ return {
2175
2257
  "2.16.840.1.101.3.4.1.6": { "d": "aes128-GCM", "c": "NIST Algorithm" },
2176
2258
  "2.16.840.1.101.3.4.1.7": { "d": "aes128-CCM", "c": "NIST Algorithm" },
2177
2259
  "2.16.840.1.101.3.4.1.8": { "d": "aes128-wrap-pad", "c": "NIST Algorithm" },
2260
+ "2.16.840.1.101.3.4.1.9": { "d": "aes128-GMAC", "c": "NIST Algorithm" },
2178
2261
  "2.16.840.1.101.3.4.1.21": { "d": "aes192-ECB", "c": "NIST Algorithm" },
2179
2262
  "2.16.840.1.101.3.4.1.22": { "d": "aes192-CBC", "c": "NIST Algorithm" },
2180
2263
  "2.16.840.1.101.3.4.1.23": { "d": "aes192-OFB", "c": "NIST Algorithm" },
@@ -2183,6 +2266,7 @@ return {
2183
2266
  "2.16.840.1.101.3.4.1.26": { "d": "aes192-GCM", "c": "NIST Algorithm" },
2184
2267
  "2.16.840.1.101.3.4.1.27": { "d": "aes192-CCM", "c": "NIST Algorithm" },
2185
2268
  "2.16.840.1.101.3.4.1.28": { "d": "aes192-wrap-pad", "c": "NIST Algorithm" },
2269
+ "2.16.840.1.101.3.4.1.29": { "d": "aes192-GMAC", "c": "NIST Algorithm" },
2186
2270
  "2.16.840.1.101.3.4.1.41": { "d": "aes256-ECB", "c": "NIST Algorithm" },
2187
2271
  "2.16.840.1.101.3.4.1.42": { "d": "aes256-CBC", "c": "NIST Algorithm" },
2188
2272
  "2.16.840.1.101.3.4.1.43": { "d": "aes256-OFB", "c": "NIST Algorithm" },
@@ -2191,11 +2275,16 @@ return {
2191
2275
  "2.16.840.1.101.3.4.1.46": { "d": "aes256-GCM", "c": "NIST Algorithm" },
2192
2276
  "2.16.840.1.101.3.4.1.47": { "d": "aes256-CCM", "c": "NIST Algorithm" },
2193
2277
  "2.16.840.1.101.3.4.1.48": { "d": "aes256-wrap-pad", "c": "NIST Algorithm" },
2278
+ "2.16.840.1.101.3.4.1.49": { "d": "aes256-GMAC", "c": "NIST Algorithm" },
2194
2279
  "2.16.840.1.101.3.4.2": { "d": "hashAlgos", "c": "NIST Algorithm" },
2195
2280
  "2.16.840.1.101.3.4.2.1": { "d": "sha-256", "c": "NIST Algorithm" },
2196
2281
  "2.16.840.1.101.3.4.2.2": { "d": "sha-384", "c": "NIST Algorithm" },
2197
2282
  "2.16.840.1.101.3.4.2.3": { "d": "sha-512", "c": "NIST Algorithm" },
2198
2283
  "2.16.840.1.101.3.4.2.4": { "d": "sha-224", "c": "NIST Algorithm" },
2284
+ "2.16.840.1.101.3.4.2.7": { "d": "sha3-224", "c": "NIST Algorithm" },
2285
+ "2.16.840.1.101.3.4.2.8": { "d": "sha3-256", "c": "NIST Algorithm" },
2286
+ "2.16.840.1.101.3.4.2.9": { "d": "sha3-384", "c": "NIST Algorithm" },
2287
+ "2.16.840.1.101.3.4.2.10": { "d": "sha3-512", "c": "NIST Algorithm" },
2199
2288
  "2.16.840.1.101.3.4.2.11": { "d": "shake128", "c": "NIST Algorithm" },
2200
2289
  "2.16.840.1.101.3.4.2.12": { "d": "shake256", "c": "NIST Algorithm" },
2201
2290
  "2.16.840.1.101.3.4.2.17": { "d": "shake128len", "c": "NIST Algorithm" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lapo/asn1js",
3
- "version": "1.2.1",
3
+ "version": "1.2.4",
4
4
  "description": "Generic ASN.1 parser/decoder that can decode any valid ASN.1 DER or BER structures.",
5
5
  "main": "asn1.js",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  "homepage": "https://lapo.it/asn1js/",
15
15
  "files": [ "asn1.js", "base64.js", "hex.js", "int10.js", "oids.js" ],
16
16
  "scripts" : {
17
- "lint" : "npx eslint *.js",
17
+ "lint" : "npx eslint asn1.js base64.js hex.js int10.js oids.js parseRFC.js dumpASN1.js",
18
18
  "test" : "node test"
19
19
  },
20
20
  "eslintConfig": {
@@ -36,7 +36,10 @@
36
36
  },
37
37
  "overrides": [
38
38
  {
39
- "files": [ "test.js" ],
39
+ "files": [ "test.js", "parseRFC.js", "dumpASN1.js" ],
40
+ "parserOptions": {
41
+ "ecmaVersion": 2020
42
+ },
40
43
  "rules": {
41
44
  "strict": [ "error", "global" ],
42
45
  "comma-dangle": [ "error", "always-multiline" ]