@shieldfive/crypto 1.0.0-rc.2 → 1.0.0-rc.4
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/CHANGELOG.md +18 -0
- package/dist/format/signature-tail.d.ts +54 -0
- package/dist/format/signature-tail.d.ts.map +1 -0
- package/dist/format/signature-tail.js +82 -0
- package/dist/format/signature-tail.js.map +1 -0
- package/dist/identity/inbound.d.ts +35 -0
- package/dist/identity/inbound.d.ts.map +1 -1
- package/dist/identity/inbound.js +71 -1
- package/dist/identity/inbound.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/types.d.ts +1 -0
- package/dist/internal/types.d.ts.map +1 -1
- package/dist/internal/types.js +3 -0
- package/dist/internal/types.js.map +1 -1
- package/dist/migration/v0-bridge.d.ts +22 -2
- package/dist/migration/v0-bridge.d.ts.map +1 -1
- package/dist/migration/v0-bridge.js.map +1 -1
- package/dist/streams/aes-gcm-v1.d.ts +3 -37
- package/dist/streams/aes-gcm-v1.d.ts.map +1 -1
- package/dist/streams/aes-gcm-v1.js +8 -64
- package/dist/streams/aes-gcm-v1.js.map +1 -1
- package/dist/suites/aes-gcm-v1/api.d.ts +18 -0
- package/dist/suites/aes-gcm-v1/api.d.ts.map +1 -1
- package/dist/suites/aes-gcm-v1/api.js +23 -5
- package/dist/suites/aes-gcm-v1/api.js.map +1 -1
- package/dist/suites/aes-gcm-v1/index.d.ts.map +1 -1
- package/dist/suites/aes-gcm-v1/index.js +11 -0
- package/dist/suites/aes-gcm-v1/index.js.map +1 -1
- package/dist/suites/aes-gcm-v2/api.d.ts +17 -0
- package/dist/suites/aes-gcm-v2/api.d.ts.map +1 -1
- package/dist/suites/aes-gcm-v2/api.js +19 -3
- package/dist/suites/aes-gcm-v2/api.js.map +1 -1
- package/dist/suites/aes-gcm-v2/index.d.ts.map +1 -1
- package/dist/suites/aes-gcm-v2/index.js +7 -0
- package/dist/suites/aes-gcm-v2/index.js.map +1 -1
- package/dist/suites/pq-hybrid-v1/api.d.ts +17 -0
- package/dist/suites/pq-hybrid-v1/api.d.ts.map +1 -1
- package/dist/suites/pq-hybrid-v1/api.js +19 -3
- package/dist/suites/pq-hybrid-v1/api.js.map +1 -1
- package/dist/suites/xchacha-v1/api.d.ts +17 -0
- package/dist/suites/xchacha-v1/api.d.ts.map +1 -1
- package/dist/suites/xchacha-v1/api.js +19 -3
- package/dist/suites/xchacha-v1/api.js.map +1 -1
- package/dist/suites/xchacha-v1/index.d.ts.map +1 -1
- package/dist/suites/xchacha-v1/index.js +8 -0
- package/dist/suites/xchacha-v1/index.js.map +1 -1
- package/package.json +1 -1
- package/spec/key-derivation.md +19 -5
- package/src/format/signature-tail.ts +114 -0
- package/src/identity/inbound.ts +118 -1
- package/src/index.ts +1 -1
- package/src/internal/types.ts +3 -0
- package/src/migration/v0-bridge.ts +22 -2
- package/src/streams/aes-gcm-v1.ts +17 -91
- package/src/suites/aes-gcm-v1/api.ts +46 -5
- package/src/suites/aes-gcm-v1/index.ts +11 -0
- package/src/suites/aes-gcm-v2/api.ts +41 -3
- package/src/suites/aes-gcm-v2/index.ts +7 -0
- package/src/suites/pq-hybrid-v1/api.ts +41 -3
- package/src/suites/xchacha-v1/api.ts +41 -3
- package/src/suites/xchacha-v1/index.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,24 @@ All notable changes to `@shieldfive/crypto` will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 1.0.0-rc.3 — 2026-08-03
|
|
9
|
+
|
|
10
|
+
No wire-format changes; suite `0x03` and the identity bundle are untouched. Adds
|
|
11
|
+
firm key-bundle signing for the inbound-intake "Request documents" feature.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **Firm key-bundle signing** in the `inbound` module. `deriveInboundSigningKeypair`
|
|
16
|
+
derives a deterministic Ed25519 identity keypair from the master secret;
|
|
17
|
+
`signInboundKeyBundle` signs the domain-separated, length-framed
|
|
18
|
+
`(ml_kem || x25519)` public-key bundle, and `verifyInboundKeyBundle` checks it.
|
|
19
|
+
This lets a guest detect a swapped firm key (the signature must verify against
|
|
20
|
+
the firm's out-of-band-trusted signing key) — it does not defeat a server that
|
|
21
|
+
also serves malicious verifying code (the honest-claim ceiling). Reuses the
|
|
22
|
+
audited Ed25519 primitives from `sign.ts`. Integration tests cover the
|
|
23
|
+
round trip and detection of a swapped ml_kem/x25519 key, a wrong signer, and a
|
|
24
|
+
tampered signature.
|
|
25
|
+
|
|
8
26
|
## 1.0.0-rc.2 — 2026-08-02
|
|
9
27
|
|
|
10
28
|
No wire-format changes; every file written by a `1.0.0-*` release still decrypts
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared trailing-signature-block handling for the v1 wire format.
|
|
3
|
+
*
|
|
4
|
+
* A v1 file MAY carry an optional trailing Ed25519 signature block after
|
|
5
|
+
* the last chunk (see `spec/format-v1.md § "Signature block"`). Both the
|
|
6
|
+
* streaming decoders and the whole-blob decryptors need identical
|
|
7
|
+
* semantics for that tail — parse it, reject malformed trailing garbage,
|
|
8
|
+
* and optionally verify it against a caller-pinned public key — so the
|
|
9
|
+
* logic lives here, in one place, rather than being duplicated (or, as
|
|
10
|
+
* happened before, implemented by the streams and silently omitted by the
|
|
11
|
+
* blob readers).
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Verified signature metadata surfaced by a v1 decryptor.
|
|
15
|
+
*
|
|
16
|
+
* - `algorithm`, `publicKey`, `signature` come from the parsed block.
|
|
17
|
+
* - `verified` is `true` if the caller passed `expectedSignerPublicKey`
|
|
18
|
+
* AND it matched the embedded pubkey AND the signature verifies; it
|
|
19
|
+
* is `false` if the check ran and failed; it is `null` if the caller
|
|
20
|
+
* passed no `expectedSignerPublicKey` (the application policy layer
|
|
21
|
+
* is expected to do its own verification using the surfaced bytes).
|
|
22
|
+
*/
|
|
23
|
+
export interface VerifiedSignature {
|
|
24
|
+
algorithm: number;
|
|
25
|
+
publicKey: Uint8Array;
|
|
26
|
+
signature: Uint8Array;
|
|
27
|
+
verified: boolean | null;
|
|
28
|
+
}
|
|
29
|
+
export interface DecryptionMetadata {
|
|
30
|
+
/** Null when the file has no signature block (legacy / unsigned). */
|
|
31
|
+
signature: VerifiedSignature | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Parse a trailing signature block (if any) from a decryptor's residual
|
|
35
|
+
* bytes, optionally verifying it against the caller's trusted public key.
|
|
36
|
+
*
|
|
37
|
+
* `transcriptDigest` is the {@link SenderSigTranscript} digest rebuilt
|
|
38
|
+
* over the header and every chunk's full ciphertext as it was decrypted,
|
|
39
|
+
* so `verified: true` means the signer signed exactly these bytes. It is
|
|
40
|
+
* only consulted when `expectedSignerPublicKey` is supplied.
|
|
41
|
+
*
|
|
42
|
+
* Returns `null` for a file with no trailing bytes (legacy / unsigned).
|
|
43
|
+
* Throws `HeaderError` if the trailing bytes are not a well-formed
|
|
44
|
+
* signature block or carry garbage after it — the spec's MUST-reject.
|
|
45
|
+
*
|
|
46
|
+
* Shared between the AES-GCM and PQ-hybrid stream decoders and every
|
|
47
|
+
* whole-blob decryptor so the signature semantics live in one place.
|
|
48
|
+
*/
|
|
49
|
+
export declare function finalizeSignatureMetadata(input: {
|
|
50
|
+
trailingBytes: Uint8Array;
|
|
51
|
+
transcriptDigest: Uint8Array;
|
|
52
|
+
expectedSignerPublicKey: Uint8Array | undefined;
|
|
53
|
+
}): VerifiedSignature | null;
|
|
54
|
+
//# sourceMappingURL=signature-tail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature-tail.d.ts","sourceRoot":"","sources":["../../src/format/signature-tail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,UAAU,CAAA;IACrB,SAAS,EAAE,UAAU,CAAA;IACrB,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAA;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAA;CACpC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,aAAa,EAAE,UAAU,CAAA;IACzB,gBAAgB,EAAE,UAAU,CAAA;IAC5B,uBAAuB,EAAE,UAAU,GAAG,SAAS,CAAA;CAChD,GAAG,iBAAiB,GAAG,IAAI,CAwC3B"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared trailing-signature-block handling for the v1 wire format.
|
|
3
|
+
*
|
|
4
|
+
* A v1 file MAY carry an optional trailing Ed25519 signature block after
|
|
5
|
+
* the last chunk (see `spec/format-v1.md § "Signature block"`). Both the
|
|
6
|
+
* streaming decoders and the whole-blob decryptors need identical
|
|
7
|
+
* semantics for that tail — parse it, reject malformed trailing garbage,
|
|
8
|
+
* and optionally verify it against a caller-pinned public key — so the
|
|
9
|
+
* logic lives here, in one place, rather than being duplicated (or, as
|
|
10
|
+
* happened before, implemented by the streams and silently omitted by the
|
|
11
|
+
* blob readers).
|
|
12
|
+
*/
|
|
13
|
+
import { HeaderError } from './header.js';
|
|
14
|
+
import { parseSignatureBlock, SignatureError, SIGNATURE_ALGO_ED25519, verifySenderTranscript, } from '../identity/sign.js';
|
|
15
|
+
/**
|
|
16
|
+
* Parse a trailing signature block (if any) from a decryptor's residual
|
|
17
|
+
* bytes, optionally verifying it against the caller's trusted public key.
|
|
18
|
+
*
|
|
19
|
+
* `transcriptDigest` is the {@link SenderSigTranscript} digest rebuilt
|
|
20
|
+
* over the header and every chunk's full ciphertext as it was decrypted,
|
|
21
|
+
* so `verified: true` means the signer signed exactly these bytes. It is
|
|
22
|
+
* only consulted when `expectedSignerPublicKey` is supplied.
|
|
23
|
+
*
|
|
24
|
+
* Returns `null` for a file with no trailing bytes (legacy / unsigned).
|
|
25
|
+
* Throws `HeaderError` if the trailing bytes are not a well-formed
|
|
26
|
+
* signature block or carry garbage after it — the spec's MUST-reject.
|
|
27
|
+
*
|
|
28
|
+
* Shared between the AES-GCM and PQ-hybrid stream decoders and every
|
|
29
|
+
* whole-blob decryptor so the signature semantics live in one place.
|
|
30
|
+
*/
|
|
31
|
+
export function finalizeSignatureMetadata(input) {
|
|
32
|
+
if (input.trailingBytes.length === 0) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
let parsed;
|
|
36
|
+
try {
|
|
37
|
+
parsed = parseSignatureBlock(input.trailingBytes, 0);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (err instanceof SignatureError) {
|
|
41
|
+
throw new HeaderError(`signature_block_${err.code}`);
|
|
42
|
+
}
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
if (parsed.consumed !== input.trailingBytes.length) {
|
|
46
|
+
throw new HeaderError('trailing_bytes_after_signature_block');
|
|
47
|
+
}
|
|
48
|
+
const { algorithm, publicKey, signature } = parsed.block;
|
|
49
|
+
let verified = null;
|
|
50
|
+
if (input.expectedSignerPublicKey) {
|
|
51
|
+
if (algorithm !== SIGNATURE_ALGO_ED25519) {
|
|
52
|
+
// Unknown / unsupported algorithm: cannot verify with our
|
|
53
|
+
// Ed25519-only verifier; treat as a verification failure under
|
|
54
|
+
// the caller's policy (they asked us to verify, we couldn't).
|
|
55
|
+
verified = false;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// Pubkey-pinning: if the embedded pubkey doesn't match the caller's
|
|
59
|
+
// expected one, fail without doing the (still-honest) Ed25519
|
|
60
|
+
// math. This keeps the "verified=true" contract tight: it means
|
|
61
|
+
// the file was signed by the key the caller expected.
|
|
62
|
+
verified =
|
|
63
|
+
bytesEqualConstantTime(publicKey, input.expectedSignerPublicKey) &&
|
|
64
|
+
verifySenderTranscript({
|
|
65
|
+
ed25519PublicKey: input.expectedSignerPublicKey,
|
|
66
|
+
transcriptDigest: input.transcriptDigest,
|
|
67
|
+
signature,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { algorithm, publicKey, signature, verified };
|
|
72
|
+
}
|
|
73
|
+
function bytesEqualConstantTime(a, b) {
|
|
74
|
+
if (a.length !== b.length)
|
|
75
|
+
return false;
|
|
76
|
+
let diff = 0;
|
|
77
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
78
|
+
diff |= a[i] ^ b[i];
|
|
79
|
+
}
|
|
80
|
+
return diff === 0;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=signature-tail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature-tail.js","sourceRoot":"","sources":["../../src/format/signature-tail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EACL,mBAAmB,EAEnB,cAAc,EACd,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAwB5B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAIzC;IACC,IAAI,KAAK,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,MAAmD,CAAA;IACvD,IAAI,CAAC;QACH,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;IACtD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,cAAc,EAAE,CAAC;YAClC,MAAM,IAAI,WAAW,CA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GAAG,CAAC,CAAC,CAAC,CAAE,CAAA;IACvB,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,CAAA;AACnB,CAAC"}
|
|
@@ -69,4 +69,39 @@ export declare function openInboundEnvelopeKey(options: {
|
|
|
69
69
|
}): Promise<{
|
|
70
70
|
envelopeKey: Uint8Array;
|
|
71
71
|
}>;
|
|
72
|
+
/** Ed25519 signing public key length (bytes). */
|
|
73
|
+
export declare const INBOUND_SIGNING_PUBLIC_KEY_LENGTH = 32;
|
|
74
|
+
/** Ed25519 key-bundle signature length (bytes). */
|
|
75
|
+
export declare const INBOUND_KEY_BUNDLE_SIGNATURE_LENGTH = 64;
|
|
76
|
+
export interface InboundSigningKeypair {
|
|
77
|
+
/** Ed25519 public key (32 bytes) — publish so guests can verify the bundle. */
|
|
78
|
+
ed25519PublicKey: Uint8Array;
|
|
79
|
+
/** Ed25519 secret seed (32 bytes) — treat as highly sensitive. */
|
|
80
|
+
ed25519SecretKey: Uint8Array;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Deterministically derive the firm's Ed25519 signing keypair from its master
|
|
84
|
+
* secret, mirroring the ML-KEM / X25519 derivations. Stable across devices.
|
|
85
|
+
*/
|
|
86
|
+
export declare function deriveInboundSigningKeypair(masterSecret: Uint8Array): Promise<InboundSigningKeypair>;
|
|
87
|
+
/**
|
|
88
|
+
* Sign the firm's published (ml_kem || x25519) bundle with its Ed25519 signing
|
|
89
|
+
* secret. Returns a raw 64-byte signature to store next to the keys.
|
|
90
|
+
*/
|
|
91
|
+
export declare function signInboundKeyBundle(options: {
|
|
92
|
+
ed25519SecretKey: Uint8Array;
|
|
93
|
+
mlKemPublicKey: Uint8Array;
|
|
94
|
+
x25519PublicKey: Uint8Array;
|
|
95
|
+
}): Uint8Array;
|
|
96
|
+
/**
|
|
97
|
+
* Guest side: verify a firm key-bundle signature. Returns false on any failure
|
|
98
|
+
* (never throws). The guest must additionally trust the signing public key via
|
|
99
|
+
* an out-of-band fingerprint.
|
|
100
|
+
*/
|
|
101
|
+
export declare function verifyInboundKeyBundle(options: {
|
|
102
|
+
ed25519PublicKey: Uint8Array;
|
|
103
|
+
mlKemPublicKey: Uint8Array;
|
|
104
|
+
x25519PublicKey: Uint8Array;
|
|
105
|
+
signature: Uint8Array;
|
|
106
|
+
}): boolean;
|
|
72
107
|
//# sourceMappingURL=inbound.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbound.d.ts","sourceRoot":"","sources":["../../src/identity/inbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;
|
|
1
|
+
{"version":3,"file":"inbound.d.ts","sourceRoot":"","sources":["../../src/identity/inbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAkBH,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAC1C,mCAAmC;AACnC,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAI1C,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,eAAe,EAAE,UAAU,CAAA;IAC3B,0EAA0E;IAC1E,eAAe,EAAE,UAAU,CAAA;CAC5B;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,YAAY,EAAE,UAAU,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAa/B;AA0BD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE;IACpD,wBAAwB,EAAE,UAAU,CAAA;IACpC,MAAM,EAAE,UAAU,CAAA;CACnB,GAAG,OAAO,CAAC;IAAE,WAAW,EAAE,UAAU,CAAC;IAAC,kBAAkB,EAAE,UAAU,CAAA;CAAE,CAAC,CA0BvE;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE;IACpD,eAAe,EAAE,UAAU,CAAA;IAC3B,kBAAkB,EAAE,UAAU,CAAA;IAC9B,MAAM,EAAE,UAAU,CAAA;CACnB,GAAG,OAAO,CAAC;IAAE,WAAW,EAAE,UAAU,CAAA;CAAE,CAAC,CA4BvC;AAYD,iDAAiD;AACjD,eAAO,MAAM,iCAAiC,KAA4B,CAAA;AAC1E,mDAAmD;AACnD,eAAO,MAAM,mCAAmC,KAA2B,CAAA;AAM3E,MAAM,WAAW,qBAAqB;IACpC,+EAA+E;IAC/E,gBAAgB,EAAE,UAAU,CAAA;IAC5B,kEAAkE;IAClE,gBAAgB,EAAE,UAAU,CAAA;CAC7B;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,UAAU,GACvB,OAAO,CAAC,qBAAqB,CAAC,CAahC;AAsBD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,gBAAgB,EAAE,UAAU,CAAA;IAC5B,cAAc,EAAE,UAAU,CAAA;IAC1B,eAAe,EAAE,UAAU,CAAA;CAC5B,GAAG,UAAU,CASb;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC9C,gBAAgB,EAAE,UAAU,CAAA;IAC5B,cAAc,EAAE,UAAU,CAAA;IAC1B,eAAe,EAAE,UAAU,CAAA;IAC3B,SAAS,EAAE,UAAU,CAAA;CACtB,GAAG,OAAO,CAUV"}
|
package/dist/identity/inbound.js
CHANGED
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
* This module does the cryptography; it does not establish key authenticity.
|
|
28
28
|
*/
|
|
29
29
|
import { x25519 } from '@noble/curves/ed25519.js';
|
|
30
|
-
import {
|
|
30
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
31
|
+
import { deriveEd25519PublicKey, ED25519_PUBLIC_KEY_LENGTH, ED25519_SECRET_KEY_LENGTH, ED25519_SIGNATURE_LENGTH, signSenderTranscript, verifySenderTranscript, } from './sign.js';
|
|
32
|
+
import { concatBytes, uint32BE } from '../internal/encoding.js';
|
|
31
33
|
import { hkdfSha256 } from '../internal/hkdf.js';
|
|
32
34
|
import { randomBytes } from '../internal/runtime.js';
|
|
33
35
|
import { HEADER_SIZES, HKDF_INFO } from '../internal/types.js';
|
|
@@ -117,4 +119,72 @@ export async function openInboundEnvelopeKey(options) {
|
|
|
117
119
|
const envelopeKey = await deriveEnvelopeKey(sharedSecret, ephemeralPublicKey, recipientStaticPublicKey, fileId);
|
|
118
120
|
return { envelopeKey };
|
|
119
121
|
}
|
|
122
|
+
// ── Firm key-bundle signing ──────────────────────────────────────────────────
|
|
123
|
+
//
|
|
124
|
+
// The guest fetches the firm's ml_kem + x25519 public keys from a server it does
|
|
125
|
+
// not trust. To detect a swapped key, the firm signs its published key bundle
|
|
126
|
+
// with a long-lived Ed25519 identity key derived from the same master secret,
|
|
127
|
+
// and the guest verifies the signature against the firm's published signing key
|
|
128
|
+
// (whose fingerprint the firm communicates out of band). This raises the bar to
|
|
129
|
+
// a firm-key forgery; it does not defeat a server that also serves malicious
|
|
130
|
+
// verifying code (the honest-claim ceiling).
|
|
131
|
+
/** Ed25519 signing public key length (bytes). */
|
|
132
|
+
export const INBOUND_SIGNING_PUBLIC_KEY_LENGTH = ED25519_PUBLIC_KEY_LENGTH;
|
|
133
|
+
/** Ed25519 key-bundle signature length (bytes). */
|
|
134
|
+
export const INBOUND_KEY_BUNDLE_SIGNATURE_LENGTH = ED25519_SIGNATURE_LENGTH;
|
|
135
|
+
const INBOUND_KEY_BUNDLE_DOMAIN = new TextEncoder().encode('shieldfive/v1/inbound/key-bundle');
|
|
136
|
+
/**
|
|
137
|
+
* Deterministically derive the firm's Ed25519 signing keypair from its master
|
|
138
|
+
* secret, mirroring the ML-KEM / X25519 derivations. Stable across devices.
|
|
139
|
+
*/
|
|
140
|
+
export async function deriveInboundSigningKeypair(masterSecret) {
|
|
141
|
+
if (masterSecret.length < 16) {
|
|
142
|
+
throw new RangeError('deriveInboundSigningKeypair: masterSecret must be at least 16 bytes');
|
|
143
|
+
}
|
|
144
|
+
const seed = await hkdfSha256({
|
|
145
|
+
ikm: masterSecret,
|
|
146
|
+
info: HKDF_INFO.INBOUND_SIGNING_SEED,
|
|
147
|
+
length: ED25519_SECRET_KEY_LENGTH,
|
|
148
|
+
});
|
|
149
|
+
const ed25519PublicKey = deriveEd25519PublicKey(seed);
|
|
150
|
+
return { ed25519PublicKey, ed25519SecretKey: seed };
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Domain-separated, length-framed digest over the published key bundle. Framing
|
|
154
|
+
* the lengths prevents a (ml_kem, x25519) split from colliding with a different
|
|
155
|
+
* pairing.
|
|
156
|
+
*/
|
|
157
|
+
function inboundKeyBundleDigest(mlKemPublicKey, x25519PublicKey) {
|
|
158
|
+
return sha256(concatBytes([
|
|
159
|
+
INBOUND_KEY_BUNDLE_DOMAIN,
|
|
160
|
+
uint32BE(mlKemPublicKey.length),
|
|
161
|
+
mlKemPublicKey,
|
|
162
|
+
uint32BE(x25519PublicKey.length),
|
|
163
|
+
x25519PublicKey,
|
|
164
|
+
]));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Sign the firm's published (ml_kem || x25519) bundle with its Ed25519 signing
|
|
168
|
+
* secret. Returns a raw 64-byte signature to store next to the keys.
|
|
169
|
+
*/
|
|
170
|
+
export function signInboundKeyBundle(options) {
|
|
171
|
+
const digest = inboundKeyBundleDigest(options.mlKemPublicKey, options.x25519PublicKey);
|
|
172
|
+
return signSenderTranscript({
|
|
173
|
+
ed25519SecretKey: options.ed25519SecretKey,
|
|
174
|
+
transcriptDigest: digest,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Guest side: verify a firm key-bundle signature. Returns false on any failure
|
|
179
|
+
* (never throws). The guest must additionally trust the signing public key via
|
|
180
|
+
* an out-of-band fingerprint.
|
|
181
|
+
*/
|
|
182
|
+
export function verifyInboundKeyBundle(options) {
|
|
183
|
+
const digest = inboundKeyBundleDigest(options.mlKemPublicKey, options.x25519PublicKey);
|
|
184
|
+
return verifySenderTranscript({
|
|
185
|
+
ed25519PublicKey: options.ed25519PublicKey,
|
|
186
|
+
transcriptDigest: digest,
|
|
187
|
+
signature: options.signature,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
120
190
|
//# sourceMappingURL=inbound.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbound.js","sourceRoot":"","sources":["../../src/identity/inbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"inbound.js","sourceRoot":"","sources":["../../src/identity/inbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAE9D,0DAA0D;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAC1C,mCAAmC;AACnC,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAE1C,MAAM,0BAA0B,GAAG,EAAE,CAAA;AASrC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,YAAwB;IAExB,IAAI,YAAY,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI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GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAKtC;IACC,MAAM,MAAM,GAAG,sBAAsB,CACnC,OAAO,CAAC,cAAc,EACtB,OAAO,CAAC,eAAe,CACxB,CAAA;IACD,OAAO,sBAAsB,CAAC;QAC5B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,gBAAgB,EAAE,MAAM;QACxB,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export interface AutoDecryptOptions {
|
|
|
54
54
|
*/
|
|
55
55
|
export declare function autoDecryptBlob(options: AutoDecryptOptions): Promise<Blob>;
|
|
56
56
|
/** Library version, also written into format documentation. */
|
|
57
|
-
export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-rc.
|
|
57
|
+
export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-rc.4";
|
|
58
58
|
/** Default cipher suite for new files when not specified by the caller. */
|
|
59
59
|
export declare const DEFAULT_SUITE: 3;
|
|
60
60
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -141,7 +141,7 @@ export async function autoDecryptBlob(options) {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
/** Library version, also written into format documentation. */
|
|
144
|
-
export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.
|
|
144
|
+
export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.4';
|
|
145
145
|
/** Default cipher suite for new files when not specified by the caller. */
|
|
146
146
|
export const DEFAULT_SUITE = SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1;
|
|
147
147
|
//# sourceMappingURL=index.js.map
|
package/dist/internal/types.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export declare const HKDF_INFO: Readonly<{
|
|
|
58
58
|
SHARE_TRANSPORT: "shieldfive/v1/share-transport";
|
|
59
59
|
INBOUND_X25519_STATIC_SEED: "shieldfive/v1/inbound/x25519-static-seed";
|
|
60
60
|
INBOUND_ENVELOPE: "shieldfive/v1/inbound/envelope-key";
|
|
61
|
+
INBOUND_SIGNING_SEED: "shieldfive/v1/inbound/ed25519-signing-seed";
|
|
61
62
|
ARGON2ID_SALT_COMPRESSION: "shieldfive/v1/argon2id/salt-compression";
|
|
62
63
|
}>;
|
|
63
64
|
/** AAD domain string mixed into every chunk's authenticator */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,YAAY,CAAA;IACpB,eAAe,CAAC,CAAC,SAAS,eAAe,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;CACxD,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAA;AAElD;;;GAGG;AACH,eAAO,MAAM,KAAK;;;;;CAKR,CAAA;AAEV,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAA;AAExD,MAAM,MAAM,SAAS,GACjB,gBAAgB,GAChB,uBAAuB,GACvB,gCAAgC,GAChC,gBAAgB,CAAA;AAEpB,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,CAKlD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,UAEzB,CAAA;AAEF,eAAO,MAAM,mBAAmB,IAAI,CAAA;AAEpC,iDAAiD;AACjD,eAAO,MAAM,YAAY;;;;;;;;;;EAUvB,CAAA;AAEF,8DAA8D;AAC9D,eAAO,MAAM,0BAA0B,QAQP,CAAA;AAEhC,gEAAgE;AAChE,eAAO,MAAM,kBAAkB,QAAkB,CAAA;AAEjD,8DAA8D;AAC9D,eAAO,MAAM,cAAc,aAAc,CAAA;AAEzC,+EAA+E;AAC/E,e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ACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,UAAU,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,UAAU,CAAA;IACxB,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,UAAU,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA"}
|
package/dist/internal/types.js
CHANGED
|
@@ -76,6 +76,9 @@ export const HKDF_INFO = Object.freeze({
|
|
|
76
76
|
// nowhere else.
|
|
77
77
|
INBOUND_X25519_STATIC_SEED: 'shieldfive/v1/inbound/x25519-static-seed',
|
|
78
78
|
INBOUND_ENVELOPE: 'shieldfive/v1/inbound/envelope-key',
|
|
79
|
+
// Ed25519 identity signing key for inbound intake. The firm signs its
|
|
80
|
+
// published (ml_kem || x25519) bundle so a guest can detect a key swap.
|
|
81
|
+
INBOUND_SIGNING_SEED: 'shieldfive/v1/inbound/ed25519-signing-seed',
|
|
79
82
|
ARGON2ID_SALT_COMPRESSION: 'shieldfive/v1/argon2id/salt-compression',
|
|
80
83
|
});
|
|
81
84
|
/** AAD domain string mixed into every chunk's authenticator */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,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AAE,0BAA0B;IACtC,iBAAiB,EAAE,iCAAiC;IACpD,oBAAoB,EAAE,oCAAoC;IAC1D,uBAAuB,EAAE,uCAAuC;IAChE,iBAAiB,EAAE,iCAAiC;IACpD,oBAAoB,EAAE,oCAAoC;IAC1D,iBAAiB,EAAE,iCAAiC;IACpD,gBAAgB,EAAE,0CAA0C;IAC5D,4EAA4E;IAC5E,yEAAyE;IACzE,mEAAmE;IACnE,4DAA4D;IAC5D,eAAe,EAAE,+BAA+B;IAChD,8EAA8E;IAC9E,sEAAsE;IACtE,6EAA6E;IAC7E,4EAA4E;IAC5E,+EAA+E;IAC/E,8EAA8E;IAC9E,gBAAgB;IAChB,0BAA0B,EAAE,0CAA0C;IACtE,gBAAgB,EAAE,oCAAoC;IACtD,sEAAsE;IACtE,wEAAwE;IACxE,oBAAoB,EAAE,4CAA4C;IAClE,yBAAyB,EAAE,yCAAyC;CACrE,CAAC,CAAA;AAEF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAA;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA"}
|
|
@@ -27,9 +27,29 @@ export { decryptV0, decryptV0ToBytes, V0_IV_BYTES, V0_KEY_BYTES, V0_NONCE_PREFIX
|
|
|
27
27
|
export interface V0EncryptOptions {
|
|
28
28
|
/** Plaintext blob. */
|
|
29
29
|
blob: Blob;
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* 32-byte AES-256 content key. Must already be unwrapped.
|
|
32
|
+
*
|
|
33
|
+
* SECURITY: `contentKey` and `noncePrefix` together form this file's
|
|
34
|
+
* AES-GCM nonce namespace. Reusing the same (contentKey, noncePrefix)
|
|
35
|
+
* pair across two DIFFERENT plaintexts reuses every chunk's (key, IV)
|
|
36
|
+
* and is catastrophic — it reproduces the keystream (ct1 ^ ct2 = pt1 ^
|
|
37
|
+
* pt2, enabling plaintext recovery) and leaks the GHASH authentication
|
|
38
|
+
* key (enabling forgery). See the note on `noncePrefix`.
|
|
39
|
+
*/
|
|
31
40
|
contentKey: Uint8Array;
|
|
32
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* 4-byte per-file nonce prefix. Generated fresh (random) when omitted —
|
|
43
|
+
* that is the safe default and requires no caller cooperation.
|
|
44
|
+
*
|
|
45
|
+
* SECURITY: if you persist and re-supply a prefix (which the returned
|
|
46
|
+
* {@link V0EncryptResult} explicitly invites you to do), you MUST use a
|
|
47
|
+
* FRESH prefix whenever you re-encrypt an edited file under the same
|
|
48
|
+
* `contentKey`. Re-encrypting different content under an unchanged
|
|
49
|
+
* (contentKey, noncePrefix) pair reuses the AES-GCM nonce and is
|
|
50
|
+
* catastrophic (see `contentKey`). This legacy v0 writer exists solely
|
|
51
|
+
* for the Phase-1 migration; new data must use a v1 suite instead.
|
|
52
|
+
*/
|
|
33
53
|
noncePrefix?: Uint8Array;
|
|
34
54
|
/** Plaintext bytes per chunk. Production uses 5 MiB or 8 MiB. */
|
|
35
55
|
chunkSize: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v0-bridge.d.ts","sourceRoot":"","sources":["../../src/migration/v0-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,YAAY,EACZ,KAAK,gBAAgB,EACtB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,YAAY,EACZ,KAAK,gBAAgB,GACtB,CAAA;AAMD,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB;IACtB,IAAI,EAAE,IAAI,CAAA;IACV
|
|
1
|
+
{"version":3,"file":"v0-bridge.d.ts","sourceRoot":"","sources":["../../src/migration/v0-bridge.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D,IAAI,CAAA;IACR,WAAW,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CACpC;AAWD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAkH9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v0-bridge.js","sourceRoot":"","sources":["../../src/migration/v0-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,YAAY,GAEb,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,YAAY,GAEb,CAAA;
|
|
1
|
+
{"version":3,"file":"v0-bridge.js","sourceRoot":"","sources":["../../src/migration/v0-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,YAAY,GAEb,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,YAAY,GAEb,CAAA;AAyDD,SAAS,SAAS,CAAC,MAAkB,EAAE,OAAe;IACpD,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAA;IACtC,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC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EAAE,SAAS,EAAE,CAAC,CAAA;gBACtC,OAAM;YACR,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAChD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,KAAK,CAAC,WAAW,CAAC;gBAChB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAG,GAAa,CAAC,OAAO,IAAI,eAAe;aACjD,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
* adding them is a copy of the AES module with the suite primitive
|
|
19
19
|
* swapped, but we ship one suite first to lock the streaming contract.
|
|
20
20
|
*/
|
|
21
|
+
import { finalizeSignatureMetadata, type DecryptionMetadata } from '../format/signature-tail.js';
|
|
22
|
+
export { finalizeSignatureMetadata };
|
|
23
|
+
export type { DecryptionMetadata, VerifiedSignature } from '../format/signature-tail.js';
|
|
21
24
|
export interface AesGcmV1EncryptStreamOptions {
|
|
22
25
|
/** Total plaintext byte count. Required because the header carries it. */
|
|
23
26
|
plaintextSize: number;
|
|
@@ -67,26 +70,6 @@ export interface AesGcmV1DecryptStreamOptions {
|
|
|
67
70
|
*/
|
|
68
71
|
expectedSignerPublicKey?: Uint8Array;
|
|
69
72
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Verified signature metadata surfaced by the decrypt stream.
|
|
72
|
-
*
|
|
73
|
-
* - `algorithm`, `publicKey`, `signature` come from the parsed block.
|
|
74
|
-
* - `verified` is `true` if the caller passed `expectedSignerPublicKey`
|
|
75
|
-
* AND it matched the embedded pubkey AND the signature verifies; it
|
|
76
|
-
* is `false` if the check ran and failed; it is `null` if the caller
|
|
77
|
-
* passed no `expectedSignerPublicKey` (the application policy layer
|
|
78
|
-
* is expected to do its own verification using the surfaced bytes).
|
|
79
|
-
*/
|
|
80
|
-
export interface VerifiedSignature {
|
|
81
|
-
algorithm: number;
|
|
82
|
-
publicKey: Uint8Array;
|
|
83
|
-
signature: Uint8Array;
|
|
84
|
-
verified: boolean | null;
|
|
85
|
-
}
|
|
86
|
-
export interface DecryptionMetadata {
|
|
87
|
-
/** Null when the file has no signature block (legacy / unsigned). */
|
|
88
|
-
signature: VerifiedSignature | null;
|
|
89
|
-
}
|
|
90
73
|
export interface AesGcmV1DecryptStreamResult {
|
|
91
74
|
stream: TransformStream<Uint8Array, Uint8Array>;
|
|
92
75
|
/**
|
|
@@ -128,21 +111,4 @@ export declare function decryptStreamAesGcmV1(source: ReadableStream<Uint8Array>
|
|
|
128
111
|
plaintext: ReadableStream<Uint8Array>;
|
|
129
112
|
metadata: Promise<DecryptionMetadata>;
|
|
130
113
|
};
|
|
131
|
-
/**
|
|
132
|
-
* Parse a trailing signature block (if any) from the decrypt stream's
|
|
133
|
-
* residual buffer, optionally verifying it against the caller's
|
|
134
|
-
* trusted public key.
|
|
135
|
-
*
|
|
136
|
-
* `transcriptDigest` is the {@link SenderSigTranscript} digest rebuilt
|
|
137
|
-
* over the header and every chunk's full ciphertext as it was decrypted,
|
|
138
|
-
* so `verified: true` means the signer signed exactly these bytes.
|
|
139
|
-
*
|
|
140
|
-
* Shared between the AES-GCM and PQ-hybrid stream decoders so the
|
|
141
|
-
* signature semantics live in one place.
|
|
142
|
-
*/
|
|
143
|
-
export declare function finalizeSignatureMetadata(input: {
|
|
144
|
-
trailingBytes: Uint8Array;
|
|
145
|
-
transcriptDigest: Uint8Array;
|
|
146
|
-
expectedSignerPublicKey: Uint8Array | undefined;
|
|
147
|
-
}): VerifiedSignature | null;
|
|
148
114
|
//# sourceMappingURL=aes-gcm-v1.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aes-gcm-v1.d.ts","sourceRoot":"","sources":["../../src/streams/aes-gcm-v1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"aes-gcm-v1.d.ts","sourceRoot":"","sources":["../../src/streams/aes-gcm-v1.ts"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7B;AAMD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,OAAO,EAAE,4BAA4B,GACpC;IACD,UAAU,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;IACtC,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,UAAU,CAAA;CACnB,CAQA;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,OAAO,EAAE,4BAA4B,GACpC;IACD,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;IACrC,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAA;CACtC,CAMA"}
|
|
@@ -23,7 +23,12 @@ import { AES_GCM_V1_SUITE_PAYLOAD_LENGTH, AES_GCM_V1_TAG_BYTES, createChunkConte
|
|
|
23
23
|
import { DEFAULT_CHUNK_SIZE, HEADER_SIZES, MAX_TOTAL_CHUNKS, SUITE, } from '../internal/types.js';
|
|
24
24
|
import { concatBytes, readUint32BE, uint32BE } from '../internal/encoding.js';
|
|
25
25
|
import { hmacSha256 } from '../internal/hmac.js';
|
|
26
|
-
import { buildSignatureBlock, deriveEd25519PublicKey, ED25519_SECRET_KEY_LENGTH,
|
|
26
|
+
import { buildSignatureBlock, deriveEd25519PublicKey, ED25519_SECRET_KEY_LENGTH, SenderSigTranscript, SIGNATURE_ALGO_ED25519, signSenderTranscript, } from '../identity/sign.js';
|
|
27
|
+
import { finalizeSignatureMetadata, } from '../format/signature-tail.js';
|
|
28
|
+
// Re-exported so `streams/aes-gcm-v1.js` stays the import site these
|
|
29
|
+
// symbols have always had (the PQ-hybrid stream and public barrels
|
|
30
|
+
// import them from here).
|
|
31
|
+
export { finalizeSignatureMetadata };
|
|
27
32
|
const LENGTH_PREFIX_BYTES = 4;
|
|
28
33
|
/**
|
|
29
34
|
* Build a TransformStream that encrypts plaintext into v1 wire-format
|
|
@@ -400,67 +405,6 @@ export function decryptStreamAesGcmV1(source, options) {
|
|
|
400
405
|
metadata,
|
|
401
406
|
};
|
|
402
407
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
* residual buffer, optionally verifying it against the caller's
|
|
406
|
-
* trusted public key.
|
|
407
|
-
*
|
|
408
|
-
* `transcriptDigest` is the {@link SenderSigTranscript} digest rebuilt
|
|
409
|
-
* over the header and every chunk's full ciphertext as it was decrypted,
|
|
410
|
-
* so `verified: true` means the signer signed exactly these bytes.
|
|
411
|
-
*
|
|
412
|
-
* Shared between the AES-GCM and PQ-hybrid stream decoders so the
|
|
413
|
-
* signature semantics live in one place.
|
|
414
|
-
*/
|
|
415
|
-
export function finalizeSignatureMetadata(input) {
|
|
416
|
-
if (input.trailingBytes.length === 0) {
|
|
417
|
-
return null;
|
|
418
|
-
}
|
|
419
|
-
let parsed;
|
|
420
|
-
try {
|
|
421
|
-
parsed = parseSignatureBlock(input.trailingBytes, 0);
|
|
422
|
-
}
|
|
423
|
-
catch (err) {
|
|
424
|
-
if (err instanceof SignatureError) {
|
|
425
|
-
throw new HeaderError(`signature_block_${err.code}`);
|
|
426
|
-
}
|
|
427
|
-
throw err;
|
|
428
|
-
}
|
|
429
|
-
if (parsed.consumed !== input.trailingBytes.length) {
|
|
430
|
-
throw new HeaderError('trailing_bytes_after_signature_block');
|
|
431
|
-
}
|
|
432
|
-
const { algorithm, publicKey, signature } = parsed.block;
|
|
433
|
-
let verified = null;
|
|
434
|
-
if (input.expectedSignerPublicKey) {
|
|
435
|
-
if (algorithm !== SIGNATURE_ALGO_ED25519) {
|
|
436
|
-
// Unknown / unsupported algorithm: cannot verify with our
|
|
437
|
-
// Ed25519-only verifier; treat as a verification failure under
|
|
438
|
-
// the caller's policy (they asked us to verify, we couldn't).
|
|
439
|
-
verified = false;
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
442
|
-
// Pubkey-pinning: if the embedded pubkey doesn't match the caller's
|
|
443
|
-
// expected one, fail without doing the (still-honest) Ed25519
|
|
444
|
-
// math. This keeps the "verified=true" contract tight: it means
|
|
445
|
-
// the file was signed by the key the caller expected.
|
|
446
|
-
verified =
|
|
447
|
-
bytesEqualConstantTime(publicKey, input.expectedSignerPublicKey) &&
|
|
448
|
-
verifySenderTranscript({
|
|
449
|
-
ed25519PublicKey: input.expectedSignerPublicKey,
|
|
450
|
-
transcriptDigest: input.transcriptDigest,
|
|
451
|
-
signature,
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
return { algorithm, publicKey, signature, verified };
|
|
456
|
-
}
|
|
457
|
-
function bytesEqualConstantTime(a, b) {
|
|
458
|
-
if (a.length !== b.length)
|
|
459
|
-
return false;
|
|
460
|
-
let diff = 0;
|
|
461
|
-
for (let i = 0; i < a.length; i += 1) {
|
|
462
|
-
diff |= a[i] ^ b[i];
|
|
463
|
-
}
|
|
464
|
-
return diff === 0;
|
|
465
|
-
}
|
|
408
|
+
// `finalizeSignatureMetadata` moved to `../format/signature-tail.js`
|
|
409
|
+
// (re-exported above) so the whole-blob decryptors share it.
|
|
466
410
|
//# sourceMappingURL=aes-gcm-v1.js.map
|