pqbox 1.0.0 → 1.1.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/README.md +97 -21
- package/dist/generated/pqbox_wasm.d.ts +17 -0
- package/dist/generated/pqbox_wasm.js +56 -0
- package/dist/generated/wasm-bytes.js +1 -1
- package/dist/index.d.ts +36 -0
- package/dist/index.js +30 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,14 +5,19 @@ hybrid key encapsulation, sealed boxes, composite signatures, authenticated encr
|
|
|
5
5
|
derivation, hashing and password hashing.
|
|
6
6
|
|
|
7
7
|
pqbox implements no cryptographic primitive itself. Every algorithm comes from a pinned crate,
|
|
8
|
-
mostly from [RustCrypto](https://github.com/RustCrypto), plus
|
|
9
|
-
|
|
8
|
+
mostly from [RustCrypto](https://github.com/RustCrypto), plus Cryspen's formally verified
|
|
9
|
+
[libcrux](https://github.com/cryspen/libcrux) for ML-KEM-1024 and `classic-mceliece-rust` for
|
|
10
|
+
Classic McEliece. pqbox only adds the hybrid combiners, the composite signature framing and a versioned
|
|
10
11
|
wire format.
|
|
11
12
|
|
|
12
13
|
- **Rust:** crate [`pqbox`](crates/pqbox-core) (sans-IO, `#![forbid(unsafe_code)]`) and the CLI [`pqbox-cli`](crates/pqbox-cli).
|
|
13
14
|
- **Python:** package `pqbox` on PyPI, built with PyO3 (abi3, Python ≥ 3.10).
|
|
14
15
|
- **JavaScript / TypeScript:** package `pqbox` on npm, built with WebAssembly (Node ≥ 20 and browsers, ESM, synchronous API).
|
|
15
16
|
|
|
17
|
+
Website: <https://maxgfr.github.io/pqbox/>. Applications that use pqbox follow one integration
|
|
18
|
+
guide, [`docs/INTEGRATION.md`](docs/INTEGRATION.md): which function for which job, labels and
|
|
19
|
+
format versions, key storage, and an audit checklist.
|
|
20
|
+
|
|
16
21
|
## Suites
|
|
17
22
|
|
|
18
23
|
Every key, ciphertext, sealed box and signature records its suite in its header, so objects from
|
|
@@ -21,7 +26,7 @@ different suites can never be mixed.
|
|
|
21
26
|
| Id | Name | KEM | Signature | Use it for |
|
|
22
27
|
|---|---|---|---|---|
|
|
23
28
|
| `0x02` | **`pqbox-max`** (default) | ML-KEM-1024 + ECDH P-384 | ML-DSA-87 + ECDSA P-384 (SHA-384) | Everything, unless you have a reason below |
|
|
24
|
-
| `0x03` | `pqbox-paranoid` (experimental) | ML-KEM-1024 + Classic McEliece 8192128 + ECDH P-384 | ML-DSA-87 + SLH-DSA-SHAKE-256s + ECDSA P-384 |
|
|
29
|
+
| `0x03` | `pqbox-paranoid` (experimental, not recommended for new keys) | ML-KEM-1024 + Classic McEliece 8192128 + ECDH P-384 | ML-DSA-87 + SLH-DSA-SHAKE-256s + ECDSA P-384 | Reading and using existing paranoid keys and archives. Not for new keys: see [Classic McEliece](#classic-mceliece-not-recommended-for-new-keys) |
|
|
25
30
|
| `0x01` | `xwing` (compat only) | X-Wing (ML-KEM-768 + X25519) | ML-DSA-65 + Ed25519 | Interop with X-Wing tooling such as hush. Never the default |
|
|
26
31
|
|
|
27
32
|
**Suite policy.** The functions that read keys, ciphertexts, signatures and sealed boxes accept
|
|
@@ -40,11 +45,28 @@ Key generation takes the suite by name and needs no policy.
|
|
|
40
45
|
**The `paranoid` feature.** `pqbox-paranoid` is **experimental**: its SLH-DSA half comes from
|
|
41
46
|
`slh-dsa` 0.2.0-rc.5, a release candidate. The Rust crates compile it only with the `paranoid`
|
|
42
47
|
cargo feature, off by default (`cargo add pqbox --features paranoid`,
|
|
43
|
-
`cargo install pqbox-cli --features paranoid`); without it, paranoid objects are refused with
|
|
48
|
+
`cargo install --locked pqbox-cli --features paranoid`); without it, paranoid objects are refused with
|
|
44
49
|
`SuiteNotEnabled`. The Python wheels and the npm package include it: it adds about 66 KB to a
|
|
45
50
|
wheel (542 KB to 608 KB, macOS arm64) and about 67 KB to the WebAssembly module (801 KB to 868 KB
|
|
46
51
|
before wasm-bindgen).
|
|
47
52
|
|
|
53
|
+
#### Classic McEliece: not recommended for new keys
|
|
54
|
+
|
|
55
|
+
BSI's [Notes on recent developments concerning Classic McEliece](https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Crypto/Notes_Classic_McEliece.html)
|
|
56
|
+
(1 October 2026) say Classic McEliece should no longer be used in new developments. Structural
|
|
57
|
+
attacks have improved fast in 2026, among them a quasipolynomial distinguisher with a heuristic key
|
|
58
|
+
recovery ([ePrint 2026/1630](https://eprint.iacr.org/2026/1630)) and an improved heuristic key
|
|
59
|
+
recovery ([ePrint 2026/1984](https://eprint.iacr.org/2026/1984)). None is practical against the
|
|
60
|
+
recommended parameter sets, and BSI expects further progress. For pqbox:
|
|
61
|
+
|
|
62
|
+
- `pqbox-paranoid` objects stay readable and usable, and the format does not change.
|
|
63
|
+
- Do not create new `pqbox-paranoid` KEM keys: use `pqbox-max`.
|
|
64
|
+
- The paranoid KEM is still a hybrid: its shared secret holds as long as ML-KEM-1024 or P-384
|
|
65
|
+
holds. What Classic McEliece no longer reliably adds is protection against a break of lattices.
|
|
66
|
+
The paranoid signatures (SLH-DSA) are not affected.
|
|
67
|
+
- Replacing Classic McEliece with HQC or FrodoKEM, which BSI recommends instead, would change the
|
|
68
|
+
bytes, so it would need a new suite id. The `0x03` suite stays as it is.
|
|
69
|
+
|
|
48
70
|
**Hybrid rationale.** A hybrid stays secure as long as one of its components holds. KEM shared
|
|
49
71
|
secrets go through a combiner, so recovering the session key means breaking every component.
|
|
50
72
|
A composite signature verifies only if every component signature verifies.
|
|
@@ -56,8 +78,10 @@ A composite signature verifies only if every component signature verifies.
|
|
|
56
78
|
keeps as an interim choice. That advisory lists elliptic curves other than P-384/P-521, and
|
|
57
79
|
EdDSA, among the algorithms to inventory and replace. Some cryptographers read it as a sign that
|
|
58
80
|
256-bit curves may be weaker than believed. The advisory itself does not say they are broken.
|
|
59
|
-
- `pqbox-paranoid` also
|
|
60
|
-
SLH-DSA (hash-based) do not rely on lattices.
|
|
81
|
+
- `pqbox-paranoid` was meant to also survive a break of lattice cryptography: Classic McEliece
|
|
82
|
+
(code-based) and SLH-DSA (hash-based) do not rely on lattices. Recent attacks on Classic McEliece
|
|
83
|
+
weaken that for its KEM (see [above](#classic-mceliece-not-recommended-for-new-keys)); its
|
|
84
|
+
signatures are not affected.
|
|
61
85
|
- `xwing` exists only for compatibility. Its classical half is a 256-bit curve, so treat its
|
|
62
86
|
security as resting entirely on ML-KEM-768 and ML-DSA-65.
|
|
63
87
|
|
|
@@ -87,18 +111,19 @@ order (signing normalizes it; the malleable `n - s` twin is refused).
|
|
|
87
111
|
|
|
88
112
|
| Purpose | Algorithm | Crate |
|
|
89
113
|
|---|---|---|
|
|
90
|
-
| KEM | ML-KEM-
|
|
114
|
+
| KEM | ML-KEM-1024 (FIPS 203), in `pqbox-max` and `pqbox-paranoid` | `libcrux-ml-kem` 0.0.12 (portable build, SIMD code not compiled) |
|
|
115
|
+
| KEM | ML-KEM-768 (FIPS 203), inside X-Wing | `ml-kem` 0.3.4 |
|
|
91
116
|
| KEM | X-Wing (draft-connolly-cfrg-xwing-kem) | `x-wing` 0.1.1 |
|
|
92
117
|
| KEM | Classic McEliece 8192128 | `classic-mceliece-rust` 3.1.0 |
|
|
93
|
-
| KEM (classical half) | ECDH P-384, X25519 | `p384` 0.14.0, `x25519-dalek` 3.0.0 |
|
|
118
|
+
| KEM (classical half) | ECDH P-384, X25519 | `p384` 0.14.0, `x25519-dalek` 3.0.0 (both with fiat-crypto field arithmetic) |
|
|
94
119
|
| Signature | ML-DSA-65 / ML-DSA-87 (FIPS 204) | `ml-dsa` 0.1.2 |
|
|
95
120
|
| Signature | SLH-DSA-SHAKE-256s (FIPS 205), `paranoid` feature only, experimental | `slh-dsa` 0.2.0-rc.5 (release candidate) |
|
|
96
|
-
| Signature (classical half) | ECDSA P-384 with SHA-384, Ed25519 | `p384` 0.14.0, `ed25519-dalek` 3.0.0 |
|
|
121
|
+
| Signature (classical half) | ECDSA P-384 with SHA-384, Ed25519 | `p384` 0.14.0, `ed25519-dalek` 3.0.0 (both with fiat-crypto field arithmetic) |
|
|
97
122
|
| Sealed box | suite KEM + HKDF-SHA-256 + XChaCha20-Poly1305 | |
|
|
98
123
|
| AEAD | XChaCha20-Poly1305 (default), AES-256-GCM | `chacha20poly1305` 0.11.0, `aes-gcm` 0.11.1 |
|
|
99
124
|
| KDF / MAC | HKDF-SHA-256, HMAC-SHA-256 | `hkdf` 0.13.0, `hmac` 0.13.0 |
|
|
100
125
|
| Hash | SHA-256, SHA3-256, BLAKE3 | `sha2` 0.11.1, `sha3` 0.12.0, `blake3` 1.8.9 |
|
|
101
|
-
| Password | Argon2id (64 MiB, t=3, p=1 by default; verification capped at 256 MiB, t=10, p=8)
|
|
126
|
+
| Password | Argon2id (64 MiB, t=3, p=1 by default; verification and key derivation capped at 256 MiB, t=10, p=8): PHC strings, and keys derived from a password and a stored salt | `argon2` 0.6.0 |
|
|
102
127
|
|
|
103
128
|
Symmetric keys are always 256-bit.
|
|
104
129
|
|
|
@@ -117,7 +142,7 @@ show orders of magnitude, not guarantees.
|
|
|
117
142
|
| Suite | KEM keygen | Encapsulate | Decapsulate | Seal 1 KiB | Open 1 KiB | Sign keygen | Sign | Verify |
|
|
118
143
|
|---|---:|---:|---:|---:|---:|---:|---:|---:|
|
|
119
144
|
| `xwing` | 53 µs | 50 µs | 80 µs | 54 µs | 83 µs | 264 µs | 378 µs | 61 µs |
|
|
120
|
-
| `pqbox-max` |
|
|
145
|
+
| `pqbox-max` | 311 µs | 607 µs | 642 µs | 595 µs | 601 µs | 730 µs | 775 µs | 446 µs |
|
|
121
146
|
| `pqbox-paranoid` | 966.99 ms | 1.13 ms | 62.03 ms | 2.37 ms | 62.98 ms | 37.48 ms | 435.01 ms | 1.06 ms |
|
|
122
147
|
|
|
123
148
|
Paranoid KEM key generation varies a lot from run to run (0.74 s to 1.20 s here), because Classic
|
|
@@ -128,22 +153,43 @@ XChaCha20-Poly1305 62 µs, AES-256-GCM 14 µs, SHA-256 20 µs, SHA3-256 59 µs,
|
|
|
128
153
|
## Install
|
|
129
154
|
|
|
130
155
|
```sh
|
|
131
|
-
cargo add pqbox
|
|
132
|
-
cargo install pqbox-cli
|
|
133
|
-
pip install pqbox
|
|
134
|
-
npm install pqbox
|
|
156
|
+
cargo add pqbox # Rust library (add `--features paranoid` for pqbox-paranoid)
|
|
157
|
+
cargo install --locked pqbox-cli # `pqbox` command (same feature)
|
|
158
|
+
pip install pqbox # Python ≥ 3.10
|
|
159
|
+
npm install pqbox # Node ≥ 20, browsers
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Build options.** The CLI binaries, the wheels and the npm package are built with the
|
|
163
|
+
repository's [`.cargo/config.toml`](.cargo/config.toml): P-384 and Curve25519 use the formally
|
|
164
|
+
verified field arithmetic synthesized by [fiat-crypto](https://github.com/mit-plv/fiat-crypto)
|
|
165
|
+
(the same bytes as the default backends, checked by the frozen KATs), and only the portable code
|
|
166
|
+
of libcrux is compiled (see [docs/BACKENDS.md](docs/BACKENDS.md)). `cargo install`, `cargo add`
|
|
167
|
+
and a build from the Python sdist do not read that file; to build the same way, set:
|
|
168
|
+
|
|
169
|
+
```sh
|
|
170
|
+
RUSTFLAGS='--cfg p384_backend="fiat" --cfg curve25519_dalek_backend="fiat"' \
|
|
171
|
+
LIBCRUX_DISABLE_SIMD128=1 LIBCRUX_DISABLE_SIMD256=1 \
|
|
172
|
+
cargo install --locked pqbox-cli
|
|
135
173
|
```
|
|
136
174
|
|
|
137
175
|
Each GitHub release also carries prebuilt `pqbox` binaries, `pqbox-<target>` for macOS (arm64,
|
|
138
176
|
x86_64) and Linux (arm64, x86_64), with a `SHA256SUMS` file. `pqbox --version` reports the release,
|
|
139
177
|
and `pqbox selftest` checks the installed binary offline.
|
|
140
178
|
|
|
179
|
+
Every release asset made after v1.1.0 (binaries, wheels, sdist, npm tarball and `SHA256SUMS`) also
|
|
180
|
+
has a signed build provenance attestation. Check a download with the GitHub CLI (see
|
|
181
|
+
[RELEASING.md](RELEASING.md#verify-a-release)):
|
|
182
|
+
|
|
183
|
+
```sh
|
|
184
|
+
gh attestation verify pqbox-aarch64-apple-darwin -R maxgfr/pqbox
|
|
185
|
+
```
|
|
186
|
+
|
|
141
187
|
## Examples
|
|
142
188
|
|
|
143
189
|
### Rust
|
|
144
190
|
|
|
145
191
|
```rust
|
|
146
|
-
use pqbox::{Suite, SuitePolicy, kem, seal, sign};
|
|
192
|
+
use pqbox::{Suite, SuitePolicy, aead, kem, password, seal, sign};
|
|
147
193
|
use rand_core::UnwrapErr;
|
|
148
194
|
|
|
149
195
|
let mut rng = UnwrapErr(getrandom::SysRng); // getrandom 0.4 with the `sys_rng` feature
|
|
@@ -168,6 +214,12 @@ let bytes = legacy.public_key().to_bytes();
|
|
|
168
214
|
assert!(kem::PublicKey::from_bytes(&bytes).is_err()); // SuiteNotAllowed
|
|
169
215
|
let policy = SuitePolicy::DEFAULT.allow(Suite::XWing);
|
|
170
216
|
let pk = kem::PublicKey::from_bytes_with_policy(&bytes, policy)?;
|
|
217
|
+
|
|
218
|
+
// A key derived from a password: store the salt (and the costs) with the data, and derive the
|
|
219
|
+
// same key again later. Argon2id, 64 MiB, 3 passes, 1 lane by default; the key is wiped on drop.
|
|
220
|
+
let salt = password::generate_salt(&mut rng);
|
|
221
|
+
let key = password::derive_key(b"correct horse battery staple", &salt, password::Params::default(), 32)?;
|
|
222
|
+
let ct = aead::encrypt(aead::Algorithm::XChaCha20Poly1305, key.as_bytes(), b"data", b"header", &mut rng)?;
|
|
171
223
|
# Ok::<(), pqbox::Error>(())
|
|
172
224
|
```
|
|
173
225
|
|
|
@@ -195,12 +247,17 @@ assert pqbox.decrypt(key, ct, aad=b"header") == b"data"
|
|
|
195
247
|
|
|
196
248
|
phc = pqbox.password_hash("correct horse battery staple")
|
|
197
249
|
assert pqbox.password_verify("correct horse battery staple", phc)
|
|
250
|
+
|
|
251
|
+
# A key derived from a password and a stored salt (Argon2id, same defaults as password_hash).
|
|
252
|
+
salt = pqbox.password_generate_salt() # 16 random bytes: store them with the data
|
|
253
|
+
key = pqbox.password_derive_key("correct horse battery staple", salt) # 32 bytes
|
|
254
|
+
assert pqbox.password_derive_key("correct horse battery staple", salt) == key
|
|
198
255
|
```
|
|
199
256
|
|
|
200
257
|
### JavaScript / TypeScript
|
|
201
258
|
|
|
202
259
|
```ts
|
|
203
|
-
import { kemKeygen, seal, open, signKeygen, sign, verify, blake3 } from "pqbox";
|
|
260
|
+
import { kemKeygen, seal, open, signKeygen, sign, verify, blake3, passwordDeriveKey, passwordGenerateSalt } from "pqbox";
|
|
204
261
|
|
|
205
262
|
const { publicKey, secretKey } = kemKeygen(); // "pqbox-max"
|
|
206
263
|
const box = seal(publicKey, new TextEncoder().encode("hello"));
|
|
@@ -217,6 +274,10 @@ console.log(blake3(msg));
|
|
|
217
274
|
const legacy = kemKeygen("xwing");
|
|
218
275
|
const box2 = seal(legacy.publicKey, msg, { allowSuites: ["xwing"] });
|
|
219
276
|
open(legacy.secretKey, box2, { allowSuites: ["xwing"] });
|
|
277
|
+
|
|
278
|
+
// A key derived from a password and a stored salt (Argon2id, same defaults as passwordHash).
|
|
279
|
+
const salt = passwordGenerateSalt(); // 16 random bytes: store them with the data
|
|
280
|
+
const key = passwordDeriveKey("correct horse battery staple", salt); // 32 bytes
|
|
220
281
|
```
|
|
221
282
|
|
|
222
283
|
Errors are thrown as `PqboxError` (in Python, raised as `pqbox.PqboxError`, a `ValueError`). They
|
|
@@ -290,7 +351,10 @@ is refused. The body layouts are documented in [`format.rs`](crates/pqbox-core/s
|
|
|
290
351
|
|
|
291
352
|
- **The post-quantum crates are not independently audited.** `ml-kem`, `ml-dsa`, `x-wing` and
|
|
292
353
|
`slh-dsa` (a release candidate) come from RustCrypto, which has not had them audited, and
|
|
293
|
-
`classic-mceliece-rust` is a community crate.
|
|
354
|
+
`classic-mceliece-rust` is a community crate. `libcrux-ml-kem` (ML-KEM-1024) is partly formally
|
|
355
|
+
verified (panic freedom and functional correctness of most of its code, not constant time; see
|
|
356
|
+
[docs/BACKENDS.md](docs/BACKENDS.md)) but has no public audit either. pqbox itself has not been
|
|
357
|
+
audited.
|
|
294
358
|
- **Why bother now: harvest now, decrypt later.** No practical break of RSA is publicly known, and
|
|
295
359
|
no cryptographically relevant quantum computer is known to exist. Data recorded today, however,
|
|
296
360
|
can be decrypted whenever one appears. Hybrids protect it against that while keeping a classical
|
|
@@ -302,6 +366,16 @@ is refused. The body layouts are documented in [`format.rs`](crates/pqbox-core/s
|
|
|
302
366
|
more expensive hashes from a trusted source, raise the limits explicitly:
|
|
303
367
|
`verify_password_with_limits` in Rust, `max_m_cost`/`max_t_cost`/`max_p_cost` in Python,
|
|
304
368
|
`{ maxMCost, maxTCost, maxPCost }` in JavaScript.
|
|
369
|
+
- **Keys derived from passwords.** `password::derive_key` (Python `password_derive_key`,
|
|
370
|
+
JavaScript `passwordDeriveKey`) is plain Argon2id (version 0x13, no secret, no associated
|
|
371
|
+
data), so it matches other Argon2 libraries given the same inputs. It needs a salt of at least
|
|
372
|
+
16 bytes (`generate_salt` makes one; store it, and the costs, next to the data) and derives 16
|
|
373
|
+
to 64 bytes, 32 by default. The costs default to 64 MiB, 3 passes and 1 lane, and are held to
|
|
374
|
+
the same limits as verification, with the same opt-in to raise them. Choose the highest memory
|
|
375
|
+
cost your slowest target can afford (RFC 9106 suggests 64 MiB with 3 passes when 2 GiB is too
|
|
376
|
+
much), and never lower the costs of existing data. There is no context input: keep keys for
|
|
377
|
+
different purposes apart with distinct salts, or derive one key and expand it with HKDF-SHA-256
|
|
378
|
+
using one `info` label per purpose.
|
|
305
379
|
- **AES-256-GCM nonce limit.** `encrypt` draws a random nonce per message. AES-256-GCM's nonce is
|
|
306
380
|
96 bits, so encrypt at most about 2^32 messages under one key (NIST SP 800-38D) and rotate it
|
|
307
381
|
after that. XChaCha20-Poly1305, the default, has a 192-bit nonce and no practical limit: prefer
|
|
@@ -314,16 +388,18 @@ is refused. The body layouts are documented in [`format.rs`](crates/pqbox-core/s
|
|
|
314
388
|
## Upstream
|
|
315
389
|
|
|
316
390
|
pqbox stands on these projects. The versions are pinned in the `Cargo.toml` files (exactly, with
|
|
317
|
-
`=`, for every cryptographic crate); Dependabot proposes updates, and a
|
|
391
|
+
`=`, for every cryptographic crate); Dependabot proposes updates, and a daily
|
|
318
392
|
[upstream watch](.github/workflows/upstream-watch.yml) reports advisories, new releases and
|
|
319
393
|
alternatives ([`scripts/watch/`](scripts/watch)). [`docs/BACKENDS.md`](docs/BACKENDS.md) compares
|
|
320
|
-
the
|
|
394
|
+
the backends with the alternatives (RustCrypto, libcrux and AWS-LC), and explains the move of
|
|
395
|
+
ML-KEM-1024 to libcrux.
|
|
321
396
|
|
|
322
397
|
### Cryptography (crate `pqbox`)
|
|
323
398
|
|
|
324
399
|
| Crate | Purpose | Repository | crates.io | Implements |
|
|
325
400
|
|---|---|---|---|---|
|
|
326
|
-
| `ml-kem` | ML-KEM-
|
|
401
|
+
| `libcrux-ml-kem` | ML-KEM-1024 (`pqbox-max`, `pqbox-paranoid`), portable build; formally verified with [hax](https://github.com/cryspen/hax) and F* ([verification status](https://github.com/cryspen/libcrux/blob/libcrux-ml-kem-v0.0.12/libcrux-ml-kem/proofs/verification_status.md)) | [cryspen/libcrux](https://github.com/cryspen/libcrux/tree/main/libcrux-ml-kem) | [libcrux-ml-kem](https://crates.io/crates/libcrux-ml-kem) | [FIPS 203](https://csrc.nist.gov/pubs/fips/203/final) |
|
|
402
|
+
| `ml-kem` | ML-KEM-768 (inside X-Wing) | [RustCrypto/KEMs](https://github.com/RustCrypto/KEMs/tree/master/ml-kem) | [ml-kem](https://crates.io/crates/ml-kem) | [FIPS 203](https://csrc.nist.gov/pubs/fips/203/final) |
|
|
327
403
|
| `x-wing` | X-Wing KEM (`xwing` suite) | [RustCrypto/KEMs](https://github.com/RustCrypto/KEMs/tree/master/x-wing) | [x-wing](https://crates.io/crates/x-wing) | [draft-connolly-cfrg-xwing-kem](https://datatracker.ietf.org/doc/draft-connolly-cfrg-xwing-kem/) |
|
|
328
404
|
| `classic-mceliece-rust` | Classic McEliece 8192128 (`paranoid`) | [Colfenor/classic-mceliece-rust](https://github.com/Colfenor/classic-mceliece-rust) | [classic-mceliece-rust](https://crates.io/crates/classic-mceliece-rust) | [Classic McEliece NIST submission](https://classic.mceliece.org/nist.html) |
|
|
329
405
|
| `ml-dsa` | ML-DSA-65 / ML-DSA-87 | [RustCrypto/signatures](https://github.com/RustCrypto/signatures/tree/master/ml-dsa) | [ml-dsa](https://crates.io/crates/ml-dsa) | [FIPS 204](https://csrc.nist.gov/pubs/fips/204/final) |
|
|
@@ -88,6 +88,21 @@ export function kemKeygen(suite_name: string): object;
|
|
|
88
88
|
*/
|
|
89
89
|
export function open(secret_key: Uint8Array, sealed: Uint8Array, allow_suites: string[]): Uint8Array;
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Derives a key from a password and a stored salt with Argon2id (version 0x13, no secret, no
|
|
93
|
+
* associated data).
|
|
94
|
+
*
|
|
95
|
+
* # Errors
|
|
96
|
+
* `InvalidParams` for a salt shorter than 16 bytes, a length outside `16..=64`, or costs that
|
|
97
|
+
* are out of range or above the given limits (checked before any memory is allocated).
|
|
98
|
+
*/
|
|
99
|
+
export function passwordDeriveKey(password: Uint8Array, salt: Uint8Array, length: number, m_cost: number, t_cost: number, p_cost: number, max_m_cost: number, max_t_cost: number, max_p_cost: number): Uint8Array;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A fresh random 16-byte salt for [`password_derive_key`].
|
|
103
|
+
*/
|
|
104
|
+
export function passwordGenerateSalt(): Uint8Array;
|
|
105
|
+
|
|
91
106
|
/**
|
|
92
107
|
* Argon2id password hash as a PHC string.
|
|
93
108
|
*
|
|
@@ -174,6 +189,8 @@ export interface InitOutput {
|
|
|
174
189
|
readonly kemEncapsulate: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
175
190
|
readonly kemKeygen: (a: number, b: number, c: number) => void;
|
|
176
191
|
readonly open: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
192
|
+
readonly passwordDeriveKey: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
193
|
+
readonly passwordGenerateSalt: (a: number) => void;
|
|
177
194
|
readonly passwordHash: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
178
195
|
readonly passwordVerify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
179
196
|
readonly seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
@@ -334,6 +334,62 @@ export function open(secret_key, sealed, allow_suites) {
|
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
/**
|
|
338
|
+
* Derives a key from a password and a stored salt with Argon2id (version 0x13, no secret, no
|
|
339
|
+
* associated data).
|
|
340
|
+
*
|
|
341
|
+
* # Errors
|
|
342
|
+
* `InvalidParams` for a salt shorter than 16 bytes, a length outside `16..=64`, or costs that
|
|
343
|
+
* are out of range or above the given limits (checked before any memory is allocated).
|
|
344
|
+
* @param {Uint8Array} password
|
|
345
|
+
* @param {Uint8Array} salt
|
|
346
|
+
* @param {number} length
|
|
347
|
+
* @param {number} m_cost
|
|
348
|
+
* @param {number} t_cost
|
|
349
|
+
* @param {number} p_cost
|
|
350
|
+
* @param {number} max_m_cost
|
|
351
|
+
* @param {number} max_t_cost
|
|
352
|
+
* @param {number} max_p_cost
|
|
353
|
+
* @returns {Uint8Array}
|
|
354
|
+
*/
|
|
355
|
+
export function passwordDeriveKey(password, salt, length, m_cost, t_cost, p_cost, max_m_cost, max_t_cost, max_p_cost) {
|
|
356
|
+
try {
|
|
357
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
358
|
+
const ptr0 = passArray8ToWasm0(password, wasm.__wbindgen_export);
|
|
359
|
+
const len0 = WASM_VECTOR_LEN;
|
|
360
|
+
const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_export);
|
|
361
|
+
const len1 = WASM_VECTOR_LEN;
|
|
362
|
+
wasm.passwordDeriveKey(retptr, ptr0, len0, ptr1, len1, length, m_cost, t_cost, p_cost, max_m_cost, max_t_cost, max_p_cost);
|
|
363
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
364
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
365
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
366
|
+
if (r2) {
|
|
367
|
+
throw takeObject(r1);
|
|
368
|
+
}
|
|
369
|
+
return takeObject(r0);
|
|
370
|
+
} finally {
|
|
371
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* A fresh random 16-byte salt for [`password_derive_key`].
|
|
377
|
+
* @returns {Uint8Array}
|
|
378
|
+
*/
|
|
379
|
+
export function passwordGenerateSalt() {
|
|
380
|
+
try {
|
|
381
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
382
|
+
wasm.passwordGenerateSalt(retptr);
|
|
383
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
384
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
385
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
386
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
387
|
+
return v1;
|
|
388
|
+
} finally {
|
|
389
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
337
393
|
/**
|
|
338
394
|
* Argon2id password hash as a PHC string.
|
|
339
395
|
*
|