node-opcua-crypto 4.11.0 → 4.15.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.
- package/README.md +15 -20
- package/dist/{chunk-UH5AT3JE.mjs → chunk-C4C76C7T.mjs} +4 -4
- package/dist/chunk-C4C76C7T.mjs.map +1 -0
- package/dist/{chunk-2RCYFHGG.mjs → chunk-F5EAPW2U.mjs} +187 -182
- package/dist/chunk-F5EAPW2U.mjs.map +1 -0
- package/dist/chunk-RQA4DO2Z.mjs +1 -0
- package/dist/chunk-RQA4DO2Z.mjs.map +1 -0
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +181 -176
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -7
- package/dist/source/index.d.mts +1 -15
- package/dist/source/index.d.ts +1 -15
- package/dist/source/index.js +176 -171
- package/dist/source/index.js.map +1 -1
- package/dist/source/index.mjs +5 -6
- package/dist/source/index_web.d.mts +518 -4
- package/dist/source/index_web.d.ts +518 -4
- package/dist/source/index_web.js +187 -177
- package/dist/source/index_web.js.map +1 -1
- package/dist/source/index_web.mjs +5 -3
- package/dist/source_nodejs/index.js +22 -19
- package/dist/source_nodejs/index.js.map +1 -1
- package/dist/source_nodejs/index.mjs +3 -3
- package/package.json +4 -4
- package/dist/chunk-2RCYFHGG.mjs.map +0 -1
- package/dist/chunk-C7PROBPE.mjs +0 -14
- package/dist/chunk-C7PROBPE.mjs.map +0 -1
- package/dist/chunk-UH5AT3JE.mjs.map +0 -1
- package/dist/index_web-C5Oeu9mq.d.mts +0 -503
- package/dist/index_web-D1qc4UN2.d.ts +0 -503
|
@@ -1,4 +1,518 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
import 'crypto';
|
|
4
|
-
import '@peculiar/x509';
|
|
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
|
+
export { c as createPrivateKeyFromNodeJSCrypto, i as isKeyObject } from '../common-CFr95Map.js';
|
|
3
|
+
import { KeyLike } from 'crypto';
|
|
4
|
+
import * as x509 from '@peculiar/x509';
|
|
5
|
+
|
|
6
|
+
declare function publicKeyAndPrivateKeyMatches(certificate: Certificate, privateKey: PrivateKey): boolean;
|
|
7
|
+
declare function certificateMatchesPrivateKey(certificate: Certificate, privateKey: PrivateKey): boolean;
|
|
8
|
+
|
|
9
|
+
interface DirectoryName {
|
|
10
|
+
stateOrProvinceName?: string;
|
|
11
|
+
localityName?: string;
|
|
12
|
+
organizationName?: string;
|
|
13
|
+
organizationUnitName?: string;
|
|
14
|
+
commonName?: string;
|
|
15
|
+
countryName?: string;
|
|
16
|
+
}
|
|
17
|
+
declare function readDirectoryName(buffer: Buffer, block: BlockInfo): DirectoryName;
|
|
18
|
+
|
|
19
|
+
declare enum TagType {
|
|
20
|
+
BOOLEAN = 1,
|
|
21
|
+
INTEGER = 2,
|
|
22
|
+
BIT_STRING = 3,
|
|
23
|
+
OCTET_STRING = 4,
|
|
24
|
+
NULL = 5,
|
|
25
|
+
OBJECT_IDENTIFIER = 6,
|
|
26
|
+
UTF8String = 12,
|
|
27
|
+
NumericString = 18,
|
|
28
|
+
PrintableString = 19,
|
|
29
|
+
TeletexString = 20,
|
|
30
|
+
IA5String = 22,
|
|
31
|
+
UTCTime = 23,
|
|
32
|
+
GeneralizedTime = 24,
|
|
33
|
+
GraphicString = 25,
|
|
34
|
+
VisibleString = 26,
|
|
35
|
+
GeneralString = 27,
|
|
36
|
+
UniversalString = 28,
|
|
37
|
+
BMPString = 30,
|
|
38
|
+
SEQUENCE = 48,
|
|
39
|
+
SET = 49,
|
|
40
|
+
CONTEXT_SPECIFIC0 = 160,
|
|
41
|
+
CONTEXT_SPECIFIC1 = 161,
|
|
42
|
+
CONTEXT_SPECIFIC2 = 162,
|
|
43
|
+
CONTEXT_SPECIFIC3 = 163,
|
|
44
|
+
A4 = 164
|
|
45
|
+
}
|
|
46
|
+
interface BlockInfo {
|
|
47
|
+
tag: TagType | number;
|
|
48
|
+
position: number;
|
|
49
|
+
length: number;
|
|
50
|
+
start: number;
|
|
51
|
+
}
|
|
52
|
+
declare function readTag(buf: Buffer, pos: number): BlockInfo;
|
|
53
|
+
declare function readStruct(buf: Buffer, blockInfo: BlockInfo): BlockInfo[];
|
|
54
|
+
interface AlgorithmIdentifier {
|
|
55
|
+
identifier: string;
|
|
56
|
+
}
|
|
57
|
+
declare function readAlgorithmIdentifier(buffer: Buffer, block: BlockInfo): AlgorithmIdentifier;
|
|
58
|
+
type SignatureValue = 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;
|
|
76
|
+
}
|
|
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;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @module node_opcua_crypto
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
interface AttributeTypeAndValue {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
}
|
|
93
|
+
interface Validity {
|
|
94
|
+
notBefore: Date;
|
|
95
|
+
notAfter: Date;
|
|
96
|
+
}
|
|
97
|
+
interface X509KeyUsage {
|
|
98
|
+
digitalSignature: boolean;
|
|
99
|
+
nonRepudiation: boolean;
|
|
100
|
+
keyEncipherment: boolean;
|
|
101
|
+
dataEncipherment: boolean;
|
|
102
|
+
keyAgreement: boolean;
|
|
103
|
+
keyCertSign: boolean;
|
|
104
|
+
cRLSign: boolean;
|
|
105
|
+
encipherOnly: boolean;
|
|
106
|
+
decipherOnly: boolean;
|
|
107
|
+
}
|
|
108
|
+
interface X509ExtKeyUsage {
|
|
109
|
+
clientAuth: boolean;
|
|
110
|
+
serverAuth: boolean;
|
|
111
|
+
codeSigning: boolean;
|
|
112
|
+
emailProtection: boolean;
|
|
113
|
+
timeStamping: boolean;
|
|
114
|
+
ocspSigning: boolean;
|
|
115
|
+
ipsecEndSystem: boolean;
|
|
116
|
+
ipsecTunnel: boolean;
|
|
117
|
+
ipsecUser: boolean;
|
|
118
|
+
}
|
|
119
|
+
interface SubjectPublicKey {
|
|
120
|
+
modulus: Buffer;
|
|
121
|
+
}
|
|
122
|
+
declare function readExtension(buffer: Buffer, block: BlockInfo): {
|
|
123
|
+
identifier: {
|
|
124
|
+
oid: string;
|
|
125
|
+
name: string;
|
|
126
|
+
};
|
|
127
|
+
value: any;
|
|
128
|
+
};
|
|
129
|
+
interface SubjectPublicKeyInfo {
|
|
130
|
+
algorithm: string;
|
|
131
|
+
keyLength: PublicKeyLength;
|
|
132
|
+
subjectPublicKey: SubjectPublicKey;
|
|
133
|
+
}
|
|
134
|
+
interface BasicConstraints {
|
|
135
|
+
critical: boolean;
|
|
136
|
+
cA: boolean;
|
|
137
|
+
pathLengthConstraint?: number;
|
|
138
|
+
}
|
|
139
|
+
interface AuthorityKeyIdentifier {
|
|
140
|
+
keyIdentifier: string | null;
|
|
141
|
+
authorityCertIssuer: DirectoryName | null;
|
|
142
|
+
authorityCertIssuerFingerPrint: string;
|
|
143
|
+
serial: string | null;
|
|
144
|
+
}
|
|
145
|
+
interface CertificateExtension {
|
|
146
|
+
basicConstraints: BasicConstraints;
|
|
147
|
+
subjectKeyIdentifier?: string;
|
|
148
|
+
authorityKeyIdentifier?: AuthorityKeyIdentifier;
|
|
149
|
+
keyUsage?: X509KeyUsage;
|
|
150
|
+
extKeyUsage?: X509ExtKeyUsage;
|
|
151
|
+
subjectAltName?: any;
|
|
152
|
+
}
|
|
153
|
+
interface TbsCertificate {
|
|
154
|
+
version: number;
|
|
155
|
+
serialNumber: string;
|
|
156
|
+
issuer: any;
|
|
157
|
+
signature: AlgorithmIdentifier;
|
|
158
|
+
validity: Validity;
|
|
159
|
+
subject: DirectoryName;
|
|
160
|
+
subjectFingerPrint: string;
|
|
161
|
+
subjectPublicKeyInfo: SubjectPublicKeyInfo;
|
|
162
|
+
extensions: CertificateExtension | null;
|
|
163
|
+
}
|
|
164
|
+
declare function readTbsCertificate(buffer: Buffer, block: BlockInfo): TbsCertificate;
|
|
165
|
+
interface CertificateInternals {
|
|
166
|
+
tbsCertificate: TbsCertificate;
|
|
167
|
+
signatureAlgorithm: AlgorithmIdentifier;
|
|
168
|
+
signatureValue: SignatureValue;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* explore a certificate structure
|
|
172
|
+
* @param certificate
|
|
173
|
+
* @returns a json object that exhibits the internal data of the certificate
|
|
174
|
+
*/
|
|
175
|
+
declare function exploreCertificate(certificate: Certificate): CertificateInternals;
|
|
176
|
+
/**
|
|
177
|
+
* @method split_der
|
|
178
|
+
* split a multi chain certificates
|
|
179
|
+
* @param certificateChain the certificate chain in der (binary) format}
|
|
180
|
+
* @returns an array of Der , each element of the array is one certificate of the chain
|
|
181
|
+
*/
|
|
182
|
+
declare function split_der(certificateChain: Certificate): Certificate[];
|
|
183
|
+
/**
|
|
184
|
+
* @method combine_der
|
|
185
|
+
* combine an array of certificates into a single blob
|
|
186
|
+
* @param certificates a array with the individual DER certificates of the chain
|
|
187
|
+
* @return a concatenated buffer containing the certificates
|
|
188
|
+
*/
|
|
189
|
+
declare function combine_der(certificates: Certificate[]): Certificate;
|
|
190
|
+
|
|
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
|
+
}
|
|
207
|
+
/**
|
|
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
|
|
222
|
+
*/
|
|
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
|
|
230
|
+
}
|
|
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;
|
|
239
|
+
/**
|
|
240
|
+
* extract the publickey from a certificate
|
|
241
|
+
* @async
|
|
242
|
+
*/
|
|
243
|
+
declare function extractPublicKeyFromCertificate(certificate: CertificatePEM | Certificate, callback: (err: Error | null, publicKeyPEM?: PublicKeyPEM) => void): void;
|
|
244
|
+
|
|
245
|
+
/***
|
|
246
|
+
* @method rsaLengthPrivateKey
|
|
247
|
+
* A very expensive way to determine the rsa key length ( i.e 2048bits or 1024bits)
|
|
248
|
+
* @param key a PEM public key or a PEM rsa private key
|
|
249
|
+
* @return the key length in bytes.
|
|
250
|
+
*/
|
|
251
|
+
declare function rsaLengthPrivateKey(key: PrivateKey): number;
|
|
252
|
+
/**
|
|
253
|
+
* @method toPem2
|
|
254
|
+
* @param raw_key
|
|
255
|
+
* @param pem
|
|
256
|
+
*
|
|
257
|
+
*
|
|
258
|
+
* @return a PEM string containing the Private Key
|
|
259
|
+
*
|
|
260
|
+
* Note: a Pem key can be converted back to a private key object using coercePrivateKey
|
|
261
|
+
*
|
|
262
|
+
*/
|
|
263
|
+
declare function toPem2(raw_key: Buffer | string | KeyObject | PrivateKey, pem: string): string;
|
|
264
|
+
declare function coercePrivateKeyPem(privateKey: PrivateKey): PrivateKeyPEM;
|
|
265
|
+
declare function coercePublicKeyPem(publicKey: PublicKey | PublicKeyPEM): PublicKeyPEM;
|
|
266
|
+
declare function coerceRsaPublicKeyPem(publicKey: PublicKey | KeyObject | PublicKeyPEM): PublicKeyPEM;
|
|
267
|
+
declare function rsaLengthPublicKey(key: PublicKeyPEM | PublicKey): number;
|
|
268
|
+
declare function rsaLengthRsaPublicKey(key: PublicKeyPEM | PublicKey): number;
|
|
269
|
+
|
|
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;
|
|
341
|
+
|
|
342
|
+
type Version = string;
|
|
343
|
+
type Name = string;
|
|
344
|
+
type CertificateSerialNumber = string;
|
|
345
|
+
type Extensions = Record<string, unknown>;
|
|
346
|
+
interface RevokedCertificate {
|
|
347
|
+
userCertificate: CertificateSerialNumber;
|
|
348
|
+
revocationDate: Date;
|
|
349
|
+
crlEntryExtensions?: Extensions;
|
|
350
|
+
}
|
|
351
|
+
interface TBSCertList {
|
|
352
|
+
version?: Version;
|
|
353
|
+
signature: AlgorithmIdentifier;
|
|
354
|
+
issuer: Name;
|
|
355
|
+
issuerFingerprint: string;
|
|
356
|
+
thisUpdate: Date;
|
|
357
|
+
nextUpdate?: Date;
|
|
358
|
+
revokedCertificates: RevokedCertificate[];
|
|
359
|
+
}
|
|
360
|
+
interface CertificateRevocationListInfo {
|
|
361
|
+
tbsCertList: TBSCertList;
|
|
362
|
+
signatureAlgorithm: AlgorithmIdentifier;
|
|
363
|
+
signatureValue: Buffer;
|
|
364
|
+
}
|
|
365
|
+
declare function readNameForCrl(buffer: Buffer, block: BlockInfo): DirectoryName;
|
|
366
|
+
declare function exploreCertificateRevocationList(crl: CertificateRevocationList): CertificateRevocationListInfo;
|
|
367
|
+
|
|
368
|
+
interface ExtensionRequest {
|
|
369
|
+
basicConstraints: BasicConstraints;
|
|
370
|
+
keyUsage: X509KeyUsage;
|
|
371
|
+
subjectAltName: any;
|
|
372
|
+
}
|
|
373
|
+
interface CertificateSigningRequestInfo {
|
|
374
|
+
extensionRequest: ExtensionRequest;
|
|
375
|
+
}
|
|
376
|
+
declare function readCertificationRequestInfo(buffer: Buffer, block: BlockInfo): CertificateSigningRequestInfo;
|
|
377
|
+
declare function exploreCertificateSigningRequest(crl: Buffer): CertificateSigningRequestInfo;
|
|
378
|
+
|
|
379
|
+
interface PrivateKeyInternals {
|
|
380
|
+
/***/
|
|
381
|
+
version: Buffer;
|
|
382
|
+
modulus: Buffer;
|
|
383
|
+
publicExponent: Buffer;
|
|
384
|
+
privateExponent: Buffer;
|
|
385
|
+
prime1: Buffer;
|
|
386
|
+
prime2: Buffer;
|
|
387
|
+
exponent1: Buffer;
|
|
388
|
+
exponent2: Buffer;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
*
|
|
392
|
+
* @param privateKey RSAPrivateKey ::= SEQUENCE {
|
|
393
|
+
* version Version,
|
|
394
|
+
* modulus INTEGER, -- n
|
|
395
|
+
* publicExponent INTEGER, -- e
|
|
396
|
+
* privateExponent INTEGER, -- d
|
|
397
|
+
* prime1 INTEGER, -- p
|
|
398
|
+
* prime2 INTEGER, -- q
|
|
399
|
+
* exponent1 INTEGER, -- d mod (p-1)
|
|
400
|
+
* exponent2 INTEGER, -- d mod (q-1)
|
|
401
|
+
* coefficient INTEGER, -- (inverse of q) mod p
|
|
402
|
+
* otherPrimeInfos OtherPrimeInfos OPTIONAL
|
|
403
|
+
}
|
|
404
|
+
*/
|
|
405
|
+
declare function explorePrivateKey(privateKey2: PrivateKey): PrivateKeyInternals;
|
|
406
|
+
|
|
407
|
+
declare function makePrivateKeyFromPem(privateKeyInPem: string): PrivateKey;
|
|
408
|
+
|
|
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
|
+
}
|
|
420
|
+
/**
|
|
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.
|
|
423
|
+
*/
|
|
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;
|
|
449
|
+
/**
|
|
450
|
+
*
|
|
451
|
+
* @private
|
|
452
|
+
*/
|
|
453
|
+
declare function _coercePrivateKey(privateKey: any): Promise<KeyObject>;
|
|
454
|
+
|
|
455
|
+
interface CreateCertificateSigningRequestOptions {
|
|
456
|
+
privateKey: CryptoKey;
|
|
457
|
+
notBefore?: Date;
|
|
458
|
+
notAfter?: Date;
|
|
459
|
+
validity?: number;
|
|
460
|
+
subject?: string;
|
|
461
|
+
dns?: string[];
|
|
462
|
+
ip?: string[];
|
|
463
|
+
applicationUri?: string;
|
|
464
|
+
purpose: CertificatePurpose;
|
|
465
|
+
}
|
|
466
|
+
declare function createCertificateSigningRequest({ privateKey, subject, dns, ip, applicationUri, purpose, }: CreateCertificateSigningRequestOptions): Promise<{
|
|
467
|
+
csr: string;
|
|
468
|
+
der: x509.Pkcs10CertificateRequest;
|
|
469
|
+
}>;
|
|
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
|
+
|
|
486
|
+
interface CreateSelfSignCertificateOptions {
|
|
487
|
+
privateKey: CryptoKey;
|
|
488
|
+
notBefore?: Date;
|
|
489
|
+
notAfter?: Date;
|
|
490
|
+
validity?: number;
|
|
491
|
+
subject?: string;
|
|
492
|
+
dns?: string[];
|
|
493
|
+
ip?: string[];
|
|
494
|
+
applicationUri?: string;
|
|
495
|
+
purpose: CertificatePurpose;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
*
|
|
499
|
+
* construct a self-signed certificate
|
|
500
|
+
*/
|
|
501
|
+
declare function createSelfSignedCertificate({ privateKey, notAfter, notBefore, validity, subject, dns, ip, applicationUri, purpose, }: CreateSelfSignCertificateOptions): Promise<{
|
|
502
|
+
cert: string;
|
|
503
|
+
der: x509.X509Certificate;
|
|
504
|
+
}>;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* @module node_opcua_crypto
|
|
508
|
+
*/
|
|
509
|
+
|
|
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
|
+
};
|
|
517
|
+
|
|
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 };
|