node-opcua-crypto 4.9.4 → 4.11.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/LICENSE +23 -23
- package/README.md +119 -114
- package/dist/{chunk-WLW5XUML.mjs → chunk-2RCYFHGG.mjs} +755 -724
- package/dist/chunk-2RCYFHGG.mjs.map +1 -0
- package/dist/chunk-C7PROBPE.mjs +14 -0
- package/dist/chunk-C7PROBPE.mjs.map +1 -0
- package/dist/{chunk-UEV3YRUV.mjs → chunk-UH5AT3JE.mjs} +9 -15
- package/dist/chunk-UH5AT3JE.mjs.map +1 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +553 -552
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -52
- package/dist/index_web-C5Oeu9mq.d.mts +503 -0
- package/dist/index_web-D1qc4UN2.d.ts +503 -0
- package/dist/source/index.d.mts +11 -516
- package/dist/source/index.d.ts +11 -516
- package/dist/source/index.js +537 -529
- package/dist/source/index.js.map +1 -1
- package/dist/source/index.mjs +9 -50
- package/dist/source/index_web.d.mts +1 -1
- package/dist/source/index_web.d.ts +1 -1
- package/dist/source/index_web.js +525 -522
- package/dist/source/index_web.js.map +1 -1
- package/dist/source/index_web.mjs +5 -49
- package/dist/source_nodejs/index.d.mts +1 -2
- package/dist/source_nodejs/index.d.ts +1 -2
- package/dist/source_nodejs/index.js +33 -41
- package/dist/source_nodejs/index.js.map +1 -1
- package/dist/source_nodejs/index.mjs +3 -5
- package/package.json +9 -4
- package/dist/chunk-5NV4OKIV.mjs +0 -1
- package/dist/chunk-5NV4OKIV.mjs.map +0 -1
- package/dist/chunk-UEV3YRUV.mjs.map +0 -1
- package/dist/chunk-WLW5XUML.mjs.map +0 -1
- package/dist/index_web.d.mts +0 -4
- package/dist/index_web.d.ts +0 -4
- package/dist/index_web.js +0 -6365
- package/dist/index_web.js.map +0 -1
- package/dist/index_web.mjs +0 -192
- package/dist/index_web.mjs.map +0 -1
- package/index.mjs +0 -1
- package/index_web.ts +0 -1
- package/web.d.ts +0 -1
- package/web.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
generatePrivateKeyFile,
|
|
3
3
|
generatePrivateKeyFileAlternate,
|
|
4
4
|
getCertificateStore,
|
|
5
|
-
makePrivateKeyThumbPrint,
|
|
6
5
|
readCertificate,
|
|
7
6
|
readCertificatePEM,
|
|
8
7
|
readCertificateRevocationList,
|
|
@@ -14,36 +13,18 @@ import {
|
|
|
14
13
|
readPublicKeyPEM,
|
|
15
14
|
readPublicRsaKey,
|
|
16
15
|
setCertificateStore
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import
|
|
16
|
+
} from "./chunk-UH5AT3JE.mjs";
|
|
17
|
+
import {
|
|
18
|
+
asn1
|
|
19
|
+
} from "./chunk-C7PROBPE.mjs";
|
|
19
20
|
import {
|
|
20
21
|
CertificatePurpose,
|
|
21
22
|
PaddingAlgorithm,
|
|
22
23
|
RSA_PKCS1_OAEP_PADDING,
|
|
23
24
|
RSA_PKCS1_PADDING,
|
|
24
25
|
Subject,
|
|
25
|
-
TagType,
|
|
26
26
|
_coercePrivateKey,
|
|
27
|
-
_findBlockAtIndex,
|
|
28
|
-
_getBlock,
|
|
29
|
-
_readAlgorithmIdentifier,
|
|
30
|
-
_readBitString,
|
|
31
|
-
_readBooleanValue,
|
|
32
|
-
_readDirectoryName,
|
|
33
|
-
_readECCAlgorithmIdentifier,
|
|
34
27
|
_readExtension,
|
|
35
|
-
_readIntegerAsByteString,
|
|
36
|
-
_readIntegerValue,
|
|
37
|
-
_readListOfInteger,
|
|
38
|
-
_readLongIntegerValue,
|
|
39
|
-
_readObjectIdentifier,
|
|
40
|
-
_readOctetString,
|
|
41
|
-
_readSignatureValue,
|
|
42
|
-
_readSignatureValueBin,
|
|
43
|
-
_readStruct,
|
|
44
|
-
_readTime,
|
|
45
|
-
_readValue,
|
|
46
|
-
_readVersionValue,
|
|
47
28
|
certificateMatchesPrivateKey,
|
|
48
29
|
coerceCertificate,
|
|
49
30
|
coerceCertificatePem,
|
|
@@ -52,7 +33,6 @@ import {
|
|
|
52
33
|
coercePublicKeyPem,
|
|
53
34
|
coerceRsaPublicKeyPem,
|
|
54
35
|
combine_der,
|
|
55
|
-
compactDirectoryName,
|
|
56
36
|
computeDerivedKeys,
|
|
57
37
|
computePaddingFooter,
|
|
58
38
|
convertPEMtoDER,
|
|
@@ -62,6 +42,7 @@ import {
|
|
|
62
42
|
decryptBufferWithDerivedKeys,
|
|
63
43
|
derToPrivateKey,
|
|
64
44
|
encryptBufferWithDerivedKeys,
|
|
45
|
+
exploreAsn1,
|
|
65
46
|
exploreCertificate,
|
|
66
47
|
exploreCertificateInfo,
|
|
67
48
|
exploreCertificateRevocationList,
|
|
@@ -69,7 +50,6 @@ import {
|
|
|
69
50
|
explorePrivateKey,
|
|
70
51
|
extractPublicKeyFromCertificate,
|
|
71
52
|
extractPublicKeyFromCertificateSync,
|
|
72
|
-
formatBuffer2DigitHexWithColum,
|
|
73
53
|
generateKeyPair,
|
|
74
54
|
generatePrivateKey,
|
|
75
55
|
hexDump,
|
|
@@ -78,9 +58,9 @@ import {
|
|
|
78
58
|
makeMessageChunkSignature,
|
|
79
59
|
makeMessageChunkSignatureWithDerivedKeys,
|
|
80
60
|
makePrivateKeyFromPem,
|
|
61
|
+
makePrivateKeyThumbPrint,
|
|
81
62
|
makePseudoRandomBuffer,
|
|
82
63
|
makeSHA1Thumbprint,
|
|
83
|
-
parseBitString,
|
|
84
64
|
pemToPrivateKey,
|
|
85
65
|
privateDecrypt,
|
|
86
66
|
privateDecrypt_long,
|
|
@@ -92,7 +72,6 @@ import {
|
|
|
92
72
|
publicKeyAndPrivateKeyMatches,
|
|
93
73
|
readCertificationRequestInfo,
|
|
94
74
|
readNameForCrl,
|
|
95
|
-
readTag,
|
|
96
75
|
readTbsCertificate,
|
|
97
76
|
reduceLength,
|
|
98
77
|
removePadding,
|
|
@@ -110,35 +89,16 @@ import {
|
|
|
110
89
|
verifyChunkSignature,
|
|
111
90
|
verifyChunkSignatureWithDerivedKeys,
|
|
112
91
|
verifyMessageChunkSignature
|
|
113
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-2RCYFHGG.mjs";
|
|
114
93
|
export {
|
|
115
94
|
CertificatePurpose,
|
|
116
95
|
PaddingAlgorithm,
|
|
117
96
|
RSA_PKCS1_OAEP_PADDING,
|
|
118
97
|
RSA_PKCS1_PADDING,
|
|
119
98
|
Subject,
|
|
120
|
-
TagType,
|
|
121
99
|
_coercePrivateKey,
|
|
122
|
-
_findBlockAtIndex,
|
|
123
|
-
_getBlock,
|
|
124
|
-
_readAlgorithmIdentifier,
|
|
125
|
-
_readBitString,
|
|
126
|
-
_readBooleanValue,
|
|
127
|
-
_readDirectoryName,
|
|
128
|
-
_readECCAlgorithmIdentifier,
|
|
129
100
|
_readExtension,
|
|
130
|
-
|
|
131
|
-
_readIntegerValue,
|
|
132
|
-
_readListOfInteger,
|
|
133
|
-
_readLongIntegerValue,
|
|
134
|
-
_readObjectIdentifier,
|
|
135
|
-
_readOctetString,
|
|
136
|
-
_readSignatureValue,
|
|
137
|
-
_readSignatureValueBin,
|
|
138
|
-
_readStruct,
|
|
139
|
-
_readTime,
|
|
140
|
-
_readValue,
|
|
141
|
-
_readVersionValue,
|
|
101
|
+
asn1,
|
|
142
102
|
certificateMatchesPrivateKey,
|
|
143
103
|
coerceCertificate,
|
|
144
104
|
coerceCertificatePem,
|
|
@@ -147,7 +107,6 @@ export {
|
|
|
147
107
|
coercePublicKeyPem,
|
|
148
108
|
coerceRsaPublicKeyPem,
|
|
149
109
|
combine_der,
|
|
150
|
-
compactDirectoryName,
|
|
151
110
|
computeDerivedKeys,
|
|
152
111
|
computePaddingFooter,
|
|
153
112
|
convertPEMtoDER,
|
|
@@ -157,6 +116,7 @@ export {
|
|
|
157
116
|
decryptBufferWithDerivedKeys,
|
|
158
117
|
derToPrivateKey,
|
|
159
118
|
encryptBufferWithDerivedKeys,
|
|
119
|
+
exploreAsn1,
|
|
160
120
|
exploreCertificate,
|
|
161
121
|
exploreCertificateInfo,
|
|
162
122
|
exploreCertificateRevocationList,
|
|
@@ -164,7 +124,6 @@ export {
|
|
|
164
124
|
explorePrivateKey,
|
|
165
125
|
extractPublicKeyFromCertificate,
|
|
166
126
|
extractPublicKeyFromCertificateSync,
|
|
167
|
-
formatBuffer2DigitHexWithColum,
|
|
168
127
|
generateKeyPair,
|
|
169
128
|
generatePrivateKey,
|
|
170
129
|
generatePrivateKeyFile,
|
|
@@ -179,7 +138,6 @@ export {
|
|
|
179
138
|
makePrivateKeyThumbPrint,
|
|
180
139
|
makePseudoRandomBuffer,
|
|
181
140
|
makeSHA1Thumbprint,
|
|
182
|
-
parseBitString,
|
|
183
141
|
pemToPrivateKey,
|
|
184
142
|
privateDecrypt,
|
|
185
143
|
privateDecrypt_long,
|
|
@@ -201,7 +159,6 @@ export {
|
|
|
201
159
|
readPublicKey,
|
|
202
160
|
readPublicKeyPEM,
|
|
203
161
|
readPublicRsaKey,
|
|
204
|
-
readTag,
|
|
205
162
|
readTbsCertificate,
|
|
206
163
|
reduceLength,
|
|
207
164
|
removePadding,
|
|
@@ -0,0 +1,503 @@
|
|
|
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.mjs';
|
|
2
|
+
import { KeyLike } from 'crypto';
|
|
3
|
+
import * as x509 from '@peculiar/x509';
|
|
4
|
+
|
|
5
|
+
declare function publicKeyAndPrivateKeyMatches(certificate: Certificate, privateKey: PrivateKey): boolean;
|
|
6
|
+
declare function certificateMatchesPrivateKey(certificate: Certificate, privateKey: PrivateKey): boolean;
|
|
7
|
+
|
|
8
|
+
declare enum TagType {
|
|
9
|
+
BOOLEAN = 1,
|
|
10
|
+
INTEGER = 2,
|
|
11
|
+
BIT_STRING = 3,
|
|
12
|
+
OCTET_STRING = 4,
|
|
13
|
+
NULL = 5,
|
|
14
|
+
OBJECT_IDENTIFIER = 6,
|
|
15
|
+
UTF8String = 12,
|
|
16
|
+
NumericString = 18,
|
|
17
|
+
PrintableString = 19,
|
|
18
|
+
TeletexString = 20,
|
|
19
|
+
IA5String = 22,
|
|
20
|
+
UTCTime = 23,
|
|
21
|
+
GeneralizedTime = 24,
|
|
22
|
+
GraphicString = 25,
|
|
23
|
+
VisibleString = 26,
|
|
24
|
+
GeneralString = 27,
|
|
25
|
+
UniversalString = 28,
|
|
26
|
+
BMPString = 30,
|
|
27
|
+
SEQUENCE = 48,
|
|
28
|
+
SET = 49,
|
|
29
|
+
CONTEXT_SPECIFIC0 = 160,
|
|
30
|
+
CONTEXT_SPECIFIC1 = 161,
|
|
31
|
+
CONTEXT_SPECIFIC2 = 162,
|
|
32
|
+
CONTEXT_SPECIFIC3 = 163,
|
|
33
|
+
A4 = 164
|
|
34
|
+
}
|
|
35
|
+
interface BlockInfo {
|
|
36
|
+
tag: TagType | number;
|
|
37
|
+
position: number;
|
|
38
|
+
length: number;
|
|
39
|
+
start: number;
|
|
40
|
+
}
|
|
41
|
+
declare function readTag(buf: Buffer, pos: number): BlockInfo;
|
|
42
|
+
declare function readStruct(buf: Buffer, blockInfo: BlockInfo): BlockInfo[];
|
|
43
|
+
interface AlgorithmIdentifier {
|
|
44
|
+
identifier: string;
|
|
45
|
+
}
|
|
46
|
+
declare function readAlgorithmIdentifier(buffer: Buffer, block: BlockInfo): AlgorithmIdentifier;
|
|
47
|
+
type SignatureValue = string;
|
|
48
|
+
declare function readSignatureValueBin(buffer: Buffer, block: BlockInfo): Buffer;
|
|
49
|
+
interface DirectoryName {
|
|
50
|
+
stateOrProvinceName?: string;
|
|
51
|
+
localityName?: string;
|
|
52
|
+
organizationName?: string;
|
|
53
|
+
organizationUnitName?: string;
|
|
54
|
+
commonName?: string;
|
|
55
|
+
countryName?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type PublicKeyLength = 64 | 96 | 128 | 256 | 384 | 512;
|
|
59
|
+
/**
|
|
60
|
+
* A structure exposing useful information about a certificate
|
|
61
|
+
*/
|
|
62
|
+
interface CertificateInfo {
|
|
63
|
+
/** the public key length in bits */
|
|
64
|
+
publicKeyLength: PublicKeyLength;
|
|
65
|
+
/** the date at which the certificate starts to be valid */
|
|
66
|
+
notBefore: Date;
|
|
67
|
+
/** the date after which the certificate is not valid any more */
|
|
68
|
+
notAfter: Date;
|
|
69
|
+
/** info about certificate owner */
|
|
70
|
+
subject: DirectoryName;
|
|
71
|
+
/** public key */
|
|
72
|
+
publicKey: SubjectPublicKey;
|
|
73
|
+
}
|
|
74
|
+
declare function coerceCertificate(certificate: Certificate | CertificatePEM): Certificate;
|
|
75
|
+
/**
|
|
76
|
+
* @method exploreCertificateInfo
|
|
77
|
+
* returns useful information about the certificate such as public key length, start date and end of validity date,
|
|
78
|
+
* and CN
|
|
79
|
+
* @param certificate the certificate to explore
|
|
80
|
+
*/
|
|
81
|
+
declare function exploreCertificateInfo(certificate: Certificate | CertificatePEM): CertificateInfo;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @module node_opcua_crypto
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
interface AttributeTypeAndValue {
|
|
88
|
+
[key: string]: any;
|
|
89
|
+
}
|
|
90
|
+
interface Validity {
|
|
91
|
+
notBefore: Date;
|
|
92
|
+
notAfter: Date;
|
|
93
|
+
}
|
|
94
|
+
interface X509KeyUsage {
|
|
95
|
+
digitalSignature: boolean;
|
|
96
|
+
nonRepudiation: boolean;
|
|
97
|
+
keyEncipherment: boolean;
|
|
98
|
+
dataEncipherment: boolean;
|
|
99
|
+
keyAgreement: boolean;
|
|
100
|
+
keyCertSign: boolean;
|
|
101
|
+
cRLSign: boolean;
|
|
102
|
+
encipherOnly: boolean;
|
|
103
|
+
decipherOnly: boolean;
|
|
104
|
+
}
|
|
105
|
+
interface X509ExtKeyUsage {
|
|
106
|
+
clientAuth: boolean;
|
|
107
|
+
serverAuth: boolean;
|
|
108
|
+
codeSigning: boolean;
|
|
109
|
+
emailProtection: boolean;
|
|
110
|
+
timeStamping: boolean;
|
|
111
|
+
ocspSigning: boolean;
|
|
112
|
+
ipsecEndSystem: boolean;
|
|
113
|
+
ipsecTunnel: boolean;
|
|
114
|
+
ipsecUser: boolean;
|
|
115
|
+
}
|
|
116
|
+
interface SubjectPublicKey {
|
|
117
|
+
modulus: Buffer;
|
|
118
|
+
}
|
|
119
|
+
declare function _readExtension(buffer: Buffer, block: BlockInfo): {
|
|
120
|
+
identifier: {
|
|
121
|
+
oid: string;
|
|
122
|
+
name: string;
|
|
123
|
+
};
|
|
124
|
+
value: any;
|
|
125
|
+
};
|
|
126
|
+
interface SubjectPublicKeyInfo {
|
|
127
|
+
algorithm: string;
|
|
128
|
+
keyLength: PublicKeyLength;
|
|
129
|
+
subjectPublicKey: SubjectPublicKey;
|
|
130
|
+
}
|
|
131
|
+
interface BasicConstraints {
|
|
132
|
+
critical: boolean;
|
|
133
|
+
cA: boolean;
|
|
134
|
+
pathLengthConstraint?: number;
|
|
135
|
+
}
|
|
136
|
+
interface AuthorityKeyIdentifier {
|
|
137
|
+
keyIdentifier: string | null;
|
|
138
|
+
authorityCertIssuer: DirectoryName | null;
|
|
139
|
+
authorityCertIssuerFingerPrint: string;
|
|
140
|
+
serial: string | null;
|
|
141
|
+
}
|
|
142
|
+
interface CertificateExtension {
|
|
143
|
+
basicConstraints: BasicConstraints;
|
|
144
|
+
subjectKeyIdentifier?: string;
|
|
145
|
+
authorityKeyIdentifier?: AuthorityKeyIdentifier;
|
|
146
|
+
keyUsage?: X509KeyUsage;
|
|
147
|
+
extKeyUsage?: X509ExtKeyUsage;
|
|
148
|
+
subjectAltName?: any;
|
|
149
|
+
}
|
|
150
|
+
interface TbsCertificate {
|
|
151
|
+
version: number;
|
|
152
|
+
serialNumber: string;
|
|
153
|
+
issuer: any;
|
|
154
|
+
signature: AlgorithmIdentifier;
|
|
155
|
+
validity: Validity;
|
|
156
|
+
subject: DirectoryName;
|
|
157
|
+
subjectFingerPrint: string;
|
|
158
|
+
subjectPublicKeyInfo: SubjectPublicKeyInfo;
|
|
159
|
+
extensions: CertificateExtension | null;
|
|
160
|
+
}
|
|
161
|
+
declare function readTbsCertificate(buffer: Buffer, block: BlockInfo): TbsCertificate;
|
|
162
|
+
interface CertificateInternals {
|
|
163
|
+
tbsCertificate: TbsCertificate;
|
|
164
|
+
signatureAlgorithm: AlgorithmIdentifier;
|
|
165
|
+
signatureValue: SignatureValue;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* explore a certificate structure
|
|
169
|
+
* @param certificate
|
|
170
|
+
* @returns a json object that exhibits the internal data of the certificate
|
|
171
|
+
*/
|
|
172
|
+
declare function exploreCertificate(certificate: Certificate): CertificateInternals;
|
|
173
|
+
/**
|
|
174
|
+
* @method split_der
|
|
175
|
+
* split a multi chain certificates
|
|
176
|
+
* @param certificateChain the certificate chain in der (binary) format}
|
|
177
|
+
* @returns an array of Der , each element of the array is one certificate of the chain
|
|
178
|
+
*/
|
|
179
|
+
declare function split_der(certificateChain: Certificate): Certificate[];
|
|
180
|
+
/**
|
|
181
|
+
* @method combine_der
|
|
182
|
+
* combine an array of certificates into a single blob
|
|
183
|
+
* @param certificates a array with the individual DER certificates of the chain
|
|
184
|
+
* @return a concatenated buffer containing the certificates
|
|
185
|
+
*/
|
|
186
|
+
declare function combine_der(certificates: Certificate[]): Certificate;
|
|
187
|
+
|
|
188
|
+
declare function identifyPemType(rawKey: Buffer | string): undefined | string;
|
|
189
|
+
declare function removeTrailingLF(str: string): string;
|
|
190
|
+
declare function toPem(raw_key: Buffer | string, pem: string): string;
|
|
191
|
+
declare function convertPEMtoDER(raw_key: PEM): DER;
|
|
192
|
+
declare function hexDump(buffer: Buffer, width?: number): string;
|
|
193
|
+
interface MakeMessageChunkSignatureOptions {
|
|
194
|
+
signatureLength: number;
|
|
195
|
+
algorithm: string;
|
|
196
|
+
privateKey: PrivateKey;
|
|
197
|
+
}
|
|
198
|
+
declare function makeMessageChunkSignature(chunk: Buffer, options: MakeMessageChunkSignatureOptions): Buffer;
|
|
199
|
+
interface VerifyMessageChunkSignatureOptions {
|
|
200
|
+
signatureLength?: number;
|
|
201
|
+
algorithm: string;
|
|
202
|
+
publicKey: PublicKeyPEM;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* @method verifyMessageChunkSignature
|
|
206
|
+
*
|
|
207
|
+
* const signer = {
|
|
208
|
+
* signatureLength : 128,
|
|
209
|
+
* algorithm : "RSA-SHA256",
|
|
210
|
+
* publicKey: "qsdqsdqsd"
|
|
211
|
+
* };
|
|
212
|
+
* @param blockToVerify
|
|
213
|
+
* @param signature
|
|
214
|
+
* @param options
|
|
215
|
+
* @param options.signatureLength
|
|
216
|
+
* @param options.algorithm for example "RSA-SHA256"
|
|
217
|
+
* @param options.publicKey
|
|
218
|
+
* @return true if the signature is valid
|
|
219
|
+
*/
|
|
220
|
+
declare function verifyMessageChunkSignature(blockToVerify: Buffer, signature: Signature, options: VerifyMessageChunkSignatureOptions): boolean;
|
|
221
|
+
declare function makeSHA1Thumbprint(buffer: Buffer): Signature;
|
|
222
|
+
declare const RSA_PKCS1_OAEP_PADDING: number;
|
|
223
|
+
declare const RSA_PKCS1_PADDING: number;
|
|
224
|
+
declare enum PaddingAlgorithm {
|
|
225
|
+
RSA_PKCS1_OAEP_PADDING = 4,
|
|
226
|
+
RSA_PKCS1_PADDING = 1
|
|
227
|
+
}
|
|
228
|
+
declare function publicEncrypt_native(buffer: Buffer, publicKey: KeyLike, algorithm?: PaddingAlgorithm): Buffer;
|
|
229
|
+
declare function privateDecrypt_native(buffer: Buffer, privateKey: PrivateKey, algorithm?: PaddingAlgorithm): Buffer;
|
|
230
|
+
declare const publicEncrypt: typeof publicEncrypt_native;
|
|
231
|
+
declare const privateDecrypt: typeof privateDecrypt_native;
|
|
232
|
+
declare function publicEncrypt_long(buffer: Buffer, publicKey: KeyLike, blockSize: number, padding?: number, paddingAlgorithm?: PaddingAlgorithm): Buffer;
|
|
233
|
+
declare function privateDecrypt_long(buffer: Buffer, privateKey: PrivateKey, blockSize: number, paddingAlgorithm?: number): Buffer;
|
|
234
|
+
declare function coerceCertificatePem(certificate: Certificate | CertificatePEM): CertificatePEM;
|
|
235
|
+
declare function extractPublicKeyFromCertificateSync(certificate: Certificate | CertificatePEM): PublicKeyPEM;
|
|
236
|
+
/**
|
|
237
|
+
* extract the publickey from a certificate
|
|
238
|
+
* @async
|
|
239
|
+
*/
|
|
240
|
+
declare function extractPublicKeyFromCertificate(certificate: CertificatePEM | Certificate, callback: (err: Error | null, publicKeyPEM?: PublicKeyPEM) => void): void;
|
|
241
|
+
|
|
242
|
+
/***
|
|
243
|
+
* @method rsaLengthPrivateKey
|
|
244
|
+
* A very expensive way to determine the rsa key length ( i.e 2048bits or 1024bits)
|
|
245
|
+
* @param key a PEM public key or a PEM rsa private key
|
|
246
|
+
* @return the key length in bytes.
|
|
247
|
+
*/
|
|
248
|
+
declare function rsaLengthPrivateKey(key: PrivateKey): number;
|
|
249
|
+
/**
|
|
250
|
+
* @method toPem2
|
|
251
|
+
* @param raw_key
|
|
252
|
+
* @param pem
|
|
253
|
+
*
|
|
254
|
+
*
|
|
255
|
+
* @return a PEM string containing the Private Key
|
|
256
|
+
*
|
|
257
|
+
* Note: a Pem key can be converted back to a private key object using coercePrivateKey
|
|
258
|
+
*
|
|
259
|
+
*/
|
|
260
|
+
declare function toPem2(raw_key: Buffer | string | KeyObject | PrivateKey, pem: string): string;
|
|
261
|
+
declare function coercePrivateKeyPem(privateKey: PrivateKey): PrivateKeyPEM;
|
|
262
|
+
declare function coercePublicKeyPem(publicKey: PublicKey | PublicKeyPEM): PublicKeyPEM;
|
|
263
|
+
declare function coerceRsaPublicKeyPem(publicKey: PublicKey | KeyObject | PublicKeyPEM): PublicKeyPEM;
|
|
264
|
+
declare function rsaLengthPublicKey(key: PublicKeyPEM | PublicKey): number;
|
|
265
|
+
declare function rsaLengthRsaPublicKey(key: PublicKeyPEM | PublicKey): number;
|
|
266
|
+
|
|
267
|
+
declare function makePseudoRandomBuffer(secret: Nonce, seed: Nonce, minLength: number, sha1or256: "SHA1" | "SHA256"): Buffer;
|
|
268
|
+
interface ComputeDerivedKeysOptions {
|
|
269
|
+
signatureLength: number;
|
|
270
|
+
signingKeyLength: number;
|
|
271
|
+
encryptingKeyLength: number;
|
|
272
|
+
encryptingBlockSize: number;
|
|
273
|
+
algorithm: string;
|
|
274
|
+
sha1or256?: "SHA1" | "SHA256";
|
|
275
|
+
}
|
|
276
|
+
interface DerivedKeys extends ComputeDerivedKeysOptions {
|
|
277
|
+
signatureLength: number;
|
|
278
|
+
signingKeyLength: number;
|
|
279
|
+
encryptingKeyLength: number;
|
|
280
|
+
encryptingBlockSize: number;
|
|
281
|
+
algorithm: string;
|
|
282
|
+
sha1or256: "SHA1" | "SHA256";
|
|
283
|
+
signingKey: Buffer;
|
|
284
|
+
encryptingKey: Buffer;
|
|
285
|
+
initializationVector: Buffer;
|
|
286
|
+
}
|
|
287
|
+
declare function computeDerivedKeys(secret: Nonce, seed: Nonce, options: ComputeDerivedKeysOptions): DerivedKeys;
|
|
288
|
+
/**
|
|
289
|
+
* @method reduceLength
|
|
290
|
+
* @param buffer
|
|
291
|
+
* @param byteToRemove
|
|
292
|
+
* @return buffer
|
|
293
|
+
*/
|
|
294
|
+
declare function reduceLength(buffer: Buffer, byteToRemove: number): Buffer;
|
|
295
|
+
/**
|
|
296
|
+
* @method removePadding
|
|
297
|
+
* @param buffer
|
|
298
|
+
* @return buffer with padding removed
|
|
299
|
+
*/
|
|
300
|
+
declare function removePadding(buffer: Buffer): Buffer;
|
|
301
|
+
type VerifyChunkSignatureOptions = VerifyMessageChunkSignatureOptions;
|
|
302
|
+
/**
|
|
303
|
+
* @method verifyChunkSignature
|
|
304
|
+
*
|
|
305
|
+
* const signer = {
|
|
306
|
+
* signatureLength : 128,
|
|
307
|
+
* algorithm : "RSA-SHA256",
|
|
308
|
+
* public_key: "qsdqsdqsd"
|
|
309
|
+
* };
|
|
310
|
+
*
|
|
311
|
+
* @param chunk The message chunk to verify.
|
|
312
|
+
* @param options
|
|
313
|
+
* @param options.signatureLength
|
|
314
|
+
* @param options.algorithm the algorithm.
|
|
315
|
+
* @param options.publicKey
|
|
316
|
+
* @return {*}
|
|
317
|
+
*/
|
|
318
|
+
declare function verifyChunkSignature(chunk: Buffer, options: VerifyChunkSignatureOptions): boolean;
|
|
319
|
+
declare function computePaddingFooter(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
|
|
320
|
+
declare function encryptBufferWithDerivedKeys(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
|
|
321
|
+
declare function decryptBufferWithDerivedKeys(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
|
|
322
|
+
/**
|
|
323
|
+
* @method makeMessageChunkSignatureWithDerivedKeys
|
|
324
|
+
* @param message
|
|
325
|
+
* @param derivedKeys
|
|
326
|
+
* @return
|
|
327
|
+
*/
|
|
328
|
+
declare function makeMessageChunkSignatureWithDerivedKeys(message: Buffer, derivedKeys: DerivedKeys): Buffer;
|
|
329
|
+
/**
|
|
330
|
+
* @method verifyChunkSignatureWithDerivedKeys
|
|
331
|
+
* @param chunk
|
|
332
|
+
* @param derivedKeys
|
|
333
|
+
* @return
|
|
334
|
+
*/
|
|
335
|
+
declare function verifyChunkSignatureWithDerivedKeys(chunk: Buffer, derivedKeys: DerivedKeys): boolean;
|
|
336
|
+
|
|
337
|
+
declare function exploreAsn1(buffer: Buffer): void;
|
|
338
|
+
|
|
339
|
+
type Version = string;
|
|
340
|
+
type Name = string;
|
|
341
|
+
type CertificateSerialNumber = string;
|
|
342
|
+
type Extensions = Record<string, unknown>;
|
|
343
|
+
interface RevokedCertificate {
|
|
344
|
+
userCertificate: CertificateSerialNumber;
|
|
345
|
+
revocationDate: Date;
|
|
346
|
+
crlEntryExtensions?: Extensions;
|
|
347
|
+
}
|
|
348
|
+
interface TBSCertList {
|
|
349
|
+
version?: Version;
|
|
350
|
+
signature: AlgorithmIdentifier;
|
|
351
|
+
issuer: Name;
|
|
352
|
+
issuerFingerprint: string;
|
|
353
|
+
thisUpdate: Date;
|
|
354
|
+
nextUpdate?: Date;
|
|
355
|
+
revokedCertificates: RevokedCertificate[];
|
|
356
|
+
}
|
|
357
|
+
interface CertificateRevocationListInfo {
|
|
358
|
+
tbsCertList: TBSCertList;
|
|
359
|
+
signatureAlgorithm: AlgorithmIdentifier;
|
|
360
|
+
signatureValue: Buffer;
|
|
361
|
+
}
|
|
362
|
+
declare function readNameForCrl(buffer: Buffer, block: BlockInfo): DirectoryName;
|
|
363
|
+
declare function exploreCertificateRevocationList(crl: CertificateRevocationList): CertificateRevocationListInfo;
|
|
364
|
+
|
|
365
|
+
interface ExtensionRequest {
|
|
366
|
+
basicConstraints: BasicConstraints;
|
|
367
|
+
keyUsage: X509KeyUsage;
|
|
368
|
+
subjectAltName: any;
|
|
369
|
+
}
|
|
370
|
+
interface CertificateSigningRequestInfo {
|
|
371
|
+
extensionRequest: ExtensionRequest;
|
|
372
|
+
}
|
|
373
|
+
declare function readCertificationRequestInfo(buffer: Buffer, block: BlockInfo): CertificateSigningRequestInfo;
|
|
374
|
+
declare function exploreCertificateSigningRequest(crl: Buffer): CertificateSigningRequestInfo;
|
|
375
|
+
|
|
376
|
+
interface PrivateKeyInternals {
|
|
377
|
+
/***/
|
|
378
|
+
version: Buffer;
|
|
379
|
+
modulus: Buffer;
|
|
380
|
+
publicExponent: Buffer;
|
|
381
|
+
privateExponent: Buffer;
|
|
382
|
+
prime1: Buffer;
|
|
383
|
+
prime2: Buffer;
|
|
384
|
+
exponent1: Buffer;
|
|
385
|
+
exponent2: Buffer;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
*
|
|
389
|
+
* @param privateKey RSAPrivateKey ::= SEQUENCE {
|
|
390
|
+
* version Version,
|
|
391
|
+
* modulus INTEGER, -- n
|
|
392
|
+
* publicExponent INTEGER, -- e
|
|
393
|
+
* privateExponent INTEGER, -- d
|
|
394
|
+
* prime1 INTEGER, -- p
|
|
395
|
+
* prime2 INTEGER, -- q
|
|
396
|
+
* exponent1 INTEGER, -- d mod (p-1)
|
|
397
|
+
* exponent2 INTEGER, -- d mod (q-1)
|
|
398
|
+
* coefficient INTEGER, -- (inverse of q) mod p
|
|
399
|
+
* otherPrimeInfos OtherPrimeInfos OPTIONAL
|
|
400
|
+
}
|
|
401
|
+
*/
|
|
402
|
+
declare function explorePrivateKey(privateKey2: PrivateKey): PrivateKeyInternals;
|
|
403
|
+
|
|
404
|
+
declare function makePrivateKeyFromPem(privateKeyInPem: string): PrivateKey;
|
|
405
|
+
|
|
406
|
+
declare function makePrivateKeyThumbPrint(privateKey: PrivateKey): Buffer;
|
|
407
|
+
|
|
408
|
+
interface SubjectOptions {
|
|
409
|
+
commonName?: string;
|
|
410
|
+
organization?: string;
|
|
411
|
+
organizationalUnit?: string;
|
|
412
|
+
locality?: string;
|
|
413
|
+
state?: string;
|
|
414
|
+
country?: string;
|
|
415
|
+
domainComponent?: string;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* subjectName The subject name to use for the Certificate.
|
|
419
|
+
* If not specified the ApplicationName and/or domainNames are used to create a suitable default value.
|
|
420
|
+
*/
|
|
421
|
+
declare class Subject implements SubjectOptions {
|
|
422
|
+
readonly commonName?: string;
|
|
423
|
+
readonly organization?: string;
|
|
424
|
+
readonly organizationalUnit?: string;
|
|
425
|
+
readonly locality?: string;
|
|
426
|
+
readonly state?: string;
|
|
427
|
+
readonly country?: string;
|
|
428
|
+
readonly domainComponent?: string;
|
|
429
|
+
constructor(options: SubjectOptions | string);
|
|
430
|
+
static parse(str: string): SubjectOptions;
|
|
431
|
+
toStringInternal(sep: string): string;
|
|
432
|
+
toStringForOPCUA(): string;
|
|
433
|
+
toString(): string;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
declare function verifyCertificateOrClrSignature(certificateOrCrl: Buffer, parentCertificate: Certificate): boolean;
|
|
437
|
+
declare function verifyCertificateSignature(certificate: Certificate, parentCertificate: Certificate): boolean;
|
|
438
|
+
declare function verifyCertificateRevocationListSignature(certificateRevocationList: Certificate, parentCertificate: Certificate): boolean;
|
|
439
|
+
type _VerifyStatus = "BadCertificateIssuerUseNotAllowed" | "BadCertificateInvalid" | "Good";
|
|
440
|
+
declare function verifyCertificateChain(certificateChain: Certificate[]): Promise<{
|
|
441
|
+
status: _VerifyStatus;
|
|
442
|
+
reason: string;
|
|
443
|
+
}>;
|
|
444
|
+
|
|
445
|
+
declare function coercePEMorDerToPrivateKey(privateKeyInDerOrPem: string | Buffer): PrivateKey;
|
|
446
|
+
/**
|
|
447
|
+
*
|
|
448
|
+
* @private
|
|
449
|
+
*/
|
|
450
|
+
declare function _coercePrivateKey(privateKey: any): Promise<KeyObject>;
|
|
451
|
+
|
|
452
|
+
interface CreateCertificateSigningRequestOptions {
|
|
453
|
+
privateKey: CryptoKey;
|
|
454
|
+
notBefore?: Date;
|
|
455
|
+
notAfter?: Date;
|
|
456
|
+
validity?: number;
|
|
457
|
+
subject?: string;
|
|
458
|
+
dns?: string[];
|
|
459
|
+
ip?: string[];
|
|
460
|
+
applicationUri?: string;
|
|
461
|
+
purpose: CertificatePurpose;
|
|
462
|
+
}
|
|
463
|
+
declare function createCertificateSigningRequest({ privateKey, subject, dns, ip, applicationUri, purpose, }: CreateCertificateSigningRequestOptions): Promise<{
|
|
464
|
+
csr: string;
|
|
465
|
+
der: x509.Pkcs10CertificateRequest;
|
|
466
|
+
}>;
|
|
467
|
+
|
|
468
|
+
declare function generateKeyPair(modulusLength?: 1024 | 2048 | 3072 | 4096): Promise<CryptoKeyPair>;
|
|
469
|
+
/**
|
|
470
|
+
* generate a pair of private/public keys of length 1024,2048, 3072, or 4096 bits
|
|
471
|
+
*/
|
|
472
|
+
declare function generatePrivateKey(modulusLength?: 1024 | 2048 | 3072 | 4096): Promise<CryptoKey>;
|
|
473
|
+
/**
|
|
474
|
+
* convert a CryptoKey to a PEM string
|
|
475
|
+
*/
|
|
476
|
+
declare function privateKeyToPEM(privateKey: CryptoKey): Promise<{
|
|
477
|
+
privPem: string;
|
|
478
|
+
privDer: ArrayBuffer;
|
|
479
|
+
}>;
|
|
480
|
+
declare function derToPrivateKey(privDer: ArrayBuffer): Promise<CryptoKey>;
|
|
481
|
+
declare function pemToPrivateKey(pem: string): Promise<CryptoKey>;
|
|
482
|
+
|
|
483
|
+
interface CreateSelfSignCertificateOptions {
|
|
484
|
+
privateKey: CryptoKey;
|
|
485
|
+
notBefore?: Date;
|
|
486
|
+
notAfter?: Date;
|
|
487
|
+
validity?: number;
|
|
488
|
+
subject?: string;
|
|
489
|
+
dns?: string[];
|
|
490
|
+
ip?: string[];
|
|
491
|
+
applicationUri?: string;
|
|
492
|
+
purpose: CertificatePurpose;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
*
|
|
496
|
+
* construct a self-signed certificate
|
|
497
|
+
*/
|
|
498
|
+
declare function createSelfSignedCertificate({ privateKey, notAfter, notBefore, validity, subject, dns, ip, applicationUri, purpose, }: CreateSelfSignCertificateOptions): Promise<{
|
|
499
|
+
cert: string;
|
|
500
|
+
der: x509.X509Certificate;
|
|
501
|
+
}>;
|
|
502
|
+
|
|
503
|
+
export { verifyChunkSignature as $, type AttributeTypeAndValue as A, type BasicConstraints as B, type CertificateExtension as C, coerceCertificatePem as D, extractPublicKeyFromCertificateSync as E, extractPublicKeyFromCertificate as F, rsaLengthPrivateKey as G, toPem2 as H, coercePrivateKeyPem as I, coercePublicKeyPem as J, coerceRsaPublicKeyPem as K, rsaLengthPublicKey as L, rsaLengthRsaPublicKey as M, makePseudoRandomBuffer as N, type ComputeDerivedKeysOptions as O, PaddingAlgorithm as P, type DerivedKeys as Q, RSA_PKCS1_OAEP_PADDING as R, type SubjectPublicKey as S, type TbsCertificate as T, computeDerivedKeys as U, type Validity as V, reduceLength as W, type X509KeyUsage as X, removePadding as Y, type VerifyChunkSignatureOptions as Z, _readExtension as _, type X509ExtKeyUsage as a, computePaddingFooter as a0, encryptBufferWithDerivedKeys as a1, decryptBufferWithDerivedKeys as a2, makeMessageChunkSignatureWithDerivedKeys as a3, verifyChunkSignatureWithDerivedKeys as a4, exploreAsn1 as a5, type Version as a6, type Name as a7, type CertificateSerialNumber as a8, type Extensions as a9, createCertificateSigningRequest as aA, generateKeyPair as aB, generatePrivateKey as aC, privateKeyToPEM as aD, derToPrivateKey as aE, pemToPrivateKey as aF, type CreateSelfSignCertificateOptions as aG, createSelfSignedCertificate as aH, readTag as aI, readStruct as aJ, readAlgorithmIdentifier as aK, readSignatureValueBin as aL, type RevokedCertificate as aa, type TBSCertList as ab, type CertificateRevocationListInfo as ac, readNameForCrl as ad, exploreCertificateRevocationList as ae, type ExtensionRequest as af, type CertificateSigningRequestInfo as ag, readCertificationRequestInfo as ah, exploreCertificateSigningRequest as ai, type PublicKeyLength as aj, type CertificateInfo as ak, coerceCertificate as al, exploreCertificateInfo as am, type PrivateKeyInternals as an, explorePrivateKey as ao, makePrivateKeyFromPem as ap, makePrivateKeyThumbPrint as aq, type SubjectOptions as ar, Subject as as, verifyCertificateOrClrSignature as at, verifyCertificateSignature as au, verifyCertificateRevocationListSignature as av, type _VerifyStatus as aw, verifyCertificateChain as ax, coercePEMorDerToPrivateKey as ay, _coercePrivateKey as az, type SubjectPublicKeyInfo as b, certificateMatchesPrivateKey as c, type AuthorityKeyIdentifier as d, type CertificateInternals as e, exploreCertificate as f, combine_der as g, removeTrailingLF as h, identifyPemType as i, convertPEMtoDER as j, hexDump as k, type VerifyMessageChunkSignatureOptions as l, makeMessageChunkSignature as m, makeSHA1Thumbprint as n, RSA_PKCS1_PADDING as o, publicKeyAndPrivateKeyMatches as p, publicEncrypt_native as q, readTbsCertificate as r, split_der as s, toPem as t, privateDecrypt_native as u, verifyMessageChunkSignature as v, publicEncrypt as w, privateDecrypt as x, publicEncrypt_long as y, privateDecrypt_long as z };
|