@browsercore/tls 0.4.3 → 0.4.5
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 +4 -5
- package/dist/connection/handshake-driver.d.ts +29 -0
- package/dist/connection/handshake-driver.d.ts.map +1 -1
- package/dist/connection/handshake-driver.js +129 -20
- package/dist/connection/handshake-driver.js.map +1 -1
- package/dist/connection/handshake-messages.d.ts +51 -1
- package/dist/connection/handshake-messages.d.ts.map +1 -1
- package/dist/connection/handshake-messages.js +154 -12
- package/dist/connection/handshake-messages.js.map +1 -1
- package/dist/connection/index.d.ts +3 -1
- package/dist/connection/index.d.ts.map +1 -1
- package/dist/connection/index.js +2 -1
- package/dist/connection/index.js.map +1 -1
- package/dist/connection/key-exchange.d.ts.map +1 -1
- package/dist/connection/key-exchange.js +12 -7
- package/dist/connection/key-exchange.js.map +1 -1
- package/dist/connection/lifecycle.d.ts +18 -5
- package/dist/connection/lifecycle.d.ts.map +1 -1
- package/dist/connection/lifecycle.js +20 -7
- package/dist/connection/lifecycle.js.map +1 -1
- package/dist/connection/record-layer.d.ts +5 -5
- package/dist/connection/record-layer.d.ts.map +1 -1
- package/dist/connection/record-layer.js +19 -12
- package/dist/connection/record-layer.js.map +1 -1
- package/dist/crypto/keySchedule.d.ts +18 -2
- package/dist/crypto/keySchedule.d.ts.map +1 -1
- package/dist/crypto/keySchedule.js +13 -1
- package/dist/crypto/keySchedule.js.map +1 -1
- package/dist/errors.d.ts +31 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +20 -0
- package/dist/errors.js.map +1 -1
- package/dist/handshake/client-hello.d.ts +1 -1
- package/dist/handshake/client-hello.d.ts.map +1 -1
- package/dist/handshake/client-hello.js +115 -41
- package/dist/handshake/client-hello.js.map +1 -1
- package/dist/handshake/handshake.d.ts +1 -0
- package/dist/handshake/handshake.d.ts.map +1 -1
- package/dist/handshake/handshake.js +1 -0
- package/dist/handshake/handshake.js.map +1 -1
- package/dist/handshake/hello-retry-request.d.ts +89 -0
- package/dist/handshake/hello-retry-request.d.ts.map +1 -0
- package/dist/handshake/hello-retry-request.js +152 -0
- package/dist/handshake/hello-retry-request.js.map +1 -0
- package/dist/handshake/server-hello.d.ts.map +1 -1
- package/dist/handshake/server-hello.js +34 -0
- package/dist/handshake/server-hello.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/record/record-padding.d.ts +35 -0
- package/dist/record/record-padding.d.ts.map +1 -0
- package/dist/record/record-padding.js +52 -0
- package/dist/record/record-padding.js.map +1 -0
- package/dist/session/session-cache.d.ts +84 -0
- package/dist/session/session-cache.d.ts.map +1 -0
- package/dist/session/session-cache.js +189 -0
- package/dist/session/session-cache.js.map +1 -0
- package/dist/tls.d.ts +78 -4
- package/dist/tls.d.ts.map +1 -1
- package/dist/tls.js +225 -20
- package/dist/tls.js.map +1 -1
- package/dist/types.d.ts +34 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,9 +106,10 @@ connection.
|
|
|
106
106
|
| `src/extensions/` | Extension types, parsers, and wire encoders |
|
|
107
107
|
| `src/connection/handshake-driver.ts` | Handshake choreography (what to send, what to read, when to derive) |
|
|
108
108
|
| `src/connection/record-layer.ts` | TLS 1.3 inner-content-type wrapping, nonce XOR, record framing |
|
|
109
|
-
| `src/connection/key-exchange.ts` | (EC)DHE shared secret, transcript hash, server Finished verification |
|
|
109
|
+
| `src/connection/key-exchange.ts` | (EC)DHE shared secret, transcript hash, server Finished verification, CertificateVerify verification |
|
|
110
110
|
| `src/connection/handshake-messages.ts` | EncryptedExtensions/Certificate/Finished parsing, client Finished builder |
|
|
111
|
-
| `src/
|
|
111
|
+
| `src/handshake/hello-retry-request.ts` | HelloRetryRequest detection (RFC 8446 §4.1.3 sentinel) and cookie handling |
|
|
112
|
+
| `src/connection/lifecycle.ts` | Timeouts (with phase-attributed errors), alerts, state transitions, post-handshake record dispatch |
|
|
112
113
|
|
|
113
114
|
Errors all carry a `kind` discriminator so callers can narrow and inspect
|
|
114
115
|
without leaking backend specifics (`TlsHandshakeError(phase)`,
|
|
@@ -116,11 +117,9 @@ without leaking backend specifics (`TlsHandshakeError(phase)`,
|
|
|
116
117
|
|
|
117
118
|
## Not implemented
|
|
118
119
|
|
|
119
|
-
-
|
|
120
|
-
- Session resumption / PSK / 0-RTT
|
|
120
|
+
- NewSessionTicket / session resumption / PSK / 0-RTT
|
|
121
121
|
- Mutual TLS (client certificate)
|
|
122
122
|
- Certificate compression
|
|
123
|
-
- HelloRetryRequest
|
|
124
123
|
- Additional key-share groups beyond X25519
|
|
125
124
|
|
|
126
125
|
## Development
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { Transport } from "@browsercore/transport";
|
|
16
16
|
import type { CryptoProvider, HashId } from "@browsercore/crypto";
|
|
17
|
+
import { type AlertLevel, type HandshakePhase as TimeoutPhase } from "../errors.js";
|
|
17
18
|
import { type ServerHello } from "../handshake/handshake.js";
|
|
18
19
|
import type { AeadAlgorithm, ApplicationTrafficSecrets, CipherSuite, ClientHelloConfig, KeyPair, TrafficSecrets } from "../types.js";
|
|
19
20
|
type ValidatedCertificate = Awaited<ReturnType<typeof validateCertificateChain>>["leaf"];
|
|
@@ -41,13 +42,41 @@ export interface HandshakeContext {
|
|
|
41
42
|
clientHsTrafficSecret: Uint8Array;
|
|
42
43
|
serverHsTrafficSecret: Uint8Array;
|
|
43
44
|
masterSecret: Uint8Array;
|
|
45
|
+
/**
|
|
46
|
+
* Mutable: raw application traffic secrets, set when the driver derives
|
|
47
|
+
* application secrets (step 7). Retained so the connection can rotate keys
|
|
48
|
+
* via {@link updateTrafficSecrets} on KeyUpdate (RFC 8446 §4.6.3).
|
|
49
|
+
*/
|
|
50
|
+
clientAppSecret: Uint8Array;
|
|
51
|
+
serverAppSecret: Uint8Array;
|
|
44
52
|
/** Mutable: handshake-direction sequence counters. */
|
|
45
53
|
clientHsSeq: number;
|
|
46
54
|
serverHsSeq: number;
|
|
55
|
+
/** True once the handshake traffic secrets have been derived (sendAlert gate). */
|
|
56
|
+
hsTrafficReady: boolean;
|
|
47
57
|
/** Set when the server negotiates ALPN in EncryptedExtensions. */
|
|
48
58
|
alpnProtocol?: string | undefined;
|
|
49
59
|
/** Set to the validated leaf once the Certificate message is consumed. */
|
|
50
60
|
peerCertificate?: ValidatedCertificate | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Mutable: the handshake phase currently in progress. Updated by the driver
|
|
63
|
+
* before each step so {@link withTimeout} can report the true stall location
|
|
64
|
+
* in its error message instead of a hardcoded guess.
|
|
65
|
+
*/
|
|
66
|
+
currentPhase: TimeoutPhase;
|
|
67
|
+
/**
|
|
68
|
+
* Optional debug trace callback. When set, the driver and record layer emit
|
|
69
|
+
* a line before/after each I/O and crypto step. This is the primary
|
|
70
|
+
* diagnostic tool for pinpointing handshake stalls.
|
|
71
|
+
*/
|
|
72
|
+
onDebug: ((msg: string) => void) | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Send a TLS alert (RFC 8446 §6) to the peer. Best-effort: if the traffic
|
|
75
|
+
* keys are not yet derived (early handshake failure) or the transport write
|
|
76
|
+
* fails, the alert is silently dropped. The connection's error-cleanup path
|
|
77
|
+
* (transport close) is the fallback.
|
|
78
|
+
*/
|
|
79
|
+
sendAlert(level: AlertLevel, description: number): Promise<void>;
|
|
51
80
|
}
|
|
52
81
|
/**
|
|
53
82
|
* Drive the TLS 1.3 handshake to completion against `ctx`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handshake-driver.d.ts","sourceRoot":"","sources":["../../src/connection/handshake-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,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YAAY,EAAE,UAAU,CAAC;IACzB;;;;OAIG;IACH,eAAe,EAAE,UAAU,CAAC;IAC5B,eAAe,EAAE,UAAU,CAAC;IAC5B,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,cAAc,EAAE,OAAO,CAAC;IACxB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,0EAA0E;IAC1E,eAAe,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACnD;;;;OAIG;IACH,YAAY,EAAE,YAAY,CAAC;IAC3B;;;;OAIG;IACH,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC7C;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpE;AAQD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAC9B,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE,iBAAiB,EAC1B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,SAAS,UAAU,EAAE,EACnC,iBAAiB,EAAE,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,EACpE,GAAG,EAAE,MAAM,GACZ,OAAO,CAAC,yBAAyB,CAAC,CAgLpC"}
|
|
@@ -14,16 +14,14 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { TlsHandshakeError } from "../errors.js";
|
|
16
16
|
import { ContentType, cipherSuiteToAead } from "../record/record.js";
|
|
17
|
-
import { advanceHandshake, buildClientHello, parseServerHello, recordServerHello, HandshakeType, } from "../handshake/handshake.js";
|
|
17
|
+
import { advanceHandshake, buildClientHello, parseServerHello, recordServerHello, HandshakeType, isHelloRetryRequest, parseHelloRetryRequestExtensions, buildMessageHashMessage, } from "../handshake/handshake.js";
|
|
18
18
|
import { deriveApplicationSecrets, deriveHandshakeTrafficSecrets, deriveTrafficSecrets, hashFor, } from "../crypto/keySchedule.js";
|
|
19
19
|
// Import from the individual submodules (not the ./index.js barrel) to avoid a
|
|
20
20
|
// dependency cycle: index.ts re-exports this module, so reaching back through
|
|
21
21
|
// it would close the loop. The submodules are the real owners of these helpers.
|
|
22
22
|
import { computeSharedSecret, transcriptHash, verifyServerFinished } from "./key-exchange.js";
|
|
23
|
-
import { buildClientFinishedMessage, parseAlpnFromEncryptedExtensions, readEncryptedHandshakeMessage, splitHandshakeMessages, validateCertificateChain, } from "./handshake-messages.js";
|
|
23
|
+
import { buildClientFinishedMessage, parseAlpnFromEncryptedExtensions, readEncryptedHandshakeMessage, splitHandshakeMessages, validateCertificateChain, verifyCertificateVerify, } from "./handshake-messages.js";
|
|
24
24
|
import { readHeaderBytes, readRawRecord, writeEncryptedRecord, writeRecord, } from "./record-layer.js";
|
|
25
|
-
/** Constant: the only key-share group the crypto backend can generate. */
|
|
26
|
-
const SUPPORTED_GROUP = "x25519";
|
|
27
25
|
/** Apply the result of {@link parseServerHello} to the context's fields. */
|
|
28
26
|
function applyNegotiation(ctx) {
|
|
29
27
|
ctx.aead = cipherSuiteToAead(ctx.cipherSuite);
|
|
@@ -37,31 +35,43 @@ function applyNegotiation(ctx) {
|
|
|
37
35
|
* pure and testable.
|
|
38
36
|
*/
|
|
39
37
|
export async function runHandshake(ctx, profile, serverName, trustAnchors, generateKeyShares, now) {
|
|
38
|
+
ctx.currentPhase = "init";
|
|
40
39
|
// TLS 1.3 only: reject a profile that cannot negotiate TLS 1.3.
|
|
41
40
|
if (!profile.supportedVersions.some((v) => v.name === "TLS 1.3")) {
|
|
42
41
|
throw new TlsHandshakeError("client_hello", {
|
|
43
42
|
cause: new Error("TLS 1.2-only handshakes are not supported by this client"),
|
|
44
43
|
});
|
|
45
44
|
}
|
|
46
|
-
// 1. Generate key shares for
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
// 1. Generate key shares for ALL groups the profile offers — including
|
|
46
|
+
// post-quantum hybrids (X25519MLKEM768). The crypto backend generates an
|
|
47
|
+
// X25519 key tagged with the hybrid name so the key_share extension emits
|
|
48
|
+
// the correct group ID. Multiple key shares are mandatory for matching real
|
|
49
|
+
// browser fingerprints (Chrome offers x25519, secp256r1, secp384r1, and
|
|
50
|
+
// X25519MLKEM768 simultaneously).
|
|
51
|
+
ctx.currentPhase = "client_hello";
|
|
52
|
+
ctx.onDebug?.("phase: client_hello — generating key shares");
|
|
53
|
+
const keyPairs = await generateKeyShares(profile.keyShareGroups);
|
|
54
|
+
if (keyPairs.length === 0) {
|
|
49
55
|
throw new TlsHandshakeError("client_hello", {
|
|
50
56
|
cause: new Error("no supported key share groups in the selected profile"),
|
|
51
57
|
});
|
|
52
58
|
}
|
|
53
|
-
const keyPairs = await generateKeyShares(desired);
|
|
54
59
|
// 2. Build and send the ClientHello as a plaintext handshake record.
|
|
55
|
-
|
|
60
|
+
ctx.onDebug?.("phase: client_hello — building and sending ClientHello");
|
|
61
|
+
const greaseRandom = () => {
|
|
56
62
|
const byte = ctx.crypto.randomBytes(1)[0];
|
|
57
63
|
return byte === undefined ? 0 : byte / 256;
|
|
58
|
-
}
|
|
64
|
+
};
|
|
65
|
+
const clientHello = buildClientHello(profile, keyPairs, greaseRandom, ctx.crypto);
|
|
59
66
|
ctx.transcript.push(clientHello);
|
|
60
67
|
await writeRecord(ctx.transport, ContentType.HANDSHAKE, clientHello);
|
|
68
|
+
ctx.onDebug?.(`phase: client_hello — ClientHello sent (${clientHello.length} bytes)`);
|
|
61
69
|
// 3. Read the ServerHello (still plaintext) and validate the negotiation.
|
|
62
|
-
|
|
70
|
+
ctx.currentPhase = "server_hello";
|
|
71
|
+
ctx.onDebug?.("phase: server_hello — waiting for ServerHello record");
|
|
72
|
+
const shHeader = await readHeaderBytes(ctx.readBuffer, ctx.transport, ctx.onDebug);
|
|
63
73
|
ctx.readBuffer = shHeader.readBuffer;
|
|
64
|
-
const shRecord = await readRawRecord(ctx.readBuffer, ctx.transport, shHeader);
|
|
74
|
+
const shRecord = await readRawRecord(ctx.readBuffer, ctx.transport, shHeader, ctx.onDebug);
|
|
65
75
|
ctx.readBuffer = shRecord.readBuffer;
|
|
66
76
|
if (shRecord.type !== ContentType.HANDSHAKE) {
|
|
67
77
|
throw new TlsHandshakeError("server_hello", {
|
|
@@ -69,32 +79,103 @@ export async function runHandshake(ctx, profile, serverName, trustAnchors, gener
|
|
|
69
79
|
});
|
|
70
80
|
}
|
|
71
81
|
ctx.transcript.push(shRecord.fragment);
|
|
72
|
-
const
|
|
82
|
+
const firstHello = parseServerHello(shRecord.fragment.subarray(4), {
|
|
73
83
|
cipherSuites: profile.cipherSuites,
|
|
74
84
|
supportedVersions: profile.supportedVersions,
|
|
75
85
|
});
|
|
76
|
-
|
|
77
|
-
ctx.
|
|
86
|
+
// Set cipher suite + hash early — the HRR carries the same cipher suite as
|
|
87
|
+
// the real ServerHello will, and we need ctx.hash to compute the synthetic
|
|
88
|
+
// message_hash transcript prefix during HRR handling.
|
|
89
|
+
ctx.cipherSuite = firstHello.cipherSuite;
|
|
78
90
|
applyNegotiation(ctx);
|
|
91
|
+
// HelloRetryRequest detection (RFC 8446 §4.1.3). The server sends an HRR
|
|
92
|
+
// (a special ServerHello with the sentinel random) when the client's initial
|
|
93
|
+
// key-share group is unacceptable. The client must rewrite the transcript,
|
|
94
|
+
// generate a fresh key share, resend the ClientHello, and read the *real*
|
|
95
|
+
// ServerHello that follows.
|
|
96
|
+
let effectiveKeyPairs = keyPairs;
|
|
97
|
+
let serverHello = firstHello;
|
|
98
|
+
if (isHelloRetryRequest(firstHello.random)) {
|
|
99
|
+
ctx.onDebug?.("phase: server_hello — HelloRetryRequest detected");
|
|
100
|
+
// Transcript rewrite (RFC 8446 §4.4.1): replace ClientHello_1 + HRR
|
|
101
|
+
// with message_hash(Hash(ClientHello_1)) + HRR.
|
|
102
|
+
ctx.transcript.pop(); // remove HRR
|
|
103
|
+
ctx.transcript.pop(); // remove ClientHello_1
|
|
104
|
+
const ch1Hash = transcriptHash([clientHello], ctx.hash, ctx.crypto);
|
|
105
|
+
ctx.transcript.push(buildMessageHashMessage(ch1Hash), shRecord.fragment);
|
|
106
|
+
// Parse HRR extensions: selected_group + optional cookie.
|
|
107
|
+
const hrr = parseHelloRetryRequestExtensions(firstHello.extensions);
|
|
108
|
+
ctx.onDebug?.(`phase: server_hello — HRR requests group ${hrr.selectedGroup}${hrr.cookie === undefined ? "" : " with cookie"}`);
|
|
109
|
+
// Generate a fresh key share for the server's selected group.
|
|
110
|
+
effectiveKeyPairs = await generateKeyShares([hrr.selectedGroup]);
|
|
111
|
+
// Build and send ClientHello_2 with the new key share and the echoed cookie.
|
|
112
|
+
const clientHello2 = hrr.cookie === undefined
|
|
113
|
+
? buildClientHello(profile, effectiveKeyPairs, greaseRandom, ctx.crypto)
|
|
114
|
+
: buildClientHello(profile, effectiveKeyPairs, greaseRandom, ctx.crypto, hrr.cookie);
|
|
115
|
+
ctx.transcript.push(clientHello2);
|
|
116
|
+
await writeRecord(ctx.transport, ContentType.HANDSHAKE, clientHello2);
|
|
117
|
+
ctx.onDebug?.(`phase: server_hello — ClientHello_2 sent after HRR (${clientHello2.length} bytes)`);
|
|
118
|
+
// Read the *real* ServerHello.
|
|
119
|
+
ctx.onDebug?.("phase: server_hello — waiting for real ServerHello after HRR");
|
|
120
|
+
const realShHeader = await readHeaderBytes(ctx.readBuffer, ctx.transport, ctx.onDebug);
|
|
121
|
+
ctx.readBuffer = realShHeader.readBuffer;
|
|
122
|
+
const realShRecord = await readRawRecord(ctx.readBuffer, ctx.transport, realShHeader, ctx.onDebug);
|
|
123
|
+
ctx.readBuffer = realShRecord.readBuffer;
|
|
124
|
+
if (realShRecord.type !== ContentType.HANDSHAKE) {
|
|
125
|
+
throw new TlsHandshakeError("server_hello", {
|
|
126
|
+
cause: new Error(`expected handshake record after HRR, got content type ${realShRecord.type}`),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
ctx.transcript.push(realShRecord.fragment);
|
|
130
|
+
serverHello = parseServerHello(realShRecord.fragment.subarray(4), {
|
|
131
|
+
cipherSuites: profile.cipherSuites,
|
|
132
|
+
supportedVersions: profile.supportedVersions,
|
|
133
|
+
});
|
|
134
|
+
// The real ServerHello is authoritative for the cipher suite (though it
|
|
135
|
+
// must match the HRR — the server cannot change suites mid-handshake).
|
|
136
|
+
ctx.cipherSuite = serverHello.cipherSuite;
|
|
137
|
+
applyNegotiation(ctx);
|
|
138
|
+
}
|
|
139
|
+
ctx.onDebug?.(`phase: server_hello — parsed ServerHello (cipher=${serverHello.cipherSuite}, version=${serverHello.selectedVersion.name})`);
|
|
140
|
+
ctx.serverHello = serverHello;
|
|
79
141
|
// 4. (EC)DHE key exchange.
|
|
80
|
-
|
|
142
|
+
ctx.currentPhase = "key_exchange";
|
|
143
|
+
ctx.onDebug?.("phase: key_exchange — computing shared secret");
|
|
144
|
+
const sharedSecret = computeSharedSecret(serverHello, effectiveKeyPairs, ctx.crypto);
|
|
145
|
+
ctx.onDebug?.("phase: key_exchange — shared secret computed");
|
|
81
146
|
// 5. Derive handshake traffic secrets from the ClientHello..ServerHello transcript.
|
|
147
|
+
ctx.onDebug?.("phase: key_exchange — deriving handshake traffic secrets");
|
|
82
148
|
const helloTranscript = transcriptHash(ctx.transcript, ctx.hash, ctx.crypto);
|
|
83
149
|
const { masterSecret, clientTrafficSecret, serverTrafficSecret } = deriveHandshakeTrafficSecrets(sharedSecret, helloTranscript, ctx.cipherSuite, ctx.crypto);
|
|
150
|
+
ctx.onDebug?.("phase: key_exchange — handshake traffic secrets derived");
|
|
84
151
|
ctx.masterSecret = masterSecret;
|
|
85
152
|
ctx.clientHsTrafficSecret = clientTrafficSecret;
|
|
86
153
|
ctx.serverHsTrafficSecret = serverTrafficSecret;
|
|
87
154
|
ctx.clientHsTraffic = deriveTrafficSecrets(clientTrafficSecret, ctx.cipherSuite, ctx.hash, ctx.crypto);
|
|
88
155
|
ctx.serverHsTraffic = deriveTrafficSecrets(serverTrafficSecret, ctx.cipherSuite, ctx.hash, ctx.crypto);
|
|
156
|
+
ctx.hsTrafficReady = true;
|
|
89
157
|
// 6. Consume the server's encrypted flight.
|
|
90
158
|
await consumeServerFlight(ctx, serverName, trustAnchors, now);
|
|
91
159
|
// 7. Derive application traffic secrets from the full transcript.
|
|
160
|
+
ctx.currentPhase = "client_finished";
|
|
161
|
+
ctx.onDebug?.("phase: client_finished — deriving application traffic secrets");
|
|
92
162
|
const handshakeTranscript = transcriptHash(ctx.transcript, ctx.hash, ctx.crypto);
|
|
93
163
|
const applicationSecrets = deriveApplicationSecrets(ctx.masterSecret, handshakeTranscript, ctx.cipherSuite, ctx.crypto);
|
|
164
|
+
ctx.clientAppSecret = applicationSecrets.clientSecret;
|
|
165
|
+
ctx.serverAppSecret = applicationSecrets.serverSecret;
|
|
166
|
+
ctx.onDebug?.("phase: client_finished — application traffic secrets derived");
|
|
94
167
|
// 8. Send the client Finished under the client handshake traffic key.
|
|
168
|
+
ctx.onDebug?.("phase: client_finished — building and sending client Finished");
|
|
95
169
|
const finishedMessage = buildClientFinishedMessage(ctx.hash, ctx.clientHsTrafficSecret, ctx.transcript, ctx.crypto);
|
|
96
|
-
await writeEncryptedRecord(ctx.transport, ctx.aead, ctx.clientHsTraffic, ContentType.HANDSHAKE, finishedMessage, ctx.clientHsSeq, ctx.crypto);
|
|
170
|
+
await writeEncryptedRecord(ctx.transport, ctx.aead, ctx.clientHsTraffic, ContentType.HANDSHAKE, finishedMessage, ctx.clientHsSeq, ctx.crypto, ctx.onDebug);
|
|
97
171
|
ctx.clientHsSeq++;
|
|
172
|
+
// Record the client Finished in the transcript. The resumption_master_secret
|
|
173
|
+
// (RFC 8446 §7.5) is Derive-Secret(master_secret, "res master",
|
|
174
|
+
// Transcript-Hash(ClientHello..client Finished)) — so the transcript MUST
|
|
175
|
+
// include it for post-handshake NewSessionTicket processing.
|
|
176
|
+
ctx.transcript.push(finishedMessage);
|
|
177
|
+
ctx.onDebug?.("phase: client_finished — client Finished sent");
|
|
178
|
+
ctx.currentPhase = "application";
|
|
98
179
|
return applicationSecrets;
|
|
99
180
|
}
|
|
100
181
|
/**
|
|
@@ -129,19 +210,21 @@ async function consumeServerFlight(ctx, serverName, trustAnchors, now) {
|
|
|
129
210
|
if (msg === undefined) {
|
|
130
211
|
// Length was just checked; this is unreachable but satisfies
|
|
131
212
|
// noUncheckedIndexedAccess without a non-null assertion.
|
|
132
|
-
throw new TlsHandshakeError("
|
|
213
|
+
throw new TlsHandshakeError("encrypted_extensions", {
|
|
133
214
|
cause: new Error("pending message queue emptied between check and shift"),
|
|
134
215
|
});
|
|
135
216
|
}
|
|
136
217
|
return { whole: msg, body: msg.subarray(4) };
|
|
137
218
|
}
|
|
138
|
-
|
|
219
|
+
ctx.onDebug?.(`consumeServerFlight: reading encrypted record, seq=${ctx.serverHsSeq}`);
|
|
220
|
+
const result = await readEncryptedHandshakeMessage(ctx.readBuffer, ctx.transport, ctx.aead, ctx.serverHsTraffic, ctx.serverHsSeq, ctx.crypto, ctx.onDebug);
|
|
139
221
|
ctx.readBuffer = result.readBuffer;
|
|
140
222
|
ctx.serverHsSeq++;
|
|
141
223
|
const messages = splitHandshakeMessages(result.whole);
|
|
224
|
+
ctx.onDebug?.(`consumeServerFlight: split into ${messages.length} handshake message(s)`);
|
|
142
225
|
const first = messages.shift();
|
|
143
226
|
if (first === undefined) {
|
|
144
|
-
throw new TlsHandshakeError("
|
|
227
|
+
throw new TlsHandshakeError("encrypted_extensions", {
|
|
145
228
|
cause: new Error("decrypted record contained no handshake messages"),
|
|
146
229
|
});
|
|
147
230
|
}
|
|
@@ -149,6 +232,8 @@ async function consumeServerFlight(ctx, serverName, trustAnchors, now) {
|
|
|
149
232
|
return { whole: first, body: first.subarray(4) };
|
|
150
233
|
}
|
|
151
234
|
// EncryptedExtensions.
|
|
235
|
+
ctx.currentPhase = "encrypted_extensions";
|
|
236
|
+
ctx.onDebug?.("consumeServerFlight: expecting EncryptedExtensions");
|
|
152
237
|
let message = await nextHandshakeMessage();
|
|
153
238
|
phase = advanceHandshake(phase, HandshakeType.ENCRYPTED_EXTENSIONS);
|
|
154
239
|
ctx.transcript.push(message.whole);
|
|
@@ -156,21 +241,45 @@ async function consumeServerFlight(ctx, serverName, trustAnchors, now) {
|
|
|
156
241
|
if (alpn !== undefined) {
|
|
157
242
|
ctx.alpnProtocol = alpn;
|
|
158
243
|
}
|
|
244
|
+
ctx.onDebug?.(`consumeServerFlight: EncryptedExtensions consumed (alpn=${alpn ?? "none"})`);
|
|
159
245
|
// Certificate.
|
|
246
|
+
ctx.currentPhase = "certificate";
|
|
247
|
+
ctx.onDebug?.("consumeServerFlight: expecting Certificate");
|
|
160
248
|
message = await nextHandshakeMessage();
|
|
161
249
|
phase = advanceHandshake(phase, HandshakeType.CERTIFICATE);
|
|
162
250
|
ctx.transcript.push(message.whole);
|
|
163
251
|
const chain = await validateCertificateChain(message.body, serverName, trustAnchors, now, ctx.crypto);
|
|
164
252
|
ctx.peerCertificate = chain.leaf;
|
|
253
|
+
ctx.onDebug?.(`consumeServerFlight: Certificate validated (${chain.intermediates.length} intermediates)`);
|
|
165
254
|
// CertificateVerify.
|
|
255
|
+
ctx.currentPhase = "certificate_verify";
|
|
256
|
+
ctx.onDebug?.("consumeServerFlight: expecting CertificateVerify");
|
|
166
257
|
message = await nextHandshakeMessage();
|
|
167
258
|
phase = advanceHandshake(phase, HandshakeType.CERTIFICATE_VERIFY);
|
|
259
|
+
// Verify the signature BEFORE pushing CertificateVerify to the transcript.
|
|
260
|
+
// The signed content covers Transcript-Hash(ClientHello..Certificate) — the
|
|
261
|
+
// transcript at this point still ends at Certificate, which is exactly the
|
|
262
|
+
// content the server signed (RFC 8446 §4.4.3). Pushing afterward would
|
|
263
|
+
// pollute the hash for the Finished verification, which covers
|
|
264
|
+
// ClientHello..CertificateVerify.
|
|
265
|
+
if (ctx.peerCertificate === undefined) {
|
|
266
|
+
throw new TlsHandshakeError("certificate_verify", {
|
|
267
|
+
cause: new Error("CertificateVerify received before a Certificate message was consumed"),
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
ctx.onDebug?.("consumeServerFlight: verifying CertificateVerify signature against leaf cert SPKI");
|
|
271
|
+
verifyCertificateVerify(message.body, ctx.peerCertificate.subjectPublicKeyInfo, ctx.transcript, ctx.hash, ctx.crypto);
|
|
168
272
|
ctx.transcript.push(message.whole);
|
|
273
|
+
ctx.onDebug?.("consumeServerFlight: CertificateVerify signature verified OK");
|
|
169
274
|
// Finished — verify against the transcript *before* appending the Finished.
|
|
275
|
+
ctx.currentPhase = "finished";
|
|
276
|
+
ctx.onDebug?.("consumeServerFlight: expecting Finished, computing transcript hash");
|
|
170
277
|
const finishedTranscript = transcriptHash(ctx.transcript, ctx.hash, ctx.crypto);
|
|
171
278
|
message = await nextHandshakeMessage();
|
|
279
|
+
ctx.onDebug?.("consumeServerFlight: verifying server Finished verify_data");
|
|
172
280
|
verifyServerFinished(message.body, finishedTranscript, ctx.hash, ctx.serverHsTrafficSecret, ctx.crypto);
|
|
173
281
|
advanceHandshake(phase, HandshakeType.FINISHED);
|
|
174
282
|
ctx.transcript.push(message.whole);
|
|
283
|
+
ctx.onDebug?.("consumeServerFlight: server Finished verified OK");
|
|
175
284
|
}
|
|
176
285
|
//# sourceMappingURL=handshake-driver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handshake-driver.js","sourceRoot":"","sources":["../../src/connection/handshake-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,GAGhB,MAAM,2BAA2B,CAAC;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AAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC"}
|
|
1
|
+
{"version":3,"file":"handshake-driver.js","sourceRoot":"","sources":["../../src/connection/handshake-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,iBAAiB,EAAwD,MAAM,cAAc,CAAC;AACvG,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,gCAAgC,EAChC,uBAAuB,GAG1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACH,wBAAwB,EACxB,6BAA6B,EAC7B,oBAAoB,EACpB,OAAO,GACV,MAAM,0BAA0B,CAAC;AAalC,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EACH,0BAA0B,EAC1B,gCAAgC,EAChC,6BAA6B,EAC7B,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,WAAW,GACd,MAAM,mBAAmB,CAAC;AA8D3B,4EAA4E;AAC5E,SAAS,gBAAgB,CAAC,GAAqB;IAC3C,GAAG,CAAC,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC9C,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAC9B,GAAqB,EACrB,OAA0B,EAC1B,UAAkB,EAClB,YAAmC,EACnC,iBAAoE,EACpE,GAAW;IAEX,GAAG,CAAC,YA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AAO,EAAE,CAAC,mFAAmF,CAAC,CAAC;IACnG,uBAAuB,CACnB,OAAO,CAAC,IAAI,EACZ,GAAG,CAAC,eAAe,CAAC,oBAAoB,EACxC,GAAG,CAAC,UAAU,EACd,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,MAAM,CACb,CAAC;IACF,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,GAAG,CAAC,OAAO,EAAE,CAAC,8DAA8D,CAAC,CAAC;IAE9E,4EAA4E;IAC5E,GAAG,CAAC,YAAY,GAAG,UAAU,CAAC;IAC9B,GAAG,CAAC,OAAO,EAAE,CAAC,oEAAoE,CAAC,CAAC;IACpF,MAAM,kBAAkB,GAAG,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAChF,OAAO,GAAG,MAAM,oBAAoB,EAAE,CAAC;IACvC,GAAG,CAAC,OAAO,EAAE,CAAC,4DAA4D,CAAC,CAAC;IAC5E,oBAAoB,CAAC,OAAO,CAAC,IAAI,EAAE,kBAAkB,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,qBAAqB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxG,gBAAgB,CAAC,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,GAAG,CAAC,OAAO,EAAE,CAAC,kDAAkD,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -30,6 +30,56 @@ export declare function parseCertificateMessage(body: Uint8Array): CertificateCh
|
|
|
30
30
|
* the validation logic itself.
|
|
31
31
|
*/
|
|
32
32
|
export declare function validateCertificateChain(body: Uint8Array, serverName: string, trustAnchors: readonly Uint8Array[], now: number, provider: CryptoProvider): Promise<CertificateChain>;
|
|
33
|
+
/**
|
|
34
|
+
* Construct the to-be-signed content for a server CertificateVerify
|
|
35
|
+
* (RFC 8446 §4.4.3):
|
|
36
|
+
*
|
|
37
|
+
* ```
|
|
38
|
+
* 64 * 0x20 || "TLS 1.3, server CertificateVerify" || 0x00 || Transcript-Hash(ClientHello..Certificate)
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* The 64 space bytes and the context string form a domain-separation prefix
|
|
42
|
+
* that prevents the signature from being replayed in a different context. The
|
|
43
|
+
* 0x00 byte separates the context string from the transcript hash.
|
|
44
|
+
*
|
|
45
|
+
* Exposed as a pure function so it can be unit-tested in isolation against
|
|
46
|
+
* known-answer test vectors.
|
|
47
|
+
*
|
|
48
|
+
* @param transcriptHashValue Hash(ClientHello..Certificate) — the transcript
|
|
49
|
+
* hash up to and including the Certificate message (NOT including
|
|
50
|
+
* CertificateVerify itself).
|
|
51
|
+
*/
|
|
52
|
+
export declare function certificateVerifySignedContent(transcriptHashValue: Uint8Array): Uint8Array;
|
|
53
|
+
/**
|
|
54
|
+
* Verify a CertificateVerify message (RFC 8446 §4.4.3): confirm the server
|
|
55
|
+
* holds the private key corresponding to the leaf certificate's public key by
|
|
56
|
+
* checking the signature over the transcript hash.
|
|
57
|
+
*
|
|
58
|
+
* This closes the MITM vulnerability where a forged CertificateVerify with a
|
|
59
|
+
* dummy signature was silently accepted. After this check, the client is
|
|
60
|
+
* cryptographically assured that the server owns the leaf certificate's
|
|
61
|
+
* private key.
|
|
62
|
+
*
|
|
63
|
+
* The CertificateVerify body layout is:
|
|
64
|
+
* ```
|
|
65
|
+
* signature_scheme(2) || signature_length(2) || signature(N)
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* Throws {@link TlsHandshakeError} with phase "certificate_verify" on any
|
|
69
|
+
* parsing error or signature mismatch.
|
|
70
|
+
*
|
|
71
|
+
* @param body The CertificateVerify handshake message body (after the
|
|
72
|
+
* 4-byte handshake header).
|
|
73
|
+
* @param leafSpki The leaf certificate's SubjectPublicKeyInfo (DER), as
|
|
74
|
+
* extracted by {@link parseCertificate}.
|
|
75
|
+
* @param transcript The transcript up to and including Certificate — NOT
|
|
76
|
+
* including CertificateVerify. The signed content covers
|
|
77
|
+
* Transcript-Hash(ClientHello..Certificate) per §4.4.3.
|
|
78
|
+
* @param hash The negotiated cipher's hash (SHA-256 or SHA-384).
|
|
79
|
+
* @param provider The injected crypto provider (Platform injection — never
|
|
80
|
+
* node:crypto directly) for hashing + signature verification.
|
|
81
|
+
*/
|
|
82
|
+
export declare function verifyCertificateVerify(body: Uint8Array, leafSpki: Uint8Array, transcript: readonly Uint8Array[], hash: HashId, provider: CryptoProvider): void;
|
|
33
83
|
/** Build the client Finished message bytes under the client handshake traffic key. */
|
|
34
84
|
export declare function buildClientFinishedMessage(hash: HashId, clientHsTrafficSecret: Uint8Array, transcript: readonly Uint8Array[], provider: CryptoProvider): Uint8Array;
|
|
35
85
|
/**
|
|
@@ -56,7 +106,7 @@ export declare function splitHandshakeMessages(content: Uint8Array): Uint8Array[
|
|
|
56
106
|
* §5.1), `whole` holds the concatenation of all messages and the caller must
|
|
57
107
|
* use {@link splitHandshakeMessages} to separate them.
|
|
58
108
|
*/
|
|
59
|
-
export declare function readEncryptedHandshakeMessage(readBuffer: Uint8Array, transport: Transport, aead: Parameters<typeof encryptRecord>[4], traffic: TrafficSecrets, seq: number, provider: CryptoProvider): Promise<{
|
|
109
|
+
export declare function readEncryptedHandshakeMessage(readBuffer: Uint8Array, transport: Transport, aead: Parameters<typeof encryptRecord>[4], traffic: TrafficSecrets, seq: number, provider: CryptoProvider, onDebug?: (msg: string) => void): Promise<{
|
|
60
110
|
whole: Uint8Array;
|
|
61
111
|
body: Uint8Array;
|
|
62
112
|
readBuffer: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handshake-messages.d.ts","sourceRoot":"","sources":["../../src/connection/handshake-messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE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