node-opcua-crypto 1.11.0 → 2.0.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/.fossa.yml +18 -18
- package/.github/FUNDING.yml +12 -12
- package/.github/workflows/main.yml +32 -32
- package/.prettierrc.js +6 -6
- package/LICENSE +23 -22
- package/README.md +14 -14
- package/dist/source/asn1.d.ts +73 -73
- package/dist/source/asn1.js +359 -359
- package/dist/source/buffer_utils.d.ts +6 -6
- package/dist/source/buffer_utils.js +21 -21
- package/dist/source/certificate_matches_private_key.d.ts +2 -0
- package/dist/source/certificate_matches_private_key.js +22 -0
- package/dist/source/certificate_matches_private_key.js.map +1 -0
- package/dist/source/common.d.ts +12 -12
- package/dist/source/common.js +2 -2
- package/dist/source/crypto_explore_certificate.d.ts +107 -107
- package/dist/source/crypto_explore_certificate.js +601 -600
- package/dist/source/crypto_explore_certificate.js.map +1 -1
- package/dist/source/crypto_utils.d.ts +80 -78
- package/dist/source/crypto_utils.js +312 -280
- package/dist/source/crypto_utils.js.map +1 -1
- package/dist/source/derived_keys.d.ts +72 -72
- package/dist/source/derived_keys.js +248 -248
- package/dist/source/explore_certificate.d.ts +30 -30
- package/dist/source/explore_certificate.js +43 -43
- package/dist/source/explore_certificate_revocation_list.d.ts +28 -28
- package/dist/source/explore_certificate_revocation_list.js +69 -69
- package/dist/source/explore_certificate_signing_request.d.ts +13 -13
- package/dist/source/explore_certificate_signing_request.js +44 -44
- package/dist/source/explore_private_key.d.ts +29 -29
- package/dist/source/explore_private_key.js +96 -96
- package/dist/source/explore_private_key.js.map +1 -1
- package/dist/source/index.d.ts +13 -13
- package/dist/source/index.js +29 -29
- package/dist/source/oid_map.d.ts +7 -7
- package/dist/source/oid_map.js +303 -303
- package/dist/source/public_private_match.d.ts +3 -3
- package/dist/source/public_private_match.js +37 -16
- package/dist/source/public_private_match.js.map +1 -1
- package/dist/source/verify_certificate_signature.d.ts +10 -10
- package/dist/source/verify_certificate_signature.js +101 -101
- package/dist/source_nodejs/index.d.ts +3 -3
- package/dist/source_nodejs/index.js +19 -19
- package/dist/source_nodejs/read.d.ts +29 -29
- package/dist/source_nodejs/read.js +94 -94
- package/dist/source_nodejs/read.js.map +1 -1
- package/dist/source_nodejs/read_certificate_revocation_list.d.ts +2 -2
- package/dist/source_nodejs/read_certificate_revocation_list.js +27 -27
- package/dist/source_nodejs/read_certificate_signing_request.d.ts +3 -3
- package/dist/source_nodejs/read_certificate_signing_request.js +27 -27
- package/index.d.ts +2 -2
- package/index.js +4 -4
- package/index_web.js +3 -3
- package/package.json +12 -12
- package/source/asn1.ts +404 -404
- package/source/buffer_utils.ts +18 -18
- package/source/common.ts +13 -13
- package/source/crypto_explore_certificate.ts +764 -763
- package/source/crypto_utils.ts +359 -321
- package/source/derived_keys.ts +287 -287
- package/source/explore_certificate.ts +66 -66
- package/source/explore_certificate_revocation_list.ts +122 -122
- package/source/explore_certificate_signing_request.ts +58 -58
- package/source/explore_private_key.ts +121 -121
- package/source/index.ts +13 -13
- package/source/oid_map.ts +310 -310
- package/source/public_private_match.ts +41 -18
- package/source/verify_certificate_signature.ts +105 -105
- package/source_nodejs/index.ts +2 -2
- package/source_nodejs/read.ts +95 -95
- package/source_nodejs/read_certificate_revocation_list.ts +14 -14
- package/source_nodejs/read_certificate_signing_request.ts +17 -17
- package/test_certificate.ts +34 -34
- package/tsconfig.json +18 -18
- package/tslint.json +34 -34
- package/dist/asn1.d.ts +0 -69
- package/dist/asn1.js +0 -349
- package/dist/asn1.js.map +0 -1
- package/dist/buffer_utils.d.ts +0 -6
- package/dist/buffer_utils.js +0 -22
- package/dist/buffer_utils.js.map +0 -1
- package/dist/common.d.ts +0 -11
- package/dist/common.js +0 -3
- package/dist/common.js.map +0 -1
- package/dist/crypto_explore_certificate.d.ts +0 -95
- package/dist/crypto_explore_certificate.js +0 -547
- package/dist/crypto_explore_certificate.js.map +0 -1
- package/dist/crypto_utils.d.ts +0 -106
- package/dist/crypto_utils.js +0 -370
- package/dist/crypto_utils.js.map +0 -1
- package/dist/derived_keys.d.ts +0 -72
- package/dist/derived_keys.js +0 -247
- package/dist/derived_keys.js.map +0 -1
- package/dist/explore_certificate.d.ts +0 -30
- package/dist/explore_certificate.js +0 -44
- package/dist/explore_certificate.js.map +0 -1
- package/dist/explore_certificate_revocation_list.d.ts +0 -30
- package/dist/explore_certificate_revocation_list.js +0 -67
- package/dist/explore_certificate_revocation_list.js.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -23
- package/dist/index.js.map +0 -1
- package/dist/oid_map.d.ts +0 -7
- package/dist/oid_map.js +0 -262
- package/dist/oid_map.js.map +0 -1
- package/dist/verify_cerficate_signature.d.ts +0 -10
- package/dist/verify_cerficate_signature.js +0 -102
- package/dist/verify_cerficate_signature.js.map +0 -1
package/tslint.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": [
|
|
3
|
-
"tslint:recommended",
|
|
4
|
-
"tslint-config-prettier"
|
|
5
|
-
],
|
|
6
|
-
"jsRules": {},
|
|
7
|
-
"rules": {
|
|
8
|
-
"interface-name": [
|
|
9
|
-
false,
|
|
10
|
-
"never-prefix"
|
|
11
|
-
],
|
|
12
|
-
"interface-over-type-literal": true,
|
|
13
|
-
"variable-name": [
|
|
14
|
-
true,
|
|
15
|
-
"ban-keywords",
|
|
16
|
-
"allow-leading-underscore"
|
|
17
|
-
],
|
|
18
|
-
"trailing-comma": [
|
|
19
|
-
false
|
|
20
|
-
],
|
|
21
|
-
"object-literal-sort-keys": false,
|
|
22
|
-
"comment-format": [
|
|
23
|
-
false
|
|
24
|
-
],
|
|
25
|
-
"no-var-requires": false,
|
|
26
|
-
"max-line-length": [
|
|
27
|
-
false,
|
|
28
|
-
120
|
|
29
|
-
],
|
|
30
|
-
"one-variable-per-declaration": [
|
|
31
|
-
false
|
|
32
|
-
]
|
|
33
|
-
},
|
|
34
|
-
"rulesDirectory": []
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"tslint:recommended",
|
|
4
|
+
"tslint-config-prettier"
|
|
5
|
+
],
|
|
6
|
+
"jsRules": {},
|
|
7
|
+
"rules": {
|
|
8
|
+
"interface-name": [
|
|
9
|
+
false,
|
|
10
|
+
"never-prefix"
|
|
11
|
+
],
|
|
12
|
+
"interface-over-type-literal": true,
|
|
13
|
+
"variable-name": [
|
|
14
|
+
true,
|
|
15
|
+
"ban-keywords",
|
|
16
|
+
"allow-leading-underscore"
|
|
17
|
+
],
|
|
18
|
+
"trailing-comma": [
|
|
19
|
+
false
|
|
20
|
+
],
|
|
21
|
+
"object-literal-sort-keys": false,
|
|
22
|
+
"comment-format": [
|
|
23
|
+
false
|
|
24
|
+
],
|
|
25
|
+
"no-var-requires": false,
|
|
26
|
+
"max-line-length": [
|
|
27
|
+
false,
|
|
28
|
+
120
|
|
29
|
+
],
|
|
30
|
+
"one-variable-per-declaration": [
|
|
31
|
+
false
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"rulesDirectory": []
|
|
35
35
|
}
|
package/dist/asn1.d.ts
DELETED
|
@@ -1,69 +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
|
-
}
|
|
22
|
-
export interface BlockInfo {
|
|
23
|
-
tag: TagType;
|
|
24
|
-
position: number;
|
|
25
|
-
length: number;
|
|
26
|
-
}
|
|
27
|
-
export declare function readTag(buf: Buffer, pos: number): BlockInfo;
|
|
28
|
-
export declare function _readStruct(buf: Buffer, blockInfo: BlockInfo): BlockInfo[];
|
|
29
|
-
export declare function parseBitString(buffer: Buffer, start: number, end: number, maxLength: number): string;
|
|
30
|
-
export interface BitString {
|
|
31
|
-
lengthInBits: number;
|
|
32
|
-
lengthInBytes: number;
|
|
33
|
-
data: Buffer;
|
|
34
|
-
debug?: any;
|
|
35
|
-
}
|
|
36
|
-
export declare function _readBitString(buffer: Buffer, block: BlockInfo): BitString;
|
|
37
|
-
export declare function formatBuffer2DigetHexWithColum(buffer: Buffer): string;
|
|
38
|
-
export declare function _readOctetString(buffer: Buffer, block: BlockInfo): Buffer;
|
|
39
|
-
export declare function _getBlock(buffer: Buffer, block: BlockInfo): Buffer;
|
|
40
|
-
export interface AlgorithmIdentifier {
|
|
41
|
-
identifier: string;
|
|
42
|
-
}
|
|
43
|
-
export declare function _readIntegerAsByteString(buffer: Buffer, block: BlockInfo): Buffer;
|
|
44
|
-
export declare function _readListOfInteger(buffer: Buffer): Buffer[];
|
|
45
|
-
export declare function _readObjectIdentifier(buffer: Buffer, block: BlockInfo): {
|
|
46
|
-
oid: string;
|
|
47
|
-
name: string;
|
|
48
|
-
};
|
|
49
|
-
export declare function _readAlgorithmIdentifier(buffer: Buffer, block: BlockInfo): AlgorithmIdentifier;
|
|
50
|
-
export declare type SignatureValue = string;
|
|
51
|
-
export declare function _readSignatureValueBin(buffer: Buffer, block: BlockInfo): Buffer;
|
|
52
|
-
export declare function _readSignatureValue(buffer: Buffer, block: BlockInfo): SignatureValue;
|
|
53
|
-
export declare function _readLongIntegerValue(buffer: Buffer, block: BlockInfo): Buffer;
|
|
54
|
-
export declare function _readIntegerValue(buffer: Buffer, block: BlockInfo): number;
|
|
55
|
-
export declare function _readBooleanValue(buffer: Buffer, block: BlockInfo): boolean;
|
|
56
|
-
export declare function _readVersionValue(buffer: Buffer, block: BlockInfo): number;
|
|
57
|
-
export declare function _readValue(buffer: Buffer, block: BlockInfo): any;
|
|
58
|
-
export interface DirectoryName {
|
|
59
|
-
stateOrProvinceName?: string;
|
|
60
|
-
localityName?: string;
|
|
61
|
-
organizationName?: string;
|
|
62
|
-
organizationUnitName?: string;
|
|
63
|
-
commonName?: string;
|
|
64
|
-
countryName?: string;
|
|
65
|
-
}
|
|
66
|
-
export declare function compactDirectoryName(d: DirectoryName): string;
|
|
67
|
-
export declare function _readDirectoryName(buffer: Buffer, block: BlockInfo): DirectoryName;
|
|
68
|
-
export declare function _findBlockAtIndex(blocks: BlockInfo[], index: number): BlockInfo | null;
|
|
69
|
-
export declare function _readTime(buffer: Buffer, block: BlockInfo): any;
|
package/dist/asn1.js
DELETED
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._readTime = exports._findBlockAtIndex = exports._readDirectoryName = exports.compactDirectoryName = exports._readValue = exports._readVersionValue = exports._readBooleanValue = exports._readIntegerValue = exports._readLongIntegerValue = exports._readSignatureValue = exports._readSignatureValueBin = exports._readAlgorithmIdentifier = exports._readObjectIdentifier = exports._readListOfInteger = exports._readIntegerAsByteString = exports._getBlock = exports._readOctetString = exports.formatBuffer2DigetHexWithColum = exports._readBitString = exports.parseBitString = exports._readStruct = exports.readTag = exports.TagType = void 0;
|
|
4
|
-
const _ = require("underscore");
|
|
5
|
-
const assert = require("assert");
|
|
6
|
-
const oid_map_1 = require("./oid_map");
|
|
7
|
-
// https://github.com/lapo-luchini/asn1js/blob/master/asn1.js
|
|
8
|
-
var TagType;
|
|
9
|
-
(function (TagType) {
|
|
10
|
-
TagType[TagType["BOOLEAN"] = 1] = "BOOLEAN";
|
|
11
|
-
TagType[TagType["INTEGER"] = 2] = "INTEGER";
|
|
12
|
-
TagType[TagType["BIT_STRING"] = 3] = "BIT_STRING";
|
|
13
|
-
TagType[TagType["OCTET_STRING"] = 4] = "OCTET_STRING";
|
|
14
|
-
TagType[TagType["NULL"] = 5] = "NULL";
|
|
15
|
-
TagType[TagType["OBJECT_IDENTIFIER"] = 6] = "OBJECT_IDENTIFIER";
|
|
16
|
-
TagType[TagType["UTF8String"] = 12] = "UTF8String";
|
|
17
|
-
TagType[TagType["NumericString"] = 18] = "NumericString";
|
|
18
|
-
TagType[TagType["PrintableString"] = 19] = "PrintableString";
|
|
19
|
-
TagType[TagType["TeletexString"] = 20] = "TeletexString";
|
|
20
|
-
TagType[TagType["IA5String"] = 22] = "IA5String";
|
|
21
|
-
TagType[TagType["UTCTime"] = 23] = "UTCTime";
|
|
22
|
-
TagType[TagType["GeneralizedTime"] = 24] = "GeneralizedTime";
|
|
23
|
-
TagType[TagType["GraphicString"] = 25] = "GraphicString";
|
|
24
|
-
TagType[TagType["VisibleString"] = 26] = "VisibleString";
|
|
25
|
-
TagType[TagType["GeneralString"] = 27] = "GeneralString";
|
|
26
|
-
TagType[TagType["UniversalString"] = 28] = "UniversalString";
|
|
27
|
-
TagType[TagType["BMPString"] = 30] = "BMPString";
|
|
28
|
-
})(TagType = exports.TagType || (exports.TagType = {}));
|
|
29
|
-
function readTag(buf, pos) {
|
|
30
|
-
assert(buf instanceof Buffer);
|
|
31
|
-
assert(_.isNumber(pos) && pos >= 0);
|
|
32
|
-
// istanbul ignore next
|
|
33
|
-
if (buf.length <= pos) {
|
|
34
|
-
throw new Error("Invalid position : buf.length=" + buf.length + " pos =" + pos);
|
|
35
|
-
}
|
|
36
|
-
const tag = buf.readUInt8(pos);
|
|
37
|
-
pos += 1;
|
|
38
|
-
let length = buf.readUInt8(pos);
|
|
39
|
-
pos += 1;
|
|
40
|
-
// tslint:disable:no-bitwise
|
|
41
|
-
if (length > 127) {
|
|
42
|
-
const nbBytes = length & 0x7f;
|
|
43
|
-
length = 0;
|
|
44
|
-
for (let i = 0; i < nbBytes; i++) {
|
|
45
|
-
length = length * 256 + buf.readUInt8(pos);
|
|
46
|
-
pos += 1;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return { tag, position: pos, length };
|
|
50
|
-
}
|
|
51
|
-
exports.readTag = readTag;
|
|
52
|
-
function _readStruct(buf, blockInfo) {
|
|
53
|
-
const length = blockInfo.length;
|
|
54
|
-
let cursor = blockInfo.position;
|
|
55
|
-
const end = blockInfo.position + length;
|
|
56
|
-
const blocks = [];
|
|
57
|
-
while (cursor < end) {
|
|
58
|
-
const inner = readTag(buf, cursor);
|
|
59
|
-
cursor = inner.position + inner.length;
|
|
60
|
-
blocks.push(inner);
|
|
61
|
-
}
|
|
62
|
-
return blocks;
|
|
63
|
-
}
|
|
64
|
-
exports._readStruct = _readStruct;
|
|
65
|
-
function parseBitString(buffer, start, end, maxLength) {
|
|
66
|
-
const unusedBit = buffer.readUInt8(start), lenBit = ((end - start - 1) << 3) - unusedBit, intro = "(" + lenBit + " bit)\n";
|
|
67
|
-
let s = "", skip = unusedBit;
|
|
68
|
-
for (let i = end - 1; i > start; --i) {
|
|
69
|
-
const b = buffer.readUInt8(i);
|
|
70
|
-
for (let j = skip; j < 8; ++j) {
|
|
71
|
-
// noinspection JSBitwiseOperatorUsage
|
|
72
|
-
s += (b >> j) & 1 ? "1" : "0";
|
|
73
|
-
}
|
|
74
|
-
skip = 0;
|
|
75
|
-
assert(s.length <= maxLength);
|
|
76
|
-
}
|
|
77
|
-
return intro + s;
|
|
78
|
-
}
|
|
79
|
-
exports.parseBitString = parseBitString;
|
|
80
|
-
function _readBitString(buffer, block) {
|
|
81
|
-
assert(block.tag === TagType.BIT_STRING);
|
|
82
|
-
const data = _getBlock(buffer, block);
|
|
83
|
-
// number of skipped bits
|
|
84
|
-
const ignore_bits = data.readUInt8(0);
|
|
85
|
-
return {
|
|
86
|
-
lengthInBits: data.length * 8 - ignore_bits,
|
|
87
|
-
lengthInBytes: data.length - 1,
|
|
88
|
-
data: data.slice(1),
|
|
89
|
-
debug: parseBitString(buffer, block.position, block.length + block.position, 5000),
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
exports._readBitString = _readBitString;
|
|
93
|
-
function formatBuffer2DigetHexWithColum(buffer) {
|
|
94
|
-
const value = [];
|
|
95
|
-
for (let i = 0; i < buffer.length; i++) {
|
|
96
|
-
value.push(("00" + buffer.readUInt8(i).toString(16)).substr(-2, 2));
|
|
97
|
-
}
|
|
98
|
-
// remove leading 00
|
|
99
|
-
return value
|
|
100
|
-
.join(":")
|
|
101
|
-
.toUpperCase()
|
|
102
|
-
.replace(/^(00:)*/, "");
|
|
103
|
-
}
|
|
104
|
-
exports.formatBuffer2DigetHexWithColum = formatBuffer2DigetHexWithColum;
|
|
105
|
-
function _readOctetString(buffer, block) {
|
|
106
|
-
assert(block.tag === TagType.OCTET_STRING);
|
|
107
|
-
const tag = readTag(buffer, block.position);
|
|
108
|
-
assert(tag.tag === TagType.OCTET_STRING);
|
|
109
|
-
const nbBytes = tag.length;
|
|
110
|
-
const pos = tag.position;
|
|
111
|
-
const b = buffer.slice(pos, pos + nbBytes);
|
|
112
|
-
return b;
|
|
113
|
-
}
|
|
114
|
-
exports._readOctetString = _readOctetString;
|
|
115
|
-
function _getBlock(buffer, block) {
|
|
116
|
-
const start = block.position;
|
|
117
|
-
const end = block.position + block.length;
|
|
118
|
-
return buffer.slice(start, end);
|
|
119
|
-
}
|
|
120
|
-
exports._getBlock = _getBlock;
|
|
121
|
-
function _readIntegerAsByteString(buffer, block) {
|
|
122
|
-
return _getBlock(buffer, block);
|
|
123
|
-
}
|
|
124
|
-
exports._readIntegerAsByteString = _readIntegerAsByteString;
|
|
125
|
-
function _readListOfInteger(buffer) {
|
|
126
|
-
const block = readTag(buffer, 0);
|
|
127
|
-
const inner_blocks = _readStruct(buffer, block);
|
|
128
|
-
return inner_blocks.map((bblock) => {
|
|
129
|
-
return _readIntegerAsByteString(buffer, bblock);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
exports._readListOfInteger = _readListOfInteger;
|
|
133
|
-
function parseOID(buffer, start, end) {
|
|
134
|
-
// ASN.1 JavaScript decoder
|
|
135
|
-
// Copyright (c) 2008-2014 Lapo Luchini <lapo@lapo.it>
|
|
136
|
-
let s = "", n = 0, bits = 0;
|
|
137
|
-
for (let i = start; i < end; ++i) {
|
|
138
|
-
const v = buffer.readUInt8(i);
|
|
139
|
-
// tslint:disable-next-line: no-bitwise
|
|
140
|
-
n = n * 128 + (v & 0x7f);
|
|
141
|
-
bits += 7;
|
|
142
|
-
// noinspection JSBitwiseOperatorUsage
|
|
143
|
-
// tslint:disable-next-line: no-bitwise
|
|
144
|
-
if (!(v & 0x80)) {
|
|
145
|
-
// finished
|
|
146
|
-
if (s === "") {
|
|
147
|
-
const m = n < 80 ? (n < 40 ? 0 : 1) : 2;
|
|
148
|
-
s = m + "." + (n - m * 40);
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
s += "." + n.toString();
|
|
152
|
-
}
|
|
153
|
-
n = 0;
|
|
154
|
-
bits = 0;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
assert(bits === 0); // if (bits > 0) { s += ".incomplete"; }
|
|
158
|
-
return s;
|
|
159
|
-
}
|
|
160
|
-
function _readObjectIdentifier(buffer, block) {
|
|
161
|
-
assert(block.tag === TagType.OBJECT_IDENTIFIER);
|
|
162
|
-
const b = buffer.slice(block.position, block.position + block.length);
|
|
163
|
-
const oid = parseOID(b, 0, block.length);
|
|
164
|
-
return {
|
|
165
|
-
oid,
|
|
166
|
-
name: oid_map_1.oid_map[oid] ? oid_map_1.oid_map[oid].d : oid,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
exports._readObjectIdentifier = _readObjectIdentifier;
|
|
170
|
-
function _readAlgorithmIdentifier(buffer, block) {
|
|
171
|
-
const inner_blocks = _readStruct(buffer, block);
|
|
172
|
-
return {
|
|
173
|
-
identifier: _readObjectIdentifier(buffer, inner_blocks[0]).name,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
exports._readAlgorithmIdentifier = _readAlgorithmIdentifier;
|
|
177
|
-
function _readSignatureValueBin(buffer, block) {
|
|
178
|
-
return _readBitString(buffer, block).data;
|
|
179
|
-
}
|
|
180
|
-
exports._readSignatureValueBin = _readSignatureValueBin;
|
|
181
|
-
function _readSignatureValue(buffer, block) {
|
|
182
|
-
return _readSignatureValueBin(buffer, block).toString("hex");
|
|
183
|
-
}
|
|
184
|
-
exports._readSignatureValue = _readSignatureValue;
|
|
185
|
-
function _readLongIntegerValue(buffer, block) {
|
|
186
|
-
assert(block.tag === TagType.INTEGER, "expecting a INTEGER tag");
|
|
187
|
-
const pos = block.position;
|
|
188
|
-
const nbBytes = block.length;
|
|
189
|
-
const buf = buffer.slice(pos, pos + nbBytes);
|
|
190
|
-
return buf;
|
|
191
|
-
}
|
|
192
|
-
exports._readLongIntegerValue = _readLongIntegerValue;
|
|
193
|
-
function _readIntegerValue(buffer, block) {
|
|
194
|
-
assert(block.tag === TagType.INTEGER, "expecting a INTEGER tag");
|
|
195
|
-
let pos = block.position;
|
|
196
|
-
const nbBytes = block.length;
|
|
197
|
-
assert(nbBytes < 4);
|
|
198
|
-
let value = 0;
|
|
199
|
-
for (let i = 0; i < nbBytes; i++) {
|
|
200
|
-
value = value * 256 + buffer.readUInt8(pos);
|
|
201
|
-
pos += 1;
|
|
202
|
-
}
|
|
203
|
-
return value;
|
|
204
|
-
}
|
|
205
|
-
exports._readIntegerValue = _readIntegerValue;
|
|
206
|
-
function _readBooleanValue(buffer, block) {
|
|
207
|
-
assert(block.tag === TagType.BOOLEAN, "expecting a BOOLEAN tag. got " + TagType[block.tag]);
|
|
208
|
-
const pos = block.position;
|
|
209
|
-
const nbBytes = block.length;
|
|
210
|
-
assert(nbBytes < 4);
|
|
211
|
-
const value = buffer.readUInt8(pos) ? true : false;
|
|
212
|
-
return value;
|
|
213
|
-
}
|
|
214
|
-
exports._readBooleanValue = _readBooleanValue;
|
|
215
|
-
function _readVersionValue(buffer, block) {
|
|
216
|
-
block = readTag(buffer, block.position);
|
|
217
|
-
return _readIntegerValue(buffer, block);
|
|
218
|
-
}
|
|
219
|
-
exports._readVersionValue = _readVersionValue;
|
|
220
|
-
/*
|
|
221
|
-
4.1.2.5.2 GeneralizedTime
|
|
222
|
-
|
|
223
|
-
The generalized time type, GeneralizedTime, is a standard ASN.1 type
|
|
224
|
-
for variable precision representation of time. Optionally, the
|
|
225
|
-
GeneralizedTime field can include a representation of the time
|
|
226
|
-
differential between local and Greenwich Mean Time.
|
|
227
|
-
|
|
228
|
-
For the purposes of this profile, GeneralizedTime values MUST be
|
|
229
|
-
expressed Greenwich Mean Time (Zulu) and MUST include seconds (i.e.,
|
|
230
|
-
times are YYYYMMDDHHMMSSZ), even where the number of seconds is zero.
|
|
231
|
-
GeneralizedTime values MUST NOT include fractional seconds.
|
|
232
|
-
|
|
233
|
-
*/
|
|
234
|
-
function convertGeneralizedTime(str) {
|
|
235
|
-
const year = parseInt(str.substr(0, 4), 10);
|
|
236
|
-
const month = parseInt(str.substr(4, 2), 10) - 1;
|
|
237
|
-
const day = parseInt(str.substr(6, 2), 10);
|
|
238
|
-
const hours = parseInt(str.substr(8, 2), 10);
|
|
239
|
-
const mins = parseInt(str.substr(10, 2), 10);
|
|
240
|
-
const secs = parseInt(str.substr(12, 2), 10);
|
|
241
|
-
return new Date(Date.UTC(year, month, day, hours, mins, secs));
|
|
242
|
-
}
|
|
243
|
-
function _readBMPString(buffer, block) {
|
|
244
|
-
const strBuff = _getBlock(buffer, block);
|
|
245
|
-
let str = "";
|
|
246
|
-
for (let i = 0; i < strBuff.length; i += 2) {
|
|
247
|
-
const word = strBuff.readUInt16BE(i);
|
|
248
|
-
str += String.fromCharCode(word);
|
|
249
|
-
}
|
|
250
|
-
return str;
|
|
251
|
-
}
|
|
252
|
-
/*
|
|
253
|
-
http://tools.ietf.org/html/rfc5280
|
|
254
|
-
|
|
255
|
-
4.1.2.5. Validity
|
|
256
|
-
[...]
|
|
257
|
-
As conforming to this profile MUST always encode certificate
|
|
258
|
-
validity dates through the year 2049 as UTCTime; certificate validity
|
|
259
|
-
dates in 2050 or later MUST be encoded as GeneralizedTime.
|
|
260
|
-
Conforming applications MUST be able to process validity dates that
|
|
261
|
-
are encoded in either UTCTime or GeneralizedTime.
|
|
262
|
-
[...]
|
|
263
|
-
|
|
264
|
-
4.1.2.5.1 UTCTime
|
|
265
|
-
|
|
266
|
-
The universal time type, UTCTime, is a standard ASN.1 type intended
|
|
267
|
-
for representation of dates and time. UTCTime specifies the year
|
|
268
|
-
through the two low order digits and time is specified to the
|
|
269
|
-
precision of one minute or one second. UTCTime includes either Z
|
|
270
|
-
(for Zulu, or Greenwich Mean Time) or a time differential.
|
|
271
|
-
|
|
272
|
-
For the purposes of this profile, UTCTime values MUST be expressed
|
|
273
|
-
Greenwich Mean Time (Zulu) and MUST include seconds (i.e., times are
|
|
274
|
-
YYMMDDHHMMSSZ), even where the number of seconds is zero. Conforming
|
|
275
|
-
systems MUST interpret the year field (YY) as follows:
|
|
276
|
-
|
|
277
|
-
Where YY is greater than or equal to 50, the year SHALL be
|
|
278
|
-
interpreted as 19YY; and
|
|
279
|
-
|
|
280
|
-
Where YY is less than 50, the year SHALL be interpreted as 20YY.
|
|
281
|
-
*/
|
|
282
|
-
function convertUTCTime(str) {
|
|
283
|
-
let year = parseInt(str.substr(0, 2), 10);
|
|
284
|
-
const month = parseInt(str.substr(2, 2), 10) - 1;
|
|
285
|
-
const day = parseInt(str.substr(4, 2), 10);
|
|
286
|
-
const hours = parseInt(str.substr(6, 2), 10);
|
|
287
|
-
const mins = parseInt(str.substr(8, 2), 10);
|
|
288
|
-
const secs = parseInt(str.substr(10, 2), 10);
|
|
289
|
-
year += year >= 50 ? 1900 : 2000;
|
|
290
|
-
return new Date(Date.UTC(year, month, day, hours, mins, secs));
|
|
291
|
-
}
|
|
292
|
-
function _readValue(buffer, block) {
|
|
293
|
-
switch (block.tag) {
|
|
294
|
-
case TagType.BOOLEAN:
|
|
295
|
-
return _readBooleanValue(buffer, block);
|
|
296
|
-
case TagType.BMPString:
|
|
297
|
-
return _readBMPString(buffer, block);
|
|
298
|
-
case TagType.PrintableString:
|
|
299
|
-
case TagType.TeletexString:
|
|
300
|
-
case TagType.UTF8String:
|
|
301
|
-
case TagType.NumericString:
|
|
302
|
-
case TagType.IA5String:
|
|
303
|
-
return _getBlock(buffer, block).toString("ascii");
|
|
304
|
-
case TagType.UTCTime:
|
|
305
|
-
return convertUTCTime(_getBlock(buffer, block).toString("ascii"));
|
|
306
|
-
case TagType.GeneralizedTime:
|
|
307
|
-
return convertGeneralizedTime(_getBlock(buffer, block).toString("ascii"));
|
|
308
|
-
default:
|
|
309
|
-
throw new Error("Invalid tag 0x" + block.tag.toString(16) + "");
|
|
310
|
-
//xx return " ??? <" + block.tag + ">";
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
exports._readValue = _readValue;
|
|
314
|
-
function compactDirectoryName(d) {
|
|
315
|
-
return JSON.stringify(d);
|
|
316
|
-
}
|
|
317
|
-
exports.compactDirectoryName = compactDirectoryName;
|
|
318
|
-
function _readDirectoryName(buffer, block) {
|
|
319
|
-
// AttributeTypeAndValue ::= SEQUENCE {
|
|
320
|
-
// type ATTRIBUTE.&id({SupportedAttributes}),
|
|
321
|
-
// value ATTRIBUTE.&Type({SupportedAttributes}{@type}),
|
|
322
|
-
const set_blocks = _readStruct(buffer, block);
|
|
323
|
-
const names = {};
|
|
324
|
-
for (const set_block of set_blocks) {
|
|
325
|
-
assert(set_block.tag === 0x31);
|
|
326
|
-
const blocks = _readStruct(buffer, set_block);
|
|
327
|
-
assert(blocks.length === 1);
|
|
328
|
-
assert(blocks[0].tag === 0x30);
|
|
329
|
-
const sequenceBlock = _readStruct(buffer, blocks[0]);
|
|
330
|
-
assert(sequenceBlock.length === 2);
|
|
331
|
-
const type = _readObjectIdentifier(buffer, sequenceBlock[0]);
|
|
332
|
-
names[type.name] = _readValue(buffer, sequenceBlock[1]);
|
|
333
|
-
}
|
|
334
|
-
return names;
|
|
335
|
-
}
|
|
336
|
-
exports._readDirectoryName = _readDirectoryName;
|
|
337
|
-
function _findBlockAtIndex(blocks, index) {
|
|
338
|
-
const tmp = blocks.filter((b) => b.tag === 0xa0 + index || b.tag === 0x80 + index);
|
|
339
|
-
if (tmp.length === 0) {
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
|
-
return tmp[0];
|
|
343
|
-
}
|
|
344
|
-
exports._findBlockAtIndex = _findBlockAtIndex;
|
|
345
|
-
function _readTime(buffer, block) {
|
|
346
|
-
return _readValue(buffer, block);
|
|
347
|
-
}
|
|
348
|
-
exports._readTime = _readTime;
|
|
349
|
-
//# sourceMappingURL=asn1.js.map
|
package/dist/asn1.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asn1.js","sourceRoot":"","sources":["../lib/asn1.ts"],"names":[],"mappings":";;;AAAA,gCAAgC;AAChC,iCAAiC;AACjC,uCAAoC;AAEpC,6DAA6D;AAC7D,IAAY,OAmBX;AAnBD,WAAY,OAAO;IACf,2CAAc,CAAA;IACd,2CAAc,CAAA;IACd,iDAAiB,CAAA;IACjB,qDAAmB,CAAA;IACnB,qCAAW,CAAA;IACX,+DAAwB,CAAA;IACxB,kDAAiB,CAAA;IACjB,wDAAoB,CAAA;IACpB,4DAAsB,CAAA;IACtB,wDAAoB,CAAA;IACpB,gDAAgB,CAAA;IAChB,4CAAc,CAAA;IACd,4DAAsB,CAAA;IACtB,wDAAoB,CAAA;IACpB,wDAAoB,CAAA;IACpB,wDAAoB,CAAA;IACpB,4DAAsB,CAAA;IACtB,gDAAgB,CAAA;AACpB,CAAC,EAnBW,OAAO,GAAP,eAAO,KAAP,eAAO,QAmBlB;AASD,SAAgB,OAAO,CAAC,GAAW,EAAE,GAAW;IAC5C,MAAM,CAAC,GAAG,YAAY,MAAM,CAAC,CAAC;IAC9B,MA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CAAC,CAAC,CAAC;QACrD,MAAM,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;QAEnC,MAAM,IAAI,GAAG,qBAAqB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,KAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;KACpE;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAnBD,gDAmBC;AAED,SAAgB,iBAAiB,CAAC,MAAmB,EAAE,KAAa;IAChE,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAY,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,CAAC;IAC9F,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;QAClB,OAAO,IAAI,CAAC;KACf;IACD,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAND,8CAMC;AAGD,SAAgB,SAAS,CAAC,MAAc,EAAE,KAAgB;IACtD,OAAO,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACrC,CAAC;AAFD,8BAEC"}
|
package/dist/buffer_utils.d.ts
DELETED
package/dist/buffer_utils.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createFastUninitializedBuffer = void 0;
|
|
4
|
-
//
|
|
5
|
-
// note: new Buffer(size)# is deprecated since: v6.0. and is replaced with Buffer.allocUnsafe
|
|
6
|
-
// to ensure backward compatibility we have to replace
|
|
7
|
-
// new Buffer(size) with createFastUninitializedBuffer(size)
|
|
8
|
-
//
|
|
9
|
-
// Buffer.alloc and Buffer.allocUnsafe have been introduced in nodejs 5.1.0
|
|
10
|
-
// in node 0.11 new Buffer
|
|
11
|
-
//
|
|
12
|
-
/**
|
|
13
|
-
* @internal
|
|
14
|
-
* @private
|
|
15
|
-
*/
|
|
16
|
-
exports.createFastUninitializedBuffer = Buffer.allocUnsafe
|
|
17
|
-
? Buffer.allocUnsafe
|
|
18
|
-
: (size) => {
|
|
19
|
-
// istanbul ignore next
|
|
20
|
-
return new Buffer(size);
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=buffer_utils.js.map
|
package/dist/buffer_utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buffer_utils.js","sourceRoot":"","sources":["../lib/buffer_utils.ts"],"names":[],"mappings":";;;AAAA,EAAE;AACF,8FAA8F;AAC9F,4DAA4D;AAC5D,kEAAkE;AAClE,EAAE;AACF,iFAAiF;AACjF,2BAA2B;AAC3B,EAAE;AACF;;;GAGG;AACU,QAAA,6BAA6B,GAAG,MAAM,CAAC,WAAW;IAC3D,CAAC,CAAC,MAAM,CAAC,WAAW;IACpB,CAAC,CAAC,CAAC,IAAY,EAAU,EAAE;QACvB,uBAAuB;QACvB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC"}
|
package/dist/common.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
export declare type Nonce = Buffer;
|
|
3
|
-
export declare type PEM = string;
|
|
4
|
-
export declare type DER = Buffer;
|
|
5
|
-
export declare type Certificate = DER;
|
|
6
|
-
export declare type CertificatePEM = PEM;
|
|
7
|
-
export declare type PrivateKey = DER;
|
|
8
|
-
export declare type PrivateKeyPEM = PEM;
|
|
9
|
-
export declare type PublicKey = DER;
|
|
10
|
-
export declare type PublicKeyPEM = PEM;
|
|
11
|
-
export declare type Signature = Buffer;
|
package/dist/common.js
DELETED
package/dist/common.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../lib/common.ts"],"names":[],"mappings":""}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node_opcua_crypto
|
|
3
|
-
*/
|
|
4
|
-
/// <reference types="node" />
|
|
5
|
-
import { AlgorithmIdentifier, SignatureValue, DirectoryName } from "./asn1";
|
|
6
|
-
import { Certificate, PrivateKey } from "./common";
|
|
7
|
-
import { PublicKeyLength } from "./explore_certificate";
|
|
8
|
-
export interface AttributeTypeAndValue {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
}
|
|
11
|
-
export interface Validity {
|
|
12
|
-
notBefore: Date;
|
|
13
|
-
notAfter: Date;
|
|
14
|
-
}
|
|
15
|
-
export interface KeyUsage {
|
|
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 ExtKeyUsage {
|
|
27
|
-
clientAuth: boolean;
|
|
28
|
-
serverAuth: boolean;
|
|
29
|
-
codeSigning: boolean;
|
|
30
|
-
emailProtection: boolean;
|
|
31
|
-
timeStamping: boolean;
|
|
32
|
-
}
|
|
33
|
-
export interface SubjectPublicKeyInfo {
|
|
34
|
-
algorithm: string;
|
|
35
|
-
keyLength: PublicKeyLength;
|
|
36
|
-
subjectPublicKey: Buffer;
|
|
37
|
-
}
|
|
38
|
-
export interface BasicConstraints {
|
|
39
|
-
critical: boolean;
|
|
40
|
-
cA: boolean;
|
|
41
|
-
pathLengthConstraint?: number;
|
|
42
|
-
}
|
|
43
|
-
export interface AuthorithyKeyIdentifier {
|
|
44
|
-
keyIdentifier: string | null;
|
|
45
|
-
authorityCertIssuer: DirectoryName | null;
|
|
46
|
-
authorityCertIssuerFingerPrint: string;
|
|
47
|
-
serial: string | null;
|
|
48
|
-
}
|
|
49
|
-
export interface CertificateExtension {
|
|
50
|
-
basicConstraints: BasicConstraints;
|
|
51
|
-
subjectKeyIdentifier?: string;
|
|
52
|
-
authorityKeyIdentifier?: AuthorithyKeyIdentifier;
|
|
53
|
-
keyUsage?: KeyUsage;
|
|
54
|
-
extKeyUsage?: KeyUsage;
|
|
55
|
-
subjectAltName?: any;
|
|
56
|
-
}
|
|
57
|
-
export interface TbsCertificate {
|
|
58
|
-
version: number;
|
|
59
|
-
serialNumber: string;
|
|
60
|
-
issuer: any;
|
|
61
|
-
signature: AlgorithmIdentifier;
|
|
62
|
-
validity: Validity;
|
|
63
|
-
subject: DirectoryName;
|
|
64
|
-
subjectFingerPrint: string;
|
|
65
|
-
subjectPublicKeyInfo: SubjectPublicKeyInfo;
|
|
66
|
-
extensions: CertificateExtension | null;
|
|
67
|
-
}
|
|
68
|
-
export interface CertificateInternals {
|
|
69
|
-
tbsCertificate: TbsCertificate;
|
|
70
|
-
signatureAlgorithm: AlgorithmIdentifier;
|
|
71
|
-
signatureValue: SignatureValue;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* explore a certificate structure
|
|
75
|
-
* @param certificate
|
|
76
|
-
* @returns a json object that exhibits the internal data of the certificate
|
|
77
|
-
*/
|
|
78
|
-
export declare function exploreCertificate(certificate: Certificate): CertificateInternals;
|
|
79
|
-
export interface PrivateKeyInternals {
|
|
80
|
-
}
|
|
81
|
-
export declare function explorePrivateKey(privateKey: PrivateKey): PrivateKeyInternals;
|
|
82
|
-
/**
|
|
83
|
-
* @method split_der
|
|
84
|
-
* split a multi chain certificates
|
|
85
|
-
* @param certificateChain the certificate chain in der (binary) format}
|
|
86
|
-
* @returns an array of Der , each element of the array is one certificate of the chain
|
|
87
|
-
*/
|
|
88
|
-
export declare function split_der(certificateChain: Certificate): Certificate[];
|
|
89
|
-
/**
|
|
90
|
-
* @method combine_der
|
|
91
|
-
* combine an array of certificates into a single blob
|
|
92
|
-
* @param certificates a array with the individual DER certificates of the chain
|
|
93
|
-
* @return a concatenated buffer containing the certificates
|
|
94
|
-
*/
|
|
95
|
-
export declare function combine_der(certificates: Certificate[]): Certificate;
|