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,281 +1,313 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractPublicKeyFromCertificate = exports.extractPublicKeyFromCertificateSync = exports.rsa_length = exports.coercePublicKeyPem = exports.coerceCertificatePem = exports.privateDecrypt_long = exports.publicEncrypt_long = exports.privateDecrypt = exports.publicEncrypt = exports.privateDecrypt_native = exports.publicEncrypt_native = exports.PaddingAlgorithm = exports.RSA_PKCS1_PADDING = exports.RSA_PKCS1_OAEP_PADDING = exports.makeSHA1Thumbprint = exports.verifyMessageChunkSignature = exports.makeMessageChunkSignature = exports.hexDump = exports.toPem = exports.convertPEMtoDER = exports.identifyPemType = void 0;
4
- // tslint:disabled:no-var-requires
5
- /**
6
- * @module node_opcua_crypto
7
- */
8
- const constants = require("constants");
9
- const crypto = require("crypto");
10
- const buffer_utils_1 = require("./buffer_utils");
11
- const crypto_explore_certificate_1 = require("./crypto_explore_certificate");
12
- const assert = require("assert");
13
- const hexy_1 = require("hexy");
14
- const jsrsasign = require("jsrsasign");
15
- const PEM_REGEX = /^(-----BEGIN (.*)-----\r?\n([/+=a-zA-Z0-9\r\n]*)\r?\n-----END \2-----\r?\n?)/gm;
16
- const PEM_TYPE_REGEX = /^(-----BEGIN (.*)-----)/m;
17
- // Copyright 2012 The Obvious Corporation.
18
- // identifyPemType
19
- /*=
20
- * Extract and identify the PEM file type represented in the given
21
- * buffer. Returns the extracted type string or undefined if the
22
- * buffer doesn't seem to be any sort of PEM format file.
23
- */
24
- function identifyPemType(rawKey) {
25
- if (rawKey instanceof Buffer) {
26
- rawKey = rawKey.toString("utf8");
27
- }
28
- const match = PEM_TYPE_REGEX.exec(rawKey);
29
- return !match ? undefined : match[2];
30
- }
31
- exports.identifyPemType = identifyPemType;
32
- function convertPEMtoDER(raw_key) {
33
- let match;
34
- let pemType;
35
- let base64str;
36
- const parts = [];
37
- PEM_REGEX.lastIndex = 0;
38
- // tslint:disable-next-line:no-conditional-assignment
39
- while ((match = PEM_REGEX.exec(raw_key)) !== null) {
40
- pemType = match[2];
41
- // pemType shall be "RSA PRIVATE KEY" , "PUBLIC KEY", "CERTIFICATE", "X509 CRL"
42
- base64str = match[3];
43
- base64str = base64str.replace(/\r?\n/g, "");
44
- parts.push(Buffer.from(base64str, "base64"));
45
- }
46
- return (0, crypto_explore_certificate_1.combine_der)(parts);
47
- }
48
- exports.convertPEMtoDER = convertPEMtoDER;
49
- /**
50
- * @method toPem
51
- * @param raw_key
52
- * @param pem
53
- * @return
54
- */
55
- function toPem(raw_key, pem) {
56
- assert(raw_key, "expecting a key");
57
- assert(typeof pem === "string");
58
- let pemType = identifyPemType(raw_key);
59
- if (pemType) {
60
- return raw_key instanceof Buffer ? raw_key.toString("utf8") : raw_key;
61
- }
62
- else {
63
- pemType = pem;
64
- assert(["CERTIFICATE REQUEST", "CERTIFICATE", "RSA PRIVATE KEY", "PUBLIC KEY", "X509 CRL"].indexOf(pemType) >= 0);
65
- let b = raw_key.toString("base64");
66
- let str = "-----BEGIN " + pemType + "-----\n";
67
- while (b.length) {
68
- str += b.substr(0, 64) + "\n";
69
- b = b.substr(64);
70
- }
71
- str += "-----END " + pemType + "-----";
72
- str += "\n";
73
- return str;
74
- }
75
- }
76
- exports.toPem = toPem;
77
- // istanbul ignore next
78
- function hexDump(buffer, width) {
79
- if (!buffer) {
80
- return "<>";
81
- }
82
- width = width || 32;
83
- if (buffer.length > 1024) {
84
- return (0, hexy_1.hexy)(buffer.slice(0, 1024), { width, format: "twos" }) + "\n .... ( " + buffer.length + ")";
85
- }
86
- else {
87
- return (0, hexy_1.hexy)(buffer, { width, format: "twos" });
88
- }
89
- }
90
- exports.hexDump = hexDump;
91
- /**
92
- * @method makeMessageChunkSignature
93
- * @param chunk
94
- * @param options
95
- * @param options.signatureLength
96
- * @param options.algorithm for example "RSA-SHA256"
97
- * @param options.privateKey
98
- * @return - the signature
99
- */
100
- function makeMessageChunkSignature(chunk, options) {
101
- assert(Object.prototype.hasOwnProperty.call(options, "algorithm"));
102
- assert(chunk instanceof Buffer);
103
- assert(["RSA PRIVATE KEY", "PRIVATE KEY"].indexOf(identifyPemType(options.privateKey)) >= 0);
104
- // signature length = 128 bytes
105
- const signer = crypto.createSign(options.algorithm);
106
- signer.update(chunk);
107
- const signature = signer.sign(options.privateKey);
108
- assert(!options.signatureLength || signature.length === options.signatureLength);
109
- return signature;
110
- }
111
- exports.makeMessageChunkSignature = makeMessageChunkSignature;
112
- /**
113
- * @method verifyMessageChunkSignature
114
- *
115
- * const signer = {
116
- * signatureLength : 128,
117
- * algorithm : "RSA-SHA256",
118
- * publicKey: "qsdqsdqsd"
119
- * };
120
- * @param blockToVerify
121
- * @param signature
122
- * @param options
123
- * @param options.signatureLength
124
- * @param options.algorithm for example "RSA-SHA256"
125
- * @param options.publicKey
126
- * @return true if the signature is valid
127
- */
128
- function verifyMessageChunkSignature(blockToVerify, signature, options) {
129
- assert(blockToVerify instanceof Buffer);
130
- assert(signature instanceof Buffer);
131
- assert(typeof options.publicKey === "string");
132
- assert(identifyPemType(options.publicKey));
133
- const verify = crypto.createVerify(options.algorithm);
134
- verify.update(blockToVerify);
135
- return verify.verify(options.publicKey, signature);
136
- }
137
- exports.verifyMessageChunkSignature = verifyMessageChunkSignature;
138
- function makeSHA1Thumbprint(buffer) {
139
- return crypto.createHash("sha1").update(buffer).digest();
140
- }
141
- exports.makeSHA1Thumbprint = makeSHA1Thumbprint;
142
- // Basically when you =encrypt something using an RSA key (whether public or private), the encrypted value must
143
- // be smaller than the key (due to the maths used to do the actual encryption). So if you have a 1024-bit key,
144
- // in theory you could encrypt any 1023-bit value (or a 1024-bit value smaller than the key) with that key.
145
- // However, the PKCS#1 standard, which OpenSSL uses, specifies a padding scheme (so you can encrypt smaller
146
- // quantities without losing security), and that padding scheme takes a minimum of 11 bytes (it will be longer
147
- // if the value you're encrypting is smaller). So the highest number of bits you can encrypt with a 1024-bit
148
- // key is 936 bits because of this (unless you disable the padding by adding the OPENSSL_NO_PADDING flag,
149
- // in which case you can go up to 1023-1024 bits). With a 2048-bit key it's 1960 bits instead.
150
- exports.RSA_PKCS1_OAEP_PADDING = constants.RSA_PKCS1_OAEP_PADDING;
151
- exports.RSA_PKCS1_PADDING = constants.RSA_PKCS1_PADDING;
152
- var PaddingAlgorithm;
153
- (function (PaddingAlgorithm) {
154
- PaddingAlgorithm[PaddingAlgorithm["RSA_PKCS1_OAEP_PADDING"] = 4] = "RSA_PKCS1_OAEP_PADDING";
155
- PaddingAlgorithm[PaddingAlgorithm["RSA_PKCS1_PADDING"] = 1] = "RSA_PKCS1_PADDING";
156
- })(PaddingAlgorithm = exports.PaddingAlgorithm || (exports.PaddingAlgorithm = {}));
157
- assert(PaddingAlgorithm.RSA_PKCS1_OAEP_PADDING === constants.RSA_PKCS1_OAEP_PADDING);
158
- assert(PaddingAlgorithm.RSA_PKCS1_PADDING === constants.RSA_PKCS1_PADDING);
159
- // publicEncrypt and privateDecrypt only work with
160
- // small buffer that depends of the key size.
161
- function publicEncrypt_native(buffer, publicKey, algorithm) {
162
- if (algorithm === undefined) {
163
- algorithm = PaddingAlgorithm.RSA_PKCS1_PADDING;
164
- }
165
- assert(algorithm === exports.RSA_PKCS1_PADDING || algorithm === exports.RSA_PKCS1_OAEP_PADDING);
166
- assert(buffer instanceof Buffer, "Expecting a buffer");
167
- return crypto.publicEncrypt({
168
- key: publicKey,
169
- padding: algorithm,
170
- }, buffer);
171
- }
172
- exports.publicEncrypt_native = publicEncrypt_native;
173
- function privateDecrypt_native(buffer, privateKey, algorithm) {
174
- if (algorithm === undefined) {
175
- algorithm = PaddingAlgorithm.RSA_PKCS1_PADDING;
176
- }
177
- assert(algorithm === exports.RSA_PKCS1_PADDING || algorithm === exports.RSA_PKCS1_OAEP_PADDING);
178
- assert(buffer instanceof Buffer, "Expecting a buffer");
179
- try {
180
- return crypto.privateDecrypt({
181
- key: privateKey,
182
- padding: algorithm,
183
- }, buffer);
184
- }
185
- catch (err) {
186
- return Buffer.alloc(1);
187
- }
188
- }
189
- exports.privateDecrypt_native = privateDecrypt_native;
190
- exports.publicEncrypt = publicEncrypt_native;
191
- exports.privateDecrypt = privateDecrypt_native;
192
- function publicEncrypt_long(buffer, publicKey, blockSize, padding, algorithm) {
193
- if (algorithm === undefined) {
194
- algorithm = PaddingAlgorithm.RSA_PKCS1_PADDING;
195
- }
196
- assert(algorithm === exports.RSA_PKCS1_PADDING || algorithm === exports.RSA_PKCS1_OAEP_PADDING);
197
- const chunk_size = blockSize - padding;
198
- const nbBlocks = Math.ceil(buffer.length / chunk_size);
199
- const outputBuffer = (0, buffer_utils_1.createFastUninitializedBuffer)(nbBlocks * blockSize);
200
- for (let i = 0; i < nbBlocks; i++) {
201
- const currentBlock = buffer.slice(chunk_size * i, chunk_size * (i + 1));
202
- const encrypted_chunk = (0, exports.publicEncrypt)(currentBlock, publicKey, algorithm);
203
- assert(encrypted_chunk.length === blockSize);
204
- encrypted_chunk.copy(outputBuffer, i * blockSize);
205
- }
206
- return outputBuffer;
207
- }
208
- exports.publicEncrypt_long = publicEncrypt_long;
209
- function privateDecrypt_long(buffer, privateKey, blockSize, algorithm) {
210
- algorithm = algorithm || exports.RSA_PKCS1_PADDING;
211
- assert(algorithm === exports.RSA_PKCS1_PADDING || algorithm === exports.RSA_PKCS1_OAEP_PADDING);
212
- const nbBlocks = Math.ceil(buffer.length / blockSize);
213
- const outputBuffer = (0, buffer_utils_1.createFastUninitializedBuffer)(nbBlocks * blockSize);
214
- let total_length = 0;
215
- for (let i = 0; i < nbBlocks; i++) {
216
- const currentBlock = buffer.slice(blockSize * i, Math.min(blockSize * (i + 1), buffer.length));
217
- const decrypted_buf = (0, exports.privateDecrypt)(currentBlock, privateKey, algorithm);
218
- decrypted_buf.copy(outputBuffer, total_length);
219
- total_length += decrypted_buf.length;
220
- }
221
- return outputBuffer.slice(0, total_length);
222
- }
223
- exports.privateDecrypt_long = privateDecrypt_long;
224
- function coerceCertificatePem(certificate) {
225
- if (certificate instanceof Buffer) {
226
- certificate = toPem(certificate, "CERTIFICATE");
227
- }
228
- assert(typeof certificate === "string");
229
- return certificate;
230
- }
231
- exports.coerceCertificatePem = coerceCertificatePem;
232
- function coercePublicKeyPem(publicKey) {
233
- if (publicKey instanceof Buffer) {
234
- publicKey = toPem(publicKey, "PUBLIC KEY");
235
- }
236
- assert(typeof publicKey === "string");
237
- return publicKey;
238
- }
239
- exports.coercePublicKeyPem = coercePublicKeyPem;
240
- /***
241
- * @method rsa_length
242
- * A very expensive way to determine the rsa key length ( i.e 2048bits or 1024bits)
243
- * @param key a PEM public key or a PEM rsa private key
244
- * @return { the key length in bytes.
245
- */
246
- function rsa_length(key) {
247
- key = coercePublicKeyPem(key);
248
- assert(typeof key === "string");
249
- const a = jsrsasign.KEYUTIL.getKey(key);
250
- return a.n.toString(16).length / 2;
251
- }
252
- exports.rsa_length = rsa_length;
253
- function extractPublicKeyFromCertificateSync(certificate) {
254
- certificate = coerceCertificatePem(certificate);
255
- const key = jsrsasign.KEYUTIL.getKey(certificate);
256
- const publicKeyAsPem = jsrsasign.KEYUTIL.getPEM(key);
257
- assert(typeof publicKeyAsPem === "string");
258
- return publicKeyAsPem;
259
- }
260
- exports.extractPublicKeyFromCertificateSync = extractPublicKeyFromCertificateSync;
261
- // https://github.com/kjur/jsrsasign/blob/master/x509-1.1.js
262
- // tool to analyse asn1 base64 blocks : http://lapo.it/asn1js
263
- /**
264
- * extract the publickey from a certificate
265
- * @async
266
- */
267
- function extractPublicKeyFromCertificate(certificate, callback) {
268
- let err1 = null;
269
- let keyPem;
270
- try {
271
- keyPem = extractPublicKeyFromCertificateSync(certificate);
272
- }
273
- catch (err) {
274
- err1 = err;
275
- }
276
- setImmediate(() => {
277
- callback(err1, keyPem);
278
- });
279
- }
280
- exports.extractPublicKeyFromCertificate = extractPublicKeyFromCertificate;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractPublicKeyFromCertificate = exports.extractPublicKeyFromCertificateSync = exports.rsaLengthPublicKey = exports.rsaLengthPrivateKey = exports.coercePrivateKeyPem = exports.coercePublicKeyPem = exports.coerceCertificatePem = exports.privateDecrypt_long = exports.publicEncrypt_long = exports.privateDecrypt = exports.publicEncrypt = exports.privateDecrypt_native = exports.publicEncrypt_native = exports.PaddingAlgorithm = exports.RSA_PKCS1_PADDING = exports.RSA_PKCS1_OAEP_PADDING = exports.makeSHA1Thumbprint = exports.verifyMessageChunkSignature = exports.makeMessageChunkSignature = exports.hexDump = exports.toPem = exports.convertPEMtoDER = exports.identifyPemType = void 0;
4
+ // tslint:disabled:no-var-requires
5
+ /**
6
+ * @module node_opcua_crypto
7
+ */
8
+ const constants = require("constants");
9
+ const crypto = require("crypto");
10
+ const buffer_utils_1 = require("./buffer_utils");
11
+ const crypto_explore_certificate_1 = require("./crypto_explore_certificate");
12
+ const assert = require("assert");
13
+ const hexy_1 = require("hexy");
14
+ const jsrsasign = require("jsrsasign");
15
+ const PEM_REGEX = /^(-----BEGIN (.*)-----\r?\n([/+=a-zA-Z0-9\r\n]*)\r?\n-----END \2-----\r?\n?)/gm;
16
+ const PEM_TYPE_REGEX = /^(-----BEGIN (.*)-----)/m;
17
+ // Copyright 2012 The Obvious Corporation.
18
+ // identifyPemType
19
+ /*=
20
+ * Extract and identify the PEM file type represented in the given
21
+ * buffer. Returns the extracted type string or undefined if the
22
+ * buffer doesn't seem to be any sort of PEM format file.
23
+ */
24
+ function identifyPemType(rawKey) {
25
+ if (rawKey instanceof Buffer) {
26
+ rawKey = rawKey.toString("utf8");
27
+ }
28
+ const match = PEM_TYPE_REGEX.exec(rawKey);
29
+ return !match ? undefined : match[2];
30
+ }
31
+ exports.identifyPemType = identifyPemType;
32
+ function convertPEMtoDER(raw_key) {
33
+ let match;
34
+ let pemType;
35
+ let base64str;
36
+ const parts = [];
37
+ PEM_REGEX.lastIndex = 0;
38
+ // tslint:disable-next-line:no-conditional-assignment
39
+ while ((match = PEM_REGEX.exec(raw_key)) !== null) {
40
+ pemType = match[2];
41
+ // pemType shall be "RSA PRIVATE KEY" , "PUBLIC KEY", "CERTIFICATE", "X509 CRL"
42
+ base64str = match[3];
43
+ base64str = base64str.replace(/\r?\n/g, "");
44
+ parts.push(Buffer.from(base64str, "base64"));
45
+ }
46
+ return (0, crypto_explore_certificate_1.combine_der)(parts);
47
+ }
48
+ exports.convertPEMtoDER = convertPEMtoDER;
49
+ /**
50
+ * @method toPem
51
+ * @param raw_key
52
+ * @param pem
53
+ * @return
54
+ */
55
+ function toPem(raw_key, pem) {
56
+ assert(raw_key, "expecting a key");
57
+ assert(typeof pem === "string");
58
+ let pemType = identifyPemType(raw_key);
59
+ if (pemType) {
60
+ return raw_key instanceof Buffer ? raw_key.toString("utf8") : raw_key;
61
+ }
62
+ else {
63
+ pemType = pem;
64
+ assert(["CERTIFICATE REQUEST", "CERTIFICATE", "RSA PRIVATE KEY", "PUBLIC KEY", "X509 CRL"].indexOf(pemType) >= 0);
65
+ let b = raw_key.toString("base64");
66
+ let str = "-----BEGIN " + pemType + "-----\n";
67
+ while (b.length) {
68
+ str += b.substr(0, 64) + "\n";
69
+ b = b.substr(64);
70
+ }
71
+ str += "-----END " + pemType + "-----";
72
+ str += "\n";
73
+ return str;
74
+ }
75
+ }
76
+ exports.toPem = toPem;
77
+ // istanbul ignore next
78
+ function hexDump(buffer, width) {
79
+ if (!buffer) {
80
+ return "<>";
81
+ }
82
+ width = width || 32;
83
+ if (buffer.length > 1024) {
84
+ return (0, hexy_1.hexy)(buffer.subarray(0, 1024), { width, format: "twos" }) + "\n .... ( " + buffer.length + ")";
85
+ }
86
+ else {
87
+ return (0, hexy_1.hexy)(buffer, { width, format: "twos" });
88
+ }
89
+ }
90
+ exports.hexDump = hexDump;
91
+ /**
92
+ * @method makeMessageChunkSignature
93
+ * @param chunk
94
+ * @param options
95
+ * @param options.signatureLength
96
+ * @param options.algorithm for example "RSA-SHA256"
97
+ * @param options.privateKey
98
+ * @return - the signature
99
+ */
100
+ function makeMessageChunkSignature(chunk, options) {
101
+ assert(Object.prototype.hasOwnProperty.call(options, "algorithm"));
102
+ assert(chunk instanceof Buffer);
103
+ assert(["RSA PRIVATE KEY", "PRIVATE KEY"].indexOf(identifyPemType(options.privateKey)) >= 0);
104
+ // signature length = 128 bytes
105
+ const signer = crypto.createSign(options.algorithm);
106
+ signer.update(chunk);
107
+ const signature = signer.sign(options.privateKey);
108
+ assert(!options.signatureLength || signature.length === options.signatureLength);
109
+ return signature;
110
+ }
111
+ exports.makeMessageChunkSignature = makeMessageChunkSignature;
112
+ /**
113
+ * @method verifyMessageChunkSignature
114
+ *
115
+ * const signer = {
116
+ * signatureLength : 128,
117
+ * algorithm : "RSA-SHA256",
118
+ * publicKey: "qsdqsdqsd"
119
+ * };
120
+ * @param blockToVerify
121
+ * @param signature
122
+ * @param options
123
+ * @param options.signatureLength
124
+ * @param options.algorithm for example "RSA-SHA256"
125
+ * @param options.publicKey
126
+ * @return true if the signature is valid
127
+ */
128
+ function verifyMessageChunkSignature(blockToVerify, signature, options) {
129
+ assert(blockToVerify instanceof Buffer);
130
+ assert(signature instanceof Buffer);
131
+ assert(typeof options.publicKey === "string");
132
+ assert(identifyPemType(options.publicKey));
133
+ const verify = crypto.createVerify(options.algorithm);
134
+ verify.update(blockToVerify);
135
+ return verify.verify(options.publicKey, signature);
136
+ }
137
+ exports.verifyMessageChunkSignature = verifyMessageChunkSignature;
138
+ function makeSHA1Thumbprint(buffer) {
139
+ return crypto.createHash("sha1").update(buffer).digest();
140
+ }
141
+ exports.makeSHA1Thumbprint = makeSHA1Thumbprint;
142
+ // Basically when you =encrypt something using an RSA key (whether public or private), the encrypted value must
143
+ // be smaller than the key (due to the maths used to do the actual encryption). So if you have a 1024-bit key,
144
+ // in theory you could encrypt any 1023-bit value (or a 1024-bit value smaller than the key) with that key.
145
+ // However, the PKCS#1 standard, which OpenSSL uses, specifies a padding scheme (so you can encrypt smaller
146
+ // quantities without losing security), and that padding scheme takes a minimum of 11 bytes (it will be longer
147
+ // if the value you're encrypting is smaller). So the highest number of bits you can encrypt with a 1024-bit
148
+ // key is 936 bits because of this (unless you disable the padding by adding the OPENSSL_NO_PADDING flag,
149
+ // in which case you can go up to 1023-1024 bits). With a 2048-bit key it's 1960 bits instead.
150
+ exports.RSA_PKCS1_OAEP_PADDING = constants.RSA_PKCS1_OAEP_PADDING;
151
+ exports.RSA_PKCS1_PADDING = constants.RSA_PKCS1_PADDING;
152
+ var PaddingAlgorithm;
153
+ (function (PaddingAlgorithm) {
154
+ PaddingAlgorithm[PaddingAlgorithm["RSA_PKCS1_OAEP_PADDING"] = 4] = "RSA_PKCS1_OAEP_PADDING";
155
+ PaddingAlgorithm[PaddingAlgorithm["RSA_PKCS1_PADDING"] = 1] = "RSA_PKCS1_PADDING";
156
+ })(PaddingAlgorithm = exports.PaddingAlgorithm || (exports.PaddingAlgorithm = {}));
157
+ assert(PaddingAlgorithm.RSA_PKCS1_OAEP_PADDING === constants.RSA_PKCS1_OAEP_PADDING);
158
+ assert(PaddingAlgorithm.RSA_PKCS1_PADDING === constants.RSA_PKCS1_PADDING);
159
+ // publicEncrypt and privateDecrypt only work with
160
+ // small buffer that depends of the key size.
161
+ function publicEncrypt_native(buffer, publicKey, algorithm) {
162
+ if (algorithm === undefined) {
163
+ algorithm = PaddingAlgorithm.RSA_PKCS1_PADDING;
164
+ }
165
+ assert(algorithm === exports.RSA_PKCS1_PADDING || algorithm === exports.RSA_PKCS1_OAEP_PADDING);
166
+ assert(buffer instanceof Buffer, "Expecting a buffer");
167
+ return crypto.publicEncrypt({
168
+ key: publicKey,
169
+ padding: algorithm,
170
+ }, buffer);
171
+ }
172
+ exports.publicEncrypt_native = publicEncrypt_native;
173
+ function privateDecrypt_native(buffer, privateKey, algorithm) {
174
+ if (algorithm === undefined) {
175
+ algorithm = PaddingAlgorithm.RSA_PKCS1_PADDING;
176
+ }
177
+ assert(algorithm === exports.RSA_PKCS1_PADDING || algorithm === exports.RSA_PKCS1_OAEP_PADDING);
178
+ assert(buffer instanceof Buffer, "Expecting a buffer");
179
+ try {
180
+ return crypto.privateDecrypt({
181
+ key: privateKey,
182
+ padding: algorithm,
183
+ }, buffer);
184
+ }
185
+ catch (err) {
186
+ return Buffer.alloc(1);
187
+ }
188
+ }
189
+ exports.privateDecrypt_native = privateDecrypt_native;
190
+ exports.publicEncrypt = publicEncrypt_native;
191
+ exports.privateDecrypt = privateDecrypt_native;
192
+ function publicEncrypt_long(buffer, publicKey, blockSize, padding, paddingAlgorithm) {
193
+ if (paddingAlgorithm === undefined) {
194
+ paddingAlgorithm = PaddingAlgorithm.RSA_PKCS1_PADDING;
195
+ }
196
+ if (paddingAlgorithm !== exports.RSA_PKCS1_PADDING && paddingAlgorithm !== exports.RSA_PKCS1_OAEP_PADDING) {
197
+ throw new Error("Invalid padding algorithm " + paddingAlgorithm);
198
+ }
199
+ const chunk_size = blockSize - padding;
200
+ const nbBlocks = Math.ceil(buffer.length / chunk_size);
201
+ const outputBuffer = (0, buffer_utils_1.createFastUninitializedBuffer)(nbBlocks * blockSize);
202
+ for (let i = 0; i < nbBlocks; i++) {
203
+ const currentBlock = buffer.subarray(chunk_size * i, chunk_size * (i + 1));
204
+ const encrypted_chunk = (0, exports.publicEncrypt)(currentBlock, publicKey, paddingAlgorithm);
205
+ if (encrypted_chunk.length !== blockSize) {
206
+ throw new Error(`publicEncrypt_long unexpected chunk length ${encrypted_chunk.length} expecting ${blockSize}`);
207
+ }
208
+ encrypted_chunk.copy(outputBuffer, i * blockSize);
209
+ }
210
+ return outputBuffer;
211
+ }
212
+ exports.publicEncrypt_long = publicEncrypt_long;
213
+ function privateDecrypt_long(buffer, privateKey, blockSize, paddingAlgorithm) {
214
+ paddingAlgorithm = paddingAlgorithm || exports.RSA_PKCS1_PADDING;
215
+ if (paddingAlgorithm !== exports.RSA_PKCS1_PADDING && paddingAlgorithm !== exports.RSA_PKCS1_OAEP_PADDING) {
216
+ throw new Error("Invalid padding algorithm " + paddingAlgorithm);
217
+ }
218
+ const nbBlocks = Math.ceil(buffer.length / blockSize);
219
+ const outputBuffer = (0, buffer_utils_1.createFastUninitializedBuffer)(nbBlocks * blockSize);
220
+ let total_length = 0;
221
+ for (let i = 0; i < nbBlocks; i++) {
222
+ const currentBlock = buffer.subarray(blockSize * i, Math.min(blockSize * (i + 1), buffer.length));
223
+ const decrypted_buf = (0, exports.privateDecrypt)(currentBlock, privateKey, paddingAlgorithm);
224
+ decrypted_buf.copy(outputBuffer, total_length);
225
+ total_length += decrypted_buf.length;
226
+ }
227
+ return outputBuffer.subarray(0, total_length);
228
+ }
229
+ exports.privateDecrypt_long = privateDecrypt_long;
230
+ function coerceCertificatePem(certificate) {
231
+ if (certificate instanceof Buffer) {
232
+ certificate = toPem(certificate, "CERTIFICATE");
233
+ }
234
+ assert(typeof certificate === "string");
235
+ return certificate;
236
+ }
237
+ exports.coerceCertificatePem = coerceCertificatePem;
238
+ function coercePublicKeyPem(publicKey) {
239
+ if (publicKey instanceof Buffer) {
240
+ publicKey = toPem(publicKey, "PUBLIC KEY");
241
+ }
242
+ assert(typeof publicKey === "string");
243
+ return publicKey;
244
+ }
245
+ exports.coercePublicKeyPem = coercePublicKeyPem;
246
+ function coercePrivateKeyPem(privateKey) {
247
+ if (privateKey instanceof Buffer) {
248
+ const o = crypto.createPrivateKey({ key: privateKey, format: "der", type: "pkcs1" });
249
+ const e = o.export({ format: "der", type: "pkcs1" });
250
+ privateKey = toPem(e, "RSA PRIVATE KEY");
251
+ }
252
+ assert(typeof privateKey === "string");
253
+ return privateKey;
254
+ }
255
+ exports.coercePrivateKeyPem = coercePrivateKeyPem;
256
+ /***
257
+ * @method rsaLengthPrivateKey
258
+ * A very expensive way to determine the rsa key length ( i.e 2048bits or 1024bits)
259
+ * @param key a PEM public key or a PEM rsa private key
260
+ * @return the key length in bytes.
261
+ */
262
+ function rsaLengthPrivateKey(key) {
263
+ key = coercePrivateKeyPem(key);
264
+ assert(typeof key === "string");
265
+ if (/PRIVATE/.test(key)) {
266
+ const o = crypto.createPrivateKey(key);
267
+ // in node 16 and above :
268
+ // return o.asymmetricKeyDetails.modulusLength/8
269
+ // in node <16 :
270
+ const key2 = o.export({ type: "pkcs1", format: "pem" });
271
+ const a = jsrsasign.KEYUTIL.getKey(key2);
272
+ return a.n.toString(16).length / 2;
273
+ }
274
+ const a = jsrsasign.KEYUTIL.getKey(key);
275
+ return a.n.toString(16).length / 2;
276
+ }
277
+ exports.rsaLengthPrivateKey = rsaLengthPrivateKey;
278
+ function rsaLengthPublicKey(key) {
279
+ key = coercePublicKeyPem(key);
280
+ assert(typeof key === "string");
281
+ const a = jsrsasign.KEYUTIL.getKey(key);
282
+ return a.n.toString(16).length / 2;
283
+ }
284
+ exports.rsaLengthPublicKey = rsaLengthPublicKey;
285
+ function extractPublicKeyFromCertificateSync(certificate) {
286
+ certificate = coerceCertificatePem(certificate);
287
+ const key = jsrsasign.KEYUTIL.getKey(certificate);
288
+ const publicKeyAsPem = jsrsasign.KEYUTIL.getPEM(key);
289
+ assert(typeof publicKeyAsPem === "string");
290
+ return publicKeyAsPem;
291
+ }
292
+ exports.extractPublicKeyFromCertificateSync = extractPublicKeyFromCertificateSync;
293
+ // https://github.com/kjur/jsrsasign/blob/master/x509-1.1.js
294
+ // tool to analyse asn1 base64 blocks : http://lapo.it/asn1js
295
+ /**
296
+ * extract the publickey from a certificate
297
+ * @async
298
+ */
299
+ function extractPublicKeyFromCertificate(certificate, callback) {
300
+ let err1 = null;
301
+ let keyPem;
302
+ try {
303
+ keyPem = extractPublicKeyFromCertificateSync(certificate);
304
+ }
305
+ catch (err) {
306
+ err1 = err;
307
+ }
308
+ setImmediate(() => {
309
+ callback(err1, keyPem);
310
+ });
311
+ }
312
+ exports.extractPublicKeyFromCertificate = extractPublicKeyFromCertificate;
281
313
  //# sourceMappingURL=crypto_utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"crypto_utils.js","sourceRoot":"","sources":["../../source/crypto_utils.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC;;GAEG;AACH,uCAAuC;AACvC,iCAAiC;AACjC,iDAA+D;AAE/D,6EAA2D;AAC3D,iCAAiC;AACjC,+BAA4B;AAE5B,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEvC,MAAM,SAAS,GAAG,gFAAgF,CAAC;AAEnG,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAClD,0CAA0C;AAC1C,kBAAkB;AAElB;;;;GAIG;AACH,SAAgB,eAAe,CAAC,MAAuB;IACnD,IAAI,MAAM,YAAY,MAAM,EAAE;QAC1B,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KACpC;IACD,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,MAA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