node-opcua-crypto 1.7.4 → 1.9.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.
Files changed (102) hide show
  1. package/.fossa.yml +18 -18
  2. package/.github/FUNDING.yml +12 -12
  3. package/.github/workflows/main.yml +32 -32
  4. package/.prettierrc.js +6 -6
  5. package/LICENSE +22 -22
  6. package/README.md +14 -14
  7. package/dist/asn1.d.ts +69 -0
  8. package/dist/asn1.js +349 -0
  9. package/dist/asn1.js.map +1 -0
  10. package/dist/buffer_utils.d.ts +6 -0
  11. package/dist/buffer_utils.js +22 -0
  12. package/dist/buffer_utils.js.map +1 -0
  13. package/dist/common.d.ts +11 -0
  14. package/dist/common.js +3 -0
  15. package/dist/common.js.map +1 -0
  16. package/dist/crypto_explore_certificate.d.ts +95 -0
  17. package/dist/crypto_explore_certificate.js +547 -0
  18. package/dist/crypto_explore_certificate.js.map +1 -0
  19. package/dist/crypto_utils.d.ts +106 -0
  20. package/dist/crypto_utils.js +370 -0
  21. package/dist/crypto_utils.js.map +1 -0
  22. package/dist/derived_keys.d.ts +72 -0
  23. package/dist/derived_keys.js +247 -0
  24. package/dist/derived_keys.js.map +1 -0
  25. package/dist/explore_certificate.d.ts +30 -0
  26. package/dist/explore_certificate.js +44 -0
  27. package/dist/explore_certificate.js.map +1 -0
  28. package/dist/explore_certificate_revocation_list.d.ts +30 -0
  29. package/dist/explore_certificate_revocation_list.js +67 -0
  30. package/dist/explore_certificate_revocation_list.js.map +1 -0
  31. package/dist/index.d.ts +10 -0
  32. package/dist/index.js +23 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/oid_map.d.ts +7 -0
  35. package/dist/oid_map.js +262 -0
  36. package/dist/oid_map.js.map +1 -0
  37. package/dist/source/asn1.d.ts +73 -73
  38. package/dist/source/asn1.js +359 -359
  39. package/dist/source/buffer_utils.d.ts +6 -5
  40. package/dist/source/buffer_utils.js +21 -21
  41. package/dist/source/common.d.ts +12 -12
  42. package/dist/source/common.js +2 -2
  43. package/dist/source/crypto_explore_certificate.d.ts +107 -107
  44. package/dist/source/crypto_explore_certificate.js +600 -600
  45. package/dist/source/crypto_utils.d.ts +78 -78
  46. package/dist/source/crypto_utils.js +280 -280
  47. package/dist/source/derived_keys.d.ts +72 -72
  48. package/dist/source/derived_keys.js +248 -245
  49. package/dist/source/derived_keys.js.map +1 -1
  50. package/dist/source/explore_certificate.d.ts +30 -30
  51. package/dist/source/explore_certificate.js +43 -43
  52. package/dist/source/explore_certificate_revocation_list.d.ts +28 -28
  53. package/dist/source/explore_certificate_revocation_list.js +44 -44
  54. package/dist/source/explore_certificate_signing_request.d.ts +13 -13
  55. package/dist/source/explore_certificate_signing_request.js +44 -44
  56. package/dist/source/explore_private_key.d.ts +29 -29
  57. package/dist/source/explore_private_key.js +96 -96
  58. package/dist/source/index.d.ts +13 -13
  59. package/dist/source/index.js +25 -25
  60. package/dist/source/oid_map.d.ts +7 -7
  61. package/dist/source/oid_map.js +303 -303
  62. package/dist/source/public_private_match.d.ts +3 -3
  63. package/dist/source/public_private_match.js +16 -16
  64. package/dist/source/verify_certificate_signature.d.ts +10 -10
  65. package/dist/source/verify_certificate_signature.js +101 -101
  66. package/dist/source_nodejs/index.d.ts +3 -3
  67. package/dist/source_nodejs/index.js +15 -15
  68. package/dist/source_nodejs/read.d.ts +29 -29
  69. package/dist/source_nodejs/read.js +94 -94
  70. package/dist/source_nodejs/read_certificate_revocation_list.d.ts +2 -2
  71. package/dist/source_nodejs/read_certificate_revocation_list.js +27 -27
  72. package/dist/source_nodejs/read_certificate_signing_request.d.ts +3 -3
  73. package/dist/source_nodejs/read_certificate_signing_request.js +27 -27
  74. package/dist/verify_cerficate_signature.d.ts +10 -0
  75. package/dist/verify_cerficate_signature.js +102 -0
  76. package/dist/verify_cerficate_signature.js.map +1 -0
  77. package/index.d.ts +2 -2
  78. package/index.js +4 -4
  79. package/index_web.js +3 -3
  80. package/package.json +17 -17
  81. package/source/asn1.ts +404 -404
  82. package/source/buffer_utils.ts +18 -18
  83. package/source/common.ts +13 -13
  84. package/source/crypto_explore_certificate.ts +763 -763
  85. package/source/crypto_utils.ts +321 -321
  86. package/source/derived_keys.ts +287 -284
  87. package/source/explore_certificate.ts +66 -66
  88. package/source/explore_certificate_revocation_list.ts +93 -93
  89. package/source/explore_certificate_signing_request.ts +58 -58
  90. package/source/explore_private_key.ts +121 -121
  91. package/source/index.ts +13 -13
  92. package/source/oid_map.ts +310 -310
  93. package/source/public_private_match.ts +17 -17
  94. package/source/verify_certificate_signature.ts +105 -105
  95. package/source_nodejs/index.ts +2 -2
  96. package/source_nodejs/read.ts +95 -95
  97. package/source_nodejs/read_certificate_revocation_list.ts +14 -14
  98. package/source_nodejs/read_certificate_signing_request.ts +17 -17
  99. package/test_certificate.ts +34 -34
  100. package/tsconfig.json +18 -18
  101. package/tslint.json +34 -34
  102. package/pnpm-lock.yaml +0 -1689
package/.fossa.yml CHANGED
@@ -1,18 +1,18 @@
1
- # Generated by FOSSA CLI (https://github.com/fossas/fossa-cli)
2
- # Visit https://fossa.com to learn more
3
-
4
- version: 2
5
- cli:
6
- server: https://app.fossa.com
7
- fetcher: custom
8
- project: https://github.com/node-opcua/node-opcua-crypto
9
- analyze:
10
- modules:
11
- - name: .
12
- type: npm
13
- target: .
14
- path: .
15
- - name: .
16
- type: npm
17
- target: .
18
- path: .
1
+ # Generated by FOSSA CLI (https://github.com/fossas/fossa-cli)
2
+ # Visit https://fossa.com to learn more
3
+
4
+ version: 2
5
+ cli:
6
+ server: https://app.fossa.com
7
+ fetcher: custom
8
+ project: https://github.com/node-opcua/node-opcua-crypto
9
+ analyze:
10
+ modules:
11
+ - name: .
12
+ type: npm
13
+ target: .
14
+ path: .
15
+ - name: .
16
+ type: npm
17
+ target: .
18
+ path: .
@@ -1,12 +1,12 @@
1
- # These are supported funding model platforms
2
-
3
- github: [erossignon]
4
- patreon: # Replace with a single Patreon username
5
- open_collective: # Replace with a single Open Collective username
6
- ko_fi: # Replace with a single Ko-fi username
7
- tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
- community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
- liberapay: # Replace with a single Liberapay username
10
- issuehunt: # Replace with a single IssueHunt username
11
- otechie: # Replace with a single Otechie username
12
- custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
1
+ # These are supported funding model platforms
2
+
3
+ github: [erossignon]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
@@ -1,32 +1,32 @@
1
- # This is a basic workflow to help you get started with Actions
2
-
3
- name: CI
4
-
5
- # Controls when the workflow will run
6
- on:
7
- # Triggers the workflow on push or pull request events but only for the master branch
8
- push:
9
- branches: [ master ]
10
- pull_request:
11
- branches: [ master ]
12
-
13
- # Allows you to run this workflow manually from the Actions tab
14
- workflow_dispatch:
15
-
16
- # A workflow run is made up of one or more jobs that can run sequentially or in parallel
17
- jobs:
18
- # This workflow contains a single job called "build"
19
- build:
20
- # The type of runner that the job will run on
21
- runs-on: ubuntu-latest
22
-
23
- # Steps represent a sequence of tasks that will be executed as part of the job
24
- steps:
25
- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26
- - uses: actions/checkout@v2
27
-
28
- # Runs a set of commands using the runners shell
29
- - name: build
30
- run: |
31
- npm install
32
- npm run test
1
+ # This is a basic workflow to help you get started with Actions
2
+
3
+ name: CI
4
+
5
+ # Controls when the workflow will run
6
+ on:
7
+ # Triggers the workflow on push or pull request events but only for the master branch
8
+ push:
9
+ branches: [ master ]
10
+ pull_request:
11
+ branches: [ master ]
12
+
13
+ # Allows you to run this workflow manually from the Actions tab
14
+ workflow_dispatch:
15
+
16
+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
17
+ jobs:
18
+ # This workflow contains a single job called "build"
19
+ build:
20
+ # The type of runner that the job will run on
21
+ runs-on: ubuntu-latest
22
+
23
+ # Steps represent a sequence of tasks that will be executed as part of the job
24
+ steps:
25
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26
+ - uses: actions/checkout@v2
27
+
28
+ # Runs a set of commands using the runners shell
29
+ - name: build
30
+ run: |
31
+ npm install
32
+ npm run test
package/.prettierrc.js CHANGED
@@ -1,7 +1,7 @@
1
- module.exports = {
2
- semi: true,
3
- trailingComma: "es5",
4
- singleQuote: false,
5
- printWidth: 132,
6
- tabWidth: 4,
1
+ module.exports = {
2
+ semi: true,
3
+ trailingComma: "es5",
4
+ singleQuote: false,
5
+ printWidth: 132,
6
+ tabWidth: 4,
7
7
  };
package/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) Etienne Rossignon 2015-2020
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Etienne Rossignon 2015-2020
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md CHANGED
@@ -1,14 +1,14 @@
1
- # node-opcua-crypto
2
-
3
- [![Build Status](https://travis-ci.org/node-opcua/node-opcua-crypto.png?branch=master)](https://travis-ci.org/node-opcua/node-opcua-crypto)
4
- [![Code Climate](https://codeclimate.com/github/node-opcua/node-opcua-crypto/badges/gpa.svg)](https://codeclimate.com/github/node-opcua/node-opcua-crypto)
5
- [![Test Coverage](https://codeclimate.com/github/node-opcua/node-opcua-crypto/badges/coverage.svg)](https://codeclimate.com/github/node-opcua/node-opcua-crypto/coverage)
6
- [![Coverage Status](https://coveralls.io/repos/github/node-opcua/node-opcua-crypto/badge.svg?branch=master)](https://coveralls.io/github/node-opcua/node-opcua-crypto?branch=master)
7
-
8
- [![install size](https://packagephobia.com/badge?p=node-opcua-crypto)](https://packagephobia.com/result?p=node-opcua-crypto)
9
-
10
- [![FOSSA Status](https://app.fossa.com/api/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto.svg?type=shield)](https://app.fossa.com/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto?ref=badge_shield)
11
-
12
- https://app.fossa.com/reports/489947c3-2e83-48e5-8351-192f553ded57
13
-
14
- // https://linuxctl.com/2017/02/x509-certificate-manual-signature-verification/
1
+ # node-opcua-crypto
2
+
3
+ [![Build Status](https://travis-ci.org/node-opcua/node-opcua-crypto.png?branch=master)](https://travis-ci.org/node-opcua/node-opcua-crypto)
4
+ [![Code Climate](https://codeclimate.com/github/node-opcua/node-opcua-crypto/badges/gpa.svg)](https://codeclimate.com/github/node-opcua/node-opcua-crypto)
5
+ [![Test Coverage](https://codeclimate.com/github/node-opcua/node-opcua-crypto/badges/coverage.svg)](https://codeclimate.com/github/node-opcua/node-opcua-crypto/coverage)
6
+ [![Coverage Status](https://coveralls.io/repos/github/node-opcua/node-opcua-crypto/badge.svg?branch=master)](https://coveralls.io/github/node-opcua/node-opcua-crypto?branch=master)
7
+
8
+ [![install size](https://packagephobia.com/badge?p=node-opcua-crypto)](https://packagephobia.com/result?p=node-opcua-crypto)
9
+
10
+ [![FOSSA Status](https://app.fossa.com/api/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto.svg?type=shield)](https://app.fossa.com/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto?ref=badge_shield)
11
+
12
+ https://app.fossa.com/reports/489947c3-2e83-48e5-8351-192f553ded57
13
+
14
+ // https://linuxctl.com/2017/02/x509-certificate-manual-signature-verification/
package/dist/asn1.d.ts ADDED
@@ -0,0 +1,69 @@
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 ADDED
@@ -0,0 +1,349 @@
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
@@ -0,0 +1 @@
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,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;IACp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