node-opcua-crypto 4.5.0 → 4.6.1

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 (54) hide show
  1. package/dist-cjs/common-0xc4gZF8.d.ts +44 -0
  2. package/dist-cjs/index.d.ts +5 -0
  3. package/dist-cjs/source/index.d.ts +523 -0
  4. package/dist-cjs/source/index_web.d.ts +4 -0
  5. package/dist-cjs/source_nodejs/index.d.ts +46 -0
  6. package/{dist/chunk-SNCRM4BA.mjs → dist-esm/chunk-D3SBIIXU.mjs} +1 -1
  7. package/{dist/chunk-UZNNRQTR.mjs → dist-esm/chunk-R33OLRZV.mjs} +2 -2
  8. package/dist-esm/common-0xc4gZF8.d.ts +44 -0
  9. package/dist-esm/index.d.mts +5 -0
  10. package/{dist → dist-esm}/index.mjs +2 -2
  11. package/dist-esm/source/index.d.mts +523 -0
  12. package/{dist → dist-esm}/source/index.mjs +1 -1
  13. package/dist-esm/source/index_web.d.mts +4 -0
  14. package/{dist → dist-esm}/source/index_web.mjs +1 -1
  15. package/dist-esm/source_nodejs/index.d.mts +46 -0
  16. package/{dist → dist-esm}/source_nodejs/index.mjs +2 -2
  17. package/index.mjs +1 -0
  18. package/package.json +18 -28
  19. package/dist-types/index.d.ts +0 -2
  20. package/dist-types/source/asn1.d.ts +0 -73
  21. package/dist-types/source/buffer_utils.d.ts +0 -6
  22. package/dist-types/source/common.d.ts +0 -44
  23. package/dist-types/source/crypto_explore_certificate.d.ts +0 -107
  24. package/dist-types/source/crypto_utils.d.ts +0 -58
  25. package/dist-types/source/crypto_utils2.d.ts +0 -27
  26. package/dist-types/source/derived_keys.d.ts +0 -72
  27. package/dist-types/source/explore_certificate.d.ts +0 -27
  28. package/dist-types/source/explore_certificate_revocation_list.d.ts +0 -28
  29. package/dist-types/source/explore_certificate_signing_request.d.ts +0 -13
  30. package/dist-types/source/explore_private_key.d.ts +0 -29
  31. package/dist-types/source/index.d.ts +0 -21
  32. package/dist-types/source/make_private_key_from_pem.d.ts +0 -2
  33. package/dist-types/source/oid_map.d.ts +0 -7
  34. package/dist-types/source/public_private_match.d.ts +0 -3
  35. package/dist-types/source/subject.d.ts +0 -27
  36. package/dist-types/source/verify_certificate_signature.d.ts +0 -10
  37. package/dist-types/source/x509/_build_public_key.d.ts +0 -1
  38. package/dist-types/source/x509/_crypto.d.ts +0 -3
  39. package/dist-types/source/x509/_get_attributes.d.ts +0 -8
  40. package/dist-types/source/x509/coerce_private_key.d.ts +0 -8
  41. package/dist-types/source/x509/create_certificate_signing_request.d.ts +0 -18
  42. package/dist-types/source/x509/create_key_pair.d.ts +0 -14
  43. package/dist-types/source/x509/create_self_signed_certificate.d.ts +0 -21
  44. package/dist-types/source_nodejs/generate_private_key_filename.d.ts +0 -7
  45. package/dist-types/source_nodejs/index.d.ts +0 -4
  46. package/dist-types/source_nodejs/read.d.ts +0 -30
  47. package/dist-types/source_nodejs/read_certificate_revocation_list.d.ts +0 -2
  48. package/dist-types/source_nodejs/read_certificate_signing_request.d.ts +0 -3
  49. package/node-opcua-crypto-4.2.0.tgz +0 -0
  50. /package/{dist → dist-cjs}/index.js +0 -0
  51. /package/{dist → dist-cjs}/source/index.js +0 -0
  52. /package/{dist → dist-cjs}/source/index_web.js +0 -0
  53. /package/{dist → dist-cjs}/source_nodejs/index.js +0 -0
  54. /package/{dist → dist-esm}/chunk-5NV4OKIV.mjs +0 -0
@@ -0,0 +1,44 @@
1
+ import __crypto from 'crypto';
2
+
3
+ declare const createPrivateKeyFromNodeJSCrypto: typeof __crypto.createPrivateKey;
4
+ type KeyFormat = "pem" | "der" | "jwk";
5
+ type KeyObjectType = "secret" | "public" | "private";
6
+ interface KeyExportOptions<T extends KeyFormat> {
7
+ type: "pkcs1" | "spki" | "pkcs8" | "sec1";
8
+ format: T;
9
+ cipher?: string | undefined;
10
+ passphrase?: string | Buffer | undefined;
11
+ }
12
+ interface JwkKeyExportOptions {
13
+ format: "jwk";
14
+ }
15
+ interface KeyObject {
16
+ export(options: KeyExportOptions<"pem">): string | Buffer;
17
+ export(options: KeyExportOptions<"der">): Buffer;
18
+ export(options: JwkKeyExportOptions): JsonWebKey;
19
+ type: KeyObjectType;
20
+ }
21
+ declare function isKeyObject(mayBeKeyObject: any): boolean;
22
+ type PrivateKey = {
23
+ hidden: string;
24
+ } | {
25
+ hidden: KeyObject;
26
+ };
27
+ type PublicKey = KeyObject;
28
+ type Nonce = Buffer;
29
+ type PEM = string;
30
+ type DER = Buffer;
31
+ type Certificate = DER;
32
+ type CertificatePEM = PEM;
33
+ type PrivateKeyPEM = PEM;
34
+ type PublicKeyPEM = PEM;
35
+ type Signature = Buffer;
36
+ type CertificateRevocationList = Buffer;
37
+ declare enum CertificatePurpose {
38
+ NotSpecified = 0,
39
+ ForCertificateAuthority = 1,
40
+ ForApplication = 2,
41
+ ForUserAuthentication = 3
42
+ }
43
+
44
+ export { type Certificate as C, type DER as D, type KeyObject as K, type Nonce as N, type PrivateKey as P, type Signature as S, type PublicKey as a, type PEM as b, createPrivateKeyFromNodeJSCrypto as c, type CertificatePEM as d, type PrivateKeyPEM as e, type PublicKeyPEM as f, type CertificateRevocationList as g, CertificatePurpose as h, isKeyObject as i };
@@ -0,0 +1,5 @@
1
+ export { C as Certificate, d as CertificatePEM, h as CertificatePurpose, g as CertificateRevocationList, D as DER, K as KeyObject, N as Nonce, b as PEM, P as PrivateKey, e as PrivateKeyPEM, a as PublicKey, f as PublicKeyPEM, S as Signature, c as createPrivateKeyFromNodeJSCrypto, i as isKeyObject } from './common-0xc4gZF8.js';
2
+ export { AlgorithmIdentifier, AttributeTypeAndValue, AuthorityKeyIdentifier, BasicConstraints, BitString, BlockInfo, CertificateExtension, CertificateInfo, CertificateInternals, CertificateRevocationListInfo, CertificateSerialNumber, CertificateSigningRequestInfo, ComputeDerivedKeysOptions, CreateSelfSignCertificateOptions, DerivedKeys, DirectoryName, ExtensionRequest, Extensions, Name, PaddingAlgorithm, PrivateKeyInternals, PublicKeyLength, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, RevokedCertificate, SignatureValue, Subject, SubjectOptions, SubjectPublicKey, SubjectPublicKeyInfo, TBSCertList, TagType, TbsCertificate, Validity, VerifyChunkSignatureOptions, VerifyMessageChunkSignatureOptions, Version, X509ExtKeyUsage, X509KeyUsage, _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 } from './source/index.js';
3
+ export { CertificateSigningRequest, generatePrivateKeyFile, generatePrivateKeyFileAlternate, getCertificateStore, makePrivateKeyThumbPrint, readCertificate, readCertificatePEM, readCertificateRevocationList, readCertificateSigningRequest, readPrivateKey, readPrivateKeyPEM, readPrivateRsaKey, readPublicKey, readPublicKeyPEM, readPublicRsaKey, setCertificateStore } from './source_nodejs/index.js';
4
+ import 'crypto';
5
+ import '@peculiar/x509';
@@ -0,0 +1,523 @@
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-0xc4gZF8.js';
2
+ export { c as createPrivateKeyFromNodeJSCrypto, i as isKeyObject } from '../common-0xc4gZF8.js';
3
+ import { KeyLike } from 'crypto';
4
+ import * as x509 from '@peculiar/x509';
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;
59
+
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;
79
+ }
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;
129
+
130
+ declare enum TagType {
131
+ BOOLEAN = 1,
132
+ INTEGER = 2,
133
+ BIT_STRING = 3,
134
+ OCTET_STRING = 4,
135
+ NULL = 5,
136
+ OBJECT_IDENTIFIER = 6,
137
+ UTF8String = 12,
138
+ NumericString = 18,
139
+ PrintableString = 19,
140
+ TeletexString = 20,
141
+ IA5String = 22,
142
+ UTCTime = 23,
143
+ GeneralizedTime = 24,
144
+ GraphicString = 25,
145
+ VisibleString = 26,
146
+ GeneralString = 27,
147
+ UniversalString = 28,
148
+ BMPString = 30,
149
+ SEQUENCE = 48,
150
+ SET = 49,
151
+ A3 = 163
152
+ }
153
+ interface BlockInfo {
154
+ tag: TagType | number;
155
+ position: number;
156
+ length: number;
157
+ }
158
+ declare function readTag(buf: Buffer, pos: number): BlockInfo;
159
+ declare function _readStruct(buf: Buffer, blockInfo: BlockInfo): BlockInfo[];
160
+ declare function parseBitString(buffer: Buffer, start: number, end: number, maxLength: number): string;
161
+ interface BitString {
162
+ lengthInBits: number;
163
+ lengthInBytes: number;
164
+ data: Buffer;
165
+ debug?: any;
166
+ }
167
+ declare function _readBitString(buffer: Buffer, block: BlockInfo): BitString;
168
+ declare function formatBuffer2DigitHexWithColum(buffer: Buffer): string;
169
+ declare function _readOctetString(buffer: Buffer, block: BlockInfo): Buffer;
170
+ declare function _getBlock(buffer: Buffer, block: BlockInfo): Buffer;
171
+ interface AlgorithmIdentifier {
172
+ identifier: string;
173
+ }
174
+ declare function _readIntegerAsByteString(buffer: Buffer, block: BlockInfo): Buffer;
175
+ declare function _readListOfInteger(buffer: Buffer): Buffer[];
176
+ declare function _readObjectIdentifier(buffer: Buffer, block: BlockInfo): {
177
+ oid: string;
178
+ name: string;
179
+ };
180
+ declare function _readAlgorithmIdentifier(buffer: Buffer, block: BlockInfo): AlgorithmIdentifier;
181
+ declare function _readECCAlgorithmIdentifier(buffer: Buffer, block: BlockInfo): AlgorithmIdentifier;
182
+ type SignatureValue = string;
183
+ declare function _readSignatureValueBin(buffer: Buffer, block: BlockInfo): Buffer;
184
+ declare function _readSignatureValue(buffer: Buffer, block: BlockInfo): SignatureValue;
185
+ declare function _readLongIntegerValue(buffer: Buffer, block: BlockInfo): Buffer;
186
+ declare function _readIntegerValue(buffer: Buffer, block: BlockInfo): number;
187
+ declare function _readBooleanValue(buffer: Buffer, block: BlockInfo): boolean;
188
+ declare function _readVersionValue(buffer: Buffer, block: BlockInfo): number;
189
+ declare function _readValue(buffer: Buffer, block: BlockInfo): any;
190
+ interface DirectoryName {
191
+ stateOrProvinceName?: string;
192
+ localityName?: string;
193
+ organizationName?: string;
194
+ organizationUnitName?: string;
195
+ commonName?: string;
196
+ countryName?: string;
197
+ }
198
+ declare function compactDirectoryName(d: DirectoryName): string;
199
+ declare function _readDirectoryName(buffer: Buffer, block: BlockInfo): DirectoryName;
200
+ declare function _findBlockAtIndex(blocks: BlockInfo[], index: number): BlockInfo | null;
201
+ declare function _readTime(buffer: Buffer, block: BlockInfo): any;
202
+
203
+ /**
204
+ * @module node_opcua_crypto
205
+ */
206
+
207
+ interface AttributeTypeAndValue {
208
+ [key: string]: any;
209
+ }
210
+ interface Validity {
211
+ notBefore: Date;
212
+ notAfter: Date;
213
+ }
214
+ interface X509KeyUsage {
215
+ digitalSignature: boolean;
216
+ nonRepudiation: boolean;
217
+ keyEncipherment: boolean;
218
+ dataEncipherment: boolean;
219
+ keyAgreement: boolean;
220
+ keyCertSign: boolean;
221
+ cRLSign: boolean;
222
+ encipherOnly: boolean;
223
+ decipherOnly: boolean;
224
+ }
225
+ interface X509ExtKeyUsage {
226
+ clientAuth: boolean;
227
+ serverAuth: boolean;
228
+ codeSigning: boolean;
229
+ emailProtection: boolean;
230
+ timeStamping: boolean;
231
+ ocspSigning: boolean;
232
+ ipsecEndSystem: boolean;
233
+ ipsecTunnel: boolean;
234
+ ipsecUser: boolean;
235
+ }
236
+ interface SubjectPublicKey {
237
+ modulus: Buffer;
238
+ }
239
+ declare function _readExtension(buffer: Buffer, block: BlockInfo): {
240
+ identifier: {
241
+ oid: string;
242
+ name: string;
243
+ };
244
+ value: any;
245
+ };
246
+ interface SubjectPublicKeyInfo {
247
+ algorithm: string;
248
+ keyLength: PublicKeyLength;
249
+ subjectPublicKey: SubjectPublicKey;
250
+ }
251
+ interface BasicConstraints {
252
+ critical: boolean;
253
+ cA: boolean;
254
+ pathLengthConstraint?: number;
255
+ }
256
+ interface AuthorityKeyIdentifier {
257
+ keyIdentifier: string | null;
258
+ authorityCertIssuer: DirectoryName | null;
259
+ authorityCertIssuerFingerPrint: string;
260
+ serial: string | null;
261
+ }
262
+ interface CertificateExtension {
263
+ basicConstraints: BasicConstraints;
264
+ subjectKeyIdentifier?: string;
265
+ authorityKeyIdentifier?: AuthorityKeyIdentifier;
266
+ keyUsage?: X509KeyUsage;
267
+ extKeyUsage?: X509ExtKeyUsage;
268
+ subjectAltName?: any;
269
+ }
270
+ interface TbsCertificate {
271
+ version: number;
272
+ serialNumber: string;
273
+ issuer: any;
274
+ signature: AlgorithmIdentifier;
275
+ validity: Validity;
276
+ subject: DirectoryName;
277
+ subjectFingerPrint: string;
278
+ subjectPublicKeyInfo: SubjectPublicKeyInfo;
279
+ extensions: CertificateExtension | null;
280
+ }
281
+ declare function readTbsCertificate(buffer: Buffer, block: BlockInfo): TbsCertificate;
282
+ interface CertificateInternals {
283
+ tbsCertificate: TbsCertificate;
284
+ signatureAlgorithm: AlgorithmIdentifier;
285
+ signatureValue: SignatureValue;
286
+ }
287
+ /**
288
+ * explore a certificate structure
289
+ * @param certificate
290
+ * @returns a json object that exhibits the internal data of the certificate
291
+ */
292
+ declare function exploreCertificate(certificate: Certificate): CertificateInternals;
293
+ /**
294
+ * @method split_der
295
+ * split a multi chain certificates
296
+ * @param certificateChain the certificate chain in der (binary) format}
297
+ * @returns an array of Der , each element of the array is one certificate of the chain
298
+ */
299
+ declare function split_der(certificateChain: Certificate): Certificate[];
300
+ /**
301
+ * @method combine_der
302
+ * combine an array of certificates into a single blob
303
+ * @param certificates a array with the individual DER certificates of the chain
304
+ * @return a concatenated buffer containing the certificates
305
+ */
306
+ declare function combine_der(certificates: Certificate[]): Certificate;
307
+
308
+ type PublicKeyLength = 64 | 96 | 128 | 256 | 384 | 512;
309
+ /**
310
+ * A structure exposing useful information about a certificate
311
+ */
312
+ interface CertificateInfo {
313
+ /** the public key length in bits */
314
+ publicKeyLength: PublicKeyLength;
315
+ /** the date at which the certificate starts to be valid */
316
+ notBefore: Date;
317
+ /** the date after which the certificate is not valid any more */
318
+ notAfter: Date;
319
+ /** info about certificate owner */
320
+ subject: DirectoryName;
321
+ /** public key */
322
+ publicKey: SubjectPublicKey;
323
+ }
324
+ declare function coerceCertificate(certificate: Certificate | CertificatePEM): Certificate;
325
+ /**
326
+ * @method exploreCertificateInfo
327
+ * returns useful information about the certificate such as public key length, start date and end of validity date,
328
+ * and CN
329
+ * @param certificate the certificate to explore
330
+ */
331
+ declare function exploreCertificateInfo(certificate: Certificate | CertificatePEM): CertificateInfo;
332
+
333
+ /***
334
+ * @method rsaLengthPrivateKey
335
+ * A very expensive way to determine the rsa key length ( i.e 2048bits or 1024bits)
336
+ * @param key a PEM public key or a PEM rsa private key
337
+ * @return the key length in bytes.
338
+ */
339
+ declare function rsaLengthPrivateKey(key: PrivateKey): number;
340
+ /**
341
+ * @method toPem2
342
+ * @param raw_key
343
+ * @param pem
344
+ *
345
+ *
346
+ * @return a PEM string containing the Private Key
347
+ *
348
+ * Note: a Pem key can be converted back to a private key object using coercePrivateKey
349
+ *
350
+ */
351
+ declare function toPem2(raw_key: Buffer | string | KeyObject | PrivateKey, pem: string): string;
352
+ declare function coercePrivateKeyPem(privateKey: PrivateKey): PrivateKeyPEM;
353
+ declare function coercePublicKeyPem(publicKey: PublicKey | PublicKeyPEM): PublicKeyPEM;
354
+ declare function coerceRsaPublicKeyPem(publicKey: PublicKey | KeyObject | PublicKeyPEM): PublicKeyPEM;
355
+ declare function rsaLengthPublicKey(key: PublicKeyPEM | PublicKey): number;
356
+ declare function rsaLengthRsaPublicKey(key: PublicKeyPEM | PublicKey): number;
357
+
358
+ declare function verifyCertificateOrClrSignature(certificateOrCrl: Buffer, parentCertificate: Certificate): boolean;
359
+ declare function verifyCertificateSignature(certificate: Certificate, parentCertificate: Certificate): boolean;
360
+ declare function verifyCertificateRevocationListSignature(certificateRevocationList: Certificate, parentCertificate: Certificate): boolean;
361
+ type _VerifyStatus = "BadCertificateIssuerUseNotAllowed" | "BadCertificateInvalid" | "Good";
362
+ declare function verifyCertificateChain(certificateChain: Certificate[]): Promise<{
363
+ status: _VerifyStatus;
364
+ reason: string;
365
+ }>;
366
+
367
+ type Version = string;
368
+ type Name = string;
369
+ type CertificateSerialNumber = string;
370
+ type Extensions = Record<string, unknown>;
371
+ interface RevokedCertificate {
372
+ userCertificate: CertificateSerialNumber;
373
+ revocationDate: Date;
374
+ crlEntryExtensions?: Extensions;
375
+ }
376
+ interface TBSCertList {
377
+ version?: Version;
378
+ signature: AlgorithmIdentifier;
379
+ issuer: Name;
380
+ issuerFingerprint: string;
381
+ thisUpdate: Date;
382
+ nextUpdate?: Date;
383
+ revokedCertificates: RevokedCertificate[];
384
+ }
385
+ interface CertificateRevocationListInfo {
386
+ tbsCertList: TBSCertList;
387
+ signatureAlgorithm: AlgorithmIdentifier;
388
+ signatureValue: Buffer;
389
+ }
390
+ declare function readNameForCrl(buffer: Buffer, block: BlockInfo): DirectoryName;
391
+ declare function exploreCertificateRevocationList(crl: CertificateRevocationList): CertificateRevocationListInfo;
392
+
393
+ interface ExtensionRequest {
394
+ basicConstraints: BasicConstraints;
395
+ keyUsage: X509KeyUsage;
396
+ subjectAltName: any;
397
+ }
398
+ interface CertificateSigningRequestInfo {
399
+ extensionRequest: ExtensionRequest;
400
+ }
401
+ declare function readCertificationRequestInfo(buffer: Buffer, block: BlockInfo): CertificateSigningRequestInfo;
402
+ declare function exploreCertificateSigningRequest(crl: Buffer): CertificateSigningRequestInfo;
403
+
404
+ interface PrivateKeyInternals {
405
+ /***/
406
+ version: Buffer;
407
+ modulus: Buffer;
408
+ publicExponent: Buffer;
409
+ privateExponent: Buffer;
410
+ prime1: Buffer;
411
+ prime2: Buffer;
412
+ exponent1: Buffer;
413
+ exponent2: Buffer;
414
+ }
415
+ /**
416
+ *
417
+ * @param privateKey RSAPrivateKey ::= SEQUENCE {
418
+ * version Version,
419
+ * modulus INTEGER, -- n
420
+ * publicExponent INTEGER, -- e
421
+ * privateExponent INTEGER, -- d
422
+ * prime1 INTEGER, -- p
423
+ * prime2 INTEGER, -- q
424
+ * exponent1 INTEGER, -- d mod (p-1)
425
+ * exponent2 INTEGER, -- d mod (q-1)
426
+ * coefficient INTEGER, -- (inverse of q) mod p
427
+ * otherPrimeInfos OtherPrimeInfos OPTIONAL
428
+ }
429
+ */
430
+ declare function explorePrivateKey(privateKey2: PrivateKey): PrivateKeyInternals;
431
+
432
+ declare function publicKeyAndPrivateKeyMatches(certificate: Certificate, privateKey: PrivateKey): boolean;
433
+ declare function certificateMatchesPrivateKey(certificate: Certificate, privateKey: PrivateKey): boolean;
434
+
435
+ declare function generateKeyPair(modulusLength?: 1024 | 2048 | 3072 | 4096): Promise<CryptoKeyPair>;
436
+ /**
437
+ * generate a pair of private/public keys of length 1024,2048, 3072, or 4096 bits
438
+ */
439
+ declare function generatePrivateKey(modulusLength?: 1024 | 2048 | 3072 | 4096): Promise<CryptoKey>;
440
+ /**
441
+ * convert a CryptoKey to a PEM string
442
+ */
443
+ declare function privateKeyToPEM(privateKey: CryptoKey): Promise<{
444
+ privPem: string;
445
+ privDer: ArrayBuffer;
446
+ }>;
447
+ declare function derToPrivateKey(privDer: ArrayBuffer): Promise<CryptoKey>;
448
+ declare function pemToPrivateKey(pem: string): Promise<CryptoKey>;
449
+
450
+ interface CreateCertificateSigningRequestOptions {
451
+ privateKey: CryptoKey;
452
+ notBefore?: Date;
453
+ notAfter?: Date;
454
+ validity?: number;
455
+ subject?: string;
456
+ dns?: string[];
457
+ ip?: string[];
458
+ applicationUri?: string;
459
+ purpose: CertificatePurpose;
460
+ }
461
+ declare function createCertificateSigningRequest({ privateKey, subject, dns, ip, applicationUri, purpose, }: CreateCertificateSigningRequestOptions): Promise<{
462
+ csr: string;
463
+ der: x509.Pkcs10CertificateRequest;
464
+ }>;
465
+
466
+ interface CreateSelfSignCertificateOptions {
467
+ privateKey: CryptoKey;
468
+ notBefore?: Date;
469
+ notAfter?: Date;
470
+ validity?: number;
471
+ subject?: string;
472
+ dns?: string[];
473
+ ip?: string[];
474
+ applicationUri?: string;
475
+ purpose: CertificatePurpose;
476
+ }
477
+ /**
478
+ *
479
+ * construct a self-signed certificate
480
+ */
481
+ declare function createSelfSignedCertificate({ privateKey, notAfter, notBefore, validity, subject, dns, ip, applicationUri, purpose, }: CreateSelfSignCertificateOptions): Promise<{
482
+ cert: string;
483
+ der: x509.X509Certificate;
484
+ }>;
485
+
486
+ declare function coercePEMorDerToPrivateKey(privateKeyInDerOrPem: string | Buffer): PrivateKey;
487
+ /**
488
+ *
489
+ * @private
490
+ */
491
+ declare function _coercePrivateKey(privateKey: any): Promise<KeyObject>;
492
+
493
+ interface SubjectOptions {
494
+ commonName?: string;
495
+ organization?: string;
496
+ organizationalUnit?: string;
497
+ locality?: string;
498
+ state?: string;
499
+ country?: string;
500
+ domainComponent?: string;
501
+ }
502
+ /**
503
+ * subjectName The subject name to use for the Certificate.
504
+ * If not specified the ApplicationName and/or domainNames are used to create a suitable default value.
505
+ */
506
+ declare class Subject implements SubjectOptions {
507
+ readonly commonName?: string;
508
+ readonly organization?: string;
509
+ readonly organizationalUnit?: string;
510
+ readonly locality?: string;
511
+ readonly state?: string;
512
+ readonly country?: string;
513
+ readonly domainComponent?: string;
514
+ constructor(options: SubjectOptions | string);
515
+ static parse(str: string): SubjectOptions;
516
+ toStringInternal(sep: string): string;
517
+ toStringForOPCUA(): string;
518
+ toString(): string;
519
+ }
520
+
521
+ declare function makePrivateKeyFromPem(privateKeyInPem: string): PrivateKey;
522
+
523
+ 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 };
@@ -0,0 +1,4 @@
1
+ export { C as Certificate, d as CertificatePEM, h as CertificatePurpose, g as CertificateRevocationList, D as DER, K as KeyObject, N as Nonce, b as PEM, P as PrivateKey, e as PrivateKeyPEM, a as PublicKey, f as PublicKeyPEM, S as Signature, c as createPrivateKeyFromNodeJSCrypto, i as isKeyObject } from '../common-0xc4gZF8.js';
2
+ export { AlgorithmIdentifier, AttributeTypeAndValue, AuthorityKeyIdentifier, BasicConstraints, BitString, BlockInfo, CertificateExtension, CertificateInfo, CertificateInternals, CertificateRevocationListInfo, CertificateSerialNumber, CertificateSigningRequestInfo, ComputeDerivedKeysOptions, CreateSelfSignCertificateOptions, DerivedKeys, DirectoryName, ExtensionRequest, Extensions, Name, PaddingAlgorithm, PrivateKeyInternals, PublicKeyLength, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, RevokedCertificate, SignatureValue, Subject, SubjectOptions, SubjectPublicKey, SubjectPublicKeyInfo, TBSCertList, TagType, TbsCertificate, Validity, VerifyChunkSignatureOptions, VerifyMessageChunkSignatureOptions, Version, X509ExtKeyUsage, X509KeyUsage, _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 } from './index.js';
3
+ import 'crypto';
4
+ import '@peculiar/x509';
@@ -0,0 +1,46 @@
1
+ import { C as Certificate, a as PublicKey, P as PrivateKey, d as CertificatePEM, f as PublicKeyPEM, e as PrivateKeyPEM, g as CertificateRevocationList } from '../common-0xc4gZF8.js';
2
+ import 'crypto';
3
+
4
+ /**
5
+ * read a DER or PEM certificate from file
6
+ */
7
+ declare function readCertificate(filename: string): Certificate;
8
+ /**
9
+ * read a DER or PEM certificate from file
10
+ */
11
+ declare function readPublicKey(filename: string): PublicKey;
12
+ declare function makePrivateKeyThumbPrint(privateKey: PrivateKey): Buffer;
13
+ /**
14
+ * read a DER or PEM certificate from file
15
+ */
16
+ declare function readPrivateKey(filename: string): PrivateKey;
17
+ declare function readCertificatePEM(filename: string): CertificatePEM;
18
+ declare function readPublicKeyPEM(filename: string): PublicKeyPEM;
19
+ /**
20
+ *
21
+ * @deprecated
22
+ */
23
+ declare function readPrivateKeyPEM(filename: string): PrivateKeyPEM;
24
+ declare function setCertificateStore(store: string): string;
25
+ declare function getCertificateStore(): string;
26
+ /**
27
+ *
28
+ * @param filename
29
+ */
30
+ declare function readPrivateRsaKey(filename: string): PrivateKey;
31
+ declare function readPublicRsaKey(filename: string): PublicKey;
32
+
33
+ declare function readCertificateRevocationList(filename: string): Promise<CertificateRevocationList>;
34
+
35
+ type CertificateSigningRequest = Buffer;
36
+ declare function readCertificateSigningRequest(filename: string): Promise<CertificateSigningRequest>;
37
+
38
+ declare function generatePrivateKeyFile(privateKeyFilename: string, modulusLength: 1024 | 2048 | 3072 | 4096): Promise<void>;
39
+ /**
40
+ * alternate function to generate PrivateKeyFile, using jsrsasign.
41
+ *
42
+ * This function is slower than generatePrivateKeyFile
43
+ */
44
+ declare function generatePrivateKeyFileAlternate(privateKeyFilename: string, modulusLength: 2048 | 3072 | 4096): Promise<void>;
45
+
46
+ export { type CertificateSigningRequest, generatePrivateKeyFile, generatePrivateKeyFileAlternate, getCertificateStore, makePrivateKeyThumbPrint, readCertificate, readCertificatePEM, readCertificateRevocationList, readCertificateSigningRequest, readPrivateKey, readPrivateKeyPEM, readPrivateRsaKey, readPublicKey, readPublicKeyPEM, readPublicRsaKey, setCertificateStore };
@@ -6253,4 +6253,4 @@ asn1js/build/index.es.js:
6253
6253
  *
6254
6254
  *)
6255
6255
  */
6256
- //# sourceMappingURL=chunk-SNCRM4BA.mjs.map
6256
+ //# sourceMappingURL=chunk-D3SBIIXU.mjs.map
@@ -6,7 +6,7 @@ import {
6
6
  privateKeyToPEM,
7
7
  removeTrailingLF,
8
8
  toPem
9
- } from "./chunk-SNCRM4BA.mjs";
9
+ } from "./chunk-D3SBIIXU.mjs";
10
10
 
11
11
  // source_nodejs/read.ts
12
12
  import assert from "assert";
@@ -170,4 +170,4 @@ export {
170
170
  generatePrivateKeyFile,
171
171
  generatePrivateKeyFileAlternate
172
172
  };
173
- //# sourceMappingURL=chunk-UZNNRQTR.mjs.map
173
+ //# sourceMappingURL=chunk-R33OLRZV.mjs.map