@ai-ecoverse/slicc-kernel 1.155.0 → 1.156.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 +1 -0
- package/dist/kernel-worker.js +41 -8
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +41 -8
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +1 -1
- package/dist/types/kernel/net/tls-client.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -501,6 +501,7 @@ The module's default export (or its `main` export) is called with a context and
|
|
|
501
501
|
- Before dialling, `cert` without `key` (or the reverse) is `EINVAL`. A key that doesn't match the leaf is `ERR_OSSL_X509_KEY_VALUES_MISMATCH`, a wrong passphrase `ERR_OSSL_BAD_DECRYPT`, a missing one `ERR_OSSL_CRYPTO_INTERRUPTED_OR_CANCELLED`, and a key the engine can't read `ERR_OSSL_UNSUPPORTED`.
|
|
502
502
|
- `pfx` is `ENOTSUP`: pass `cert` and `key`.
|
|
503
503
|
- A server that requires a certificate and gets none refuses with an alert. On TLS 1.2 that fails the connect (`ERR_SSL_HANDSHAKE_FAILURE`). On TLS 1.3 the client's side of the handshake is already done, so the next read or write fails with `ERR_SSL_FATAL_ALERT`, as Node's fails after `secureConnect`.
|
|
504
|
+
- **A reply that isn't TLS** ([#1548](https://github.com/ai-ecoverse/slicc-kernel/issues/1548)) is told apart by its first record's header, in OpenSSL's order, so a program gets Node's code: an SSLv2 version is `ERR_SSL_WRONG_VERSION_NUMBER`; a length over 16704 bytes `ERR_SSL_PACKET_LENGTH_TOO_LONG` (most plain-text replies, `HTTP/1.1 …` among them); a major version other than 3 `ERR_SSL_HTTP_REQUEST` for `GET ` or `PUT ` and `ERR_SSL_WRONG_VERSION_NUMBER` otherwise (`220 …`, `SSH-2.0…`, `+OK …`); a record over 16384 bytes `ERR_SSL_DATA_LENGTH_TOO_LONG`; and a handshake record that isn't a ServerHello `ERR_SSL_UNEXPECTED_MESSAGE`. Anything else stays `ERR_SSL_HANDSHAKE_FAILURE`, or `ECONNRESET` for a server that closes.
|
|
504
505
|
- **A fatal alert from the server**, at the handshake or after it, is in the error: its `detail` ends in ` (alert <n>)`, and a JS program's error has `alert: n`, the alert's description number (116 certificate_required, 40 handshake_failure).
|
|
505
506
|
- **`keylog: true`** ([#1504](https://github.com/ai-ecoverse/slicc-kernel/issues/1504), tls-engine 4.2.0-10) gives the session's NSS key log lines as `conn.tls.keylog`, a frozen list of strings: `CLIENT_RANDOM …` on TLS 1.2, the four `…_TRAFFIC_SECRET…` lines on TLS 1.3, the lines Node's `keylog` event and `SSLKEYLOGFILE` carry. **They are the session's secrets: anyone holding them and a capture of the traffic can read it.** So a keylogged session is never sealed (`substitutes: false`; a placeholder goes out as written), and `keylog` on the transport path (A1, where the page makes the TLS) is `ENOTSUP`. Without `keylog` the engine collects nothing. The kernel wipes its copies once the lines are in the reply (the engine zeroes its buffer as it hands them out); the lines reach the program as JS strings, which can't be wiped, so they live as long as the program keeps them, as with its own `key`. A TLS server takes `keylog` too (`listen({ tls })`, `secure(conn, { server: true })`), for every connection it serves.
|
|
506
507
|
- **`sni: false`** sends no server name. The leaf is still checked against `servername` exactly as with SNI.
|
package/dist/kernel-worker.js
CHANGED
|
@@ -8112,7 +8112,7 @@ function satisfies(version, range2) {
|
|
|
8112
8112
|
}
|
|
8113
8113
|
|
|
8114
8114
|
// src/version.ts
|
|
8115
|
-
var KERNEL_VERSION = true ? "1.
|
|
8115
|
+
var KERNEL_VERSION = true ? "1.156.0" : "0.0.0-dev";
|
|
8116
8116
|
var OS_RELEASE = "6.0.0-slicc";
|
|
8117
8117
|
function procVersion() {
|
|
8118
8118
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -19467,6 +19467,7 @@ function openSession(o) {
|
|
|
19467
19467
|
var Ciphertext = class {
|
|
19468
19468
|
queue = [];
|
|
19469
19469
|
ended = false;
|
|
19470
|
+
opening = new Uint8Array(0);
|
|
19470
19471
|
conn;
|
|
19471
19472
|
session;
|
|
19472
19473
|
constructor(conn, session) {
|
|
@@ -19475,11 +19476,19 @@ var Ciphertext = class {
|
|
|
19475
19476
|
}
|
|
19476
19477
|
hand(bytes) {
|
|
19477
19478
|
if (bytes.length > 0) this.queue.push(bytes);
|
|
19479
|
+
this.note(bytes);
|
|
19480
|
+
}
|
|
19481
|
+
note(bytes) {
|
|
19482
|
+
if (this.opening.length >= OPENING) return;
|
|
19483
|
+
const next3 = new Uint8Array(Math.min(OPENING, this.opening.length + bytes.length));
|
|
19484
|
+
next3.set(this.opening);
|
|
19485
|
+
next3.set(bytes.subarray(0, next3.length - this.opening.length), this.opening.length);
|
|
19486
|
+
this.opening = next3;
|
|
19478
19487
|
}
|
|
19479
19488
|
async more() {
|
|
19480
19489
|
if (this.queue.length === 0 && !this.ended) {
|
|
19481
19490
|
const bytes = await this.conn.read();
|
|
19482
|
-
if (bytes) this.
|
|
19491
|
+
if (bytes) this.hand(bytes);
|
|
19483
19492
|
else this.ended = true;
|
|
19484
19493
|
}
|
|
19485
19494
|
if (this.queue.length === 0) {
|
|
@@ -19509,11 +19518,38 @@ async function send(conn, session) {
|
|
|
19509
19518
|
}
|
|
19510
19519
|
}
|
|
19511
19520
|
}
|
|
19512
|
-
|
|
19521
|
+
var OPENING = 6;
|
|
19522
|
+
var PLAIN_MAX = 16384;
|
|
19523
|
+
var ENCRYPTED_MAX = PLAIN_MAX + 320;
|
|
19524
|
+
var HTTP_METHODS = ["GET ", "POST ", "HEAD ", "PUT ", "PATCH", "OPTIO", "DELET", "TRACE"];
|
|
19525
|
+
function headerClass(head) {
|
|
19526
|
+
const [type, major, minor, hi, lo] = head;
|
|
19527
|
+
if (major === 0 && minor === 2) return ["ERR_SSL_WRONG_VERSION_NUMBER", "wrong version number"];
|
|
19528
|
+
const length2 = hi << 8 | lo;
|
|
19529
|
+
if (length2 > ENCRYPTED_MAX) return ["ERR_SSL_PACKET_LENGTH_TOO_LONG", "packet length too long"];
|
|
19530
|
+
if (major !== 3) {
|
|
19531
|
+
const text = new TextDecoder("latin1").decode(head.subarray(0, 5));
|
|
19532
|
+
if (HTTP_METHODS.some((m) => text.startsWith(m)))
|
|
19533
|
+
return ["ERR_SSL_HTTP_REQUEST", "http request"];
|
|
19534
|
+
return ["ERR_SSL_WRONG_VERSION_NUMBER", "wrong version number"];
|
|
19535
|
+
}
|
|
19536
|
+
if (length2 > PLAIN_MAX) return ["ERR_SSL_DATA_LENGTH_TOO_LONG", "data length too long"];
|
|
19537
|
+
if (type === 22 && head.length > 5 && head[5] !== 2)
|
|
19538
|
+
return ["ERR_SSL_UNEXPECTED_MESSAGE", "unexpected message"];
|
|
19539
|
+
return void 0;
|
|
19540
|
+
}
|
|
19541
|
+
function recordRefusal(opening2) {
|
|
19542
|
+
if (opening2.length < 5) return void 0;
|
|
19543
|
+
const found = headerClass(opening2);
|
|
19544
|
+
return found && new KernelError("EPROTO", `${found[0]}: ${found[1]}`);
|
|
19545
|
+
}
|
|
19546
|
+
function refused2(engine, session, err, opening2) {
|
|
19513
19547
|
const flags2 = session.verifyResult;
|
|
19514
19548
|
const code = verifyCode(flags2);
|
|
19515
19549
|
if (code && flags2 !== -1)
|
|
19516
19550
|
return new KernelError("EPROTO", `${code}: ${engine.verifyInfo(flags2).trim()}`);
|
|
19551
|
+
const record2 = recordRefusal(opening2);
|
|
19552
|
+
if (record2) return record2;
|
|
19517
19553
|
const text = err instanceof TlsError ? err.message : String(err);
|
|
19518
19554
|
return new KernelError("EPROTO", `ERR_SSL_HANDSHAKE_FAILURE: ${text}${alertOf(session)}`);
|
|
19519
19555
|
}
|
|
@@ -19528,15 +19564,12 @@ async function handshake(conn, o, session, inbox) {
|
|
|
19528
19564
|
done5 = session.handshake();
|
|
19529
19565
|
} catch (err) {
|
|
19530
19566
|
await send(conn, session).catch(() => void 0);
|
|
19531
|
-
throw refused2(o.engine, session, err);
|
|
19567
|
+
throw refused2(o.engine, session, err, inbox.opening);
|
|
19532
19568
|
}
|
|
19533
19569
|
await send(conn, session);
|
|
19534
19570
|
if (done5) return;
|
|
19535
19571
|
if (!await inbox.more()) {
|
|
19536
|
-
throw new KernelError(
|
|
19537
|
-
"ECONNRESET",
|
|
19538
|
-
"the server closed the connection during the TLS handshake"
|
|
19539
|
-
);
|
|
19572
|
+
throw recordRefusal(inbox.opening) ?? new KernelError("ECONNRESET", "the server closed the connection during the TLS handshake");
|
|
19540
19573
|
}
|
|
19541
19574
|
}
|
|
19542
19575
|
}
|