node-opcua-crypto 4.5.0 → 4.6.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/dist-cjs/common-0xc4gZF8.d.ts +44 -0
- package/dist-cjs/index.d.ts +5 -0
- package/dist-cjs/source/index.d.ts +523 -0
- package/dist-cjs/source/index_web.d.ts +4 -0
- package/dist-cjs/source_nodejs/index.d.ts +46 -0
- package/{dist/chunk-SNCRM4BA.mjs → dist-esm/chunk-D3SBIIXU.mjs} +1 -1
- package/{dist/chunk-UZNNRQTR.mjs → dist-esm/chunk-R33OLRZV.mjs} +2 -2
- package/dist-esm/common-0xc4gZF8.d.ts +44 -0
- package/dist-esm/index.d.mts +5 -0
- package/{dist → dist-esm}/index.mjs +2 -2
- package/dist-esm/source/index.d.mts +523 -0
- package/{dist → dist-esm}/source/index.mjs +1 -1
- package/dist-esm/source/index_web.d.mts +4 -0
- package/{dist → dist-esm}/source/index_web.mjs +1 -1
- package/dist-esm/source_nodejs/index.d.mts +46 -0
- package/{dist → dist-esm}/source_nodejs/index.mjs +2 -2
- package/index.mjs +1 -0
- package/package.json +17 -27
- package/dist-types/index.d.ts +0 -2
- package/dist-types/source/asn1.d.ts +0 -73
- package/dist-types/source/buffer_utils.d.ts +0 -6
- package/dist-types/source/common.d.ts +0 -44
- package/dist-types/source/crypto_explore_certificate.d.ts +0 -107
- package/dist-types/source/crypto_utils.d.ts +0 -58
- package/dist-types/source/crypto_utils2.d.ts +0 -27
- package/dist-types/source/derived_keys.d.ts +0 -72
- package/dist-types/source/explore_certificate.d.ts +0 -27
- package/dist-types/source/explore_certificate_revocation_list.d.ts +0 -28
- package/dist-types/source/explore_certificate_signing_request.d.ts +0 -13
- package/dist-types/source/explore_private_key.d.ts +0 -29
- package/dist-types/source/index.d.ts +0 -21
- package/dist-types/source/make_private_key_from_pem.d.ts +0 -2
- package/dist-types/source/oid_map.d.ts +0 -7
- package/dist-types/source/public_private_match.d.ts +0 -3
- package/dist-types/source/subject.d.ts +0 -27
- package/dist-types/source/verify_certificate_signature.d.ts +0 -10
- package/dist-types/source/x509/_build_public_key.d.ts +0 -1
- package/dist-types/source/x509/_crypto.d.ts +0 -3
- package/dist-types/source/x509/_get_attributes.d.ts +0 -8
- package/dist-types/source/x509/coerce_private_key.d.ts +0 -8
- package/dist-types/source/x509/create_certificate_signing_request.d.ts +0 -18
- package/dist-types/source/x509/create_key_pair.d.ts +0 -14
- package/dist-types/source/x509/create_self_signed_certificate.d.ts +0 -21
- package/dist-types/source_nodejs/generate_private_key_filename.d.ts +0 -7
- package/dist-types/source_nodejs/index.d.ts +0 -4
- package/dist-types/source_nodejs/read.d.ts +0 -30
- package/dist-types/source_nodejs/read_certificate_revocation_list.d.ts +0 -2
- package/dist-types/source_nodejs/read_certificate_signing_request.d.ts +0 -3
- package/node-opcua-crypto-4.2.0.tgz +0 -0
- /package/{dist → dist-cjs}/index.js +0 -0
- /package/{dist → dist-cjs}/source/index.js +0 -0
- /package/{dist → dist-cjs}/source/index_web.js +0 -0
- /package/{dist → dist-cjs}/source_nodejs/index.js +0 -0
- /package/{dist → dist-esm}/chunk-5NV4OKIV.mjs +0 -0
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
readPublicKeyPEM,
|
|
15
15
|
readPublicRsaKey,
|
|
16
16
|
setCertificateStore
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-R33OLRZV.mjs";
|
|
18
18
|
import "../chunk-5NV4OKIV.mjs";
|
|
19
|
-
import "../chunk-
|
|
19
|
+
import "../chunk-D3SBIIXU.mjs";
|
|
20
20
|
export {
|
|
21
21
|
generatePrivateKeyFile,
|
|
22
22
|
generatePrivateKeyFileAlternate,
|
package/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./dist-esm/index.mjs";
|
package/package.json
CHANGED
|
@@ -1,39 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-crypto",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "Crypto tools for Node-OPCUA",
|
|
5
5
|
"types": "./dist-types/index.d.ts",
|
|
6
|
-
"main": "./dist/index.js",
|
|
6
|
+
"main": "./dist-esm/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
"require": {
|
|
14
|
-
"types": "./dist-types/index.d.ts",
|
|
15
|
-
"default": "./dist/index.js"
|
|
16
|
-
}
|
|
9
|
+
"types": "./dist-types/index.d.ts",
|
|
10
|
+
"import": "./dist-esm/index.mjs",
|
|
11
|
+
"require": "./dist-cjs/index.js"
|
|
17
12
|
},
|
|
18
13
|
"./web": {
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
"require": {
|
|
24
|
-
"types": "./dist-types/source/index.d.ts",
|
|
25
|
-
"default": "./dist/source/index.js"
|
|
26
|
-
}
|
|
14
|
+
"types": "./dist-types/source/index.d.ts",
|
|
15
|
+
"import": "./dist/source/index.mjs",
|
|
16
|
+
"require": "./dist/source/index.js"
|
|
27
17
|
}
|
|
28
18
|
},
|
|
29
19
|
"scripts": {
|
|
30
|
-
"build:tsup": "tsup ./index.ts
|
|
20
|
+
"build:tsup:esm": "tsup ./index.ts ./source/index.ts ./source/index_web.ts ./source_nodejs/index.ts --shims --format esm --out-dir dist-esm --sourcemap --clean --dts ",
|
|
21
|
+
"build:tsup:cjs": "tsup ./index.ts ./source/index.ts ./source/index_web.ts ./source_nodejs/index.ts --shims --format cjs --out-dir dist-cjs --sourcemap --clean --dts",
|
|
31
22
|
"build:types": "tsc -p tsconfig.types.json",
|
|
32
23
|
"compile": "tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json ./tsconfig.types.json",
|
|
33
24
|
"build:demo": "node web/esbuild.mjs",
|
|
34
25
|
"build:clean": "npx rimraf ./dist ./dist-* *.tsbuildinfo",
|
|
35
26
|
"build:old": "npm run build:clean && npm run compile && node ../../scripts/prepare-package-json.mjs",
|
|
36
|
-
"build": "npm run build:tsup",
|
|
27
|
+
"build": "npm run build:tsup:esm && npm run build:tsup:cjs",
|
|
37
28
|
"prepare": "npm run build",
|
|
38
29
|
"tslint": "tslint --project . --fix",
|
|
39
30
|
"lint": "eslint . --ext .ts",
|
|
@@ -58,20 +49,19 @@
|
|
|
58
49
|
"node": ">15.0"
|
|
59
50
|
},
|
|
60
51
|
"devDependencies": {
|
|
61
|
-
"@types/node": "^20.
|
|
52
|
+
"@types/node": "^20.9.1",
|
|
62
53
|
"lorem-ipsum": "^2.0.8"
|
|
63
54
|
},
|
|
64
55
|
"dependencies": {
|
|
65
56
|
"@peculiar/webcrypto": "^1.4.3",
|
|
66
57
|
"@peculiar/x509": "^1.9.5",
|
|
67
|
-
"@types/jsrsasign": "^10.5.
|
|
68
|
-
"@types/sshpk": "^1.17.
|
|
69
|
-
"assert": "^2.
|
|
70
|
-
"better-assert": "^1.0.2",
|
|
58
|
+
"@types/jsrsasign": "^10.5.12",
|
|
59
|
+
"@types/sshpk": "^1.17.4",
|
|
60
|
+
"assert": "^2.1.0",
|
|
71
61
|
"chalk": "^4.1.2",
|
|
72
62
|
"hexy": "0.3.5",
|
|
73
63
|
"jsrsasign": "^10.8.6",
|
|
74
|
-
"sshpk": "^1.
|
|
64
|
+
"sshpk": "^1.18.0"
|
|
75
65
|
},
|
|
76
66
|
"repository": {
|
|
77
67
|
"type": "git",
|
|
@@ -80,5 +70,5 @@
|
|
|
80
70
|
"bugs": {
|
|
81
71
|
"url": "https://github.com/node-opcua/node-opcua-crypto/issues"
|
|
82
72
|
},
|
|
83
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "7702c2f5cedc41cf324fc30e38349ff9d0cb2505"
|
|
84
74
|
}
|
package/dist-types/index.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
export declare enum TagType {
|
|
3
|
-
BOOLEAN = 1,
|
|
4
|
-
INTEGER = 2,
|
|
5
|
-
BIT_STRING = 3,
|
|
6
|
-
OCTET_STRING = 4,
|
|
7
|
-
NULL = 5,
|
|
8
|
-
OBJECT_IDENTIFIER = 6,
|
|
9
|
-
UTF8String = 12,
|
|
10
|
-
NumericString = 18,
|
|
11
|
-
PrintableString = 19,
|
|
12
|
-
TeletexString = 20,
|
|
13
|
-
IA5String = 22,
|
|
14
|
-
UTCTime = 23,
|
|
15
|
-
GeneralizedTime = 24,
|
|
16
|
-
GraphicString = 25,
|
|
17
|
-
VisibleString = 26,
|
|
18
|
-
GeneralString = 27,
|
|
19
|
-
UniversalString = 28,
|
|
20
|
-
BMPString = 30,
|
|
21
|
-
SEQUENCE = 48,
|
|
22
|
-
SET = 49,
|
|
23
|
-
A3 = 163
|
|
24
|
-
}
|
|
25
|
-
export interface BlockInfo {
|
|
26
|
-
tag: TagType | number;
|
|
27
|
-
position: number;
|
|
28
|
-
length: number;
|
|
29
|
-
}
|
|
30
|
-
export declare function readTag(buf: Buffer, pos: number): BlockInfo;
|
|
31
|
-
export declare function _readStruct(buf: Buffer, blockInfo: BlockInfo): BlockInfo[];
|
|
32
|
-
export declare function parseBitString(buffer: Buffer, start: number, end: number, maxLength: number): string;
|
|
33
|
-
export interface BitString {
|
|
34
|
-
lengthInBits: number;
|
|
35
|
-
lengthInBytes: number;
|
|
36
|
-
data: Buffer;
|
|
37
|
-
debug?: any;
|
|
38
|
-
}
|
|
39
|
-
export declare function _readBitString(buffer: Buffer, block: BlockInfo): BitString;
|
|
40
|
-
export declare function formatBuffer2DigitHexWithColum(buffer: Buffer): string;
|
|
41
|
-
export declare function _readOctetString(buffer: Buffer, block: BlockInfo): Buffer;
|
|
42
|
-
export declare function _getBlock(buffer: Buffer, block: BlockInfo): Buffer;
|
|
43
|
-
export interface AlgorithmIdentifier {
|
|
44
|
-
identifier: string;
|
|
45
|
-
}
|
|
46
|
-
export declare function _readIntegerAsByteString(buffer: Buffer, block: BlockInfo): Buffer;
|
|
47
|
-
export declare function _readListOfInteger(buffer: Buffer): Buffer[];
|
|
48
|
-
export declare function _readObjectIdentifier(buffer: Buffer, block: BlockInfo): {
|
|
49
|
-
oid: string;
|
|
50
|
-
name: string;
|
|
51
|
-
};
|
|
52
|
-
export declare function _readAlgorithmIdentifier(buffer: Buffer, block: BlockInfo): AlgorithmIdentifier;
|
|
53
|
-
export declare function _readECCAlgorithmIdentifier(buffer: Buffer, block: BlockInfo): AlgorithmIdentifier;
|
|
54
|
-
export type SignatureValue = string;
|
|
55
|
-
export declare function _readSignatureValueBin(buffer: Buffer, block: BlockInfo): Buffer;
|
|
56
|
-
export declare function _readSignatureValue(buffer: Buffer, block: BlockInfo): SignatureValue;
|
|
57
|
-
export declare function _readLongIntegerValue(buffer: Buffer, block: BlockInfo): Buffer;
|
|
58
|
-
export declare function _readIntegerValue(buffer: Buffer, block: BlockInfo): number;
|
|
59
|
-
export declare function _readBooleanValue(buffer: Buffer, block: BlockInfo): boolean;
|
|
60
|
-
export declare function _readVersionValue(buffer: Buffer, block: BlockInfo): number;
|
|
61
|
-
export declare function _readValue(buffer: Buffer, block: BlockInfo): any;
|
|
62
|
-
export interface DirectoryName {
|
|
63
|
-
stateOrProvinceName?: string;
|
|
64
|
-
localityName?: string;
|
|
65
|
-
organizationName?: string;
|
|
66
|
-
organizationUnitName?: string;
|
|
67
|
-
commonName?: string;
|
|
68
|
-
countryName?: string;
|
|
69
|
-
}
|
|
70
|
-
export declare function compactDirectoryName(d: DirectoryName): string;
|
|
71
|
-
export declare function _readDirectoryName(buffer: Buffer, block: BlockInfo): DirectoryName;
|
|
72
|
-
export declare function _findBlockAtIndex(blocks: BlockInfo[], index: number): BlockInfo | null;
|
|
73
|
-
export declare function _readTime(buffer: Buffer, block: BlockInfo): any;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import __crypto from "crypto";
|
|
4
|
-
export declare const createPrivateKeyFromNodeJSCrypto: typeof __crypto.createPrivateKey;
|
|
5
|
-
type KeyFormat = "pem" | "der" | "jwk";
|
|
6
|
-
type KeyObjectType = "secret" | "public" | "private";
|
|
7
|
-
interface KeyExportOptions<T extends KeyFormat> {
|
|
8
|
-
type: "pkcs1" | "spki" | "pkcs8" | "sec1";
|
|
9
|
-
format: T;
|
|
10
|
-
cipher?: string | undefined;
|
|
11
|
-
passphrase?: string | Buffer | undefined;
|
|
12
|
-
}
|
|
13
|
-
interface JwkKeyExportOptions {
|
|
14
|
-
format: "jwk";
|
|
15
|
-
}
|
|
16
|
-
export interface KeyObject {
|
|
17
|
-
export(options: KeyExportOptions<"pem">): string | Buffer;
|
|
18
|
-
export(options: KeyExportOptions<"der">): Buffer;
|
|
19
|
-
export(options: JwkKeyExportOptions): JsonWebKey;
|
|
20
|
-
type: KeyObjectType;
|
|
21
|
-
}
|
|
22
|
-
export declare function isKeyObject(mayBeKeyObject: any): boolean;
|
|
23
|
-
export type PrivateKey = {
|
|
24
|
-
hidden: string;
|
|
25
|
-
} | {
|
|
26
|
-
hidden: KeyObject;
|
|
27
|
-
};
|
|
28
|
-
export type PublicKey = KeyObject;
|
|
29
|
-
export type Nonce = Buffer;
|
|
30
|
-
export type PEM = string;
|
|
31
|
-
export type DER = Buffer;
|
|
32
|
-
export type Certificate = DER;
|
|
33
|
-
export type CertificatePEM = PEM;
|
|
34
|
-
export type PrivateKeyPEM = PEM;
|
|
35
|
-
export type PublicKeyPEM = PEM;
|
|
36
|
-
export type Signature = Buffer;
|
|
37
|
-
export type CertificateRevocationList = Buffer;
|
|
38
|
-
export declare enum CertificatePurpose {
|
|
39
|
-
NotSpecified = 0,
|
|
40
|
-
ForCertificateAuthority = 1,
|
|
41
|
-
ForApplication = 2,
|
|
42
|
-
ForUserAuthentication = 3
|
|
43
|
-
}
|
|
44
|
-
export {};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node_opcua_crypto
|
|
3
|
-
*/
|
|
4
|
-
/// <reference types="node" />
|
|
5
|
-
import { BlockInfo, AlgorithmIdentifier, SignatureValue, DirectoryName } from "./asn1.js";
|
|
6
|
-
import { Certificate } from "./common.js";
|
|
7
|
-
import { PublicKeyLength } from "./explore_certificate.js";
|
|
8
|
-
export interface AttributeTypeAndValue {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
}
|
|
11
|
-
export interface Validity {
|
|
12
|
-
notBefore: Date;
|
|
13
|
-
notAfter: Date;
|
|
14
|
-
}
|
|
15
|
-
export interface X509KeyUsage {
|
|
16
|
-
digitalSignature: boolean;
|
|
17
|
-
nonRepudiation: boolean;
|
|
18
|
-
keyEncipherment: boolean;
|
|
19
|
-
dataEncipherment: boolean;
|
|
20
|
-
keyAgreement: boolean;
|
|
21
|
-
keyCertSign: boolean;
|
|
22
|
-
cRLSign: boolean;
|
|
23
|
-
encipherOnly: boolean;
|
|
24
|
-
decipherOnly: boolean;
|
|
25
|
-
}
|
|
26
|
-
export interface X509ExtKeyUsage {
|
|
27
|
-
clientAuth: boolean;
|
|
28
|
-
serverAuth: boolean;
|
|
29
|
-
codeSigning: boolean;
|
|
30
|
-
emailProtection: boolean;
|
|
31
|
-
timeStamping: boolean;
|
|
32
|
-
ocspSigning: boolean;
|
|
33
|
-
ipsecEndSystem: boolean;
|
|
34
|
-
ipsecTunnel: boolean;
|
|
35
|
-
ipsecUser: boolean;
|
|
36
|
-
}
|
|
37
|
-
export interface SubjectPublicKey {
|
|
38
|
-
modulus: Buffer;
|
|
39
|
-
}
|
|
40
|
-
export declare function _readExtension(buffer: Buffer, block: BlockInfo): {
|
|
41
|
-
identifier: {
|
|
42
|
-
oid: string;
|
|
43
|
-
name: string;
|
|
44
|
-
};
|
|
45
|
-
value: any;
|
|
46
|
-
};
|
|
47
|
-
export interface SubjectPublicKeyInfo {
|
|
48
|
-
algorithm: string;
|
|
49
|
-
keyLength: PublicKeyLength;
|
|
50
|
-
subjectPublicKey: SubjectPublicKey;
|
|
51
|
-
}
|
|
52
|
-
export interface BasicConstraints {
|
|
53
|
-
critical: boolean;
|
|
54
|
-
cA: boolean;
|
|
55
|
-
pathLengthConstraint?: number;
|
|
56
|
-
}
|
|
57
|
-
export interface AuthorityKeyIdentifier {
|
|
58
|
-
keyIdentifier: string | null;
|
|
59
|
-
authorityCertIssuer: DirectoryName | null;
|
|
60
|
-
authorityCertIssuerFingerPrint: string;
|
|
61
|
-
serial: string | null;
|
|
62
|
-
}
|
|
63
|
-
export interface CertificateExtension {
|
|
64
|
-
basicConstraints: BasicConstraints;
|
|
65
|
-
subjectKeyIdentifier?: string;
|
|
66
|
-
authorityKeyIdentifier?: AuthorityKeyIdentifier;
|
|
67
|
-
keyUsage?: X509KeyUsage;
|
|
68
|
-
extKeyUsage?: X509ExtKeyUsage;
|
|
69
|
-
subjectAltName?: any;
|
|
70
|
-
}
|
|
71
|
-
export interface TbsCertificate {
|
|
72
|
-
version: number;
|
|
73
|
-
serialNumber: string;
|
|
74
|
-
issuer: any;
|
|
75
|
-
signature: AlgorithmIdentifier;
|
|
76
|
-
validity: Validity;
|
|
77
|
-
subject: DirectoryName;
|
|
78
|
-
subjectFingerPrint: string;
|
|
79
|
-
subjectPublicKeyInfo: SubjectPublicKeyInfo;
|
|
80
|
-
extensions: CertificateExtension | null;
|
|
81
|
-
}
|
|
82
|
-
export declare function readTbsCertificate(buffer: Buffer, block: BlockInfo): TbsCertificate;
|
|
83
|
-
export interface CertificateInternals {
|
|
84
|
-
tbsCertificate: TbsCertificate;
|
|
85
|
-
signatureAlgorithm: AlgorithmIdentifier;
|
|
86
|
-
signatureValue: SignatureValue;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* explore a certificate structure
|
|
90
|
-
* @param certificate
|
|
91
|
-
* @returns a json object that exhibits the internal data of the certificate
|
|
92
|
-
*/
|
|
93
|
-
export declare function exploreCertificate(certificate: Certificate): CertificateInternals;
|
|
94
|
-
/**
|
|
95
|
-
* @method split_der
|
|
96
|
-
* split a multi chain certificates
|
|
97
|
-
* @param certificateChain the certificate chain in der (binary) format}
|
|
98
|
-
* @returns an array of Der , each element of the array is one certificate of the chain
|
|
99
|
-
*/
|
|
100
|
-
export declare function split_der(certificateChain: Certificate): Certificate[];
|
|
101
|
-
/**
|
|
102
|
-
* @method combine_der
|
|
103
|
-
* combine an array of certificates into a single blob
|
|
104
|
-
* @param certificates a array with the individual DER certificates of the chain
|
|
105
|
-
* @return a concatenated buffer containing the certificates
|
|
106
|
-
*/
|
|
107
|
-
export declare function combine_der(certificates: Certificate[]): Certificate;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { KeyLike } from "crypto";
|
|
4
|
-
import { Certificate, CertificatePEM, DER, PEM, PublicKeyPEM, Signature, PrivateKey } from "./common.js";
|
|
5
|
-
export declare function identifyPemType(rawKey: Buffer | string): undefined | string;
|
|
6
|
-
export declare function removeTrailingLF(str: string): string;
|
|
7
|
-
export declare function toPem(raw_key: Buffer | string, pem: string): string;
|
|
8
|
-
export declare function convertPEMtoDER(raw_key: PEM): DER;
|
|
9
|
-
export declare function hexDump(buffer: Buffer, width?: number): string;
|
|
10
|
-
interface MakeMessageChunkSignatureOptions {
|
|
11
|
-
signatureLength: number;
|
|
12
|
-
algorithm: string;
|
|
13
|
-
privateKey: PrivateKey;
|
|
14
|
-
}
|
|
15
|
-
export declare function makeMessageChunkSignature(chunk: Buffer, options: MakeMessageChunkSignatureOptions): Buffer;
|
|
16
|
-
export interface VerifyMessageChunkSignatureOptions {
|
|
17
|
-
signatureLength?: number;
|
|
18
|
-
algorithm: string;
|
|
19
|
-
publicKey: PublicKeyPEM;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @method verifyMessageChunkSignature
|
|
23
|
-
*
|
|
24
|
-
* const signer = {
|
|
25
|
-
* signatureLength : 128,
|
|
26
|
-
* algorithm : "RSA-SHA256",
|
|
27
|
-
* publicKey: "qsdqsdqsd"
|
|
28
|
-
* };
|
|
29
|
-
* @param blockToVerify
|
|
30
|
-
* @param signature
|
|
31
|
-
* @param options
|
|
32
|
-
* @param options.signatureLength
|
|
33
|
-
* @param options.algorithm for example "RSA-SHA256"
|
|
34
|
-
* @param options.publicKey
|
|
35
|
-
* @return true if the signature is valid
|
|
36
|
-
*/
|
|
37
|
-
export declare function verifyMessageChunkSignature(blockToVerify: Buffer, signature: Signature, options: VerifyMessageChunkSignatureOptions): boolean;
|
|
38
|
-
export declare function makeSHA1Thumbprint(buffer: Buffer): Signature;
|
|
39
|
-
export declare const RSA_PKCS1_OAEP_PADDING: number;
|
|
40
|
-
export declare const RSA_PKCS1_PADDING: number;
|
|
41
|
-
export declare enum PaddingAlgorithm {
|
|
42
|
-
RSA_PKCS1_OAEP_PADDING = 4,
|
|
43
|
-
RSA_PKCS1_PADDING = 1
|
|
44
|
-
}
|
|
45
|
-
export declare function publicEncrypt_native(buffer: Buffer, publicKey: KeyLike, algorithm?: PaddingAlgorithm): Buffer;
|
|
46
|
-
export declare function privateDecrypt_native(buffer: Buffer, privateKey: PrivateKey, algorithm?: PaddingAlgorithm): Buffer;
|
|
47
|
-
export declare const publicEncrypt: typeof publicEncrypt_native;
|
|
48
|
-
export declare const privateDecrypt: typeof privateDecrypt_native;
|
|
49
|
-
export declare function publicEncrypt_long(buffer: Buffer, publicKey: KeyLike, blockSize: number, padding: number, paddingAlgorithm?: PaddingAlgorithm): Buffer;
|
|
50
|
-
export declare function privateDecrypt_long(buffer: Buffer, privateKey: PrivateKey, blockSize: number, paddingAlgorithm?: number): Buffer;
|
|
51
|
-
export declare function coerceCertificatePem(certificate: Certificate | CertificatePEM): CertificatePEM;
|
|
52
|
-
export declare function extractPublicKeyFromCertificateSync(certificate: Certificate | CertificatePEM): PublicKeyPEM;
|
|
53
|
-
/**
|
|
54
|
-
* extract the publickey from a certificate
|
|
55
|
-
* @async
|
|
56
|
-
*/
|
|
57
|
-
export declare function extractPublicKeyFromCertificate(certificate: CertificatePEM | Certificate, callback: (err: Error | null, publicKeyPEM?: PublicKeyPEM) => void): void;
|
|
58
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { KeyObject } from "./common.js";
|
|
3
|
-
import { PublicKey, PublicKeyPEM, PrivateKeyPEM, PrivateKey } from "./common.js";
|
|
4
|
-
/***
|
|
5
|
-
* @method rsaLengthPrivateKey
|
|
6
|
-
* A very expensive way to determine the rsa key length ( i.e 2048bits or 1024bits)
|
|
7
|
-
* @param key a PEM public key or a PEM rsa private key
|
|
8
|
-
* @return the key length in bytes.
|
|
9
|
-
*/
|
|
10
|
-
export declare function rsaLengthPrivateKey(key: PrivateKey): number;
|
|
11
|
-
/**
|
|
12
|
-
* @method toPem2
|
|
13
|
-
* @param raw_key
|
|
14
|
-
* @param pem
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @return a PEM string containing the Private Key
|
|
18
|
-
*
|
|
19
|
-
* Note: a Pem key can be converted back to a private key object using coercePrivateKey
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
export declare function toPem2(raw_key: Buffer | string | KeyObject | PrivateKey, pem: string): string;
|
|
23
|
-
export declare function coercePrivateKeyPem(privateKey: PrivateKey): PrivateKeyPEM;
|
|
24
|
-
export declare function coercePublicKeyPem(publicKey: PublicKey | PublicKeyPEM): PublicKeyPEM;
|
|
25
|
-
export declare function coerceRsaPublicKeyPem(publicKey: PublicKey | KeyObject | PublicKeyPEM): PublicKeyPEM;
|
|
26
|
-
export declare function rsaLengthPublicKey(key: PublicKeyPEM | PublicKey): number;
|
|
27
|
-
export declare function rsaLengthRsaPublicKey(key: PublicKeyPEM | PublicKey): number;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Nonce } from "./common.js";
|
|
3
|
-
import { VerifyMessageChunkSignatureOptions } from "./crypto_utils.js";
|
|
4
|
-
export declare function makePseudoRandomBuffer(secret: Nonce, seed: Nonce, minLength: number, sha1or256: "SHA1" | "SHA256"): Buffer;
|
|
5
|
-
export interface ComputeDerivedKeysOptions {
|
|
6
|
-
signatureLength: number;
|
|
7
|
-
signingKeyLength: number;
|
|
8
|
-
encryptingKeyLength: number;
|
|
9
|
-
encryptingBlockSize: number;
|
|
10
|
-
algorithm: string;
|
|
11
|
-
sha1or256?: "SHA1" | "SHA256";
|
|
12
|
-
}
|
|
13
|
-
export interface DerivedKeys extends ComputeDerivedKeysOptions {
|
|
14
|
-
signatureLength: number;
|
|
15
|
-
signingKeyLength: number;
|
|
16
|
-
encryptingKeyLength: number;
|
|
17
|
-
encryptingBlockSize: number;
|
|
18
|
-
algorithm: string;
|
|
19
|
-
sha1or256: "SHA1" | "SHA256";
|
|
20
|
-
signingKey: Buffer;
|
|
21
|
-
encryptingKey: Buffer;
|
|
22
|
-
initializationVector: Buffer;
|
|
23
|
-
}
|
|
24
|
-
export declare function computeDerivedKeys(secret: Nonce, seed: Nonce, options: ComputeDerivedKeysOptions): DerivedKeys;
|
|
25
|
-
/**
|
|
26
|
-
* @method reduceLength
|
|
27
|
-
* @param buffer
|
|
28
|
-
* @param byteToRemove
|
|
29
|
-
* @return buffer
|
|
30
|
-
*/
|
|
31
|
-
export declare function reduceLength(buffer: Buffer, byteToRemove: number): Buffer;
|
|
32
|
-
/**
|
|
33
|
-
* @method removePadding
|
|
34
|
-
* @param buffer
|
|
35
|
-
* @return buffer with padding removed
|
|
36
|
-
*/
|
|
37
|
-
export declare function removePadding(buffer: Buffer): Buffer;
|
|
38
|
-
export type VerifyChunkSignatureOptions = VerifyMessageChunkSignatureOptions;
|
|
39
|
-
/**
|
|
40
|
-
* @method verifyChunkSignature
|
|
41
|
-
*
|
|
42
|
-
* const signer = {
|
|
43
|
-
* signatureLength : 128,
|
|
44
|
-
* algorithm : "RSA-SHA256",
|
|
45
|
-
* public_key: "qsdqsdqsd"
|
|
46
|
-
* };
|
|
47
|
-
*
|
|
48
|
-
* @param chunk The message chunk to verify.
|
|
49
|
-
* @param options
|
|
50
|
-
* @param options.signatureLength
|
|
51
|
-
* @param options.algorithm the algorithm.
|
|
52
|
-
* @param options.publicKey
|
|
53
|
-
* @return {*}
|
|
54
|
-
*/
|
|
55
|
-
export declare function verifyChunkSignature(chunk: Buffer, options: VerifyChunkSignatureOptions): boolean;
|
|
56
|
-
export declare function computePaddingFooter(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
|
|
57
|
-
export declare function encryptBufferWithDerivedKeys(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
|
|
58
|
-
export declare function decryptBufferWithDerivedKeys(buffer: Buffer, derivedKeys: DerivedKeys): Buffer;
|
|
59
|
-
/**
|
|
60
|
-
* @method makeMessageChunkSignatureWithDerivedKeys
|
|
61
|
-
* @param message
|
|
62
|
-
* @param derivedKeys
|
|
63
|
-
* @return
|
|
64
|
-
*/
|
|
65
|
-
export declare function makeMessageChunkSignatureWithDerivedKeys(message: Buffer, derivedKeys: DerivedKeys): Buffer;
|
|
66
|
-
/**
|
|
67
|
-
* @method verifyChunkSignatureWithDerivedKeys
|
|
68
|
-
* @param chunk
|
|
69
|
-
* @param derivedKeys
|
|
70
|
-
* @return
|
|
71
|
-
*/
|
|
72
|
-
export declare function verifyChunkSignatureWithDerivedKeys(chunk: Buffer, derivedKeys: DerivedKeys): boolean;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Certificate, CertificatePEM } from "./common.js";
|
|
2
|
-
import { SubjectPublicKey } from "./crypto_explore_certificate.js";
|
|
3
|
-
import { DirectoryName } from "./asn1.js";
|
|
4
|
-
export type PublicKeyLength = 64 | 96 | 128 | 256 | 384 | 512;
|
|
5
|
-
/**
|
|
6
|
-
* A structure exposing useful information about a certificate
|
|
7
|
-
*/
|
|
8
|
-
export interface CertificateInfo {
|
|
9
|
-
/** the public key length in bits */
|
|
10
|
-
publicKeyLength: PublicKeyLength;
|
|
11
|
-
/** the date at which the certificate starts to be valid */
|
|
12
|
-
notBefore: Date;
|
|
13
|
-
/** the date after which the certificate is not valid any more */
|
|
14
|
-
notAfter: Date;
|
|
15
|
-
/** info about certificate owner */
|
|
16
|
-
subject: DirectoryName;
|
|
17
|
-
/** public key */
|
|
18
|
-
publicKey: SubjectPublicKey;
|
|
19
|
-
}
|
|
20
|
-
export declare function coerceCertificate(certificate: Certificate | CertificatePEM): Certificate;
|
|
21
|
-
/**
|
|
22
|
-
* @method exploreCertificateInfo
|
|
23
|
-
* returns useful information about the certificate such as public key length, start date and end of validity date,
|
|
24
|
-
* and CN
|
|
25
|
-
* @param certificate the certificate to explore
|
|
26
|
-
*/
|
|
27
|
-
export declare function exploreCertificateInfo(certificate: Certificate | CertificatePEM): CertificateInfo;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { AlgorithmIdentifier, BlockInfo, DirectoryName } from "./asn1.js";
|
|
3
|
-
import { CertificateRevocationList } from "./common.js";
|
|
4
|
-
export type Version = string;
|
|
5
|
-
export type Name = string;
|
|
6
|
-
export type CertificateSerialNumber = string;
|
|
7
|
-
export type Extensions = Record<string, unknown>;
|
|
8
|
-
export interface RevokedCertificate {
|
|
9
|
-
userCertificate: CertificateSerialNumber;
|
|
10
|
-
revocationDate: Date;
|
|
11
|
-
crlEntryExtensions?: Extensions;
|
|
12
|
-
}
|
|
13
|
-
export interface TBSCertList {
|
|
14
|
-
version?: Version;
|
|
15
|
-
signature: AlgorithmIdentifier;
|
|
16
|
-
issuer: Name;
|
|
17
|
-
issuerFingerprint: string;
|
|
18
|
-
thisUpdate: Date;
|
|
19
|
-
nextUpdate?: Date;
|
|
20
|
-
revokedCertificates: RevokedCertificate[];
|
|
21
|
-
}
|
|
22
|
-
export interface CertificateRevocationListInfo {
|
|
23
|
-
tbsCertList: TBSCertList;
|
|
24
|
-
signatureAlgorithm: AlgorithmIdentifier;
|
|
25
|
-
signatureValue: Buffer;
|
|
26
|
-
}
|
|
27
|
-
export declare function readNameForCrl(buffer: Buffer, block: BlockInfo): DirectoryName;
|
|
28
|
-
export declare function exploreCertificateRevocationList(crl: CertificateRevocationList): CertificateRevocationListInfo;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { BlockInfo } from "./asn1.js";
|
|
3
|
-
import { BasicConstraints, X509KeyUsage } from "./crypto_explore_certificate.js";
|
|
4
|
-
export interface ExtensionRequest {
|
|
5
|
-
basicConstraints: BasicConstraints;
|
|
6
|
-
keyUsage: X509KeyUsage;
|
|
7
|
-
subjectAltName: any;
|
|
8
|
-
}
|
|
9
|
-
export interface CertificateSigningRequestInfo {
|
|
10
|
-
extensionRequest: ExtensionRequest;
|
|
11
|
-
}
|
|
12
|
-
export declare function readCertificationRequestInfo(buffer: Buffer, block: BlockInfo): CertificateSigningRequestInfo;
|
|
13
|
-
export declare function exploreCertificateSigningRequest(crl: Buffer): CertificateSigningRequestInfo;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { PrivateKey } from "./common.js";
|
|
3
|
-
export interface PrivateKeyInternals {
|
|
4
|
-
/***/
|
|
5
|
-
version: Buffer;
|
|
6
|
-
modulus: Buffer;
|
|
7
|
-
publicExponent: Buffer;
|
|
8
|
-
privateExponent: Buffer;
|
|
9
|
-
prime1: Buffer;
|
|
10
|
-
prime2: Buffer;
|
|
11
|
-
exponent1: Buffer;
|
|
12
|
-
exponent2: Buffer;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param privateKey RSAPrivateKey ::= SEQUENCE {
|
|
17
|
-
* version Version,
|
|
18
|
-
* modulus INTEGER, -- n
|
|
19
|
-
* publicExponent INTEGER, -- e
|
|
20
|
-
* privateExponent INTEGER, -- d
|
|
21
|
-
* prime1 INTEGER, -- p
|
|
22
|
-
* prime2 INTEGER, -- q
|
|
23
|
-
* exponent1 INTEGER, -- d mod (p-1)
|
|
24
|
-
* exponent2 INTEGER, -- d mod (q-1)
|
|
25
|
-
* coefficient INTEGER, -- (inverse of q) mod p
|
|
26
|
-
* otherPrimeInfos OtherPrimeInfos OPTIONAL
|
|
27
|
-
}
|
|
28
|
-
*/
|
|
29
|
-
export declare function explorePrivateKey(privateKey2: PrivateKey): PrivateKeyInternals;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node_opcua_crypto
|
|
3
|
-
*/
|
|
4
|
-
export * from "./common.js";
|
|
5
|
-
export * from "./derived_keys.js";
|
|
6
|
-
export * from "./explore_certificate.js";
|
|
7
|
-
export * from "./crypto_utils.js";
|
|
8
|
-
export * from "./crypto_utils2.js";
|
|
9
|
-
export * from "./crypto_explore_certificate.js";
|
|
10
|
-
export * from "./verify_certificate_signature.js";
|
|
11
|
-
export * from "./explore_certificate_revocation_list.js";
|
|
12
|
-
export * from "./explore_certificate_signing_request.js";
|
|
13
|
-
export * from "./explore_private_key.js";
|
|
14
|
-
export { publicKeyAndPrivateKeyMatches, certificateMatchesPrivateKey } from "./public_private_match.js";
|
|
15
|
-
export * from "./x509/create_key_pair.js";
|
|
16
|
-
export * from "./x509/create_certificate_signing_request.js";
|
|
17
|
-
export * from "./x509/create_self_signed_certificate.js";
|
|
18
|
-
export * from "./x509/coerce_private_key.js";
|
|
19
|
-
export * from "./subject.js";
|
|
20
|
-
export * from "./asn1.js";
|
|
21
|
-
export * from "./make_private_key_from_pem.js";
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { Certificate, PrivateKey } from "./common.js";
|
|
2
|
-
export declare function publicKeyAndPrivateKeyMatches(certificate: Certificate, privateKey: PrivateKey): boolean;
|
|
3
|
-
export declare function certificateMatchesPrivateKey(certificate: Certificate, privateKey: PrivateKey): boolean;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export interface SubjectOptions {
|
|
2
|
-
commonName?: string;
|
|
3
|
-
organization?: string;
|
|
4
|
-
organizationalUnit?: string;
|
|
5
|
-
locality?: string;
|
|
6
|
-
state?: string;
|
|
7
|
-
country?: string;
|
|
8
|
-
domainComponent?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* subjectName The subject name to use for the Certificate.
|
|
12
|
-
* If not specified the ApplicationName and/or domainNames are used to create a suitable default value.
|
|
13
|
-
*/
|
|
14
|
-
export declare class Subject implements SubjectOptions {
|
|
15
|
-
readonly commonName?: string;
|
|
16
|
-
readonly organization?: string;
|
|
17
|
-
readonly organizationalUnit?: string;
|
|
18
|
-
readonly locality?: string;
|
|
19
|
-
readonly state?: string;
|
|
20
|
-
readonly country?: string;
|
|
21
|
-
readonly domainComponent?: string;
|
|
22
|
-
constructor(options: SubjectOptions | string);
|
|
23
|
-
static parse(str: string): SubjectOptions;
|
|
24
|
-
toStringInternal(sep: string): string;
|
|
25
|
-
toStringForOPCUA(): string;
|
|
26
|
-
toString(): string;
|
|
27
|
-
}
|