@joclaim/tls 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +221 -0
- package/lib/crypto/common.d.ts +3 -0
- package/lib/crypto/common.js +26 -0
- package/lib/crypto/index.d.ts +3 -0
- package/lib/crypto/index.js +4 -0
- package/lib/crypto/insecure-rand.d.ts +1 -0
- package/lib/crypto/insecure-rand.js +9 -0
- package/lib/crypto/pure-js.d.ts +2 -0
- package/lib/crypto/pure-js.js +144 -0
- package/lib/crypto/webcrypto.d.ts +3 -0
- package/lib/crypto/webcrypto.js +310 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/make-tls-client.d.ts +74 -0
- package/lib/make-tls-client.js +657 -0
- package/lib/scripts/build-jsc.d.ts +1 -0
- package/lib/scripts/build-jsc.js +20 -0
- package/lib/scripts/ca-template.d.ts +5 -0
- package/lib/scripts/ca-template.js +6 -0
- package/lib/scripts/fallbacks/crypto.d.ts +4 -0
- package/lib/scripts/fallbacks/crypto.js +2 -0
- package/lib/scripts/handshake.d.ts +1 -0
- package/lib/scripts/handshake.js +61 -0
- package/lib/scripts/jsc.d.ts +28 -0
- package/lib/scripts/jsc.js +92 -0
- package/lib/scripts/update-ca-certs.d.ts +1 -0
- package/lib/scripts/update-ca-certs.js +29 -0
- package/lib/types/crypto.d.ts +62 -0
- package/lib/types/crypto.js +1 -0
- package/lib/types/index.d.ts +15 -0
- package/lib/types/index.js +4 -0
- package/lib/types/logger.d.ts +6 -0
- package/lib/types/logger.js +1 -0
- package/lib/types/tls.d.ts +141 -0
- package/lib/types/tls.js +1 -0
- package/lib/types/x509.d.ts +32 -0
- package/lib/types/x509.js +1 -0
- package/lib/utils/additional-root-cas.d.ts +1 -0
- package/lib/utils/additional-root-cas.js +197 -0
- package/lib/utils/client-hello.d.ts +23 -0
- package/lib/utils/client-hello.js +167 -0
- package/lib/utils/constants.d.ts +239 -0
- package/lib/utils/constants.js +244 -0
- package/lib/utils/decryption-utils.d.ts +64 -0
- package/lib/utils/decryption-utils.js +166 -0
- package/lib/utils/finish-messages.d.ts +11 -0
- package/lib/utils/finish-messages.js +49 -0
- package/lib/utils/generics.d.ts +35 -0
- package/lib/utils/generics.js +146 -0
- package/lib/utils/index.d.ts +18 -0
- package/lib/utils/index.js +18 -0
- package/lib/utils/key-share.d.ts +13 -0
- package/lib/utils/key-share.js +72 -0
- package/lib/utils/key-update.d.ts +2 -0
- package/lib/utils/key-update.js +14 -0
- package/lib/utils/logger.d.ts +2 -0
- package/lib/utils/logger.js +15 -0
- package/lib/utils/make-queue.d.ts +3 -0
- package/lib/utils/make-queue.js +22 -0
- package/lib/utils/mozilla-root-cas.d.ts +5 -0
- package/lib/utils/mozilla-root-cas.js +4459 -0
- package/lib/utils/packets.d.ts +51 -0
- package/lib/utils/packets.js +148 -0
- package/lib/utils/parse-alert.d.ts +7 -0
- package/lib/utils/parse-alert.js +28 -0
- package/lib/utils/parse-certificate.d.ts +29 -0
- package/lib/utils/parse-certificate.js +188 -0
- package/lib/utils/parse-client-hello.d.ts +11 -0
- package/lib/utils/parse-client-hello.js +39 -0
- package/lib/utils/parse-extensions.d.ts +11 -0
- package/lib/utils/parse-extensions.js +74 -0
- package/lib/utils/parse-server-hello.d.ts +10 -0
- package/lib/utils/parse-server-hello.js +52 -0
- package/lib/utils/session-ticket.d.ts +17 -0
- package/lib/utils/session-ticket.js +51 -0
- package/lib/utils/wrapped-record.d.ts +25 -0
- package/lib/utils/wrapped-record.js +191 -0
- package/lib/utils/x509.d.ts +5 -0
- package/lib/utils/x509.js +124 -0
- package/package.json +82 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/* eslint indent: 0 */
|
|
2
|
+
let TLS_ADDITIONAL_ROOT_CA_LIST;
|
|
3
|
+
let TLS_INTERMEDIATE_CA_CACHE;
|
|
4
|
+
if (typeof globalThis === 'object' && globalThis) {
|
|
5
|
+
TLS_ADDITIONAL_ROOT_CA_LIST = (globalThis.TLS_ADDITIONAL_ROOT_CA_LIST ||= []);
|
|
6
|
+
TLS_INTERMEDIATE_CA_CACHE = (globalThis.TLS_INTERMEDIATE_CA_CACHE ||= {});
|
|
7
|
+
}
|
|
8
|
+
else if (typeof window === 'object' && window) {
|
|
9
|
+
TLS_ADDITIONAL_ROOT_CA_LIST = (window.TLS_ADDITIONAL_ROOT_CA_LIST ||= []);
|
|
10
|
+
TLS_INTERMEDIATE_CA_CACHE = (window.TLS_INTERMEDIATE_CA_CACHE ||= {});
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
TLS_ADDITIONAL_ROOT_CA_LIST = [];
|
|
14
|
+
TLS_INTERMEDIATE_CA_CACHE = {};
|
|
15
|
+
}
|
|
16
|
+
TLS_ADDITIONAL_ROOT_CA_LIST.push(`-----BEGIN CERTIFICATE-----
|
|
17
|
+
MIIFjDCCA3SgAwIBAgIQfx8skC6D0OO2+zvuR4tegDANBgkqhkiG9w0BAQsFADBM
|
|
18
|
+
MSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xv
|
|
19
|
+
YmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjAeFw0yMzA3MTkwMzQzMjVaFw0y
|
|
20
|
+
NjA3MTkwMDAwMDBaMFUxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWdu
|
|
21
|
+
IG52LXNhMSswKQYDVQQDEyJHbG9iYWxTaWduIEdDQyBSNiBBbHBoYVNTTCBDQSAy
|
|
22
|
+
MDIzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA00Jvk5ADppO0rgDn
|
|
23
|
+
j1M14XIb032Aas409JJFAb8cUjipFOth7ySLdaWLe3s63oSs5x3eWwzTpX4BFkzZ
|
|
24
|
+
bxT1eoJSHfT2M0wZ5QOPcCIjsr+YB8TAvV2yJSyq+emRrN/FtgCSTaWXSJ5jipW8
|
|
25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8tD8d51bymCg5J6J6wcXpmsSGnksBobac1+nXmgB7jQC9edU8Z41FFo87BV3k
|
|
40
|
+
CtrWWsdkQavObMsXUPl/AO8y/jOuAWz0wyvPnKom+o6W4vKDY6/6XPypNdebOJ6m
|
|
41
|
+
jyaILp0quoQvhjx87BzENh5s57AIOyIGpS0sDEChVDPzLEfRsH2FJ8/W5woF0nvs
|
|
42
|
+
BTqfYSCqblQbHeDDtCj7Mlf8JfqaMuqcbE4rMSyfeHyCdZQwnc/r9ujnth691AJh
|
|
43
|
+
xyYeCM04metJIe7cB6d4dFm+Pd5ervY4x32r0uQ1Q0spy1VjNqUJjussYuXNyMmF
|
|
44
|
+
HSuLQQ6PrePmH5lcSMQpYKzPoD/RiNVD/PK0O3vuO5vh3o7oKb1FfzoanDsFFTrw
|
|
45
|
+
0aLOdRW/tmLPWVNVlAb8ad+B80YJsL4HXYnQG8wYAFb8LhwSDyT9v+C1C1lcIHE7
|
|
46
|
+
nE0AAp9JSHxDYsma9pi4g0Phg3BgOm2euTRzw7R0SzU=
|
|
47
|
+
-----END CERTIFICATE-----`, // GlobalSign GCC R6 AlphaSSL CA 2023 intermediate till 2026
|
|
48
|
+
`-----BEGIN CERTIFICATE-----
|
|
49
|
+
MIIGGTCCBAGgAwIBAgIQE31TnKp8MamkM3AZaIR6jTANBgkqhkiG9w0BAQwFADCB
|
|
50
|
+
iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl
|
|
51
|
+
cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV
|
|
52
|
+
BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTgx
|
|
53
|
+
MTAyMDAwMDAwWhcNMzAxMjMxMjM1OTU5WjCBlTELMAkGA1UEBhMCR0IxGzAZBgNV
|
|
54
|
+
BAgTEkdyZWF0ZXIgTWFuY2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RqMGgwPwYIKwYBBQUHMAKGM2h0dHA6Ly9jcnQudXNlcnRy
|
|
69
|
+
dXN0LmNvbS9VU0VSVHJ1c3RSU0FBZGRUcnVzdENBLmNydDAlBggrBgEFBQcwAYYZ
|
|
70
|
+
aHR0cDovL29jc3AudXNlcnRydXN0LmNvbTANBgkqhkiG9w0BAQwFAAOCAgEAThNA
|
|
71
|
+
lsnD5m5bwOO69Bfhrgkfyb/LDCUW8nNTs3Yat6tIBtbNAHwgRUNFbBZaGxNh10m6
|
|
72
|
+
pAKkrOjOzi3JKnSj3N6uq9BoNviRrzwB93fVC8+Xq+uH5xWo+jBaYXEgscBDxLmP
|
|
73
|
+
bYox6xU2JPti1Qucj+lmveZhUZeTth2HvbC1bP6mESkGYTQxMD0gJ3NR0N6Fg9N3
|
|
74
|
+
OSBGltqnxloWJ4Wyz04PToxcvr44APhL+XJ71PJ616IphdAEutNCLFGIUi7RPSRn
|
|
75
|
+
R+xVzBv0yjTqJsHe3cQhifa6ezIejpZehEU4z4CqN2mLYBd0FUiRnG3wTqN3yhsc
|
|
76
|
+
SPr5z0noX0+FCuKPkBurcEya67emP7SsXaRfz+bYipaQ908mgWB2XQ8kd5GzKjGf
|
|
77
|
+
FlqyXYwcKapInI5v03hAcNt37N3j0VcFcC3mSZiIBYRiBXBWdoY5TtMibx3+bfEO
|
|
78
|
+
s2LEPMvAhblhHrrhFYBZlAyuBbuMf1a+HNJav5fyakywxnB2sJCNwQs2uRHY1ihc
|
|
79
|
+
6k/+JLcYCpsM0MF8XPtpvcyiTcaQvKZN8rG61ppnW5YCUtCC+cQKXA0o4D/I+pWV
|
|
80
|
+
idWkvklsQLI+qGu41SWyxP7x09fn1txDAXYw+zuLXfdKiXyaNb78yvBXAfCNP6CH
|
|
81
|
+
MntHWpdLgtJmwsQt6j8k9Kf5qLnjatkYYaA7jBU=
|
|
82
|
+
-----END CERTIFICATE-----`, //Sectigo RSA Organization Validation Secure Server CA
|
|
83
|
+
`-----BEGIN CERTIFIC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/OF1s7vSmgYVafsRoZd/IHUrkoQvX8FZwUsmPu7amgBfaY3g+d
|
|
186
|
+
q1x0jNGKb6I6Bzdl6LgMD9qxp+3i7GQOnd9J8LFSietY6Z4jUBzVoOoz8iAU84OF
|
|
187
|
+
h2HhAuiPw1ai0VnY38RTI+8kepGWVfGxfBWzwH9uIjeooIeaosVFvE8cmYUB4TSH
|
|
188
|
+
5dUyD0jHct2+8ceKEtIoFU/FfHq/mDaVnvcDCZXtIgitdMFQdMZaVehmObyhRdDD
|
|
189
|
+
4NQCs0gaI9AAgFj4L9QtkARzhQLNyRf87Kln+YU0lgCGr9HLg3rGO8q+Y4ppLsOd
|
|
190
|
+
unQZ6ZxPNGIfOApbPVf5hCe58EZwiWdHIMn9lPP6+F404y8NNugbQixBber+x536
|
|
191
|
+
WrZhFZLjEkhp7fFXf9r32rNPfb74X/U90Bdy4lzp3+X1ukh1BuMxA/EEhDoTOS3l
|
|
192
|
+
7ABvc7BYSQubQ2490OcdkIzUh3ZwDrakMVrbaTxUM2p24N6dB+ns2zptWCva6jzW
|
|
193
|
+
r8IWKIMxzxLPv5Kt3ePKcUdvkBU/smqujSczTzzSjIoR5QqQA6lN1ZRSnuHIWCvh
|
|
194
|
+
JEltkYnTAH41QJ6SAWO66GrrUESwN/cgZzL4JLEqz1Y=
|
|
195
|
+
-----END CERTIFICATE-----` // Sectigo Public Server Authentication CA DV R36
|
|
196
|
+
);
|
|
197
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Key, TLSHelloBaseOptions, TLSPresharedKey } from '../types/index.ts';
|
|
2
|
+
import { SUPPORTED_NAMED_CURVE_MAP } from './constants.ts';
|
|
3
|
+
type SupportedNamedCurve = keyof typeof SUPPORTED_NAMED_CURVE_MAP;
|
|
4
|
+
type PublicKeyData = {
|
|
5
|
+
type: SupportedNamedCurve;
|
|
6
|
+
key: Key;
|
|
7
|
+
};
|
|
8
|
+
type ClientHelloOptions = TLSHelloBaseOptions & {
|
|
9
|
+
host: string;
|
|
10
|
+
keysToShare: PublicKeyData[];
|
|
11
|
+
random?: Uint8Array;
|
|
12
|
+
sessionId?: Uint8Array;
|
|
13
|
+
psk?: TLSPresharedKey;
|
|
14
|
+
};
|
|
15
|
+
export declare function packClientHello({ host, sessionId, random, keysToShare, psk, cipherSuites, supportedProtocolVersions, signatureAlgorithms, applicationLayerProtocols }: ClientHelloOptions): Promise<Uint8Array<ArrayBufferLike>>;
|
|
16
|
+
export declare function computeBinderSuffix(packedHandshakePrefix: Uint8Array, psk: TLSPresharedKey): Promise<Uint8Array<ArrayBufferLike>>;
|
|
17
|
+
/**
|
|
18
|
+
* Packs the preshared key extension; the binder is assumed to be 0
|
|
19
|
+
* The empty binder is suffixed to the end of the extension
|
|
20
|
+
* and should be replaced with the correct binder after the full handshake is computed
|
|
21
|
+
*/
|
|
22
|
+
export declare function packPresharedKeyExtension({ identity, ticketAge, cipherSuite }: TLSPresharedKey): Uint8Array<ArrayBuffer>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { crypto } from "../crypto/index.js";
|
|
2
|
+
import { getHash } from "../utils/decryption-utils.js";
|
|
3
|
+
import { SUPPORTED_CIPHER_SUITE_MAP, SUPPORTED_EXTENSION_MAP, SUPPORTED_NAMED_CURVE_MAP, SUPPORTED_RECORD_TYPE_MAP, SUPPORTED_SIGNATURE_ALGS_MAP, TLS_PROTOCOL_VERSION_MAP } from "./constants.js";
|
|
4
|
+
import { asciiToUint8Array, concatenateUint8Arrays, uint8ArrayToDataView } from "./generics.js";
|
|
5
|
+
import { packWith3ByteLength, packWithLength } from "./packets.js";
|
|
6
|
+
const CLIENT_VERSION = new Uint8Array([0x03, 0x03]);
|
|
7
|
+
// no compression, as our client won't support it
|
|
8
|
+
// neither does TLS1.3
|
|
9
|
+
const COMPRESSION_MODE = new Uint8Array([0x01, 0x00]);
|
|
10
|
+
const RENEGOTIATION_INFO = new Uint8Array([0xff, 0x01, 0x00, 0x01, 0x00]);
|
|
11
|
+
export async function packClientHello({ host, sessionId = crypto.randomBytes(32), random = crypto.randomBytes(32), keysToShare, psk, cipherSuites, supportedProtocolVersions = Object
|
|
12
|
+
.keys(TLS_PROTOCOL_VERSION_MAP), signatureAlgorithms = Object
|
|
13
|
+
.keys(SUPPORTED_SIGNATURE_ALGS_MAP), applicationLayerProtocols = [] }) {
|
|
14
|
+
// generate random & sessionId if not provided
|
|
15
|
+
const packedSessionId = packWithLength(sessionId).slice(1);
|
|
16
|
+
const cipherSuiteList = (cipherSuites || Object.keys(SUPPORTED_CIPHER_SUITE_MAP)).map(cipherSuite => SUPPORTED_CIPHER_SUITE_MAP[cipherSuite].identifier);
|
|
17
|
+
const packedCipherSuites = packWithLength(concatenateUint8Arrays(cipherSuiteList));
|
|
18
|
+
const extensionsList = [
|
|
19
|
+
RENEGOTIATION_INFO,
|
|
20
|
+
packServerNameExtension(host),
|
|
21
|
+
packSupportedGroupsExtension(keysToShare.map(k => k.type)),
|
|
22
|
+
packSessionTicketExtension(),
|
|
23
|
+
packVersionsExtension(supportedProtocolVersions),
|
|
24
|
+
packSignatureAlgorithmsExtension(signatureAlgorithms),
|
|
25
|
+
packPresharedKeyModeExtension(),
|
|
26
|
+
await packKeyShareExtension(keysToShare),
|
|
27
|
+
];
|
|
28
|
+
if (psk) {
|
|
29
|
+
extensionsList.push(packPresharedKeyExtension(psk));
|
|
30
|
+
}
|
|
31
|
+
if (applicationLayerProtocols.length) {
|
|
32
|
+
const protocols = applicationLayerProtocols.map(alp => (
|
|
33
|
+
// 1 byte for length
|
|
34
|
+
packWithLength(asciiToUint8Array(alp)).slice(1)));
|
|
35
|
+
extensionsList.push(packExtension({
|
|
36
|
+
type: 'ALPN',
|
|
37
|
+
data: concatenateUint8Arrays(protocols),
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
const packedExtensions = packWithLength(concatenateUint8Arrays(extensionsList));
|
|
41
|
+
const handshakeData = concatenateUint8Arrays([
|
|
42
|
+
CLIENT_VERSION,
|
|
43
|
+
random,
|
|
44
|
+
packedSessionId,
|
|
45
|
+
packedCipherSuites,
|
|
46
|
+
COMPRESSION_MODE,
|
|
47
|
+
packedExtensions
|
|
48
|
+
]);
|
|
49
|
+
const packedHandshake = concatenateUint8Arrays([
|
|
50
|
+
new Uint8Array([SUPPORTED_RECORD_TYPE_MAP.CLIENT_HELLO]),
|
|
51
|
+
packWith3ByteLength(handshakeData)
|
|
52
|
+
]);
|
|
53
|
+
if (psk) {
|
|
54
|
+
const { hashLength } = SUPPORTED_CIPHER_SUITE_MAP[psk.cipherSuite];
|
|
55
|
+
const prefixHandshake = packedHandshake.slice(0, -hashLength - 3);
|
|
56
|
+
const binder = await computeBinderSuffix(prefixHandshake, psk);
|
|
57
|
+
packedHandshake.set(binder, packedHandshake.length - binder.length);
|
|
58
|
+
}
|
|
59
|
+
return packedHandshake;
|
|
60
|
+
}
|
|
61
|
+
export async function computeBinderSuffix(packedHandshakePrefix, psk) {
|
|
62
|
+
const { hashAlgorithm } = SUPPORTED_CIPHER_SUITE_MAP[psk.cipherSuite];
|
|
63
|
+
const hashedHelloHandshake = await getHash([packedHandshakePrefix], psk.cipherSuite);
|
|
64
|
+
return crypto.hmac(hashAlgorithm, psk.finishKey, hashedHelloHandshake);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Packs the preshared key extension; the binder is assumed to be 0
|
|
68
|
+
* The empty binder is suffixed to the end of the extension
|
|
69
|
+
* and should be replaced with the correct binder after the full handshake is computed
|
|
70
|
+
*/
|
|
71
|
+
export function packPresharedKeyExtension({ identity, ticketAge, cipherSuite }) {
|
|
72
|
+
const binderLength = SUPPORTED_CIPHER_SUITE_MAP[cipherSuite].hashLength;
|
|
73
|
+
const packedIdentity = packWithLength(identity);
|
|
74
|
+
const packedTicketAge = new Uint8Array(4);
|
|
75
|
+
const packedTicketAgeView = uint8ArrayToDataView(packedTicketAge);
|
|
76
|
+
packedTicketAgeView.setUint32(0, ticketAge);
|
|
77
|
+
const serialisedIdentity = concatenateUint8Arrays([
|
|
78
|
+
packedIdentity,
|
|
79
|
+
packedTicketAge
|
|
80
|
+
]);
|
|
81
|
+
const identityPacked = packWithLength(serialisedIdentity);
|
|
82
|
+
const binderHolderBytes = new Uint8Array(binderLength + 2 + 1);
|
|
83
|
+
const binderHolderBytesView = uint8ArrayToDataView(binderHolderBytes);
|
|
84
|
+
binderHolderBytesView.setUint16(0, binderLength + 1);
|
|
85
|
+
binderHolderBytesView.setUint8(2, binderLength);
|
|
86
|
+
const total = concatenateUint8Arrays([
|
|
87
|
+
identityPacked,
|
|
88
|
+
// 2 bytes for binders
|
|
89
|
+
// 1 byte for each binder length
|
|
90
|
+
binderHolderBytes
|
|
91
|
+
]);
|
|
92
|
+
const totalPacked = packWithLength(total);
|
|
93
|
+
const ext = new Uint8Array(2 + totalPacked.length);
|
|
94
|
+
ext.set(totalPacked, 2);
|
|
95
|
+
const extView = uint8ArrayToDataView(ext);
|
|
96
|
+
extView.setUint16(0, SUPPORTED_EXTENSION_MAP.PRE_SHARED_KEY);
|
|
97
|
+
return ext;
|
|
98
|
+
}
|
|
99
|
+
function packPresharedKeyModeExtension() {
|
|
100
|
+
return packExtension({
|
|
101
|
+
type: 'PRE_SHARED_KEY_MODE',
|
|
102
|
+
data: new Uint8Array([0x00, 0x01]),
|
|
103
|
+
lengthBytes: 1
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function packSessionTicketExtension() {
|
|
107
|
+
return packExtension({
|
|
108
|
+
type: 'SESSION_TICKET',
|
|
109
|
+
data: new Uint8Array(),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function packVersionsExtension(supportedVersions) {
|
|
113
|
+
return packExtension({
|
|
114
|
+
type: 'SUPPORTED_VERSIONS',
|
|
115
|
+
data: concatenateUint8Arrays(supportedVersions.map(v => TLS_PROTOCOL_VERSION_MAP[v])),
|
|
116
|
+
lengthBytes: 1
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function packSignatureAlgorithmsExtension(algs) {
|
|
120
|
+
return packExtension({
|
|
121
|
+
type: 'SIGNATURE_ALGS',
|
|
122
|
+
data: concatenateUint8Arrays(algs.map(v => SUPPORTED_SIGNATURE_ALGS_MAP[v].identifier))
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function packSupportedGroupsExtension(namedCurves) {
|
|
126
|
+
return packExtension({
|
|
127
|
+
type: 'SUPPORTED_GROUPS',
|
|
128
|
+
data: concatenateUint8Arrays(namedCurves
|
|
129
|
+
.map(n => SUPPORTED_NAMED_CURVE_MAP[n].identifier))
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
async function packKeyShareExtension(keys) {
|
|
133
|
+
const buffs = [];
|
|
134
|
+
for (const { key, type } of keys) {
|
|
135
|
+
const exportedKey = await crypto.exportKey(key);
|
|
136
|
+
buffs.push(SUPPORTED_NAMED_CURVE_MAP[type].identifier, packWithLength(exportedKey));
|
|
137
|
+
}
|
|
138
|
+
return packExtension({
|
|
139
|
+
type: 'KEY_SHARE',
|
|
140
|
+
data: concatenateUint8Arrays(buffs)
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function packServerNameExtension(host) {
|
|
144
|
+
return packExtension({
|
|
145
|
+
type: 'SERVER_NAME',
|
|
146
|
+
data: concatenateUint8Arrays([
|
|
147
|
+
// specify that this is a server hostname
|
|
148
|
+
new Uint8Array([0x0]),
|
|
149
|
+
// pack the remaining data prefixed with length
|
|
150
|
+
packWithLength(asciiToUint8Array(host))
|
|
151
|
+
])
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function packExtension({ type, data, lengthBytes }) {
|
|
155
|
+
lengthBytes ||= 2;
|
|
156
|
+
let packed = data.length ? packWithLength(data) : data;
|
|
157
|
+
if (lengthBytes === 1) {
|
|
158
|
+
packed = packed.slice(1);
|
|
159
|
+
}
|
|
160
|
+
// 2 bytes for type, 2 bytes for packed data length
|
|
161
|
+
const result = new Uint8Array(2 + 2 + packed.length);
|
|
162
|
+
const resultView = uint8ArrayToDataView(result);
|
|
163
|
+
resultView.setUint8(1, SUPPORTED_EXTENSION_MAP[type]);
|
|
164
|
+
resultView.setUint16(2, packed.length);
|
|
165
|
+
result.set(packed, 4);
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/** Max size of an encrypted packet */
|
|
2
|
+
export declare const MAX_ENC_PACKET_SIZE = 16380;
|
|
3
|
+
export declare const TLS_PROTOCOL_VERSION_MAP: {
|
|
4
|
+
TLS1_3: Uint8Array<ArrayBuffer>;
|
|
5
|
+
TLS1_2: Uint8Array<ArrayBuffer>;
|
|
6
|
+
};
|
|
7
|
+
export declare const SUPPORTED_NAMED_CURVE_MAP: {
|
|
8
|
+
SECP256R1: {
|
|
9
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
10
|
+
readonly algorithm: "P-256";
|
|
11
|
+
};
|
|
12
|
+
SECP384R1: {
|
|
13
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
14
|
+
readonly algorithm: "P-384";
|
|
15
|
+
};
|
|
16
|
+
X25519: {
|
|
17
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
18
|
+
readonly algorithm: "X25519";
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const SUPPORTED_RECORD_TYPE_MAP: {
|
|
22
|
+
CLIENT_HELLO: number;
|
|
23
|
+
SERVER_HELLO: number;
|
|
24
|
+
HELLO_RETRY_REQUEST: number;
|
|
25
|
+
SESSION_TICKET: number;
|
|
26
|
+
ENCRYPTED_EXTENSIONS: number;
|
|
27
|
+
CERTIFICATE: number;
|
|
28
|
+
SERVER_KEY_SHARE: number;
|
|
29
|
+
CERTIFICATE_REQUEST: number;
|
|
30
|
+
SERVER_HELLO_DONE: number;
|
|
31
|
+
CERTIFICATE_VERIFY: number;
|
|
32
|
+
CLIENT_KEY_SHARE: number;
|
|
33
|
+
FINISHED: number;
|
|
34
|
+
KEY_UPDATE: number;
|
|
35
|
+
};
|
|
36
|
+
export declare const CONTENT_TYPE_MAP: {
|
|
37
|
+
CHANGE_CIPHER_SPEC: number;
|
|
38
|
+
ALERT: number;
|
|
39
|
+
HANDSHAKE: number;
|
|
40
|
+
APPLICATION_DATA: number;
|
|
41
|
+
};
|
|
42
|
+
export declare const AUTH_TAG_BYTE_LENGTH = 16;
|
|
43
|
+
export declare const SUPPORTED_NAMED_CURVES: (keyof typeof SUPPORTED_NAMED_CURVE_MAP)[];
|
|
44
|
+
/**
|
|
45
|
+
* Supported cipher suites.
|
|
46
|
+
* In a client hello, these are sent in order of preference
|
|
47
|
+
* as listed below
|
|
48
|
+
*/
|
|
49
|
+
export declare const SUPPORTED_CIPHER_SUITE_MAP: {
|
|
50
|
+
readonly TLS_CHACHA20_POLY1305_SHA256: {
|
|
51
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
52
|
+
readonly keyLength: 32;
|
|
53
|
+
readonly hashLength: 32;
|
|
54
|
+
readonly ivLength: 12;
|
|
55
|
+
readonly hashAlgorithm: "SHA-256";
|
|
56
|
+
readonly cipher: "CHACHA20-POLY1305";
|
|
57
|
+
};
|
|
58
|
+
readonly TLS_AES_256_GCM_SHA384: {
|
|
59
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
60
|
+
readonly keyLength: 32;
|
|
61
|
+
readonly hashLength: 48;
|
|
62
|
+
readonly ivLength: 12;
|
|
63
|
+
readonly hashAlgorithm: "SHA-384";
|
|
64
|
+
readonly cipher: "AES-256-GCM";
|
|
65
|
+
};
|
|
66
|
+
readonly TLS_AES_128_GCM_SHA256: {
|
|
67
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
68
|
+
readonly keyLength: 16;
|
|
69
|
+
readonly hashLength: 32;
|
|
70
|
+
readonly ivLength: 12;
|
|
71
|
+
readonly hashAlgorithm: "SHA-256";
|
|
72
|
+
readonly cipher: "AES-128-GCM";
|
|
73
|
+
};
|
|
74
|
+
readonly TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: {
|
|
75
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
76
|
+
readonly keyLength: 32;
|
|
77
|
+
readonly hashLength: 32;
|
|
78
|
+
readonly ivLength: 12;
|
|
79
|
+
readonly hashAlgorithm: "SHA-256";
|
|
80
|
+
readonly cipher: "CHACHA20-POLY1305";
|
|
81
|
+
};
|
|
82
|
+
readonly TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: {
|
|
83
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
84
|
+
readonly keyLength: 32;
|
|
85
|
+
readonly hashLength: 32;
|
|
86
|
+
readonly ivLength: 12;
|
|
87
|
+
readonly hashAlgorithm: "SHA-256";
|
|
88
|
+
readonly cipher: "CHACHA20-POLY1305";
|
|
89
|
+
};
|
|
90
|
+
readonly TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: {
|
|
91
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
92
|
+
readonly keyLength: 16;
|
|
93
|
+
readonly hashLength: 32;
|
|
94
|
+
readonly ivLength: 4;
|
|
95
|
+
readonly hashAlgorithm: "SHA-256";
|
|
96
|
+
readonly cipher: "AES-128-GCM";
|
|
97
|
+
};
|
|
98
|
+
readonly TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: {
|
|
99
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
100
|
+
readonly keyLength: 16;
|
|
101
|
+
readonly hashLength: 32;
|
|
102
|
+
readonly ivLength: 4;
|
|
103
|
+
readonly hashAlgorithm: "SHA-256";
|
|
104
|
+
readonly cipher: "AES-128-GCM";
|
|
105
|
+
};
|
|
106
|
+
readonly TLS_RSA_WITH_AES_128_GCM_SHA256: {
|
|
107
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
108
|
+
readonly keyLength: 16;
|
|
109
|
+
readonly hashLength: 32;
|
|
110
|
+
readonly ivLength: 4;
|
|
111
|
+
readonly hashAlgorithm: "SHA-256";
|
|
112
|
+
readonly cipher: "AES-128-GCM";
|
|
113
|
+
readonly isRsaEcdh: true;
|
|
114
|
+
};
|
|
115
|
+
readonly TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: {
|
|
116
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
117
|
+
readonly keyLength: 32;
|
|
118
|
+
readonly hashLength: 48;
|
|
119
|
+
readonly ivLength: 4;
|
|
120
|
+
readonly hashAlgorithm: "SHA-384";
|
|
121
|
+
readonly cipher: "AES-256-GCM";
|
|
122
|
+
};
|
|
123
|
+
readonly TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: {
|
|
124
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
125
|
+
readonly keyLength: 32;
|
|
126
|
+
readonly hashLength: 48;
|
|
127
|
+
readonly ivLength: 4;
|
|
128
|
+
readonly hashAlgorithm: "SHA-384";
|
|
129
|
+
readonly cipher: "AES-256-GCM";
|
|
130
|
+
};
|
|
131
|
+
readonly TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: {
|
|
132
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
133
|
+
readonly keyLength: 16;
|
|
134
|
+
readonly hashLength: 20;
|
|
135
|
+
readonly ivLength: 16;
|
|
136
|
+
readonly hashAlgorithm: "SHA-1";
|
|
137
|
+
readonly prfHashAlgorithm: "SHA-256";
|
|
138
|
+
readonly cipher: "AES-128-CBC";
|
|
139
|
+
};
|
|
140
|
+
readonly TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: {
|
|
141
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
142
|
+
readonly keyLength: 16;
|
|
143
|
+
readonly hashLength: 20;
|
|
144
|
+
readonly ivLength: 16;
|
|
145
|
+
readonly hashAlgorithm: "SHA-1";
|
|
146
|
+
readonly prfHashAlgorithm: "SHA-256";
|
|
147
|
+
readonly cipher: "AES-128-CBC";
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
export declare const ALERT_LEVEL: {
|
|
151
|
+
WARNING: number;
|
|
152
|
+
FATAL: number;
|
|
153
|
+
};
|
|
154
|
+
export declare const ALERT_DESCRIPTION: {
|
|
155
|
+
CLOSE_NOTIFY: number;
|
|
156
|
+
UNEXPECTED_MESSAGE: number;
|
|
157
|
+
BAD_RECORD_MAC: number;
|
|
158
|
+
RECORD_OVERFLOW: number;
|
|
159
|
+
HANDSHAKE_FAILURE: number;
|
|
160
|
+
BAD_CERTIFICATE: number;
|
|
161
|
+
UNSUPPORTED_CERTIFICATE: number;
|
|
162
|
+
CERTIFICATE_REVOKED: number;
|
|
163
|
+
CERTIFICATE_EXPIRED: number;
|
|
164
|
+
CERTIFICATE_UNKNOWN: number;
|
|
165
|
+
ILLEGAL_PARAMETER: number;
|
|
166
|
+
UNKNOWN_CA: number;
|
|
167
|
+
ACCESS_DENIED: number;
|
|
168
|
+
DECODE_ERROR: number;
|
|
169
|
+
DECRYPT_ERROR: number;
|
|
170
|
+
PROTOCOL_VERSION: number;
|
|
171
|
+
INSUFFICIENT_SECURITY: number;
|
|
172
|
+
INTERNAL_ERROR: number;
|
|
173
|
+
INAPPROPRIATE_FALLBACK: number;
|
|
174
|
+
USER_CANCELED: number;
|
|
175
|
+
MISSING_EXTENSION: number;
|
|
176
|
+
UNSUPPORTED_EXTENSION: number;
|
|
177
|
+
UNRECOGNIZED_NAME: number;
|
|
178
|
+
BAD_CERTIFICATE_STATUS_RESPONSE: number;
|
|
179
|
+
UNKNOWN_PSK_IDENTITY: number;
|
|
180
|
+
CERTIFICATE_REQUIRED: number;
|
|
181
|
+
NO_APPLICATION_PROTOCOL: number;
|
|
182
|
+
DECRYPTION_FAILED_RESERVED: number;
|
|
183
|
+
DECOMPRESSION_FAILURE: number;
|
|
184
|
+
NO_CERTIFICATE_RESERVED: number;
|
|
185
|
+
EXPORT_RESTRICTION_RESERVED: number;
|
|
186
|
+
NO_RENEGOTIATION: number;
|
|
187
|
+
};
|
|
188
|
+
export declare const SUPPORTED_CIPHER_SUITES: (keyof typeof SUPPORTED_CIPHER_SUITE_MAP)[];
|
|
189
|
+
export declare const SUPPORTED_SIGNATURE_ALGS_MAP: {
|
|
190
|
+
readonly ECDSA_SECP256R1_SHA256: {
|
|
191
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
192
|
+
readonly algorithm: "ECDSA-SECP256R1-SHA256";
|
|
193
|
+
};
|
|
194
|
+
readonly ECDSA_SECP384R1_SHA256: {
|
|
195
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
196
|
+
readonly algorithm: "ECDSA-SECP384R1-SHA384";
|
|
197
|
+
};
|
|
198
|
+
readonly RSA_PSS_RSAE_SHA256: {
|
|
199
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
200
|
+
readonly algorithm: "RSA-PSS-SHA256";
|
|
201
|
+
};
|
|
202
|
+
readonly RSA_PKCS1_SHA256: {
|
|
203
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
204
|
+
readonly algorithm: "RSA-PKCS1-SHA256";
|
|
205
|
+
};
|
|
206
|
+
readonly RSA_PKCS1_SHA384: {
|
|
207
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
208
|
+
readonly algorithm: "RSA-PKCS1-SHA384";
|
|
209
|
+
};
|
|
210
|
+
readonly RSA_PKCS1_SHA512: {
|
|
211
|
+
readonly identifier: Uint8Array<ArrayBuffer>;
|
|
212
|
+
readonly algorithm: "RSA-PKCS1-SHA512";
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
export declare const SUPPORTED_SIGNATURE_ALGS: (keyof typeof SUPPORTED_SIGNATURE_ALGS_MAP)[];
|
|
216
|
+
export declare const SUPPORTED_EXTENSION_MAP: {
|
|
217
|
+
SERVER_NAME: number;
|
|
218
|
+
MAX_FRAGMENT_LENGTH: number;
|
|
219
|
+
KEY_SHARE: number;
|
|
220
|
+
SUPPORTED_GROUPS: number;
|
|
221
|
+
SIGNATURE_ALGS: number;
|
|
222
|
+
SUPPORTED_VERSIONS: number;
|
|
223
|
+
SESSION_TICKET: number;
|
|
224
|
+
EARLY_DATA: number;
|
|
225
|
+
PRE_SHARED_KEY: number;
|
|
226
|
+
PRE_SHARED_KEY_MODE: number;
|
|
227
|
+
ALPN: number;
|
|
228
|
+
};
|
|
229
|
+
export declare const SUPPORTED_EXTENSIONS: (keyof typeof SUPPORTED_EXTENSION_MAP)[];
|
|
230
|
+
export declare const PACKET_TYPE: {
|
|
231
|
+
HELLO: number;
|
|
232
|
+
WRAPPED_RECORD: number;
|
|
233
|
+
CHANGE_CIPHER_SPEC: number;
|
|
234
|
+
ALERT: number;
|
|
235
|
+
};
|
|
236
|
+
export declare const KEY_UPDATE_TYPE_MAP: {
|
|
237
|
+
UPDATE_NOT_REQUESTED: number;
|
|
238
|
+
UPDATE_REQUESTED: number;
|
|
239
|
+
};
|