node-opcua-crypto 4.10.0 → 4.12.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 (41) hide show
  1. package/README.md +9 -4
  2. package/dist/{chunk-GNEWUC7X.mjs → chunk-AXAFLVME.mjs} +9 -15
  3. package/dist/chunk-AXAFLVME.mjs.map +1 -0
  4. package/dist/{chunk-46EEAYVO.mjs → chunk-LHUQUHQQ.mjs} +845 -829
  5. package/dist/chunk-LHUQUHQQ.mjs.map +1 -0
  6. package/dist/chunk-RQA4DO2Z.mjs +1 -0
  7. package/dist/index.d.mts +2 -3
  8. package/dist/index.d.ts +2 -3
  9. package/dist/index.js +658 -701
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +9 -56
  12. package/dist/source/index.d.mts +1 -5
  13. package/dist/source/index.d.ts +1 -5
  14. package/dist/source/index.js +622 -658
  15. package/dist/source/index.js.map +1 -1
  16. package/dist/source/index.mjs +9 -54
  17. package/dist/source/index_web.d.mts +224 -234
  18. package/dist/source/index_web.d.ts +224 -234
  19. package/dist/source/index_web.js +650 -657
  20. package/dist/source/index_web.js.map +1 -1
  21. package/dist/source/index_web.mjs +9 -51
  22. package/dist/source_nodejs/index.d.mts +1 -2
  23. package/dist/source_nodejs/index.d.ts +1 -2
  24. package/dist/source_nodejs/index.js +46 -50
  25. package/dist/source_nodejs/index.js.map +1 -1
  26. package/dist/source_nodejs/index.mjs +3 -5
  27. package/package.json +9 -4
  28. package/dist/chunk-46EEAYVO.mjs.map +0 -1
  29. package/dist/chunk-GNEWUC7X.mjs.map +0 -1
  30. package/dist/chunk-VI4S2NM5.mjs +0 -38
  31. package/dist/chunk-VI4S2NM5.mjs.map +0 -1
  32. package/dist/index_web.d.mts +0 -5
  33. package/dist/index_web.d.ts +0 -5
  34. package/dist/index_web.js +0 -6414
  35. package/dist/index_web.js.map +0 -1
  36. package/dist/index_web.mjs +0 -195
  37. package/index.mjs +0 -1
  38. package/index_web.ts +0 -1
  39. package/web.d.ts +0 -1
  40. package/web.mjs +0 -1
  41. /package/dist/{index_web.mjs.map → chunk-RQA4DO2Z.mjs.map} +0 -0
@@ -1,131 +1,20 @@
1
- import { b as PEM, D as DER, f as PublicKeyPEM, S as Signature, P as PrivateKey, C as Certificate, d as CertificatePEM, N as Nonce, K as KeyObject, e as PrivateKeyPEM, a as PublicKey, g as CertificateRevocationList, h as CertificatePurpose } from '../common-CFr95Map.js';
1
+ import { C as Certificate, P as PrivateKey, d as CertificatePEM, b as PEM, D as DER, f as PublicKeyPEM, S as Signature, K as KeyObject, e as PrivateKeyPEM, a as PublicKey, N as Nonce, g as CertificateRevocationList, h as CertificatePurpose } from '../common-CFr95Map.js';
2
2
  export { c as createPrivateKeyFromNodeJSCrypto, i as isKeyObject } from '../common-CFr95Map.js';
3
3
  import { KeyLike } from 'crypto';
4
4
  import * as x509 from '@peculiar/x509';
5
5
 
6
- declare function identifyPemType(rawKey: Buffer | string): undefined | string;
7
- declare function removeTrailingLF(str: string): string;
8
- declare function toPem(raw_key: Buffer | string, pem: string): string;
9
- declare function convertPEMtoDER(raw_key: PEM): DER;
10
- declare function hexDump(buffer: Buffer, width?: number): string;
11
- interface MakeMessageChunkSignatureOptions {
12
- signatureLength: number;
13
- algorithm: string;
14
- privateKey: PrivateKey;
15
- }
16
- declare function makeMessageChunkSignature(chunk: Buffer, options: MakeMessageChunkSignatureOptions): Buffer;
17
- interface VerifyMessageChunkSignatureOptions {
18
- signatureLength?: number;
19
- algorithm: string;
20
- publicKey: PublicKeyPEM;
21
- }
22
- /**
23
- * @method verifyMessageChunkSignature
24
- *
25
- * const signer = {
26
- * signatureLength : 128,
27
- * algorithm : "RSA-SHA256",
28
- * publicKey: "qsdqsdqsd"
29
- * };
30
- * @param blockToVerify
31
- * @param signature
32
- * @param options
33
- * @param options.signatureLength
34
- * @param options.algorithm for example "RSA-SHA256"
35
- * @param options.publicKey
36
- * @return true if the signature is valid
37
- */
38
- declare function verifyMessageChunkSignature(blockToVerify: Buffer, signature: Signature, options: VerifyMessageChunkSignatureOptions): boolean;
39
- declare function makeSHA1Thumbprint(buffer: Buffer): Signature;
40
- declare const RSA_PKCS1_OAEP_PADDING: number;
41
- declare const RSA_PKCS1_PADDING: number;
42
- declare enum PaddingAlgorithm {
43
- RSA_PKCS1_OAEP_PADDING = 4,
44
- RSA_PKCS1_PADDING = 1
45
- }
46
- declare function publicEncrypt_native(buffer: Buffer, publicKey: KeyLike, algorithm?: PaddingAlgorithm): Buffer;
47
- declare function privateDecrypt_native(buffer: Buffer, privateKey: PrivateKey, algorithm?: PaddingAlgorithm): Buffer;
48
- declare const publicEncrypt: typeof publicEncrypt_native;
49
- declare const privateDecrypt: typeof privateDecrypt_native;
50
- declare function publicEncrypt_long(buffer: Buffer, publicKey: KeyLike, blockSize: number, padding?: number, paddingAlgorithm?: PaddingAlgorithm): Buffer;
51
- declare function privateDecrypt_long(buffer: Buffer, privateKey: PrivateKey, blockSize: number, paddingAlgorithm?: number): Buffer;
52
- declare function coerceCertificatePem(certificate: Certificate | CertificatePEM): CertificatePEM;
53
- declare function extractPublicKeyFromCertificateSync(certificate: Certificate | CertificatePEM): PublicKeyPEM;
54
- /**
55
- * extract the publickey from a certificate
56
- * @async
57
- */
58
- declare function extractPublicKeyFromCertificate(certificate: CertificatePEM | Certificate, callback: (err: Error | null, publicKeyPEM?: PublicKeyPEM) => void): void;
6
+ declare function publicKeyAndPrivateKeyMatches(certificate: Certificate, privateKey: PrivateKey): boolean;
7
+ declare function certificateMatchesPrivateKey(certificate: Certificate, privateKey: PrivateKey): boolean;
59
8
 
60
- declare function makePseudoRandomBuffer(secret: Nonce, seed: Nonce, minLength: number, sha1or256: "SHA1" | "SHA256"): Buffer;
61
- interface ComputeDerivedKeysOptions {
62
- signatureLength: number;
63
- signingKeyLength: number;
64
- encryptingKeyLength: number;
65
- encryptingBlockSize: number;
66
- algorithm: string;
67
- sha1or256?: "SHA1" | "SHA256";
68
- }
69
- interface DerivedKeys extends ComputeDerivedKeysOptions {
70
- signatureLength: number;
71
- signingKeyLength: number;
72
- encryptingKeyLength: number;
73
- encryptingBlockSize: number;
74
- algorithm: string;
75
- sha1or256: "SHA1" | "SHA256";
76
- signingKey: Buffer;
77
- encryptingKey: Buffer;
78
- initializationVector: Buffer;
9
+ interface DirectoryName {
10
+ stateOrProvinceName?: string;
11
+ localityName?: string;
12
+ organizationName?: string;
13
+ organizationUnitName?: string;
14
+ commonName?: string;
15
+ countryName?: string;
79
16
  }
80
- declare function computeDerivedKeys(secret: Nonce, seed: Nonce, options: ComputeDerivedKeysOptions): DerivedKeys;
81
- /**
82
- * @method reduceLength
83
- * @param buffer
84
- * @param byteToRemove
85
- * @return buffer
86
- */
87
- declare function reduceLength(buffer: Buffer, byteToRemove: number): Buffer;
88
- /**
89
- * @method removePadding
90
- * @param buffer
91
- * @return buffer with padding removed
92
- */
93
- declare function removePadding(buffer: Buffer): Buffer;
94
- type VerifyChunkSignatureOptions = VerifyMessageChunkSignatureOptions;
95
- /**
96
- * @method verifyChunkSignature
97
- *
98
- * const signer = {
99
- * signatureLength : 128,
100
- * algorithm : "RSA-SHA256",
101
- * public_key: "qsdqsdqsd"
102
- * };
103
- *
104
- * @param chunk The message chunk to verify.
105
- * @param options
106
- * @param options.signatureLength
107
- * @param options.algorithm the algorithm.
108
- * @param options.publicKey
109
- * @return {*}
110
- */
111
- declare function verifyChunkSignature(chunk: Buffer, options: VerifyChunkSignatureOptions): boolean;
112
- declare function computePaddingFooter(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
113
- declare function encryptBufferWithDerivedKeys(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
114
- declare function decryptBufferWithDerivedKeys(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
115
- /**
116
- * @method makeMessageChunkSignatureWithDerivedKeys
117
- * @param message
118
- * @param derivedKeys
119
- * @return
120
- */
121
- declare function makeMessageChunkSignatureWithDerivedKeys(message: Buffer, derivedKeys: DerivedKeys): Buffer;
122
- /**
123
- * @method verifyChunkSignatureWithDerivedKeys
124
- * @param chunk
125
- * @param derivedKeys
126
- * @return
127
- */
128
- declare function verifyChunkSignatureWithDerivedKeys(chunk: Buffer, derivedKeys: DerivedKeys): boolean;
17
+ declare function readDirectoryName(buffer: Buffer, block: BlockInfo): DirectoryName;
129
18
 
130
19
  declare enum TagType {
131
20
  BOOLEAN = 1,
@@ -161,49 +50,38 @@ interface BlockInfo {
161
50
  start: number;
162
51
  }
163
52
  declare function readTag(buf: Buffer, pos: number): BlockInfo;
164
- declare function _readStruct(buf: Buffer, blockInfo: BlockInfo): BlockInfo[];
165
- declare function parseBitString(buffer: Buffer, start: number, end: number, maxLength: number): string;
166
- interface BitString {
167
- lengthInBits: number;
168
- lengthInBytes: number;
169
- data: Buffer;
170
- debug?: any;
171
- }
172
- declare function _readBitString(buffer: Buffer, block: BlockInfo): BitString;
173
- declare function formatBuffer2DigitHexWithColum(buffer: Buffer): string;
174
- declare function _readOctetString(buffer: Buffer, block: BlockInfo): Buffer;
175
- declare function _getBlock(buffer: Buffer, block: BlockInfo): Buffer;
53
+ declare function readStruct(buf: Buffer, blockInfo: BlockInfo): BlockInfo[];
176
54
  interface AlgorithmIdentifier {
177
55
  identifier: string;
178
56
  }
179
- declare function _readIntegerAsByteString(buffer: Buffer, block: BlockInfo): Buffer;
180
- declare function _readListOfInteger(buffer: Buffer): Buffer[];
181
- declare function _readObjectIdentifier(buffer: Buffer, block: BlockInfo): {
182
- oid: string;
183
- name: string;
184
- };
185
- declare function _readAlgorithmIdentifier(buffer: Buffer, block: BlockInfo): AlgorithmIdentifier;
186
- declare function _readECCAlgorithmIdentifier(buffer: Buffer, block: BlockInfo): AlgorithmIdentifier;
57
+ declare function readAlgorithmIdentifier(buffer: Buffer, block: BlockInfo): AlgorithmIdentifier;
187
58
  type SignatureValue = string;
188
- declare function _readSignatureValueBin(buffer: Buffer, block: BlockInfo): Buffer;
189
- declare function _readSignatureValue(buffer: Buffer, block: BlockInfo): SignatureValue;
190
- declare function _readLongIntegerValue(buffer: Buffer, block: BlockInfo): Buffer;
191
- declare function _readIntegerValue(buffer: Buffer, block: BlockInfo): number;
192
- declare function _readBooleanValue(buffer: Buffer, block: BlockInfo): boolean;
193
- declare function _readVersionValue(buffer: Buffer, block: BlockInfo): number;
194
- declare function _readValue(buffer: Buffer, block: BlockInfo): any;
195
- interface DirectoryName {
196
- stateOrProvinceName?: string;
197
- localityName?: string;
198
- organizationName?: string;
199
- organizationUnitName?: string;
200
- commonName?: string;
201
- countryName?: string;
59
+ declare function readSignatureValueBin(buffer: Buffer, block: BlockInfo): Buffer;
60
+
61
+ type PublicKeyLength = 64 | 96 | 128 | 256 | 384 | 512;
62
+ /**
63
+ * A structure exposing useful information about a certificate
64
+ */
65
+ interface CertificateInfo {
66
+ /** the public key length in bits */
67
+ publicKeyLength: PublicKeyLength;
68
+ /** the date at which the certificate starts to be valid */
69
+ notBefore: Date;
70
+ /** the date after which the certificate is not valid any more */
71
+ notAfter: Date;
72
+ /** info about certificate owner */
73
+ subject: DirectoryName;
74
+ /** public key */
75
+ publicKey: SubjectPublicKey;
202
76
  }
203
- declare function compactDirectoryName(d: DirectoryName): string;
204
- declare function _readDirectoryName(buffer: Buffer, block: BlockInfo): DirectoryName;
205
- declare function _findBlockAtIndex(blocks: BlockInfo[], index: number): BlockInfo | null;
206
- declare function _readTime(buffer: Buffer, block: BlockInfo): any;
77
+ declare function coerceCertificate(certificate: Certificate | CertificatePEM): Certificate;
78
+ /**
79
+ * @method exploreCertificateInfo
80
+ * returns useful information about the certificate such as public key length, start date and end of validity date,
81
+ * and CN
82
+ * @param certificate the certificate to explore
83
+ */
84
+ declare function exploreCertificateInfo(certificate: Certificate | CertificatePEM): CertificateInfo;
207
85
 
208
86
  /**
209
87
  * @module node_opcua_crypto
@@ -241,7 +119,7 @@ interface X509ExtKeyUsage {
241
119
  interface SubjectPublicKey {
242
120
  modulus: Buffer;
243
121
  }
244
- declare function _readExtension(buffer: Buffer, block: BlockInfo): {
122
+ declare function readExtension(buffer: Buffer, block: BlockInfo): {
245
123
  identifier: {
246
124
  oid: string;
247
125
  name: string;
@@ -310,30 +188,59 @@ declare function split_der(certificateChain: Certificate): Certificate[];
310
188
  */
311
189
  declare function combine_der(certificates: Certificate[]): Certificate;
312
190
 
313
- type PublicKeyLength = 64 | 96 | 128 | 256 | 384 | 512;
191
+ declare function identifyPemType(rawKey: Buffer | string): undefined | string;
192
+ declare function removeTrailingLF(str: string): string;
193
+ declare function toPem(raw_key: Buffer | string, pem: string): string;
194
+ declare function convertPEMtoDER(raw_key: PEM): DER;
195
+ declare function hexDump(buffer: Buffer, width?: number): string;
196
+ interface MakeMessageChunkSignatureOptions {
197
+ signatureLength: number;
198
+ algorithm: string;
199
+ privateKey: PrivateKey;
200
+ }
201
+ declare function makeMessageChunkSignature(chunk: Buffer, options: MakeMessageChunkSignatureOptions): Buffer;
202
+ interface VerifyMessageChunkSignatureOptions {
203
+ signatureLength?: number;
204
+ algorithm: string;
205
+ publicKey: PublicKeyPEM;
206
+ }
314
207
  /**
315
- * A structure exposing useful information about a certificate
208
+ * @method verifyMessageChunkSignature
209
+ *
210
+ * const signer = {
211
+ * signatureLength : 128,
212
+ * algorithm : "RSA-SHA256",
213
+ * publicKey: "qsdqsdqsd"
214
+ * };
215
+ * @param blockToVerify
216
+ * @param signature
217
+ * @param options
218
+ * @param options.signatureLength
219
+ * @param options.algorithm for example "RSA-SHA256"
220
+ * @param options.publicKey
221
+ * @return true if the signature is valid
316
222
  */
317
- interface CertificateInfo {
318
- /** the public key length in bits */
319
- publicKeyLength: PublicKeyLength;
320
- /** the date at which the certificate starts to be valid */
321
- notBefore: Date;
322
- /** the date after which the certificate is not valid any more */
323
- notAfter: Date;
324
- /** info about certificate owner */
325
- subject: DirectoryName;
326
- /** public key */
327
- publicKey: SubjectPublicKey;
223
+ declare function verifyMessageChunkSignature(blockToVerify: Buffer, signature: Signature, options: VerifyMessageChunkSignatureOptions): boolean;
224
+ declare function makeSHA1Thumbprint(buffer: Buffer): Signature;
225
+ declare const RSA_PKCS1_OAEP_PADDING: number;
226
+ declare const RSA_PKCS1_PADDING: number;
227
+ declare enum PaddingAlgorithm {
228
+ RSA_PKCS1_OAEP_PADDING = 4,
229
+ RSA_PKCS1_PADDING = 1
328
230
  }
329
- declare function coerceCertificate(certificate: Certificate | CertificatePEM): Certificate;
231
+ declare function publicEncrypt_native(buffer: Buffer, publicKey: KeyLike, algorithm?: PaddingAlgorithm): Buffer;
232
+ declare function privateDecrypt_native(buffer: Buffer, privateKey: PrivateKey, algorithm?: PaddingAlgorithm): Buffer;
233
+ declare const publicEncrypt: typeof publicEncrypt_native;
234
+ declare const privateDecrypt: typeof privateDecrypt_native;
235
+ declare function publicEncrypt_long(buffer: Buffer, publicKey: KeyLike, blockSize: number, padding?: number, paddingAlgorithm?: PaddingAlgorithm): Buffer;
236
+ declare function privateDecrypt_long(buffer: Buffer, privateKey: PrivateKey, blockSize: number, paddingAlgorithm?: number): Buffer;
237
+ declare function coerceCertificatePem(certificate: Certificate | CertificatePEM): CertificatePEM;
238
+ declare function extractPublicKeyFromCertificateSync(certificate: Certificate | CertificatePEM): PublicKeyPEM;
330
239
  /**
331
- * @method exploreCertificateInfo
332
- * returns useful information about the certificate such as public key length, start date and end of validity date,
333
- * and CN
334
- * @param certificate the certificate to explore
240
+ * extract the publickey from a certificate
241
+ * @async
335
242
  */
336
- declare function exploreCertificateInfo(certificate: Certificate | CertificatePEM): CertificateInfo;
243
+ declare function extractPublicKeyFromCertificate(certificate: CertificatePEM | Certificate, callback: (err: Error | null, publicKeyPEM?: PublicKeyPEM) => void): void;
337
244
 
338
245
  /***
339
246
  * @method rsaLengthPrivateKey
@@ -360,14 +267,77 @@ declare function coerceRsaPublicKeyPem(publicKey: PublicKey | KeyObject | Public
360
267
  declare function rsaLengthPublicKey(key: PublicKeyPEM | PublicKey): number;
361
268
  declare function rsaLengthRsaPublicKey(key: PublicKeyPEM | PublicKey): number;
362
269
 
363
- declare function verifyCertificateOrClrSignature(certificateOrCrl: Buffer, parentCertificate: Certificate): boolean;
364
- declare function verifyCertificateSignature(certificate: Certificate, parentCertificate: Certificate): boolean;
365
- declare function verifyCertificateRevocationListSignature(certificateRevocationList: Certificate, parentCertificate: Certificate): boolean;
366
- type _VerifyStatus = "BadCertificateIssuerUseNotAllowed" | "BadCertificateInvalid" | "Good";
367
- declare function verifyCertificateChain(certificateChain: Certificate[]): Promise<{
368
- status: _VerifyStatus;
369
- reason: string;
370
- }>;
270
+ declare function makePseudoRandomBuffer(secret: Nonce, seed: Nonce, minLength: number, sha1or256: "SHA1" | "SHA256"): Buffer;
271
+ interface ComputeDerivedKeysOptions {
272
+ signatureLength: number;
273
+ signingKeyLength: number;
274
+ encryptingKeyLength: number;
275
+ encryptingBlockSize: number;
276
+ algorithm: string;
277
+ sha1or256?: "SHA1" | "SHA256";
278
+ }
279
+ interface DerivedKeys extends ComputeDerivedKeysOptions {
280
+ signatureLength: number;
281
+ signingKeyLength: number;
282
+ encryptingKeyLength: number;
283
+ encryptingBlockSize: number;
284
+ algorithm: string;
285
+ sha1or256: "SHA1" | "SHA256";
286
+ signingKey: Buffer;
287
+ encryptingKey: Buffer;
288
+ initializationVector: Buffer;
289
+ }
290
+ declare function computeDerivedKeys(secret: Nonce, seed: Nonce, options: ComputeDerivedKeysOptions): DerivedKeys;
291
+ /**
292
+ * @method reduceLength
293
+ * @param buffer
294
+ * @param byteToRemove
295
+ * @return buffer
296
+ */
297
+ declare function reduceLength(buffer: Buffer, byteToRemove: number): Buffer;
298
+ /**
299
+ * @method removePadding
300
+ * @param buffer
301
+ * @return buffer with padding removed
302
+ */
303
+ declare function removePadding(buffer: Buffer): Buffer;
304
+ type VerifyChunkSignatureOptions = VerifyMessageChunkSignatureOptions;
305
+ /**
306
+ * @method verifyChunkSignature
307
+ *
308
+ * const signer = {
309
+ * signatureLength : 128,
310
+ * algorithm : "RSA-SHA256",
311
+ * public_key: "qsdqsdqsd"
312
+ * };
313
+ *
314
+ * @param chunk The message chunk to verify.
315
+ * @param options
316
+ * @param options.signatureLength
317
+ * @param options.algorithm the algorithm.
318
+ * @param options.publicKey
319
+ * @return {*}
320
+ */
321
+ declare function verifyChunkSignature(chunk: Buffer, options: VerifyChunkSignatureOptions): boolean;
322
+ declare function computePaddingFooter(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
323
+ declare function encryptBufferWithDerivedKeys(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
324
+ declare function decryptBufferWithDerivedKeys(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
325
+ /**
326
+ * @method makeMessageChunkSignatureWithDerivedKeys
327
+ * @param message
328
+ * @param derivedKeys
329
+ * @return
330
+ */
331
+ declare function makeMessageChunkSignatureWithDerivedKeys(message: Buffer, derivedKeys: DerivedKeys): Buffer;
332
+ /**
333
+ * @method verifyChunkSignatureWithDerivedKeys
334
+ * @param chunk
335
+ * @param derivedKeys
336
+ * @return
337
+ */
338
+ declare function verifyChunkSignatureWithDerivedKeys(chunk: Buffer, derivedKeys: DerivedKeys): boolean;
339
+
340
+ declare function exploreAsn1(buffer: Buffer): void;
371
341
 
372
342
  type Version = string;
373
343
  type Name = string;
@@ -434,23 +404,53 @@ interface PrivateKeyInternals {
434
404
  */
435
405
  declare function explorePrivateKey(privateKey2: PrivateKey): PrivateKeyInternals;
436
406
 
437
- declare function publicKeyAndPrivateKeyMatches(certificate: Certificate, privateKey: PrivateKey): boolean;
438
- declare function certificateMatchesPrivateKey(certificate: Certificate, privateKey: PrivateKey): boolean;
407
+ declare function makePrivateKeyFromPem(privateKeyInPem: string): PrivateKey;
439
408
 
440
- declare function generateKeyPair(modulusLength?: 1024 | 2048 | 3072 | 4096): Promise<CryptoKeyPair>;
409
+ declare function makePrivateKeyThumbPrint(privateKey: PrivateKey): Buffer;
410
+
411
+ interface SubjectOptions {
412
+ commonName?: string;
413
+ organization?: string;
414
+ organizationalUnit?: string;
415
+ locality?: string;
416
+ state?: string;
417
+ country?: string;
418
+ domainComponent?: string;
419
+ }
441
420
  /**
442
- * generate a pair of private/public keys of length 1024,2048, 3072, or 4096 bits
421
+ * subjectName The subject name to use for the Certificate.
422
+ * If not specified the ApplicationName and/or domainNames are used to create a suitable default value.
443
423
  */
444
- declare function generatePrivateKey(modulusLength?: 1024 | 2048 | 3072 | 4096): Promise<CryptoKey>;
424
+ declare class Subject implements SubjectOptions {
425
+ readonly commonName?: string;
426
+ readonly organization?: string;
427
+ readonly organizationalUnit?: string;
428
+ readonly locality?: string;
429
+ readonly state?: string;
430
+ readonly country?: string;
431
+ readonly domainComponent?: string;
432
+ constructor(options: SubjectOptions | string);
433
+ static parse(str: string): SubjectOptions;
434
+ toStringInternal(sep: string): string;
435
+ toStringForOPCUA(): string;
436
+ toString(): string;
437
+ }
438
+
439
+ declare function verifyCertificateOrClrSignature(certificateOrCrl: Buffer, parentCertificate: Certificate): boolean;
440
+ declare function verifyCertificateSignature(certificate: Certificate, parentCertificate: Certificate): boolean;
441
+ declare function verifyCertificateRevocationListSignature(certificateRevocationList: Certificate, parentCertificate: Certificate): boolean;
442
+ type _VerifyStatus = "BadCertificateIssuerUseNotAllowed" | "BadCertificateInvalid" | "Good";
443
+ declare function verifyCertificateChain(certificateChain: Certificate[]): Promise<{
444
+ status: _VerifyStatus;
445
+ reason: string;
446
+ }>;
447
+
448
+ declare function coercePEMorDerToPrivateKey(privateKeyInDerOrPem: string | Buffer): PrivateKey;
445
449
  /**
446
- * convert a CryptoKey to a PEM string
450
+ *
451
+ * @private
447
452
  */
448
- declare function privateKeyToPEM(privateKey: CryptoKey): Promise<{
449
- privPem: string;
450
- privDer: ArrayBuffer;
451
- }>;
452
- declare function derToPrivateKey(privDer: ArrayBuffer): Promise<CryptoKey>;
453
- declare function pemToPrivateKey(pem: string): Promise<CryptoKey>;
453
+ declare function _coercePrivateKey(privateKey: any): Promise<KeyObject>;
454
454
 
455
455
  interface CreateCertificateSigningRequestOptions {
456
456
  privateKey: CryptoKey;
@@ -468,6 +468,21 @@ declare function createCertificateSigningRequest({ privateKey, subject, dns, ip,
468
468
  der: x509.Pkcs10CertificateRequest;
469
469
  }>;
470
470
 
471
+ declare function generateKeyPair(modulusLength?: 1024 | 2048 | 3072 | 4096): Promise<CryptoKeyPair>;
472
+ /**
473
+ * generate a pair of private/public keys of length 1024,2048, 3072, or 4096 bits
474
+ */
475
+ declare function generatePrivateKey(modulusLength?: 1024 | 2048 | 3072 | 4096): Promise<CryptoKey>;
476
+ /**
477
+ * convert a CryptoKey to a PEM string
478
+ */
479
+ declare function privateKeyToPEM(privateKey: CryptoKey): Promise<{
480
+ privPem: string;
481
+ privDer: ArrayBuffer;
482
+ }>;
483
+ declare function derToPrivateKey(privDer: ArrayBuffer): Promise<CryptoKey>;
484
+ declare function pemToPrivateKey(pem: string): Promise<CryptoKey>;
485
+
471
486
  interface CreateSelfSignCertificateOptions {
472
487
  privateKey: CryptoKey;
473
488
  notBefore?: Date;
@@ -488,41 +503,16 @@ declare function createSelfSignedCertificate({ privateKey, notAfter, notBefore,
488
503
  der: x509.X509Certificate;
489
504
  }>;
490
505
 
491
- declare function coercePEMorDerToPrivateKey(privateKeyInDerOrPem: string | Buffer): PrivateKey;
492
506
  /**
493
- *
494
- * @private
495
- */
496
- declare function _coercePrivateKey(privateKey: any): Promise<KeyObject>;
497
-
498
- interface SubjectOptions {
499
- commonName?: string;
500
- organization?: string;
501
- organizationalUnit?: string;
502
- locality?: string;
503
- state?: string;
504
- country?: string;
505
- domainComponent?: string;
506
- }
507
- /**
508
- * subjectName The subject name to use for the Certificate.
509
- * If not specified the ApplicationName and/or domainNames are used to create a suitable default value.
507
+ * @module node_opcua_crypto
510
508
  */
511
- declare class Subject implements SubjectOptions {
512
- readonly commonName?: string;
513
- readonly organization?: string;
514
- readonly organizationalUnit?: string;
515
- readonly locality?: string;
516
- readonly state?: string;
517
- readonly country?: string;
518
- readonly domainComponent?: string;
519
- constructor(options: SubjectOptions | string);
520
- static parse(str: string): SubjectOptions;
521
- toStringInternal(sep: string): string;
522
- toStringForOPCUA(): string;
523
- toString(): string;
524
- }
525
509
 
526
- declare function makePrivateKeyFromPem(privateKeyInPem: string): PrivateKey;
510
+ declare const asn1: {
511
+ readDirectoryName: typeof readDirectoryName;
512
+ readTag: typeof readTag;
513
+ readStruct: typeof readStruct;
514
+ readAlgorithmIdentifier: typeof readAlgorithmIdentifier;
515
+ readSignatureValueBin: typeof readSignatureValueBin;
516
+ };
527
517
 
528
- export { type AlgorithmIdentifier, type AttributeTypeAndValue, type AuthorityKeyIdentifier, type BasicConstraints, type BitString, type BlockInfo, Certificate, type CertificateExtension, type CertificateInfo, type CertificateInternals, CertificatePEM, CertificatePurpose, CertificateRevocationList, type CertificateRevocationListInfo, type CertificateSerialNumber, type CertificateSigningRequestInfo, type ComputeDerivedKeysOptions, type CreateSelfSignCertificateOptions, DER, type DerivedKeys, type DirectoryName, type ExtensionRequest, type Extensions, KeyObject, type Name, Nonce, PEM, PaddingAlgorithm, PrivateKey, type PrivateKeyInternals, PrivateKeyPEM, PublicKey, type PublicKeyLength, PublicKeyPEM, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, type RevokedCertificate, Signature, type SignatureValue, Subject, type SubjectOptions, type SubjectPublicKey, type SubjectPublicKeyInfo, type TBSCertList, TagType, type TbsCertificate, type Validity, type VerifyChunkSignatureOptions, type VerifyMessageChunkSignatureOptions, type Version, type X509ExtKeyUsage, type X509KeyUsage, type _VerifyStatus, _coercePrivateKey, _findBlockAtIndex, _getBlock, _readAlgorithmIdentifier, _readBitString, _readBooleanValue, _readDirectoryName, _readECCAlgorithmIdentifier, _readExtension, _readIntegerAsByteString, _readIntegerValue, _readListOfInteger, _readLongIntegerValue, _readObjectIdentifier, _readOctetString, _readSignatureValue, _readSignatureValueBin, _readStruct, _readTime, _readValue, _readVersionValue, certificateMatchesPrivateKey, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, compactDirectoryName, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateSigningRequest, createSelfSignedCertificate, decryptBufferWithDerivedKeys, derToPrivateKey, encryptBufferWithDerivedKeys, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, formatBuffer2DigitHexWithColum, generateKeyPair, generatePrivateKey, hexDump, identifyPemType, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePseudoRandomBuffer, makeSHA1Thumbprint, parseBitString, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readNameForCrl, readTag, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyMessageChunkSignature };
518
+ export { type AttributeTypeAndValue, type AuthorityKeyIdentifier, type BasicConstraints, Certificate, type CertificateExtension, type CertificateInfo, type CertificateInternals, CertificatePEM, CertificatePurpose, CertificateRevocationList, type CertificateRevocationListInfo, type CertificateSerialNumber, type CertificateSigningRequestInfo, type ComputeDerivedKeysOptions, type CreateSelfSignCertificateOptions, DER, type DerivedKeys, type DirectoryName, type ExtensionRequest, type Extensions, KeyObject, type Name, Nonce, PEM, PaddingAlgorithm, PrivateKey, type PrivateKeyInternals, PrivateKeyPEM, PublicKey, type PublicKeyLength, PublicKeyPEM, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, type RevokedCertificate, Signature, Subject, type SubjectOptions, type SubjectPublicKey, type SubjectPublicKeyInfo, type TBSCertList, type TbsCertificate, type Validity, type VerifyChunkSignatureOptions, type VerifyMessageChunkSignatureOptions, type Version, type X509ExtKeyUsage, type X509KeyUsage, type _VerifyStatus, _coercePrivateKey, asn1, certificateMatchesPrivateKey, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateSigningRequest, createSelfSignedCertificate, decryptBufferWithDerivedKeys, derToPrivateKey, encryptBufferWithDerivedKeys, exploreAsn1, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, generateKeyPair, generatePrivateKey, hexDump, identifyPemType, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePrivateKeyThumbPrint, makePseudoRandomBuffer, makeSHA1Thumbprint, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readExtension, readNameForCrl, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyMessageChunkSignature };