node-opcua-crypto 1.11.0 → 2.0.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 (108) hide show
  1. package/.fossa.yml +18 -18
  2. package/.github/FUNDING.yml +12 -12
  3. package/.github/workflows/main.yml +32 -32
  4. package/.prettierrc.js +6 -6
  5. package/LICENSE +23 -22
  6. package/README.md +14 -14
  7. package/dist/source/asn1.d.ts +73 -73
  8. package/dist/source/asn1.js +359 -359
  9. package/dist/source/buffer_utils.d.ts +6 -6
  10. package/dist/source/buffer_utils.js +21 -21
  11. package/dist/source/certificate_matches_private_key.d.ts +2 -0
  12. package/dist/source/certificate_matches_private_key.js +22 -0
  13. package/dist/source/certificate_matches_private_key.js.map +1 -0
  14. package/dist/source/common.d.ts +12 -12
  15. package/dist/source/common.js +2 -2
  16. package/dist/source/crypto_explore_certificate.d.ts +107 -107
  17. package/dist/source/crypto_explore_certificate.js +601 -600
  18. package/dist/source/crypto_explore_certificate.js.map +1 -1
  19. package/dist/source/crypto_utils.d.ts +80 -78
  20. package/dist/source/crypto_utils.js +312 -280
  21. package/dist/source/crypto_utils.js.map +1 -1
  22. package/dist/source/derived_keys.d.ts +72 -72
  23. package/dist/source/derived_keys.js +248 -248
  24. package/dist/source/explore_certificate.d.ts +30 -30
  25. package/dist/source/explore_certificate.js +43 -43
  26. package/dist/source/explore_certificate_revocation_list.d.ts +28 -28
  27. package/dist/source/explore_certificate_revocation_list.js +69 -69
  28. package/dist/source/explore_certificate_signing_request.d.ts +13 -13
  29. package/dist/source/explore_certificate_signing_request.js +44 -44
  30. package/dist/source/explore_private_key.d.ts +29 -29
  31. package/dist/source/explore_private_key.js +96 -96
  32. package/dist/source/explore_private_key.js.map +1 -1
  33. package/dist/source/index.d.ts +13 -13
  34. package/dist/source/index.js +29 -29
  35. package/dist/source/oid_map.d.ts +7 -7
  36. package/dist/source/oid_map.js +303 -303
  37. package/dist/source/public_private_match.d.ts +3 -3
  38. package/dist/source/public_private_match.js +37 -16
  39. package/dist/source/public_private_match.js.map +1 -1
  40. package/dist/source/verify_certificate_signature.d.ts +10 -10
  41. package/dist/source/verify_certificate_signature.js +101 -101
  42. package/dist/source_nodejs/index.d.ts +3 -3
  43. package/dist/source_nodejs/index.js +19 -19
  44. package/dist/source_nodejs/read.d.ts +29 -29
  45. package/dist/source_nodejs/read.js +94 -94
  46. package/dist/source_nodejs/read.js.map +1 -1
  47. package/dist/source_nodejs/read_certificate_revocation_list.d.ts +2 -2
  48. package/dist/source_nodejs/read_certificate_revocation_list.js +27 -27
  49. package/dist/source_nodejs/read_certificate_signing_request.d.ts +3 -3
  50. package/dist/source_nodejs/read_certificate_signing_request.js +27 -27
  51. package/index.d.ts +2 -2
  52. package/index.js +4 -4
  53. package/index_web.js +3 -3
  54. package/package.json +12 -12
  55. package/source/asn1.ts +404 -404
  56. package/source/buffer_utils.ts +18 -18
  57. package/source/common.ts +13 -13
  58. package/source/crypto_explore_certificate.ts +764 -763
  59. package/source/crypto_utils.ts +359 -321
  60. package/source/derived_keys.ts +287 -287
  61. package/source/explore_certificate.ts +66 -66
  62. package/source/explore_certificate_revocation_list.ts +122 -122
  63. package/source/explore_certificate_signing_request.ts +58 -58
  64. package/source/explore_private_key.ts +121 -121
  65. package/source/index.ts +13 -13
  66. package/source/oid_map.ts +310 -310
  67. package/source/public_private_match.ts +41 -18
  68. package/source/verify_certificate_signature.ts +105 -105
  69. package/source_nodejs/index.ts +2 -2
  70. package/source_nodejs/read.ts +95 -95
  71. package/source_nodejs/read_certificate_revocation_list.ts +14 -14
  72. package/source_nodejs/read_certificate_signing_request.ts +17 -17
  73. package/test_certificate.ts +34 -34
  74. package/tsconfig.json +18 -18
  75. package/tslint.json +34 -34
  76. package/dist/asn1.d.ts +0 -69
  77. package/dist/asn1.js +0 -349
  78. package/dist/asn1.js.map +0 -1
  79. package/dist/buffer_utils.d.ts +0 -6
  80. package/dist/buffer_utils.js +0 -22
  81. package/dist/buffer_utils.js.map +0 -1
  82. package/dist/common.d.ts +0 -11
  83. package/dist/common.js +0 -3
  84. package/dist/common.js.map +0 -1
  85. package/dist/crypto_explore_certificate.d.ts +0 -95
  86. package/dist/crypto_explore_certificate.js +0 -547
  87. package/dist/crypto_explore_certificate.js.map +0 -1
  88. package/dist/crypto_utils.d.ts +0 -106
  89. package/dist/crypto_utils.js +0 -370
  90. package/dist/crypto_utils.js.map +0 -1
  91. package/dist/derived_keys.d.ts +0 -72
  92. package/dist/derived_keys.js +0 -247
  93. package/dist/derived_keys.js.map +0 -1
  94. package/dist/explore_certificate.d.ts +0 -30
  95. package/dist/explore_certificate.js +0 -44
  96. package/dist/explore_certificate.js.map +0 -1
  97. package/dist/explore_certificate_revocation_list.d.ts +0 -30
  98. package/dist/explore_certificate_revocation_list.js +0 -67
  99. package/dist/explore_certificate_revocation_list.js.map +0 -1
  100. package/dist/index.d.ts +0 -10
  101. package/dist/index.js +0 -23
  102. package/dist/index.js.map +0 -1
  103. package/dist/oid_map.d.ts +0 -7
  104. package/dist/oid_map.js +0 -262
  105. package/dist/oid_map.js.map +0 -1
  106. package/dist/verify_cerficate_signature.d.ts +0 -10
  107. package/dist/verify_cerficate_signature.js +0 -102
  108. package/dist/verify_cerficate_signature.js.map +0 -1
@@ -1,547 +0,0 @@
1
- "use strict";
2
- /**
3
- * @module node_opcua_crypto
4
- */
5
- // ---------------------------------------------------------------------------------------------------------------------
6
- // crypto_explore_certificate
7
- // ---------------------------------------------------------------------------------------------------------------------
8
- // Copyright (c) 2014-2020 - Etienne Rossignon
9
- // ---------------------------------------------------------------------------------------------------------------------
10
- //
11
- // This project is licensed under the terms of the MIT license.
12
- //
13
- // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
14
- // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
15
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
16
- // permit persons to whom the Software is furnished to do so, subject to the following conditions:
17
- //
18
- // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
19
- // Software.
20
- //
21
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
22
- // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23
- // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- //
26
- //
27
- // ---------------------------------------------------------------------------------------------------------------------
28
- // ASN.1 JavaScript decoder Copyright (c) 2008-2014 Lapo Luchini lapo@lapo.it
29
- // Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
30
- // granted, provided that the above copyright notice and this permission notice appear in all copies.
31
- // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
32
- // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
33
- // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
34
- // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
35
- // PERFORMANCE OF THIS SOFTWARE.
36
- // ---------------------------------------------------------------------------------------------------------------------
37
- /*jslint bitwise: true */
38
- // tslint:disable:no-shadowed-variable
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.combine_der = exports.split_der = exports.explorePrivateKey = exports.exploreCertificate = void 0;
41
- // references:
42
- // - http://tools.ietf.org/html/rfc5280
43
- // - http://www-lor.int-evry.fr/~michel/Supports/presentation.pdf
44
- // - ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
45
- // - pubs.opengroup.org/onlinepubs/009609799/7a_nch02.htm#tagcjh_49_03
46
- // - https://github.com/lapo-luchini/asn1js/blob/master/asn1.js
47
- // - http://lapo.it/asn1js
48
- // - https://www.cs.auckland.ac.nz/~pgut001/dumpasn1.cfg
49
- // - http://pubs.opengroup.org/onlinepubs/009609799/7a_nch02.htm
50
- // - http://stackoverflow.com/questions/5929050/how-does-asn-1-encode-an-object-identifier
51
- // - http://luca.ntop.org/Teaching/Appunti/asn1.html
52
- // note:
53
- // - http://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art030
54
- // openssl can be also used to discover the content of a DER file
55
- // $ openssl asn1parse -in cert.pem
56
- const _ = require("underscore");
57
- const assert = require("assert");
58
- const asn1_1 = require("./asn1");
59
- const crypto_utils_1 = require("./crypto_utils");
60
- // Converted from: https://www.cs.auckland.ac.nz/~pgut001/dumpasn1.cfg
61
- // which is made by Peter Gutmann and whose license states:
62
- // You can use this code in whatever way you want,
63
- // as long as you don't try to claim you wrote it.
64
- const doDebug = false;
65
- function _readAttributeTypeAndValue(buffer, block) {
66
- let inner_blocks = asn1_1._readStruct(buffer, block);
67
- inner_blocks = asn1_1._readStruct(buffer, inner_blocks[0]);
68
- const data = {
69
- identifier: asn1_1._readObjectIdentifier(buffer, inner_blocks[0]).name,
70
- value: asn1_1._readValue(buffer, inner_blocks[1]),
71
- };
72
- const result = {};
73
- _.forEach(data, (value, key) => {
74
- result[key] = value;
75
- });
76
- return result;
77
- }
78
- function _readRelativeDistinguishedName(buffer, block) {
79
- const inner_blocks = asn1_1._readStruct(buffer, block);
80
- const data = inner_blocks.map((block) => _readAttributeTypeAndValue(buffer, block));
81
- const result = {};
82
- for (const e of data) {
83
- result[e.identifier] = e.value;
84
- }
85
- return result;
86
- }
87
- function _readName(buffer, block) {
88
- return _readRelativeDistinguishedName(buffer, block);
89
- }
90
- function _readValidity(buffer, block) {
91
- const inner_blocks = asn1_1._readStruct(buffer, block);
92
- return {
93
- notBefore: asn1_1._readTime(buffer, inner_blocks[0]),
94
- notAfter: asn1_1._readTime(buffer, inner_blocks[1]),
95
- };
96
- }
97
- function _readAuthorityKeyIdentifier(buffer) {
98
- /**
99
- * where a CA distributes its public key in the form of a "self-signed"
100
- * certificate, the authority key identifier MAY be omitted. Th
101
- * signature on a self-signed certificate is generated with the private
102
- * key associated with the certificate's subject public key. (This
103
- * proves that the issuer possesses both the public and private keys.)
104
- * In this case, the subject and authority key identifiers would be
105
- * identical, but only the subject key identifier is needed for
106
- * certification path building.
107
- */
108
- // see: https://www.ietf.org/rfc/rfc3280.txt page 25
109
- // AuthorityKeyIdentifier ::= SEQUENCE {
110
- // keyIdentifier [0] KeyIdentifier OPTIONAL,
111
- // authorityCertIssuer [1] GeneralNames OPTIONAL,
112
- // authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL }
113
- // KeyIdentifier ::= OCTET STRING
114
- const block_info = asn1_1.readTag(buffer, 0);
115
- const blocks = asn1_1._readStruct(buffer, block_info);
116
- const keyIdentifier_block = asn1_1._findBlockAtIndex(blocks, 0);
117
- const authorityCertIssuer_block = asn1_1._findBlockAtIndex(blocks, 1);
118
- const authorityCertSerialNumber_block = asn1_1._findBlockAtIndex(blocks, 2);
119
- function _readAuthorithyCertIssuer(block) {
120
- const inner_blocks = asn1_1._readStruct(buffer, block);
121
- const directoryName_block = asn1_1._findBlockAtIndex(inner_blocks, 4);
122
- if (directoryName_block) {
123
- const a = asn1_1._readStruct(buffer, directoryName_block);
124
- return asn1_1._readDirectoryName(buffer, a[0]);
125
- }
126
- else {
127
- throw new Error("Invalid _readAuthorithyCertIssuer");
128
- }
129
- }
130
- function _readAuthorithyCertIssuerFingerPrint(block) {
131
- const inner_blocks = asn1_1._readStruct(buffer, block);
132
- const directoryName_block = asn1_1._findBlockAtIndex(inner_blocks, 4);
133
- if (!directoryName_block) {
134
- return "";
135
- }
136
- ;
137
- const a = asn1_1._readStruct(buffer, directoryName_block);
138
- if (a.length < 1) {
139
- return "";
140
- }
141
- return directoryName_block ? asn1_1.formatBuffer2DigetHexWithColum(crypto_utils_1.makeSHA1Thumbprint(asn1_1._getBlock(buffer, a[0]))) : "";
142
- }
143
- const authorityCertIssuer = authorityCertIssuer_block ? _readAuthorithyCertIssuer(authorityCertIssuer_block) : null;
144
- const authorityCertIssuerFingerPrint = authorityCertIssuer_block ? _readAuthorithyCertIssuerFingerPrint(authorityCertIssuer_block) : "";
145
- return {
146
- authorityCertIssuer,
147
- authorityCertIssuerFingerPrint,
148
- serial: authorityCertSerialNumber_block
149
- ? asn1_1.formatBuffer2DigetHexWithColum(asn1_1._getBlock(buffer, authorityCertSerialNumber_block))
150
- : null,
151
- keyIdentifier: keyIdentifier_block ? asn1_1.formatBuffer2DigetHexWithColum(asn1_1._getBlock(buffer, keyIdentifier_block)) : null,
152
- };
153
- }
154
- /*
155
- Extension ::= SEQUENCE {
156
- extnID OBJECT IDENTIFIER,
157
- critical BOOLEAN DEFAULT FALSE,
158
- extnValue OCTET STRING
159
- -- contains the DER encoding of an ASN.1 value
160
- -- corresponding to the extension type identified
161
- -- by extnID
162
- }
163
-
164
- id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 }
165
-
166
- KeyUsage ::= BIT STRING {
167
- digitalSignature (0),
168
- nonRepudiation (1), -- recent editions of X.509 have
169
- -- renamed this bit to contentCommitment
170
- keyEncipherment (2),
171
- dataEncipherment (3),
172
- keyAgreement (4),
173
- keyCertSign (5),
174
- cRLSign (6),
175
- encipherOnly (7),
176
- decipherOnly (8) }
177
-
178
- extKeyUsage
179
- */
180
- function readBasicConstraint2_5_29_19(buffer, block) {
181
- const block_info = asn1_1.readTag(buffer, 0);
182
- const inner_blocks = asn1_1._readStruct(buffer, block_info);
183
- const cA = inner_blocks.length > 0 ? asn1_1._readBooleanValue(buffer, inner_blocks[0]) : false;
184
- // console.log("buffer[block_info.position] = ", buffer[block_info.position]);
185
- // const cA = buffer[block_info.position] ? true : false;
186
- let pathLengthConstraint = 0;
187
- if (inner_blocks.length > 1) {
188
- pathLengthConstraint = asn1_1._readIntegerValue(buffer, inner_blocks[1]);
189
- }
190
- return { critical: true, cA, pathLengthConstraint };
191
- }
192
- // GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
193
- // GeneralName ::= CHOICE {
194
- // otherName [0] AnotherName,
195
- // rfc822Name [1] IA5String,
196
- // dNSName [2] IA5String,
197
- // x400Address [3] ORAddress,
198
- // directoryName [4] Name,
199
- // ediPartyName [5] EDIPartyName,
200
- // uniformResourceIdentifier [6] IA5String,
201
- // iPAddress [7] OCTET STRING,
202
- // registeredID [8] OBJECT IDENTIFIER }
203
- function _readGeneralNames(buffer, block) {
204
- const _data = {
205
- 1: { name: "rfc822Name", type: "IA5String" },
206
- 2: { name: "dNSName", type: "IA5String" },
207
- 3: { name: "x400Address", type: "ORAddress" },
208
- 4: { name: "directoryName", type: "Name" },
209
- 5: { name: "ediPartyName", type: "EDIPartyName" },
210
- 6: { name: "uniformResourceIdentifier", type: "IA5String" },
211
- 7: { name: "iPAddress", type: "OCTET_STRING" },
212
- 8: { name: "registeredID", type: "OBJECT_IDENTIFIER" },
213
- };
214
- const blocks = asn1_1._readStruct(buffer, block);
215
- function _readFromType(buffer, block, type) {
216
- switch (type) {
217
- case "IA5String":
218
- return buffer.slice(block.position, block.position + block.length).toString("ascii");
219
- default:
220
- return buffer.slice(block.position, block.position + block.length).toString("hex");
221
- }
222
- }
223
- const n = {};
224
- for (const block of blocks) {
225
- // tslint:disable-next-line: no-bitwise
226
- assert((block.tag & 0x80) === 0x80);
227
- // tslint:disable-next-line: no-bitwise
228
- const t = block.tag & 0x7f;
229
- const type = _data[t];
230
- // istanbul ignore next
231
- if (!type) {
232
- throw new Error(" INVALID TYPE => " + t + "0x" + t.toString(16));
233
- }
234
- n[type.name] = n[type.name] || [];
235
- n[type.name].push(_readFromType(buffer, block, type.type));
236
- }
237
- return n;
238
- }
239
- function _readSubjectAltNames(buffer) {
240
- const block_info = asn1_1.readTag(buffer, 0);
241
- return _readGeneralNames(buffer, block_info);
242
- }
243
- function readKeyUsage(oid, buffer) {
244
- const block_info = asn1_1.readTag(buffer, 0);
245
- // get value as BIT STRING
246
- let b2 = 0x00;
247
- let b3 = 0x00;
248
- if (block_info.length > 1) {
249
- // skip first byte, just indicates unused bits which
250
- // will be padded with 0s anyway
251
- // get bytes with flag bits
252
- b2 = buffer[block_info.position + 1];
253
- b3 = block_info.length > 2 ? buffer[block_info.position + 2] : 0;
254
- }
255
- // set flags
256
- return {
257
- // tslint:disable-next-line: no-bitwise
258
- digitalSignature: (b2 & 0x80) === 0x80,
259
- // tslint:disable-next-line: no-bitwise
260
- nonRepudiation: (b2 & 0x40) === 0x40,
261
- // tslint:disable-next-line: no-bitwise
262
- keyEncipherment: (b2 & 0x20) === 0x20,
263
- // tslint:disable-next-line: no-bitwise
264
- dataEncipherment: (b2 & 0x10) === 0x10,
265
- // tslint:disable-next-line: no-bitwise
266
- keyAgreement: (b2 & 0x08) === 0x08,
267
- // tslint:disable-next-line: no-bitwise
268
- keyCertSign: (b2 & 0x04) === 0x04,
269
- // tslint:disable-next-line: no-bitwise
270
- cRLSign: (b2 & 0x02) === 0x02,
271
- // tslint:disable-next-line: no-bitwise
272
- encipherOnly: (b2 & 0x01) === 0x01,
273
- // tslint:disable-next-line: no-bitwise
274
- decipherOnly: (b3 & 0x80) === 0x80,
275
- };
276
- }
277
- function readExtKeyUsage(oid, buffer) {
278
- return "readExtKeyUsage " + oid + " " + buffer.toString("hex");
279
- /* // handle extKeyUsage
280
- // value is a SEQUENCE of OIDs
281
- var ev = asn1.fromDer(e.value);
282
- for (var vi = 0; vi < ev.value.length; ++vi) {
283
- var oid = asn1.derToOid(ev.value[vi].value);
284
- if (oid in oids) {
285
- e[oids[oid]] = true;
286
- } else {
287
- e[oid] = true;
288
- }
289
- }
290
- */
291
- }
292
- /*
293
- Extension ::= SEQUENCE {
294
- extnID OBJECT IDENTIFIER,
295
- critical BOOLEAN DEFAULT FALSE,
296
- extnValue OCTET STRING
297
- -- contains the DER encoding of an ASN.1 value
298
- -- corresponding to the extension type identified
299
- -- by extnID
300
- }
301
- */
302
- function _readExtension(buffer, block) {
303
- const inner_blocks = asn1_1._readStruct(buffer, block);
304
- if (inner_blocks.length === 3) {
305
- assert(inner_blocks[1].tag === asn1_1.TagType.BOOLEAN);
306
- inner_blocks[1] = inner_blocks[2];
307
- }
308
- const identifier = asn1_1._readObjectIdentifier(buffer, inner_blocks[0]);
309
- const buf = asn1_1._getBlock(buffer, inner_blocks[1]);
310
- let value = null;
311
- switch (identifier.name) {
312
- case "subjectKeyIdentifier":
313
- /* from https://tools.ietf.org/html/rfc3280#section-4.1 :
314
- For CA certificates, subject key identifiers SHOULD be derived from
315
- the public key or a method that generates unique values. Two common
316
- methods for generating key identifiers from the public key are:
317
-
318
- (1) The keyIdentifier is composed of the 160-bit SHA-1 hash of the
319
- value of the BIT STRING subjectPublicKey (excluding the tag,
320
- length, and number of unused bits).
321
-
322
- (2) The keyIdentifier is composed of a four bit type field with
323
- the value 0100 followed by the least significant 60 bits of the
324
- SHA-1 hash of the value of the BIT STRING subjectPublicKey
325
- (excluding the tag, length, and number of unused bit string bits).
326
- */
327
- value = asn1_1.formatBuffer2DigetHexWithColum(asn1_1._readOctetString(buffer, inner_blocks[1]));
328
- break;
329
- case "subjectAltName":
330
- value = _readSubjectAltNames(buf);
331
- break;
332
- case "authorityKeyIdentifier":
333
- value = _readAuthorityKeyIdentifier(buf);
334
- break;
335
- case "basicConstraints":
336
- value = readBasicConstraint2_5_29_19(buf, inner_blocks[1]); // "2.5.29.19":
337
- // "basicConstraints ( not implemented yet) " + buf.toString("hex");
338
- break;
339
- case "certExtension": // Netscape
340
- value = "basicConstraints ( not implemented yet) " + buf.toString("hex");
341
- break;
342
- case "extKeyUsage":
343
- value = readExtKeyUsage(identifier.oid, buf);
344
- break;
345
- case "keyUsage":
346
- value = readKeyUsage(identifier.oid, buf);
347
- break;
348
- default:
349
- value = "Unknown " + identifier.name + buf.toString("hex");
350
- }
351
- return {
352
- identifier,
353
- value,
354
- };
355
- }
356
- // Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
357
- function _readExtensions(buffer, block) {
358
- assert(block.tag === 0xa3);
359
- let inner_blocks = asn1_1._readStruct(buffer, block);
360
- inner_blocks = asn1_1._readStruct(buffer, inner_blocks[0]);
361
- const exts = inner_blocks.map((block) => _readExtension(buffer, block));
362
- const result = {};
363
- _.forEach(exts, (e) => (result[e.identifier.name] = e.value));
364
- return result;
365
- }
366
- /*
367
- SEQUENCE {
368
- 204 13: SEQUENCE {
369
- 206 9: OBJECT IDENTIFIER
370
- : rsaEncryption (1 2 840 113549 1 1 1)
371
- 217 0: NULL
372
- : }
373
- 219 141: BIT STRING, encapsulates {
374
- 223 137: SEQUENCE {
375
- 226 129: INTEGER
376
- : 00 C2 D7 97 6D 28 70 AA 5B CF 23 2E 80 70 39 EE
377
- : DB 6F D5 2D D5 6A 4F 7A 34 2D F9 22 72 47 70 1D
378
- : EF 80 E9 CA 30 8C 00 C4 9A 6E 5B 45 B4 6E A5 E6
379
- : 6C 94 0D FA 91 E9 40 FC 25 9D C7 B7 68 19 56 8F
380
- : 11 70 6A D7 F1 C9 11 4F 3A 7E 3F 99 8D 6E 76 A5
381
- : 74 5F 5E A4 55 53 E5 C7 68 36 53 C7 1D 3B 12 A6
382
- : 85 FE BD 6E A1 CA DF 35 50 AC 08 D7 B9 B4 7E 5C
383
- : FE E2 A3 2C D1 23 84 AA 98 C0 9B 66 18 9A 68 47
384
- : E9
385
- 358 3: INTEGER 65537
386
- : }
387
- : }
388
- : }
389
- */
390
- function _readSubjectPublicKeyInfo(buffer, block) {
391
- const inner_blocks = asn1_1._readStruct(buffer, block);
392
- // algorithm identifier
393
- const algorithm = asn1_1._readAlgorithmIdentifier(buffer, inner_blocks[0]);
394
- //const parameters = _readBitString(buffer,inner_blocks[1]);
395
- const subjectPublicKey = asn1_1._readBitString(buffer, inner_blocks[1]);
396
- // read the 2 big integers of the key
397
- const data = subjectPublicKey.data;
398
- const values = asn1_1._readListOfInteger(data);
399
- // xx const value = _readListOfInteger(data);
400
- return {
401
- algorithm: algorithm.identifier,
402
- keyLength: (values[0].length - 1),
403
- subjectPublicKey: subjectPublicKey.data,
404
- };
405
- }
406
- function readTbsCertificate(buffer, block) {
407
- const blocks = asn1_1._readStruct(buffer, block);
408
- let version, serialNumber, signature, issuer, validity, subject, subjectFingerPrint, subjectPublicKeyInfo, extensions;
409
- if (blocks.length === 6) {
410
- // X509 Version 1:
411
- version = 1;
412
- serialNumber = asn1_1.formatBuffer2DigetHexWithColum(asn1_1._readLongIntegerValue(buffer, blocks[0]));
413
- signature = asn1_1._readAlgorithmIdentifier(buffer, blocks[1]);
414
- issuer = _readName(buffer, blocks[2]);
415
- validity = _readValidity(buffer, blocks[3]);
416
- subject = _readName(buffer, blocks[4]);
417
- subjectFingerPrint = asn1_1.formatBuffer2DigetHexWithColum(crypto_utils_1.makeSHA1Thumbprint(asn1_1._getBlock(buffer, blocks[4])));
418
- subjectPublicKeyInfo = _readSubjectPublicKeyInfo(buffer, blocks[5]);
419
- extensions = null;
420
- }
421
- else {
422
- // X509 Version 3:
423
- const version_block = asn1_1._findBlockAtIndex(blocks, 0);
424
- if (!version_block) {
425
- throw new Error("cannot find version block");
426
- }
427
- version = asn1_1._readVersionValue(buffer, version_block) + 1;
428
- serialNumber = asn1_1.formatBuffer2DigetHexWithColum(asn1_1._readLongIntegerValue(buffer, blocks[1]));
429
- signature = asn1_1._readAlgorithmIdentifier(buffer, blocks[2]);
430
- issuer = _readName(buffer, blocks[3]);
431
- validity = _readValidity(buffer, blocks[4]);
432
- subject = _readName(buffer, blocks[5]);
433
- subjectFingerPrint = asn1_1.formatBuffer2DigetHexWithColum(crypto_utils_1.makeSHA1Thumbprint(asn1_1._getBlock(buffer, blocks[5])));
434
- subjectPublicKeyInfo = _readSubjectPublicKeyInfo(buffer, blocks[6]);
435
- const extensionBlock = asn1_1._findBlockAtIndex(blocks, 3);
436
- if (!extensionBlock) {
437
- throw new Error("cannot find extention block");
438
- }
439
- extensions = _readExtensions(buffer, extensionBlock);
440
- }
441
- return {
442
- version,
443
- serialNumber,
444
- signature,
445
- issuer,
446
- validity,
447
- subject,
448
- subjectFingerPrint,
449
- subjectPublicKeyInfo,
450
- extensions,
451
- };
452
- }
453
- /**
454
- * explore a certificate structure
455
- * @param certificate
456
- * @returns a json object that exhibits the internal data of the certificate
457
- */
458
- function exploreCertificate(certificate) {
459
- assert(certificate instanceof Buffer);
460
- if (!certificate._exploreCertificate_cache) {
461
- const block_info = asn1_1.readTag(certificate, 0);
462
- const blocks = asn1_1._readStruct(certificate, block_info);
463
- certificate._exploreCertificate_cache = {
464
- tbsCertificate: readTbsCertificate(certificate, blocks[0]),
465
- signatureAlgorithm: asn1_1._readAlgorithmIdentifier(certificate, blocks[1]),
466
- signatureValue: asn1_1._readSignatureValue(certificate, blocks[2]),
467
- };
468
- }
469
- return certificate._exploreCertificate_cache;
470
- }
471
- exports.exploreCertificate = exploreCertificate;
472
- function explorePrivateKey(privateKey) {
473
- assert(privateKey instanceof Buffer);
474
- const block_info = asn1_1.readTag(privateKey, 0);
475
- const blocks = asn1_1._readStruct(privateKey, block_info);
476
- /* istanbul ignore next */
477
- if (doDebug) {
478
- // tslint:disable:no-console
479
- console.log(block_info);
480
- // tslint:disable:no-console
481
- console.log(blocks.map((b) => ({
482
- tag: asn1_1.TagType[b.tag] + " 0x" + b.tag.toString(16),
483
- l: b.length,
484
- p: b.position,
485
- buff: privateKey.slice(b.position, b.position + b.length).toString("hex"),
486
- })));
487
- }
488
- const b = blocks[2];
489
- const bb = privateKey.slice(b.position, b.position + b.length);
490
- const block_info1 = asn1_1.readTag(bb, 0);
491
- const blocks1 = asn1_1._readStruct(bb, block_info1);
492
- /* istanbul ignore next */
493
- if (doDebug) {
494
- // tslint:disable:no-console
495
- console.log(blocks1.map((b) => ({
496
- tag: asn1_1.TagType[b.tag] + " 0x" + b.tag.toString(16),
497
- l: b.length,
498
- p: b.position,
499
- buff: privateKey.slice(b.position, b.position + b.length).toString("hex"),
500
- })));
501
- }
502
- return {};
503
- }
504
- exports.explorePrivateKey = explorePrivateKey;
505
- /**
506
- * @method split_der
507
- * split a multi chain certificates
508
- * @param certificateChain the certificate chain in der (binary) format}
509
- * @returns an array of Der , each element of the array is one certificate of the chain
510
- */
511
- function split_der(certificateChain) {
512
- const certificate_chain = [];
513
- do {
514
- const block_info = asn1_1.readTag(certificateChain, 0);
515
- const length = block_info.position + block_info.length;
516
- const der_certificate = certificateChain.slice(0, length);
517
- certificate_chain.push(der_certificate);
518
- certificateChain = certificateChain.slice(length);
519
- } while (certificateChain.length > 0);
520
- return certificate_chain;
521
- }
522
- exports.split_der = split_der;
523
- /**
524
- * @method combine_der
525
- * combine an array of certificates into a single blob
526
- * @param certificates a array with the individual DER certificates of the chain
527
- * @return a concatenated buffer containing the certificates
528
- */
529
- function combine_der(certificates) {
530
- assert(_.isArray(certificates));
531
- // perform some sanity check
532
- for (const cert of certificates) {
533
- const b = split_der(cert);
534
- let sum = 0;
535
- b.forEach((block) => {
536
- const block_info = asn1_1.readTag(block, 0);
537
- //xx console.log("xxxx" ,cert.length,block_info);
538
- //xx console.log(cert.toString("base64"));
539
- assert(block_info.position + block_info.length === block.length);
540
- sum += block.length;
541
- });
542
- assert(sum === cert.length);
543
- }
544
- return Buffer.concat(certificates);
545
- }
546
- exports.combine_der = combine_der;
547
- //# sourceMappingURL=crypto_explore_certificate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto_explore_certificate.js","sourceRoot":"","sources":["../lib/crypto_explore_certificate.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,wHAAwH;AACxH,6BAA6B;AAC7B,wHAAwH;AACxH,8CAA8C;AAC9C,wHAAwH;AACxH,EAAE;AAC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