@shieldfive/crypto 1.0.0-alpha.7 → 1.0.0-beta.1
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 +164 -0
- package/LICENSE +1 -1
- package/README.md +32 -15
- package/SECURITY.md +12 -8
- package/dist/identity/index.d.ts +16 -0
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +84 -22
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/sign.d.ts +92 -0
- package/dist/identity/sign.d.ts.map +1 -0
- package/dist/identity/sign.js +182 -0
- package/dist/identity/sign.js.map +1 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/encoding.d.ts.map +1 -1
- package/dist/internal/encoding.js +0 -1
- package/dist/internal/encoding.js.map +1 -1
- package/dist/internal/types.d.ts +4 -1
- package/dist/internal/types.d.ts.map +1 -1
- package/dist/internal/types.js +8 -0
- package/dist/internal/types.js.map +1 -1
- package/dist/streams/aes-gcm-v1.d.ts +71 -3
- package/dist/streams/aes-gcm-v1.d.ts.map +1 -1
- package/dist/streams/aes-gcm-v1.js +183 -49
- package/dist/streams/aes-gcm-v1.js.map +1 -1
- package/dist/streams/pq-hybrid-v1.d.ts +34 -3
- package/dist/streams/pq-hybrid-v1.d.ts.map +1 -1
- package/dist/streams/pq-hybrid-v1.js +114 -49
- package/dist/streams/pq-hybrid-v1.js.map +1 -1
- package/dist/suites/aes-gcm-v1/api.d.ts.map +1 -1
- package/dist/suites/aes-gcm-v1/api.js +1 -1
- package/dist/suites/aes-gcm-v1/api.js.map +1 -1
- package/dist/suites/aes-gcm-v1/index.d.ts +3 -0
- package/dist/suites/aes-gcm-v1/index.d.ts.map +1 -1
- package/dist/suites/aes-gcm-v1/index.js +3 -0
- package/dist/suites/aes-gcm-v1/index.js.map +1 -1
- package/dist/suites/aes-gcm-v2/api.d.ts +44 -0
- package/dist/suites/aes-gcm-v2/api.d.ts.map +1 -0
- package/dist/suites/aes-gcm-v2/api.js +162 -0
- package/dist/suites/aes-gcm-v2/api.js.map +1 -0
- package/dist/suites/aes-gcm-v2/index.d.ts +63 -0
- package/dist/suites/aes-gcm-v2/index.d.ts.map +1 -0
- package/dist/suites/aes-gcm-v2/index.js +193 -0
- package/dist/suites/aes-gcm-v2/index.js.map +1 -0
- package/dist/suites/pq-hybrid-v1/api.d.ts +1 -1
- package/dist/suites/pq-hybrid-v1/api.d.ts.map +1 -1
- package/dist/suites/pq-hybrid-v1/api.js +1 -1
- package/dist/suites/pq-hybrid-v1/api.js.map +1 -1
- package/dist/suites/pq-hybrid-v1/index.d.ts +4 -0
- package/dist/suites/pq-hybrid-v1/index.d.ts.map +1 -1
- package/dist/suites/pq-hybrid-v1/index.js +15 -1
- package/dist/suites/pq-hybrid-v1/index.js.map +1 -1
- package/package.json +13 -3
- package/spec/format-v1.md +200 -7
- package/spec/key-derivation.md +18 -2
- package/spec/threat-model.md +36 -21
- package/src/identity/index.ts +107 -28
- package/src/identity/sign.ts +221 -0
- package/src/index.ts +32 -5
- package/src/internal/encoding.ts +0 -1
- package/src/internal/types.ts +9 -0
- package/src/streams/aes-gcm-v1.ts +263 -59
- package/src/streams/pq-hybrid-v1.ts +169 -59
- package/src/suites/aes-gcm-v1/api.ts +0 -1
- package/src/suites/aes-gcm-v1/index.ts +3 -0
- package/src/suites/aes-gcm-v2/api.ts +268 -0
- package/src/suites/aes-gcm-v2/index.ts +289 -0
- package/src/suites/pq-hybrid-v1/api.ts +2 -0
- package/src/suites/pq-hybrid-v1/index.ts +25 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,169 @@ 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-beta.1 — 2026-06-19
|
|
9
|
+
|
|
10
|
+
> Promotes the library from alpha to **beta**. There are no functional,
|
|
11
|
+
> cryptographic, or wire-format changes since `1.0.0-alpha.14`; this release
|
|
12
|
+
> records that the v1 on-disk format and the public TypeScript API are now
|
|
13
|
+
> considered stable enough to leave alpha. `1.0.0` stable remains gated on
|
|
14
|
+
> the planned external third-party audit.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **Status: alpha → beta.** The `0x03` PQ-hybrid share-bundle hardening
|
|
19
|
+
(audit findings H2/M6, doc M5) shipped in `1.0.0-alpha.14` and is unchanged
|
|
20
|
+
here. The wire format stays frozen; existing `cipher_version-3` files and
|
|
21
|
+
hardened (`SF5S` v2) share bundles remain valid.
|
|
22
|
+
- `SHIELDFIVE_CRYPTO_VERSION`, the status badge, the README/SECURITY status
|
|
23
|
+
notes, and the example decryptor updated to `1.0.0-beta.1`.
|
|
24
|
+
|
|
25
|
+
### Notes
|
|
26
|
+
|
|
27
|
+
- Beta means the v1 wire format is frozen and the public API is stable; minor,
|
|
28
|
+
backward-compatible API additions remain possible before `1.0.0` stable, but
|
|
29
|
+
breaking changes are not planned.
|
|
30
|
+
- This is **not** a security release — no vulnerabilities were fixed between
|
|
31
|
+
`1.0.0-alpha.14` and `1.0.0-beta.1`. The library has still **not** had an
|
|
32
|
+
external cryptographic audit.
|
|
33
|
+
|
|
34
|
+
## 1.0.0-alpha.14 — 2026-06-10
|
|
35
|
+
|
|
36
|
+
> Pre-launch security hardening of the `0x03` PQ-hybrid share bundle. The
|
|
37
|
+
> share-bundle wire format changes; the on-disk file format and the `0x03`
|
|
38
|
+
> file decryption path are unchanged, so existing `cipher_version-3` files
|
|
39
|
+
> remain decryptable.
|
|
40
|
+
|
|
41
|
+
### Changed (BREAKING — share-bundle wire format only)
|
|
42
|
+
|
|
43
|
+
- **Share bundle (`0x03`) re-keyed and versioned (audit H2).** The share
|
|
44
|
+
transport key is now derived from the KEM/envelope secret under a dedicated
|
|
45
|
+
HKDF label `shieldfive/v1/share-transport` instead of reusing the
|
|
46
|
+
file-combiner label `shieldfive/v1/pq-hybrid/combine`, so a share transport
|
|
47
|
+
key can never equal a file's combined key. The combined key is now wrapped
|
|
48
|
+
with XChaCha20-Poly1305 whose AAD authenticates the **whole** bundle
|
|
49
|
+
(`magic || uint32_be(pq_len) || pq_payload || wrap_nonce`) rather than an
|
|
50
|
+
AAD-less secretbox that authenticated only the 32-byte key — PQ material
|
|
51
|
+
can no longer be substituted or stripped undetected. The bundle now carries
|
|
52
|
+
a `"SF5S"` + version-2 magic prefix so the hardened format is
|
|
53
|
+
distinguishable from (and not confusable with) the earlier unversioned one.
|
|
54
|
+
Share bundles produced by earlier alpha builds are rejected and must be
|
|
55
|
+
re-issued; no real shares exist pre-launch, so this is a clean break. See
|
|
56
|
+
`spec/format-v1.md` § "Share bundle".
|
|
57
|
+
|
|
58
|
+
### Security
|
|
59
|
+
|
|
60
|
+
- **Reserved-pad enforcement (`0x03`, audit M6).** The `0x03` suite-payload
|
|
61
|
+
parser now rejects a non-zero reserved pad in `classical_wrapped` (the 24
|
|
62
|
+
bytes after the 48-byte secretbox), closing a malleable unauthenticated
|
|
63
|
+
field. The default suite combine label and file path are unchanged.
|
|
64
|
+
|
|
65
|
+
### Documentation
|
|
66
|
+
|
|
67
|
+
- README/spec: corrected the "cross-file splice prevention (file_id AAD)"
|
|
68
|
+
table cell and prose — `file_id` is NOT in the chunk AAD; splice resistance
|
|
69
|
+
is structural via `file_id` as the HKDF salt in the chunk-key derivation
|
|
70
|
+
(audit INFO). Noted that the "no parallel implementation" scope is the
|
|
71
|
+
file-content cipher suites; the keyring/envelope layer uses WebCrypto
|
|
72
|
+
AES-GCM/HMAC directly.
|
|
73
|
+
- **Planned (not in this release): suite-id binding in `0x03` chunk derivation
|
|
74
|
+
(audit M5).** The `0x03` chunk-key / nonce-prefix derivations reuse the
|
|
75
|
+
`0x02` xchacha HKDF labels and do not bind the suite id. This is **not
|
|
76
|
+
exploitable** (the header MAC authenticates the suite byte) and is left
|
|
77
|
+
**unchanged** — production `cipher_version-3` files depend on it and would
|
|
78
|
+
become undecryptable if altered. A future suite version (a new suite id,
|
|
79
|
+
not `0x03`) will bind the suite id into the chunk derivation. Recorded in
|
|
80
|
+
`spec/format-v1.md` and `spec/key-derivation.md`.
|
|
81
|
+
|
|
82
|
+
### Tests
|
|
83
|
+
|
|
84
|
+
- Added share-bundle PQ-substitution/forgery, dedicated-transport-key,
|
|
85
|
+
non-zero reserved-pad rejection, and share-bundle version-marker tests
|
|
86
|
+
(182 → 188 passing).
|
|
87
|
+
|
|
88
|
+
## 1.0.0-alpha.13 — 2026-06-09
|
|
89
|
+
|
|
90
|
+
### Fixed
|
|
91
|
+
|
|
92
|
+
- `SHIELDFIVE_CRYPTO_VERSION` now reports the actual package version
|
|
93
|
+
(it was pinned at `1.0.0-alpha.11`). The constant is informational
|
|
94
|
+
only — it is never written into file output or any test vector.
|
|
95
|
+
- Corrected a backwards source comment in the `aes-gcm-v2` suite: the
|
|
96
|
+
cross-file nonce-prefix space *widens* from 2^32 to 2^64 (the comment
|
|
97
|
+
previously said "shrinks"). No behavior change — the README and
|
|
98
|
+
CHANGELOG already described it correctly as widening.
|
|
99
|
+
|
|
100
|
+
## 1.0.0-alpha.12 — 2026-06-09
|
|
101
|
+
|
|
102
|
+
### Documentation
|
|
103
|
+
|
|
104
|
+
- README: corrected the test-suite badge and prose from 171 to
|
|
105
|
+
**182** tests. The 11 additional tests are the offline single-file
|
|
106
|
+
decryptor example suite that landed after the badge was last
|
|
107
|
+
refreshed; `npm test` now reports 182/182.
|
|
108
|
+
- README: the cipher-suite table and the "four suites" wording now
|
|
109
|
+
match the package exports. Suite 0x04 `aes-gcm-v2` shipped in
|
|
110
|
+
alpha.11 but the README published with that release still listed
|
|
111
|
+
only three suites.
|
|
112
|
+
- No source changes in this release — documentation only.
|
|
113
|
+
|
|
114
|
+
## 1.0.0-alpha.11 — 2026-05-21
|
|
115
|
+
|
|
116
|
+
### Added
|
|
117
|
+
|
|
118
|
+
- Cipher suite 0x04 `aes-gcm-v2`: 8-byte HKDF-derived nonce prefix
|
|
119
|
+
+ 4-byte BE chunk counter. Widens the cross-file IV-collision
|
|
120
|
+
space from 2^32 to 2^64 while keeping the IV at 12 bytes. v1
|
|
121
|
+
(suite 0x01) stays decrypt-only on the umbrella export.
|
|
122
|
+
- Optional sender-attribution signatures (`src/identity/sign.ts`).
|
|
123
|
+
Detached Ed25519 (alg 0x01) over
|
|
124
|
+
`header_unauthenticated_bytes || concat(chunk_macs)`, appended as
|
|
125
|
+
a trailing signature block. Legacy files without the block keep
|
|
126
|
+
decrypting unchanged; the streaming API returns
|
|
127
|
+
`{signature: null}` in that case. Algorithm 0x02 is reserved for
|
|
128
|
+
ML-DSA-65.
|
|
129
|
+
|
|
130
|
+
### Notes
|
|
131
|
+
|
|
132
|
+
- Default cipher suite is still PQ-hybrid
|
|
133
|
+
(`SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1`). aes-gcm-v2 is opt-in
|
|
134
|
+
via the dedicated subpath import.
|
|
135
|
+
- Wire format updates documented in `spec/format-v1.md`.
|
|
136
|
+
|
|
137
|
+
## [1.0.0-alpha.9] — 2026-05
|
|
138
|
+
|
|
139
|
+
### Documentation
|
|
140
|
+
|
|
141
|
+
- docs(security): align SECURITY.md bug-bounty section with
|
|
142
|
+
shieldfive.com/security/bug-bounty. The previous wording said no
|
|
143
|
+
paid bounty existed for the open-source crypto library; the
|
|
144
|
+
operator-run program at shieldfive.com/security/bug-bounty has
|
|
145
|
+
always covered this library with €1000/€500/€250 tiers, so
|
|
146
|
+
SECURITY.md now points there instead of contradicting it. Audit
|
|
147
|
+
punch-list item P0-4.
|
|
148
|
+
|
|
149
|
+
### Changed
|
|
150
|
+
|
|
151
|
+
- chore(package): drop "audited-ready" from the npm description.
|
|
152
|
+
No external audit has been performed; the project's audit
|
|
153
|
+
posture is documented in SECURITY.md and continues to be
|
|
154
|
+
"self-reviewed, external audit deferred". Audit punch-list
|
|
155
|
+
item P1-D.
|
|
156
|
+
- chore(license): replace "Copyright 2026 ShieldFive" with
|
|
157
|
+
"Copyright 2026 Cho Garcia" in LICENSE (Apache-2.0 attribution
|
|
158
|
+
block). Audit punch-list item P1-C.
|
|
159
|
+
- chore(crypto): bump `SHIELDFIVE_CRYPTO_VERSION` constant in
|
|
160
|
+
`src/index.ts` to match the published package version
|
|
161
|
+
(previously stale at 1.0.0-alpha.6).
|
|
162
|
+
|
|
163
|
+
## [1.0.0-alpha.8] — 2026-05
|
|
164
|
+
|
|
165
|
+
### Fixed
|
|
166
|
+
|
|
167
|
+
- fix(pq-hybrid-v1): re-export `generateMlKemKeypair` and
|
|
168
|
+
`deriveMlKemKeypair` from the public subpath so the README quick-start
|
|
169
|
+
compiles.
|
|
170
|
+
|
|
8
171
|
## [1.0.0-alpha.7] — 2026-05
|
|
9
172
|
|
|
10
173
|
### Dependencies
|
|
@@ -167,4 +330,5 @@ The first public release.
|
|
|
167
330
|
[1.0.0-alpha.5]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.4...v1.0.0-alpha.5
|
|
168
331
|
[1.0.0-alpha.6]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.5...v1.0.0-alpha.6
|
|
169
332
|
[1.0.0-alpha.7]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.6...v1.0.0-alpha.7
|
|
333
|
+
[1.0.0-alpha.9]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.8...v1.0.0-alpha.9
|
|
170
334
|
[Unreleased]: https://github.com/shieldfive/crypto/compare/v1.0.0-alpha.7...HEAD
|
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright 2026
|
|
189
|
+
Copyright 2026 Cho Garcia
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -5,24 +5,29 @@
|
|
|
5
5
|
> [ShieldFive](https://shieldfive.com), released as a standalone library.
|
|
6
6
|
|
|
7
7
|
[](LICENSE)
|
|
8
|
-
[](tests/)
|
|
9
|
+
[](#status)
|
|
10
10
|
|
|
11
11
|
## Status & honest scope
|
|
12
12
|
|
|
13
|
-
This library is **
|
|
13
|
+
This library is **beta**. The wire format is frozen for the v1 release;
|
|
14
14
|
the public TypeScript API may make minor adjustments before v1.0.0 stable.
|
|
15
15
|
It has **not** undergone external cryptographic audit. Until it does,
|
|
16
16
|
treat this library as a serious work-in-progress rather than a finished
|
|
17
17
|
product.
|
|
18
18
|
|
|
19
19
|
The design choices documented in [`spec/`](spec/) are deliberate and
|
|
20
|
-
reviewable. The implementation is covered by
|
|
20
|
+
reviewable. The implementation is covered by 188 passing tests including
|
|
21
21
|
truncation, reordering, splice, and tampering detection across all four
|
|
22
22
|
suites. That is enough for internal dogfooding. It is **not** enough to
|
|
23
23
|
claim "most secure crypto library" — that claim requires external review
|
|
24
24
|
this library has not yet received.
|
|
25
25
|
|
|
26
|
+
When this library says it avoids a parallel cryptographic implementation,
|
|
27
|
+
that scope is the file-content cipher suites. The keyring/envelope layer
|
|
28
|
+
that wraps content keys is built directly on WebCrypto AES-GCM and HMAC
|
|
29
|
+
(via `crypto.subtle`), not on a second hand-rolled implementation.
|
|
30
|
+
|
|
26
31
|
## Design positions
|
|
27
32
|
|
|
28
33
|
This library makes specific design choices that differ from existing
|
|
@@ -37,7 +42,7 @@ spec section that documents the choice.
|
|
|
37
42
|
| Self-describing on-disk file format | ✅ | ✅ | ⚠️ | ⚠️ |
|
|
38
43
|
| Cipher-suite agile (one byte selects) | ✅ | ⚠️ | ❌ | ❌ |
|
|
39
44
|
| Truncation detection bound to AEAD | ✅ | ✅ | ❌ | ❌ |
|
|
40
|
-
| Cross-file splice prevention (file_id
|
|
45
|
+
| Cross-file splice prevention (file_id via HKDF salt) | ✅ | ✅ | ❌ | ❌ |
|
|
41
46
|
| Streaming AEAD with random-access chunks | ✅ | ⚠️ | ✅ | ✅ |
|
|
42
47
|
| WebCrypto-only path (no WASM required) | ✅ | ❌ | ❌ | ❌ |
|
|
43
48
|
| Apache 2.0 (patent grant) | ✅ | ⚠️ (LGPL) | ⚠️ | ⚠️ |
|
|
@@ -151,9 +156,11 @@ ML-KEM-1024 secret for Suite 0x03 files deterministically from
|
|
|
151
156
|
the root key (per `spec/key-derivation.md`), and feeds each blob
|
|
152
157
|
into `autoDecryptBlob` here.
|
|
153
158
|
|
|
154
|
-
The recipe
|
|
155
|
-
|
|
156
|
-
|
|
159
|
+
The recipe lives at [shieldfive.com/export](https://shieldfive.com/export)
|
|
160
|
+
and the script ships in this repository as
|
|
161
|
+
[`examples/decrypt-one.mjs`](examples/decrypt-one.mjs), kept in
|
|
162
|
+
lock-step with the API surface; this library is the decryption
|
|
163
|
+
primitive the script depends on. If
|
|
157
164
|
you want to reproduce the path from first principles (with no
|
|
158
165
|
ShieldFive code in the loop), `spec/format-v1.md` and
|
|
159
166
|
`spec/key-derivation.md` together describe everything needed.
|
|
@@ -165,7 +172,7 @@ The complete v1 wire format is documented in
|
|
|
165
172
|
|
|
166
173
|
```
|
|
167
174
|
header := magic(5) = "SF5\x01\x00"
|
|
168
|
-
|| suite(1) = 0x01 | 0x02 | 0x03
|
|
175
|
+
|| suite(1) = 0x01 | 0x02 | 0x03 | 0x04
|
|
169
176
|
|| flags(1) = 0x00 (reserved)
|
|
170
177
|
|| file_id(16) = random per-file
|
|
171
178
|
|| chunk_size(4) = uint32 BE
|
|
@@ -179,9 +186,11 @@ chunk_i := length_prefix(4) || AEAD-ciphertext-with-tag
|
|
|
179
186
|
```
|
|
180
187
|
|
|
181
188
|
Every chunk's AEAD authenticator binds the chunk index, total chunk count,
|
|
182
|
-
final-chunk flag
|
|
183
|
-
|
|
184
|
-
|
|
189
|
+
and final-chunk flag. The `file_id` is NOT part of the AAD; cross-file
|
|
190
|
+
splice resistance is structural, coming from the suite-specific chunk-key
|
|
191
|
+
and nonce-prefix derivations that mix `file_id` in as the HKDF salt/IKM.
|
|
192
|
+
Together these make truncation, reordering, and cross-file splicing
|
|
193
|
+
detectable by the AEAD rather than by application-layer hashes.
|
|
185
194
|
|
|
186
195
|
## Cipher suites
|
|
187
196
|
|
|
@@ -190,6 +199,13 @@ application-layer hashes.
|
|
|
190
199
|
| 0x01 | `aes-256-gcm-v1` | | WebCrypto-only, hardware-accelerated |
|
|
191
200
|
| 0x02 | `xchacha20-poly1305-v1` | | libsodium, 192-bit nonces |
|
|
192
201
|
| 0x03 | `pq-hybrid-xchacha-mlkem1024-v1` | ✅ | XChaCha20-Poly1305 + ML-KEM-1024 hybrid |
|
|
202
|
+
| 0x04 | `aes-256-gcm-v2` | | WebCrypto-only, 8-byte nonce prefix |
|
|
203
|
+
|
|
204
|
+
Suite `0x04` is the current AES-GCM write path: identical to `0x01` except
|
|
205
|
+
the 12-byte GCM IV uses an 8-byte file-derived nonce prefix and a 4-byte
|
|
206
|
+
counter (rather than 4 + 8), widening the cross-file IV-collision margin.
|
|
207
|
+
`0x01` remains defined for reading files written before `0x04` existed.
|
|
208
|
+
See [`spec/format-v1.md`](spec/format-v1.md) for the per-suite derivations.
|
|
193
209
|
|
|
194
210
|
ML-KEM-1024 is FIPS 203 (NIST PQC standard, security level 5). Files
|
|
195
211
|
encrypted with suite 0x03 remain confidential against an adversary who
|
|
@@ -235,9 +251,9 @@ Requires Node 20+.
|
|
|
235
251
|
|
|
236
252
|
## Status
|
|
237
253
|
|
|
238
|
-
**
|
|
254
|
+
**Beta.** The wire format is frozen for the v1 release, but the public
|
|
239
255
|
TypeScript API may make small adjustments before 1.0.0 stable. Test
|
|
240
|
-
coverage is comprehensive (
|
|
256
|
+
coverage is comprehensive (188 tests, all four suites, all architectural
|
|
241
257
|
guarantees verified). A formal third-party security audit is planned for
|
|
242
258
|
the 1.0.0 stable milestone — until that audit lands, treat this library
|
|
243
259
|
as a serious work-in-progress rather than a finished product.
|
|
@@ -250,7 +266,8 @@ crypto library; we chose it over MIT for that reason.
|
|
|
250
266
|
## Reporting vulnerabilities
|
|
251
267
|
|
|
252
268
|
See [`SECURITY.md`](SECURITY.md). Coordinate with us at
|
|
253
|
-
`security@shieldfive.com` (
|
|
269
|
+
`security@shieldfive.com` (see SECURITY.md for the encrypted-channel
|
|
270
|
+
process). 72-hour acknowledgement,
|
|
254
271
|
30-day target patch window for high-severity issues. Researchers acting
|
|
255
272
|
in good faith are protected under the safe-harbor clause.
|
|
256
273
|
|
package/SECURITY.md
CHANGED
|
@@ -77,15 +77,19 @@ policy, we will make this authorization clear.
|
|
|
77
77
|
|
|
78
78
|
## Bug bounty
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
crypto library.
|
|
82
|
-
ShieldFive product itself; see https://shieldfive.com/security for details.
|
|
80
|
+
ShieldFive operates a paid bug bounty program covering this
|
|
81
|
+
open-source crypto library. Reward tiers:
|
|
83
82
|
|
|
84
|
-
|
|
83
|
+
- Critical: up to €1000
|
|
84
|
+
- High: up to €500
|
|
85
|
+
- Medium: up to €250
|
|
85
86
|
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
|
|
87
|
+
Lower-impact findings receive public credit (CVE, release notes,
|
|
88
|
+
dedicated thank-you page) and product credits.
|
|
89
|
+
|
|
90
|
+
For current scope, rules of engagement, submission instructions,
|
|
91
|
+
and the safe-harbor statement, see
|
|
92
|
+
https://shieldfive.com/security/bug-bounty.
|
|
89
93
|
|
|
90
94
|
## Out of scope
|
|
91
95
|
|
|
@@ -123,4 +127,4 @@ with their consent.)
|
|
|
123
127
|
|
|
124
128
|
---
|
|
125
129
|
|
|
126
|
-
Last updated: v1.0.0-
|
|
130
|
+
Last updated: v1.0.0-beta.1
|
package/dist/identity/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* want stronger identity (e.g. SAS verification, gossiped signatures),
|
|
18
18
|
* they wrap this module rather than modify it.
|
|
19
19
|
*/
|
|
20
|
+
export { SIGNATURE_ALGO_ED25519, SIGNATURE_ALGO_ML_DSA_65, ED25519_PUBLIC_KEY_LENGTH, ED25519_SECRET_KEY_LENGTH, ED25519_SIGNATURE_LENGTH, SignatureError, buildSignatureBlock, deriveEd25519PublicKey, parseSignatureBlock, signHeaderAndMacs, verifyHeaderAndMacs, } from './sign.js';
|
|
21
|
+
export type { SignatureBlock } from './sign.js';
|
|
20
22
|
export interface PublicIdentityBundle {
|
|
21
23
|
/** ML-KEM-1024 public key (1568 bytes) */
|
|
22
24
|
mlKemPublicKey: Uint8Array;
|
|
@@ -99,6 +101,20 @@ export interface ShareFileInput {
|
|
|
99
101
|
* key. To make sharing work, we use a different construction: we wrap
|
|
100
102
|
* the existing combined key under (recipient PQ KEM ⊕ recipient
|
|
101
103
|
* envelope) and emit only the wrapped form.
|
|
104
|
+
*
|
|
105
|
+
* Two properties this construction must hold (audit H2/M6):
|
|
106
|
+
* 1. The wrapping key is NOT the raw KEM/envelope combined key (which
|
|
107
|
+
* reuses the file-combiner HKDF label). We run it through one more
|
|
108
|
+
* HKDF under the dedicated `SHARE_TRANSPORT` label so a share key is
|
|
109
|
+
* never equal to a file's combined key.
|
|
110
|
+
* 2. The wrap authenticates the WHOLE bundle, not just the 32-byte
|
|
111
|
+
* combined key: the XChaCha20-Poly1305 AAD covers the version marker,
|
|
112
|
+
* the length prefix, the entire pqPayload (including its reserved pad)
|
|
113
|
+
* and the nonce, so PQ material cannot be substituted or stripped
|
|
114
|
+
* without breaking the tag.
|
|
115
|
+
*
|
|
116
|
+
* The bundle is prefixed with `SHARE_BUNDLE_MAGIC` ("SF5S" + version) so the
|
|
117
|
+
* hardened format is distinguishable from the earlier unversioned one.
|
|
102
118
|
*/
|
|
103
119
|
export declare function buildShareForRecipient(input: ShareFileInput): Promise<{
|
|
104
120
|
shareBundle: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAWH,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAyB/C,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,cAAc,EAAE,UAAU,CAAA;IAC1B,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,UAAU,CAAA;IACrB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,UAAU,CAkC7E;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,oBAAoB,CAgD5E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAEnE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAElE;AAMD,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,UAAU,CAAA;IACrB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,UAAU,CAAA;IACzB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,oBAAoB,CAAA;IAClC,+DAA+D;IAC/D,iBAAiB,EAAE,UAAU,CAAA;IAC7B,yDAAyD;IACzD,cAAc,EAAE,UAAU,CAAA;CAC3B;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,eAAe,CAAC,CAuB1B;AAMD;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IACvD,WAAW,EAAE,UAAU,CAAA;IACvB,kCAAkC;IAClC,MAAM,EAAE,UAAU,CAAA;IAClB,0EAA0E;IAC1E,SAAS,EAAE,oBAAoB,CAAA;IAC/B,kDAAkD;IAClD,oBAAoB,EAAE,UAAU,CAAA;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC;IAAE,WAAW,EAAE,UAAU,CAAA;CAAE,CAAC,CAwDtC;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,WAAW,EAAE,UAAU,CAAA;IACvB,MAAM,EAAE,UAAU,CAAA;IAClB,kBAAkB,EAAE,UAAU,CAAA;IAC9B,oBAAoB,EAAE,UAAU,CAAA;CACjC,GAAG,OAAO,CAAC,UAAU,CAAC,CAwEtB"}
|
package/dist/identity/index.js
CHANGED
|
@@ -17,12 +17,21 @@
|
|
|
17
17
|
* want stronger identity (e.g. SAS verification, gossiped signatures),
|
|
18
18
|
* they wrap this module rather than modify it.
|
|
19
19
|
*/
|
|
20
|
-
import { ML_KEM_1024_PUBLIC_KEY_BYTES, ML_KEM_1024_SECRET_KEY_BYTES, deriveMlKemKeypair, generateMlKemKeypair, encapsulateForRecipient, decapsulateFromHeader, parsePqHybridV1SuitePayload,
|
|
20
|
+
import { ML_KEM_1024_PUBLIC_KEY_BYTES, ML_KEM_1024_SECRET_KEY_BYTES, deriveMlKemKeypair, generateMlKemKeypair, encapsulateForRecipient, decapsulateFromHeader, parsePqHybridV1SuitePayload, } from '../suites/pq-hybrid-v1/index.js';
|
|
21
|
+
export { SIGNATURE_ALGO_ED25519, SIGNATURE_ALGO_ML_DSA_65, ED25519_PUBLIC_KEY_LENGTH, ED25519_SECRET_KEY_LENGTH, ED25519_SIGNATURE_LENGTH, SignatureError, buildSignatureBlock, deriveEd25519PublicKey, parseSignatureBlock, signHeaderAndMacs, verifyHeaderAndMacs, } from './sign.js';
|
|
21
22
|
import { bytesToBase64, base64ToBytes, concatBytes, uint16BE, uint32BE, readUint16BE, readUint32BE, } from '../internal/encoding.js';
|
|
22
23
|
import { randomBytes } from '../internal/runtime.js';
|
|
23
24
|
import { getSodium } from '../internal/sodium.js';
|
|
25
|
+
import { hkdfSha256 } from '../internal/hkdf.js';
|
|
26
|
+
import { HKDF_INFO } from '../internal/types.js';
|
|
24
27
|
const IDENTITY_BUNDLE_MAGIC = new Uint8Array([0x53, 0x46, 0x35, 0x49, 0x01]); // "SF5I" + version
|
|
25
|
-
|
|
28
|
+
// Share-bundle magic: "SF5S" + version byte. Version 0x02 marks the hardened
|
|
29
|
+
// share construction (audit H2/M6): a domain-separated transport key and an
|
|
30
|
+
// AEAD wrap whose AAD authenticates the whole bundle. Earlier alpha builds
|
|
31
|
+
// emitted an unversioned bundle (an AAD-less secretbox under the raw transport
|
|
32
|
+
// secret); those are NOT readable here and are rejected by the magic check.
|
|
33
|
+
// No real shares exist pre-launch, so this is a deliberate clean break.
|
|
34
|
+
const SHARE_BUNDLE_MAGIC = new Uint8Array([0x53, 0x46, 0x35, 0x53, 0x02]); // "SF5S" + version 2
|
|
26
35
|
/**
|
|
27
36
|
* Wire format for an identity bundle:
|
|
28
37
|
*
|
|
@@ -140,30 +149,60 @@ export async function createIdentity(options) {
|
|
|
140
149
|
* key. To make sharing work, we use a different construction: we wrap
|
|
141
150
|
* the existing combined key under (recipient PQ KEM ⊕ recipient
|
|
142
151
|
* envelope) and emit only the wrapped form.
|
|
152
|
+
*
|
|
153
|
+
* Two properties this construction must hold (audit H2/M6):
|
|
154
|
+
* 1. The wrapping key is NOT the raw KEM/envelope combined key (which
|
|
155
|
+
* reuses the file-combiner HKDF label). We run it through one more
|
|
156
|
+
* HKDF under the dedicated `SHARE_TRANSPORT` label so a share key is
|
|
157
|
+
* never equal to a file's combined key.
|
|
158
|
+
* 2. The wrap authenticates the WHOLE bundle, not just the 32-byte
|
|
159
|
+
* combined key: the XChaCha20-Poly1305 AAD covers the version marker,
|
|
160
|
+
* the length prefix, the entire pqPayload (including its reserved pad)
|
|
161
|
+
* and the nonce, so PQ material cannot be substituted or stripped
|
|
162
|
+
* without breaking the tag.
|
|
163
|
+
*
|
|
164
|
+
* The bundle is prefixed with `SHARE_BUNDLE_MAGIC` ("SF5S" + version) so the
|
|
165
|
+
* hardened format is distinguishable from the earlier unversioned one.
|
|
143
166
|
*/
|
|
144
167
|
export async function buildShareForRecipient(input) {
|
|
145
168
|
const sodium = await getSodium();
|
|
146
|
-
// Generate a fresh transport
|
|
169
|
+
// Generate a fresh transport secret for this share.
|
|
147
170
|
// ML-KEM encapsulation gives us the PQ-half of the transport secret.
|
|
148
|
-
const { suitePayload: pqPayload, combinedKey:
|
|
171
|
+
const { suitePayload: pqPayload, combinedKey: transportSecret } = await encapsulateForRecipient({
|
|
149
172
|
recipientPublicKey: input.recipient.mlKemPublicKey,
|
|
150
173
|
envelopeKey: input.recipientEnvelopeKey,
|
|
151
174
|
fileId: input.fileId,
|
|
152
175
|
});
|
|
153
|
-
|
|
154
|
-
// XSalsa20-Poly1305 secretbox.
|
|
155
|
-
if (transportKey.length !== 32) {
|
|
176
|
+
if (transportSecret.length !== 32) {
|
|
156
177
|
throw new Error('buildShareForRecipient: transport key length wrong');
|
|
157
178
|
}
|
|
179
|
+
// (1) Domain-separate the share transport key from the file-combiner output.
|
|
180
|
+
const shareTransportKey = await hkdfSha256({
|
|
181
|
+
ikm: transportSecret,
|
|
182
|
+
salt: input.fileId,
|
|
183
|
+
info: HKDF_INFO.SHARE_TRANSPORT,
|
|
184
|
+
length: 32,
|
|
185
|
+
});
|
|
186
|
+
// (2) Wrap the original combined key with an AEAD whose AAD authenticates
|
|
187
|
+
// the whole bundle prefix (magic || length || pqPayload || nonce). Binding
|
|
188
|
+
// the magic means the version marker cannot be stripped or downgraded
|
|
189
|
+
// without breaking the tag.
|
|
158
190
|
const wrapNonce = randomBytes(24);
|
|
159
|
-
const
|
|
191
|
+
const aad = concatBytes([
|
|
192
|
+
SHARE_BUNDLE_MAGIC,
|
|
193
|
+
uint32BE(pqPayload.length),
|
|
194
|
+
pqPayload,
|
|
195
|
+
wrapNonce,
|
|
196
|
+
]);
|
|
197
|
+
const wrappedCombinedKey = sodium.crypto_aead_xchacha20poly1305_ietf_encrypt(input.combinedKey, aad, null, wrapNonce, shareTransportKey);
|
|
160
198
|
if (wrappedCombinedKey.length !== 32 + 16) {
|
|
161
|
-
throw new Error('buildShareForRecipient:
|
|
199
|
+
throw new Error('buildShareForRecipient: AEAD produced unexpected length');
|
|
162
200
|
}
|
|
163
201
|
// Share record format:
|
|
164
|
-
// [4 bytes BE length of pqPayload][pqPayload][24-byte wrap nonce][48-byte wrapped combined key]
|
|
202
|
+
// [5-byte magic][4 bytes BE length of pqPayload][pqPayload][24-byte wrap nonce][48-byte wrapped combined key]
|
|
165
203
|
return {
|
|
166
204
|
shareBundle: concatBytes([
|
|
205
|
+
SHARE_BUNDLE_MAGIC,
|
|
167
206
|
uint32BE(pqPayload.length),
|
|
168
207
|
pqPayload,
|
|
169
208
|
wrapNonce,
|
|
@@ -178,10 +217,18 @@ export async function buildShareForRecipient(input) {
|
|
|
178
217
|
*/
|
|
179
218
|
export async function openShareAsRecipient(input) {
|
|
180
219
|
const sodium = await getSodium();
|
|
181
|
-
if (input.shareBundle.length < 4) {
|
|
220
|
+
if (input.shareBundle.length < SHARE_BUNDLE_MAGIC.length + 4) {
|
|
182
221
|
throw new Error('openShareAsRecipient: share too short');
|
|
183
222
|
}
|
|
184
|
-
|
|
223
|
+
// Reject anything that isn't a current ("SF5S" + version) share bundle.
|
|
224
|
+
// Earlier-alpha unversioned bundles fail here rather than producing an
|
|
225
|
+
// opaque authentication error later.
|
|
226
|
+
for (let i = 0; i < SHARE_BUNDLE_MAGIC.length; i += 1) {
|
|
227
|
+
if (input.shareBundle[i] !== SHARE_BUNDLE_MAGIC[i]) {
|
|
228
|
+
throw new Error('openShareAsRecipient: bad magic / unsupported share bundle version');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
let offset = SHARE_BUNDLE_MAGIC.length;
|
|
185
232
|
const pqLen = readUint32BE(input.shareBundle, offset);
|
|
186
233
|
offset += 4;
|
|
187
234
|
if (offset + pqLen + 24 + 48 !== input.shareBundle.length) {
|
|
@@ -192,22 +239,37 @@ export async function openShareAsRecipient(input) {
|
|
|
192
239
|
const wrapNonce = input.shareBundle.slice(offset, offset + 24);
|
|
193
240
|
offset += 24;
|
|
194
241
|
const wrappedCombinedKey = input.shareBundle.slice(offset, offset + 48);
|
|
195
|
-
//
|
|
242
|
+
// Structurally validate the suite payload. This rejects a non-zero reserved
|
|
243
|
+
// pad in classical_wrapped (M6) before any decapsulation work.
|
|
196
244
|
parsePqHybridV1SuitePayload(pqPayload);
|
|
197
|
-
|
|
198
|
-
const checkBytes = buildPqHybridV1SuitePayload(parsePqHybridV1SuitePayload(pqPayload));
|
|
199
|
-
if (checkBytes.length !== pqPayload.length) {
|
|
200
|
-
throw new Error('openShareAsRecipient: pq payload self-check failed');
|
|
201
|
-
}
|
|
202
|
-
const { combinedKey: transportKey } = await decapsulateFromHeader({
|
|
245
|
+
const { combinedKey: transportSecret } = await decapsulateFromHeader({
|
|
203
246
|
suitePayload: pqPayload,
|
|
204
247
|
recipientSecretKey: input.recipientSecretKey,
|
|
205
248
|
envelopeKey: input.recipientEnvelopeKey,
|
|
206
249
|
fileId: input.fileId,
|
|
207
250
|
});
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
251
|
+
const shareTransportKey = await hkdfSha256({
|
|
252
|
+
ikm: transportSecret,
|
|
253
|
+
salt: input.fileId,
|
|
254
|
+
info: HKDF_INFO.SHARE_TRANSPORT,
|
|
255
|
+
length: 32,
|
|
256
|
+
});
|
|
257
|
+
// The AAD must reproduce exactly what the builder authenticated: it binds
|
|
258
|
+
// the version marker, the length prefix, the whole pqPayload (incl. reserved
|
|
259
|
+
// pad) and the nonce, so any substitution/stripping of PQ material breaks
|
|
260
|
+
// the tag.
|
|
261
|
+
const aad = concatBytes([
|
|
262
|
+
SHARE_BUNDLE_MAGIC,
|
|
263
|
+
uint32BE(pqPayload.length),
|
|
264
|
+
pqPayload,
|
|
265
|
+
wrapNonce,
|
|
266
|
+
]);
|
|
267
|
+
let unwrapped;
|
|
268
|
+
try {
|
|
269
|
+
unwrapped = sodium.crypto_aead_xchacha20poly1305_ietf_decrypt(null, wrappedCombinedKey, aad, wrapNonce, shareTransportKey);
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
throw new Error('openShareAsRecipient: share authentication failed — wrong recipient or tampered share');
|
|
211
273
|
}
|
|
212
274
|
if (unwrapped.length !== 32) {
|
|
213
275
|
throw new Error('openShareAsRecipient: bad combined key length');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,iCAAiC,C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