Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d20993872b
|
||
|
|
0d257aaf78
|
||
|
|
0e9eeb10b2
|
||
|
|
09286d34fc
|
||
|
|
b9b8699ee7
|
||
|
|
2e1bcfe4c2
|
@@ -16,7 +16,7 @@ jobs:
|
|||||||
name: cargo fmt
|
name: cargo fmt
|
||||||
runs-on: linux_amd64
|
runs-on: linux_amd64
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
- uses: dtolnay/rust-toolchain@nightly
|
- uses: dtolnay/rust-toolchain@nightly
|
||||||
with:
|
with:
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
@@ -27,7 +27,7 @@ jobs:
|
|||||||
name: cargo clippy
|
name: cargo clippy
|
||||||
runs-on: linux_amd64
|
runs-on: linux_amd64
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
components: clippy
|
components: clippy
|
||||||
@@ -68,7 +68,7 @@ jobs:
|
|||||||
- stable
|
- stable
|
||||||
- "1.90.0"
|
- "1.90.0"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
- uses: dtolnay/rust-toolchain@${{ matrix.toolchain }}
|
- uses: dtolnay/rust-toolchain@${{ matrix.toolchain }}
|
||||||
- name: Cache cargo
|
- name: Cache cargo
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
||||||
@@ -87,7 +87,7 @@ jobs:
|
|||||||
name: test simple_login example
|
name: test simple_login example
|
||||||
runs-on: linux_amd64
|
runs-on: linux_amd64
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
- name: Run expect
|
- name: Run expect
|
||||||
run: expect -f scripts/simple_login.exp
|
run: expect -f scripts/simple_login.exp
|
||||||
@@ -96,7 +96,7 @@ jobs:
|
|||||||
name: test digital_locker example
|
name: test digital_locker example
|
||||||
runs-on: linux_amd64
|
runs-on: linux_amd64
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
- name: Run expect
|
- name: Run expect
|
||||||
run: expect -f scripts/digital_locker.exp
|
run: expect -f scripts/digital_locker.exp
|
||||||
@@ -121,7 +121,7 @@ jobs:
|
|||||||
- argon2
|
- argon2
|
||||||
- serde
|
- serde
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
@@ -139,7 +139,7 @@ jobs:
|
|||||||
- --features ristretto255,kem
|
- --features ristretto255,kem
|
||||||
- ""
|
- ""
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
- name: Run cargo bench --no-run
|
- name: Run cargo bench --no-run
|
||||||
run: cargo bench --no-default-features ${{ matrix.backend_feature }} --no-run
|
run: cargo bench --no-default-features ${{ matrix.backend_feature }} --no-run
|
||||||
@@ -148,7 +148,7 @@ jobs:
|
|||||||
name: cargo audit
|
name: cargo audit
|
||||||
runs-on: linux_amd64
|
runs-on: linux_amd64
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
- name: Install cargo-audit
|
- name: Install cargo-audit
|
||||||
run: cargo install cargo-audit
|
run: cargo install cargo-audit
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ jobs:
|
|||||||
publish:
|
publish:
|
||||||
runs-on: linux_amd64
|
runs-on: linux_amd64
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
|||||||
+11
-5
@@ -1,6 +1,12 @@
|
|||||||
.vs
|
# Generated by Cargo
|
||||||
.vscode/
|
# will have compiled files and executables
|
||||||
src/.DS_Store
|
debug/
|
||||||
/target
|
target/
|
||||||
Cargo.lock
|
pkg/
|
||||||
|
demo/
|
||||||
|
|
||||||
|
# These are backup files generated by rustfmt
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|
||||||
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
|
*.pdb
|
||||||
|
|||||||
+19
-1
@@ -1,6 +1,24 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 1.0.0-pre.0 (June 29, 2026)
|
## 1.0.0-rc.0 (July 3, 2026)
|
||||||
|
|
||||||
|
* Fixed doc showing incorrect MSRV
|
||||||
|
* Fixed readme incorrect doc link
|
||||||
|
* Bump `ecdsa` to `0.17`
|
||||||
|
* Bump `voprf-vx` to `1.0.0-rc.1`
|
||||||
|
* Added `ZeroizeOnDrop` bound to `Hash` trait
|
||||||
|
* Replaced manual `Drop` impls on `Ke2Builder` and `KemKe2Builder` with `#[derive_where(ZeroizeOnDrop)]`
|
||||||
|
* Replaced deprecated `ExpandedKeyEncoding` with seed-based serialization (`KeyInit` / `KeyExport`) for KEM decapsulation keys
|
||||||
|
* Fixed deserialization of `voprf` types to pass exact-length slices (compatibility with `voprf` trailing bytes rejection)
|
||||||
|
* Regenerated test vectors
|
||||||
|
|
||||||
|
## 1.0.0-pre.1 (July 2, 2026)
|
||||||
|
|
||||||
|
* Fixed README package name
|
||||||
|
* Implement `zeroize` feature on `argon2`, `ed25519-dalek`, `hmac`, `chacha20poly1305` and `sha2`
|
||||||
|
* Removed `rand_core` dependency to use it through `rand` re-export
|
||||||
|
|
||||||
|
## 1.0.0-pre.0 (July 1, 2026)
|
||||||
|
|
||||||
Forked from [facebook/opaque-ke](https://github.com/facebook/opaque-ke/) at `4.1.0-pre.2`.
|
Forked from [facebook/opaque-ke](https://github.com/facebook/opaque-ke/) at `4.1.0-pre.2`.
|
||||||
|
|
||||||
|
|||||||
Generated
+1903
File diff suppressed because it is too large
Load Diff
+14
-14
@@ -14,7 +14,7 @@ name = "opaque-vx"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/vexahub/opaque-vx"
|
repository = "https://github.com/vexahub/opaque-vx"
|
||||||
rust-version = "1.90"
|
rust-version = "1.90"
|
||||||
version = "1.0.0-pre.0"
|
version = "1.0.0-rc.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
argon2 = ["dep:argon2"]
|
argon2 = ["dep:argon2"]
|
||||||
@@ -22,7 +22,7 @@ curve25519 = ["dep:curve25519-dalek"]
|
|||||||
default = ["ristretto255", "serde"]
|
default = ["ristretto255", "serde"]
|
||||||
ecdsa = ["dep:ecdsa"]
|
ecdsa = ["dep:ecdsa"]
|
||||||
ed25519 = ["dep:curve25519-dalek", "dep:ed25519-dalek"]
|
ed25519 = ["dep:curve25519-dalek", "dep:ed25519-dalek"]
|
||||||
kem = ["dep:ml-kem", "dep:rand_core"]
|
kem = ["dep:ml-kem"]
|
||||||
ristretto255 = ["dep:curve25519-dalek", "voprf/ristretto255-ciphersuite"]
|
ristretto255 = ["dep:curve25519-dalek", "voprf/ristretto255-ciphersuite"]
|
||||||
serde = [
|
serde = [
|
||||||
"dep:serde",
|
"dep:serde",
|
||||||
@@ -38,19 +38,21 @@ serde = [
|
|||||||
std = ["dep:getrandom", "rand/std"]
|
std = ["dep:getrandom", "rand/std"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
argon2 = { version = "0.6.0-rc", default-features = false, features = [
|
argon2 = { version = "0.6.0-rc.8", default-features = false, features = [
|
||||||
|
"zeroize",
|
||||||
"alloc",
|
"alloc",
|
||||||
], optional = true }
|
], optional = true }
|
||||||
curve25519-dalek = { version = "5.0.0-rc", default-features = false, features = [
|
curve25519-dalek = { version = "5", default-features = false, features = [
|
||||||
"zeroize",
|
"zeroize",
|
||||||
], optional = true }
|
], optional = true }
|
||||||
derive-where = { version = "1.6", features = ["zeroize-on-drop"] }
|
derive-where = { version = "1.6", features = ["zeroize-on-drop"] }
|
||||||
digest = { version = "0.11", features = ["zeroize"] }
|
digest = { version = "0.11", features = ["zeroize"] }
|
||||||
displaydoc = { version = "0.2", default-features = false }
|
displaydoc = { version = "0.2", default-features = false }
|
||||||
ecdsa = { version = "0.17.0-rc.23", default-features = false, features = [
|
ecdsa = { version = "0.17", default-features = false, features = [
|
||||||
"algorithm",
|
"algorithm",
|
||||||
], optional = true }
|
], optional = true }
|
||||||
ed25519-dalek = { version = "3.0.0-rc", default-features = false, features = [
|
ed25519-dalek = { version = "3", default-features = false, features = [
|
||||||
|
"zeroize",
|
||||||
"digest",
|
"digest",
|
||||||
"hazmat",
|
"hazmat",
|
||||||
], optional = true }
|
], optional = true }
|
||||||
@@ -58,17 +60,16 @@ elliptic-curve = { version = "0.14", features = ["sec1"] }
|
|||||||
generic-array = { version = "1.4", features = ["hybrid-array-0_4", "zeroize"] }
|
generic-array = { version = "1.4", features = ["hybrid-array-0_4", "zeroize"] }
|
||||||
hybrid-array = { version = "0.4", features = ["extra-sizes", "zeroize"] }
|
hybrid-array = { version = "0.4", features = ["extra-sizes", "zeroize"] }
|
||||||
hkdf = "0.13"
|
hkdf = "0.13"
|
||||||
hmac = "0.13"
|
hmac = { version = "0.13", features = ["zeroize"] }
|
||||||
ml-kem = { version = "0.3", default-features = false, features = [
|
ml-kem = { version = "0.3", default-features = false, features = [
|
||||||
"zeroize",
|
"zeroize",
|
||||||
], optional = true }
|
], optional = true }
|
||||||
rand = { version = "0.10", default-features = false }
|
rand = { version = "0.10", default-features = false }
|
||||||
rand_core = { version = "0.10", default-features = false, optional = true }
|
|
||||||
serde = { version = "1", default-features = false, features = [
|
serde = { version = "1", default-features = false, features = [
|
||||||
"derive",
|
"derive",
|
||||||
], optional = true }
|
], optional = true }
|
||||||
subtle = { version = "2.6", default-features = false }
|
subtle = { version = "2.6", default-features = false }
|
||||||
voprf = { package = "voprf-vx", version = "1.0.0-pre.1", default-features = false, features = [
|
voprf = { package = "voprf-vx", version = "1.0.0-rc.1", default-features = false, features = [
|
||||||
"danger",
|
"danger",
|
||||||
] }
|
] }
|
||||||
zeroize = { version = "1.9", features = ["zeroize_derive"] }
|
zeroize = { version = "1.9", features = ["zeroize_derive"] }
|
||||||
@@ -79,19 +80,18 @@ getrandom = { version = "0.4", features = ["wasm_js"], optional = true }
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
bincode-next = { version = "3", features = ["serde", "alloc"] }
|
bincode-next = { version = "3", features = ["serde", "alloc"] }
|
||||||
chacha20poly1305 = "0.11"
|
chacha20poly1305 = { version = "0.11", features = ["zeroize"] }
|
||||||
criterion = "0.8"
|
criterion = "0.8"
|
||||||
cryptoki = "0.12"
|
cryptoki = "0.12"
|
||||||
elliptic-curve = { version = "0.14", features = ["alloc", "pkcs8"] }
|
elliptic-curve = { version = "0.14", features = ["alloc", "pkcs8"] }
|
||||||
rand_core = { version = "0.10", default-features = false }
|
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
p256 = { version = "0.14.0-rc.15", default-features = false, features = [
|
p256 = { version = "0.14", default-features = false, features = [
|
||||||
"ecdsa",
|
"ecdsa",
|
||||||
"hash2curve",
|
"hash2curve",
|
||||||
"pkcs8",
|
"pkcs8",
|
||||||
"oprf",
|
"oprf",
|
||||||
] }
|
] }
|
||||||
p384 = { version = "0.14.0-rc.15", default-features = false, features = [
|
p384 = { version = "0.14", default-features = false, features = [
|
||||||
"hash2curve",
|
"hash2curve",
|
||||||
"pkcs8",
|
"pkcs8",
|
||||||
"oprf",
|
"oprf",
|
||||||
@@ -106,7 +106,7 @@ proptest = "1"
|
|||||||
rand = "0.10"
|
rand = "0.10"
|
||||||
rand_chacha = "0.10"
|
rand_chacha = "0.10"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
sha2 = { version = "0.11", default-features = false }
|
sha2 = { version = "0.11", default-features = false, features = ["zeroize"] }
|
||||||
thiserror = "2"
|
thiserror = "2"
|
||||||
# MSRV
|
# MSRV
|
||||||
rustyline = "18"
|
rustyline = "18"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ OPAQUE is a PKI-free aPAKE that is secure against pre-computation attacks and ca
|
|||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
The API can be found [here](https://docs.rs/opaque-ke-vx/) along with an example for usage. More examples can be found
|
The API can be found [here](https://docs.rs/opaque-vx/) along with an example for usage. More examples can be found
|
||||||
in
|
in
|
||||||
the [examples](./examples) directory.
|
the [examples](./examples) directory.
|
||||||
|
|
||||||
@@ -30,12 +30,12 @@ Installation
|
|||||||
Add the following line to the dependencies of your `Cargo.toml`:
|
Add the following line to the dependencies of your `Cargo.toml`:
|
||||||
|
|
||||||
```
|
```
|
||||||
opaque-ke = { package = "opaque-ke-vx", version = "1.0.0-pre.0" }
|
opaque-vx = "1.0.0-rc.0"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Minimum Supported Rust Version
|
### Minimum Supported Rust Version
|
||||||
|
|
||||||
Rust **1.89** or higher.
|
Rust **1.90** or higher.
|
||||||
|
|
||||||
Audit
|
Audit
|
||||||
-----
|
-----
|
||||||
|
|||||||
+1
-1
@@ -7,8 +7,8 @@ extern crate criterion;
|
|||||||
|
|
||||||
use criterion::Criterion;
|
use criterion::Criterion;
|
||||||
use opaque_vx::*;
|
use opaque_vx::*;
|
||||||
|
use rand::rand_core::UnwrapErr;
|
||||||
use rand::rngs::SysRng;
|
use rand::rngs::SysRng;
|
||||||
use rand_core::UnwrapErr;
|
|
||||||
|
|
||||||
#[cfg(feature = "ristretto255")]
|
#[cfg(feature = "ristretto255")]
|
||||||
static SUFFIX: &str = "ristretto255";
|
static SUFFIX: &str = "ristretto255";
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ use opaque_vx::{
|
|||||||
CredentialResponse, RegistrationRequest, RegistrationResponse, RegistrationUpload, ServerLogin,
|
CredentialResponse, RegistrationRequest, RegistrationResponse, RegistrationUpload, ServerLogin,
|
||||||
ServerLoginParameters, ServerRegistration, ServerSetup,
|
ServerLoginParameters, ServerRegistration, ServerSetup,
|
||||||
};
|
};
|
||||||
use rand_core::UnwrapErr;
|
use rand::rand_core::UnwrapErr;
|
||||||
use rustyline::Editor;
|
use rustyline::Editor;
|
||||||
use rustyline::error::ReadlineError;
|
use rustyline::error::ReadlineError;
|
||||||
use rustyline::history::DefaultHistory;
|
use rustyline::history::DefaultHistory;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use opaque_vx::{
|
|||||||
CredentialResponse, RegistrationRequest, RegistrationResponse, RegistrationUpload, ServerLogin,
|
CredentialResponse, RegistrationRequest, RegistrationResponse, RegistrationUpload, ServerLogin,
|
||||||
ServerLoginParameters, ServerRegistration, ServerRegistrationLen, ServerSetup,
|
ServerLoginParameters, ServerRegistration, ServerRegistrationLen, ServerSetup,
|
||||||
};
|
};
|
||||||
use rand_core::UnwrapErr;
|
use rand::rand_core::UnwrapErr;
|
||||||
use rustyline::Editor;
|
use rustyline::Editor;
|
||||||
use rustyline::error::ReadlineError;
|
use rustyline::error::ReadlineError;
|
||||||
use rustyline::history::DefaultHistory;
|
use rustyline::history::DefaultHistory;
|
||||||
|
|||||||
+3
-1
@@ -48,6 +48,7 @@ pub trait Hash:
|
|||||||
+ FixedOutputReset
|
+ FixedOutputReset
|
||||||
+ CoreProxy
|
+ CoreProxy
|
||||||
+ Clone
|
+ Clone
|
||||||
|
+ zeroize::ZeroizeOnDrop
|
||||||
where
|
where
|
||||||
<Self as CoreProxy>::Core: ProxyHash,
|
<Self as CoreProxy>::Core: ProxyHash,
|
||||||
<<Self as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize: IsLess<U256>,
|
<<Self as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize: IsLess<U256>,
|
||||||
@@ -64,7 +65,8 @@ impl<
|
|||||||
+ BlockSizeUser
|
+ BlockSizeUser
|
||||||
+ FixedOutputReset
|
+ FixedOutputReset
|
||||||
+ CoreProxy
|
+ CoreProxy
|
||||||
+ Clone,
|
+ Clone
|
||||||
|
+ zeroize::ZeroizeOnDrop,
|
||||||
> Hash for T
|
> Hash for T
|
||||||
where
|
where
|
||||||
<T as CoreProxy>::Core: ProxyHash,
|
<T as CoreProxy>::Core: ProxyHash,
|
||||||
|
|||||||
@@ -429,8 +429,8 @@ mod test {
|
|||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use ed25519_dalek::{Signer, SigningKey, Verifier, VerifyingKey};
|
use ed25519_dalek::{Signer, SigningKey, Verifier, VerifyingKey};
|
||||||
|
use rand::rand_core::UnwrapErr;
|
||||||
use rand::rngs::SysRng;
|
use rand::rngs::SysRng;
|
||||||
use rand_core::UnwrapErr;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ fn ecdsa() {
|
|||||||
use p256::ecdsa::signature::RandomizedDigestSigner;
|
use p256::ecdsa::signature::RandomizedDigestSigner;
|
||||||
use p256::ecdsa::{Signature, SigningKey, VerifyingKey};
|
use p256::ecdsa::{Signature, SigningKey, VerifyingKey};
|
||||||
use p256::{NistP256, PublicKey};
|
use p256::{NistP256, PublicKey};
|
||||||
|
use rand::rand_core::UnwrapErr;
|
||||||
use rand::rngs::SysRng;
|
use rand::rngs::SysRng;
|
||||||
use rand_core::UnwrapErr;
|
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
|
|
||||||
use crate::tests::mock_rng::CycleRng;
|
use crate::tests::mock_rng::CycleRng;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ use generic_array::typenum::{IsLess, Le, NonZero, Sum, U256};
|
|||||||
use generic_array::{ArrayLength, GenericArray};
|
use generic_array::{ArrayLength, GenericArray};
|
||||||
use rand::{CryptoRng, Rng};
|
use rand::{CryptoRng, Rng};
|
||||||
use subtle::{ConstantTimeEq, CtOption};
|
use subtle::{ConstantTimeEq, CtOption};
|
||||||
use zeroize::{Zeroize, ZeroizeOnDrop};
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
Deserialize, GenerateKe1Result, GenerateKe2Result, GenerateKe3Result, KeyExchange, Serialize,
|
Deserialize, GenerateKe1Result, GenerateKe2Result, GenerateKe3Result, KeyExchange, Serialize,
|
||||||
@@ -69,7 +68,7 @@ pub struct Ke2State<H: OutputSizeUser> {
|
|||||||
serialize = "H: serde::Serialize, PublicKey<G>: serde::Serialize",
|
serialize = "H: serde::Serialize, PublicKey<G>: serde::Serialize",
|
||||||
))
|
))
|
||||||
)]
|
)]
|
||||||
#[derive_where(Clone)]
|
#[derive_where(Clone, ZeroizeOnDrop)]
|
||||||
#[derive_where(Debug, Eq, Hash, PartialEq; H, PublicKey<G>)]
|
#[derive_where(Debug, Eq, Hash, PartialEq; H, PublicKey<G>)]
|
||||||
pub struct Ke2Builder<G: Group, H: Hash>
|
pub struct Ke2Builder<G: Group, H: Hash>
|
||||||
where
|
where
|
||||||
@@ -80,7 +79,9 @@ where
|
|||||||
{
|
{
|
||||||
server_nonce: GenericArray<u8, NonceLen>,
|
server_nonce: GenericArray<u8, NonceLen>,
|
||||||
transcript_hasher: H,
|
transcript_hasher: H,
|
||||||
|
#[derive_where(skip(Zeroize))]
|
||||||
client_e_pk: PublicKey<G>,
|
client_e_pk: PublicKey<G>,
|
||||||
|
#[derive_where(skip(Zeroize))]
|
||||||
server_e_pk: PublicKey<G>,
|
server_e_pk: PublicKey<G>,
|
||||||
shared_secret_1: GenericArray<u8, G::PkLen>,
|
shared_secret_1: GenericArray<u8, G::PkLen>,
|
||||||
shared_secret_3: GenericArray<u8, G::PkLen>,
|
shared_secret_3: GenericArray<u8, G::PkLen>,
|
||||||
@@ -352,40 +353,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO: implement via derive after `Hash` gets `Zeroize` support.
|
|
||||||
impl<G: Group, H: Hash> Drop for Ke2Builder<G, H>
|
|
||||||
where
|
|
||||||
H::Core: ProxyHash,
|
|
||||||
<<H as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize: IsLess<U256>,
|
|
||||||
Le<<<H as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize, U256>: NonZero,
|
|
||||||
OutputSize<H>: ArrayLength,
|
|
||||||
{
|
|
||||||
fn drop(&mut self) {
|
|
||||||
let Self {
|
|
||||||
server_nonce,
|
|
||||||
transcript_hasher,
|
|
||||||
client_e_pk: _,
|
|
||||||
server_e_pk: _,
|
|
||||||
shared_secret_1,
|
|
||||||
shared_secret_3,
|
|
||||||
} = self;
|
|
||||||
|
|
||||||
server_nonce.zeroize();
|
|
||||||
digest::Reset::reset(transcript_hasher);
|
|
||||||
shared_secret_1.zeroize();
|
|
||||||
shared_secret_3.zeroize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<G: Group, H: Hash> ZeroizeOnDrop for Ke2Builder<G, H>
|
|
||||||
where
|
|
||||||
H::Core: ProxyHash,
|
|
||||||
<<H as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize: IsLess<U256>,
|
|
||||||
Le<<<H as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize, U256>: NonZero,
|
|
||||||
OutputSize<H>: ArrayLength,
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<G: Group, H: Hash> Deserialize for Ke2Message<G, H>
|
impl<G: Group, H: Hash> Deserialize for Ke2Message<G, H>
|
||||||
where
|
where
|
||||||
H::Core: ProxyHash,
|
H::Core: ProxyHash,
|
||||||
|
|||||||
@@ -24,15 +24,12 @@ use digest::block_api::{CoreProxy, SmallBlockSizeUser};
|
|||||||
use generic_array::typenum::{Cmp, IsLess, Le, NonZero, Sum, U256};
|
use generic_array::typenum::{Cmp, IsLess, Le, NonZero, Sum, U256};
|
||||||
use generic_array::{ArrayLength, GenericArray};
|
use generic_array::{ArrayLength, GenericArray};
|
||||||
use hybrid_array::ArraySize;
|
use hybrid_array::ArraySize;
|
||||||
#[allow(deprecated)]
|
|
||||||
use ml_kem::ExpandedKeyEncoding;
|
|
||||||
use ml_kem::kem::{
|
use ml_kem::kem::{
|
||||||
Ciphertext as MlKemCiphertext, Decapsulate, Encapsulate, Kem as MlKemTrait, KeyExport,
|
Ciphertext as MlKemCiphertext, Decapsulate, Encapsulate, Kem as MlKemTrait, KeyExport, KeyInit,
|
||||||
KeySizeUser, TryKeyInit,
|
KeySizeUser, TryKeyInit,
|
||||||
};
|
};
|
||||||
use rand::{CryptoRng, Rng};
|
use rand::{CryptoRng, Rng};
|
||||||
use subtle::{ConstantTimeEq, CtOption};
|
use subtle::{ConstantTimeEq, CtOption};
|
||||||
use zeroize::{Zeroize, ZeroizeOnDrop};
|
|
||||||
|
|
||||||
use super::shared::{self, Ke1Message, Ke1State, NonceLen};
|
use super::shared::{self, Ke1Message, Ke1State, NonceLen};
|
||||||
use super::{
|
use super::{
|
||||||
@@ -55,7 +52,7 @@ pub trait KemCoreWrapper {
|
|||||||
type EncapsulationKey: Clone;
|
type EncapsulationKey: Clone;
|
||||||
|
|
||||||
/// Secret key type used for decapsulation operations.
|
/// Secret key type used for decapsulation operations.
|
||||||
type DecapsulationKey: Clone + ZeroizeOnDrop;
|
type DecapsulationKey: Clone + zeroize::ZeroizeOnDrop;
|
||||||
|
|
||||||
/// Length (in bytes) of the serialized public key.
|
/// Length (in bytes) of the serialized public key.
|
||||||
type EncapsulationKeyLen: ArrayLength + ArraySize;
|
type EncapsulationKeyLen: ArrayLength + ArraySize;
|
||||||
@@ -116,7 +113,7 @@ pub trait KemCoreWrapper {
|
|||||||
/// which is required by `ml-kem 0.3.x`.
|
/// which is required by `ml-kem 0.3.x`.
|
||||||
struct RngCompat<'a, R>(&'a mut R);
|
struct RngCompat<'a, R>(&'a mut R);
|
||||||
|
|
||||||
impl<R: Rng> rand_core::TryRng for RngCompat<'_, R> {
|
impl<R: Rng> rand::rand_core::TryRng for RngCompat<'_, R> {
|
||||||
type Error = core::convert::Infallible;
|
type Error = core::convert::Infallible;
|
||||||
|
|
||||||
fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
|
fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
|
||||||
@@ -133,21 +130,19 @@ impl<R: Rng> rand_core::TryRng for RngCompat<'_, R> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R: Rng + CryptoRng> rand_core::TryCryptoRng for RngCompat<'_, R> {}
|
impl<R: Rng + CryptoRng> rand::rand_core::TryCryptoRng for RngCompat<'_, R> {}
|
||||||
|
|
||||||
type RcEncapsulationKeyLen<K> = <<K as MlKemTrait>::EncapsulationKey as KeySizeUser>::KeySize;
|
type RcEncapsulationKeyLen<K> = <<K as MlKemTrait>::EncapsulationKey as KeySizeUser>::KeySize;
|
||||||
#[allow(deprecated)]
|
type RcDecapsulationKeyLen<K> = <<K as MlKemTrait>::DecapsulationKey as KeySizeUser>::KeySize;
|
||||||
type RcDecapsulationKeyLen<K> =
|
|
||||||
<<K as MlKemTrait>::DecapsulationKey as ExpandedKeyEncoding>::EncodedSize;
|
|
||||||
type RcCiphertextLen<K> = <K as MlKemTrait>::CiphertextSize;
|
type RcCiphertextLen<K> = <K as MlKemTrait>::CiphertextSize;
|
||||||
type RcSharedSecretLen<K> = <K as MlKemTrait>::SharedKeySize;
|
type RcSharedSecretLen<K> = <K as MlKemTrait>::SharedKeySize;
|
||||||
|
|
||||||
#[allow(deprecated)]
|
|
||||||
impl<K> KemCoreWrapper for K
|
impl<K> KemCoreWrapper for K
|
||||||
where
|
where
|
||||||
K: MlKemTrait,
|
K: MlKemTrait,
|
||||||
K::EncapsulationKey: Encapsulate<Kem = K> + KeyExport + TryKeyInit + Clone,
|
K::EncapsulationKey: Encapsulate<Kem = K> + KeyExport + TryKeyInit + Clone,
|
||||||
K::DecapsulationKey: Decapsulate<Kem = K> + ExpandedKeyEncoding + Clone + ZeroizeOnDrop,
|
K::DecapsulationKey:
|
||||||
|
Decapsulate<Kem = K> + KeyExport + KeyInit + Clone + zeroize::ZeroizeOnDrop,
|
||||||
RcEncapsulationKeyLen<K>: ArrayLength + ArraySize,
|
RcEncapsulationKeyLen<K>: ArrayLength + ArraySize,
|
||||||
RcDecapsulationKeyLen<K>: ArrayLength + ArraySize,
|
RcDecapsulationKeyLen<K>: ArrayLength + ArraySize,
|
||||||
RcCiphertextLen<K>: ArrayLength + ArraySize,
|
RcCiphertextLen<K>: ArrayLength + ArraySize,
|
||||||
@@ -185,7 +180,7 @@ where
|
|||||||
fn serialize_decapsulation_key(
|
fn serialize_decapsulation_key(
|
||||||
key: &Self::DecapsulationKey,
|
key: &Self::DecapsulationKey,
|
||||||
) -> GenericArray<u8, Self::DecapsulationKeyLen> {
|
) -> GenericArray<u8, Self::DecapsulationKeyLen> {
|
||||||
GenericArray::from_slice(key.to_expanded_bytes().as_slice()).clone()
|
GenericArray::from_slice(key.to_bytes().as_slice()).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_decapsulation_key(
|
fn deserialize_decapsulation_key(
|
||||||
@@ -193,10 +188,9 @@ where
|
|||||||
) -> Result<Self::DecapsulationKey, ProtocolError> {
|
) -> Result<Self::DecapsulationKey, ProtocolError> {
|
||||||
let bytes: GenericArray<u8, RcDecapsulationKeyLen<K>> =
|
let bytes: GenericArray<u8, RcDecapsulationKeyLen<K>> =
|
||||||
input.take_array("kem decapsulation key")?;
|
input.take_array("kem decapsulation key")?;
|
||||||
let key = ml_kem::array::Array::try_from(bytes.as_slice())
|
let seed = ml_kem::array::Array::try_from(bytes.as_slice())
|
||||||
.map_err(|_| ProtocolError::SerializationError)?;
|
.map_err(|_| ProtocolError::SerializationError)?;
|
||||||
K::DecapsulationKey::from_expanded_bytes(&key)
|
Ok(KeyInit::new(&seed))
|
||||||
.map_err(|_| ProtocolError::SerializationError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encapsulate<R: Rng + CryptoRng>(
|
fn encapsulate<R: Rng + CryptoRng>(
|
||||||
@@ -289,7 +283,7 @@ where
|
|||||||
|
|
||||||
/// Server builder placeholder capturing the data needed to finish the KEM
|
/// Server builder placeholder capturing the data needed to finish the KEM
|
||||||
/// exchange.
|
/// exchange.
|
||||||
#[derive_where(Clone)]
|
#[derive_where(Clone, ZeroizeOnDrop)]
|
||||||
pub struct KemKe2Builder<G: Group, H: Hash, K: KemCoreWrapper>
|
pub struct KemKe2Builder<G: Group, H: Hash, K: KemCoreWrapper>
|
||||||
where
|
where
|
||||||
H::Core: ProxyHash,
|
H::Core: ProxyHash,
|
||||||
@@ -300,10 +294,13 @@ where
|
|||||||
{
|
{
|
||||||
server_nonce: GenericArray<u8, NonceLen>,
|
server_nonce: GenericArray<u8, NonceLen>,
|
||||||
transcript_hasher: H,
|
transcript_hasher: H,
|
||||||
|
#[derive_where(skip(Zeroize))]
|
||||||
client_e_pk: PublicKey<G>,
|
client_e_pk: PublicKey<G>,
|
||||||
|
#[derive_where(skip(Zeroize))]
|
||||||
server_e_pk: PublicKey<G>,
|
server_e_pk: PublicKey<G>,
|
||||||
shared_secret_1: GenericArray<u8, G::PkLen>,
|
shared_secret_1: GenericArray<u8, G::PkLen>,
|
||||||
shared_secret_3: GenericArray<u8, G::PkLen>,
|
shared_secret_3: GenericArray<u8, G::PkLen>,
|
||||||
|
#[derive_where(skip(Zeroize))]
|
||||||
kem_encapsulation_key: GenericArray<u8, K::EncapsulationKeyLen>,
|
kem_encapsulation_key: GenericArray<u8, K::EncapsulationKeyLen>,
|
||||||
kem_ciphertext: GenericArray<u8, K::CiphertextLen>,
|
kem_ciphertext: GenericArray<u8, K::CiphertextLen>,
|
||||||
kem_shared_secret: GenericArray<u8, K::SharedSecretLen>,
|
kem_shared_secret: GenericArray<u8, K::SharedSecretLen>,
|
||||||
@@ -335,40 +332,6 @@ where
|
|||||||
/// Third message remains the same as `TripleDH`.
|
/// Third message remains the same as `TripleDH`.
|
||||||
pub type KemKe3Message<H> = super::tripledh::Ke3Message<H>;
|
pub type KemKe3Message<H> = super::tripledh::Ke3Message<H>;
|
||||||
|
|
||||||
impl<G, H, K> Drop for KemKe2Builder<G, H, K>
|
|
||||||
where
|
|
||||||
G: Group,
|
|
||||||
H: Hash,
|
|
||||||
H::Core: ProxyHash,
|
|
||||||
<<H as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize: IsLess<U256>,
|
|
||||||
Le<<<H as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize, U256>: NonZero,
|
|
||||||
<<H as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize: Cmp<U256>,
|
|
||||||
OutputSize<H>: ArrayLength,
|
|
||||||
K: KemCoreWrapper,
|
|
||||||
{
|
|
||||||
fn drop(&mut self) {
|
|
||||||
self.server_nonce.zeroize();
|
|
||||||
digest::Digest::reset(&mut self.transcript_hasher);
|
|
||||||
self.shared_secret_1.zeroize();
|
|
||||||
self.shared_secret_3.zeroize();
|
|
||||||
self.kem_shared_secret.zeroize();
|
|
||||||
self.kem_ciphertext.zeroize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<G, H, K> ZeroizeOnDrop for KemKe2Builder<G, H, K>
|
|
||||||
where
|
|
||||||
G: Group,
|
|
||||||
H: Hash,
|
|
||||||
H::Core: ProxyHash,
|
|
||||||
<<H as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize: IsLess<U256>,
|
|
||||||
Le<<<H as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize, U256>: NonZero,
|
|
||||||
<<H as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize: Cmp<U256>,
|
|
||||||
OutputSize<H>: ArrayLength,
|
|
||||||
K: KemCoreWrapper,
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<G, H, K> KeyExchange for TripleDhKem<G, H, K>
|
impl<G, H, K> KeyExchange for TripleDhKem<G, H, K>
|
||||||
where
|
where
|
||||||
G: Group + 'static,
|
G: Group + 'static,
|
||||||
|
|||||||
+1
-1
@@ -307,8 +307,8 @@ mod tests {
|
|||||||
ServerRegistrationStartResult, ServerSetup,
|
ServerRegistrationStartResult, ServerSetup,
|
||||||
};
|
};
|
||||||
use hkdf::Hkdf;
|
use hkdf::Hkdf;
|
||||||
|
use rand::rand_core::UnwrapErr;
|
||||||
use rand::rngs::SysRng;
|
use rand::rngs::SysRng;
|
||||||
use rand_core::UnwrapErr;
|
|
||||||
|
|
||||||
macro_rules! test {
|
macro_rules! test {
|
||||||
($mod:ident, $point:ty) => {
|
($mod:ident, $point:ty) => {
|
||||||
|
|||||||
+19
-19
@@ -7,7 +7,7 @@
|
|||||||
//!
|
//!
|
||||||
//! ### Minimum Supported Rust Version
|
//! ### Minimum Supported Rust Version
|
||||||
//!
|
//!
|
||||||
//! Rust **1.87** or higher.
|
//! Rust **1.90** or higher.
|
||||||
//!
|
//!
|
||||||
//! # Overview
|
//! # Overview
|
||||||
//!
|
//!
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! use rand::Rng;
|
//! use rand::Rng;
|
||||||
//! use rand::rngs::SysRng;
|
//! use rand::rngs::SysRng;
|
||||||
//! use rand_core::UnwrapErr;
|
//! use rand::rand_core::UnwrapErr;
|
||||||
//!
|
//!
|
||||||
//! let mut rng = UnwrapErr(SysRng);
|
//! let mut rng = UnwrapErr(SysRng);
|
||||||
//! let server_setup = ServerSetup::<Default>::new(&mut rng);
|
//! let server_setup = ServerSetup::<Default>::new(&mut rng);
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
//! use opaque_vx::ClientRegistration;
|
//! use opaque_vx::ClientRegistration;
|
||||||
//! use rand::Rng;
|
//! use rand::Rng;
|
||||||
//! use rand::rngs::SysRng;
|
//! use rand::rngs::SysRng;
|
||||||
//! use rand_core::UnwrapErr;
|
//! use rand::rand_core::UnwrapErr;
|
||||||
//!
|
//!
|
||||||
//! let mut client_rng = UnwrapErr(SysRng);
|
//! let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! let client_registration_start_result =
|
//! let client_registration_start_result =
|
||||||
@@ -159,7 +159,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -207,7 +207,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -256,7 +256,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -308,7 +308,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! use opaque_vx::ClientLogin;
|
//! use opaque_vx::ClientLogin;
|
||||||
//!
|
//!
|
||||||
//! let mut client_rng = UnwrapErr(SysRng);
|
//! let mut client_rng = UnwrapErr(SysRng);
|
||||||
@@ -345,7 +345,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -416,7 +416,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -474,7 +474,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -572,7 +572,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -670,7 +670,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -783,7 +783,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -830,7 +830,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -888,7 +888,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -948,7 +948,7 @@
|
|||||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||||
//! # }
|
//! # }
|
||||||
//! # use rand::{rngs::SysRng, Rng};
|
//! # use rand::{rngs::SysRng, Rng};
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||||
//! # &mut client_rng,
|
//! # &mut client_rng,
|
||||||
@@ -1021,7 +1021,7 @@
|
|||||||
//! # use generic_array::{GenericArray, typenum::U0};
|
//! # use generic_array::{GenericArray, typenum::U0};
|
||||||
//! # use opaque_vx::{CipherSuite, ClientLogin, ClientRegistration, ClientRegistrationFinishParameters, ServerRegistration, keypair::{PrivateKey, PublicKey}, key_exchange::{KeyExchange, group::Group, tripledh::DiffieHellman}};
|
//! # use opaque_vx::{CipherSuite, ClientLogin, ClientRegistration, ClientRegistrationFinishParameters, ServerRegistration, keypair::{PrivateKey, PublicKey}, key_exchange::{KeyExchange, group::Group, tripledh::DiffieHellman}};
|
||||||
//! # use rand::rngs::SysRng;
|
//! # use rand::rngs::SysRng;
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//!
|
//!
|
||||||
//! type Ristretto255 = <<Default as CipherSuite>::KeyExchange as KeyExchange>::Group;
|
//! type Ristretto255 = <<Default as CipherSuite>::KeyExchange as KeyExchange>::Group;
|
||||||
//! # struct Default;
|
//! # struct Default;
|
||||||
@@ -1118,7 +1118,7 @@
|
|||||||
//! # use opaque_vx::{CipherSuite, ClientLogin, ClientRegistration, ClientRegistrationFinishParameters, keypair::{PrivateKey, PublicKey}, key_exchange::{KeyExchange, group::Group, tripledh::DiffieHellman}};
|
//! # use opaque_vx::{CipherSuite, ClientLogin, ClientRegistration, ClientRegistrationFinishParameters, keypair::{PrivateKey, PublicKey}, key_exchange::{KeyExchange, group::Group, tripledh::DiffieHellman}};
|
||||||
//! # use rand::rngs::SysRng;
|
//! # use rand::rngs::SysRng;
|
||||||
//! # use rand::Rng;
|
//! # use rand::Rng;
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//!
|
//!
|
||||||
//! type Ristretto255 = <<Default as CipherSuite>::KeyExchange as KeyExchange>::Group;
|
//! type Ristretto255 = <<Default as CipherSuite>::KeyExchange as KeyExchange>::Group;
|
||||||
//! # type Hash = <<Default as CipherSuite>::KeyExchange as KeyExchange>::Hash;
|
//! # type Hash = <<Default as CipherSuite>::KeyExchange as KeyExchange>::Hash;
|
||||||
@@ -1277,7 +1277,7 @@
|
|||||||
//! # use opaque_vx::errors::ProtocolError;
|
//! # use opaque_vx::errors::ProtocolError;
|
||||||
//! # use rand::rngs::SysRng;
|
//! # use rand::rngs::SysRng;
|
||||||
//! # use rand::Rng;
|
//! # use rand::Rng;
|
||||||
//! # use rand_core::UnwrapErr;
|
//! # use rand::rand_core::UnwrapErr;
|
||||||
//! # use std::default::Default;
|
//! # use std::default::Default;
|
||||||
//! # #[cfg(feature = "argon2")]
|
//! # #[cfg(feature = "argon2")]
|
||||||
//! # {
|
//! # {
|
||||||
|
|||||||
+22
-6
@@ -233,6 +233,10 @@ impl<CS: CipherSuite> RegistrationRequest<CS> {
|
|||||||
|
|
||||||
/// Deserialization from bytes
|
/// Deserialization from bytes
|
||||||
pub fn deserialize(input: &[u8]) -> Result<Self, ProtocolError> {
|
pub fn deserialize(input: &[u8]) -> Result<Self, ProtocolError> {
|
||||||
|
let elem_len = <OprfGroup<CS> as voprf::Group>::ElemLen::USIZE;
|
||||||
|
if input.len() < elem_len {
|
||||||
|
return Err(ProtocolError::SerializationError);
|
||||||
|
}
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
blinded_element: BlindedElement::deserialize(input)?,
|
blinded_element: BlindedElement::deserialize(input)?,
|
||||||
})
|
})
|
||||||
@@ -260,8 +264,12 @@ impl<CS: CipherSuite> RegistrationResponse<CS> {
|
|||||||
|
|
||||||
/// Deserialization from bytes
|
/// Deserialization from bytes
|
||||||
pub fn deserialize(mut input: &[u8]) -> Result<Self, ProtocolError> {
|
pub fn deserialize(mut input: &[u8]) -> Result<Self, ProtocolError> {
|
||||||
let evaluation_element = EvaluationElement::deserialize(input)?;
|
let elem_len = EvaluationElementLen::<CS::OprfCs>::USIZE;
|
||||||
input = &input[EvaluationElementLen::<CS::OprfCs>::USIZE..];
|
if input.len() < elem_len {
|
||||||
|
return Err(ProtocolError::SerializationError);
|
||||||
|
}
|
||||||
|
let evaluation_element = EvaluationElement::deserialize(&input[..elem_len])?;
|
||||||
|
input = &input[elem_len..];
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
evaluation_element,
|
evaluation_element,
|
||||||
@@ -360,8 +368,12 @@ impl<CS: CipherSuite> CredentialRequest<CS> {
|
|||||||
where
|
where
|
||||||
<CS::KeyExchange as KeyExchange>::KE1Message: Deserialize,
|
<CS::KeyExchange as KeyExchange>::KE1Message: Deserialize,
|
||||||
{
|
{
|
||||||
let blinded_element = BlindedElement::deserialize(input)?;
|
let elem_len = BlindedElementLen::<CS::OprfCs>::USIZE;
|
||||||
*input = &input[BlindedElementLen::<CS::OprfCs>::USIZE..];
|
if input.len() < elem_len {
|
||||||
|
return Err(ProtocolError::SerializationError);
|
||||||
|
}
|
||||||
|
let blinded_element = BlindedElement::deserialize(&input[..elem_len])?;
|
||||||
|
*input = &input[elem_len..];
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
blinded_element,
|
blinded_element,
|
||||||
@@ -415,8 +427,12 @@ impl<CS: CipherSuite> CredentialResponse<CS> {
|
|||||||
where
|
where
|
||||||
<CS::KeyExchange as KeyExchange>::KE2Message: Deserialize,
|
<CS::KeyExchange as KeyExchange>::KE2Message: Deserialize,
|
||||||
{
|
{
|
||||||
let evaluation_element = EvaluationElement::deserialize(input)?;
|
let elem_len = EvaluationElementLen::<CS::OprfCs>::USIZE;
|
||||||
input = &input[EvaluationElementLen::<CS::OprfCs>::USIZE..];
|
if input.len() < elem_len {
|
||||||
|
return Err(ProtocolError::SerializationError);
|
||||||
|
}
|
||||||
|
let evaluation_element = EvaluationElement::deserialize(&input[..elem_len])?;
|
||||||
|
input = &input[elem_len..];
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
evaluation_element,
|
evaluation_element,
|
||||||
|
|||||||
+12
-4
@@ -289,8 +289,12 @@ impl<CS: CipherSuite> ClientRegistration<CS> {
|
|||||||
|
|
||||||
/// Deserialization from bytes
|
/// Deserialization from bytes
|
||||||
pub fn deserialize(mut input: &[u8]) -> Result<Self, ProtocolError> {
|
pub fn deserialize(mut input: &[u8]) -> Result<Self, ProtocolError> {
|
||||||
let oprf_client = OprfClient::deserialize(input)?;
|
let client_len = OprfClientLen::<CS::OprfCs>::USIZE;
|
||||||
input = &input[OprfClientLen::<CS::OprfCs>::USIZE..];
|
if input.len() < client_len {
|
||||||
|
return Err(ProtocolError::SerializationError);
|
||||||
|
}
|
||||||
|
let oprf_client = OprfClient::deserialize(&input[..client_len])?;
|
||||||
|
input = &input[client_len..];
|
||||||
|
|
||||||
let blinded_element = BlindedElement::deserialize(input)?;
|
let blinded_element = BlindedElement::deserialize(input)?;
|
||||||
|
|
||||||
@@ -486,8 +490,12 @@ impl<CS: CipherSuite> ClientLogin<CS> {
|
|||||||
<CS::KeyExchange as KeyExchange>::KE1Message: Deserialize + Serialize,
|
<CS::KeyExchange as KeyExchange>::KE1Message: Deserialize + Serialize,
|
||||||
<CS::KeyExchange as KeyExchange>::KE1State: Deserialize + Serialize,
|
<CS::KeyExchange as KeyExchange>::KE1State: Deserialize + Serialize,
|
||||||
{
|
{
|
||||||
let oprf_client = OprfClient::deserialize(input)?;
|
let client_len = OprfClientLen::<CS::OprfCs>::USIZE;
|
||||||
input = &input[OprfClientLen::<CS::OprfCs>::USIZE..];
|
if input.len() < client_len {
|
||||||
|
return Err(ProtocolError::SerializationError);
|
||||||
|
}
|
||||||
|
let oprf_client = OprfClient::deserialize(&input[..client_len])?;
|
||||||
|
input = &input[client_len..];
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
oprf_client,
|
oprf_client,
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ use generic_array::typenum::{Sum, Unsigned};
|
|||||||
use proptest::collection::vec;
|
use proptest::collection::vec;
|
||||||
use proptest::prelude::*;
|
use proptest::prelude::*;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
use rand::rand_core::UnwrapErr;
|
||||||
use rand::rngs::SysRng;
|
use rand::rngs::SysRng;
|
||||||
use rand_core::UnwrapErr;
|
|
||||||
use voprf::Group as _;
|
use voprf::Group as _;
|
||||||
|
|
||||||
use crate::ciphersuite::{CipherSuite, KeGroup, OprfGroup, OprfHash};
|
use crate::ciphersuite::{CipherSuite, KeGroup, OprfGroup, OprfHash};
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ use generic_array::{ArrayLength, GenericArray};
|
|||||||
#[cfg(feature = "kem")]
|
#[cfg(feature = "kem")]
|
||||||
use ml_kem::MlKem768;
|
use ml_kem::MlKem768;
|
||||||
use rand::SeedableRng;
|
use rand::SeedableRng;
|
||||||
|
use rand::rand_core::UnwrapErr;
|
||||||
use rand::rngs::SysRng;
|
use rand::rngs::SysRng;
|
||||||
use rand_chacha::ChaCha20Rng;
|
use rand_chacha::ChaCha20Rng;
|
||||||
use rand_core::UnwrapErr;
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use subtle::ConstantTimeEq;
|
use subtle::ConstantTimeEq;
|
||||||
use voprf::Group as _;
|
use voprf::Group as _;
|
||||||
@@ -738,16 +738,12 @@ fn generate_test_vectors() -> Result<(), ProtocolError> {
|
|||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
output.push_str(
|
output.push_str(
|
||||||
"\
|
"\
|
||||||
|
// SPDX-License-Identifier: MIT OR Apache-2.0\n\
|
||||||
|
// Copyright (c) VexaHub and contributors.\n\
|
||||||
// Copyright (c) Meta Platforms, Inc. and affiliates.\n\
|
// Copyright (c) Meta Platforms, Inc. and affiliates.\n\
|
||||||
//\n\
|
//\n\
|
||||||
// This source code is dual-licensed under either the MIT license found in the\n\
|
|
||||||
// LICENSE-MIT file in the root directory of this source tree or the Apache\n\
|
|
||||||
// License, Version 2.0 found in the LICENSE-APACHE file in the root directory\n\
|
|
||||||
// of this source tree. You may select, at your option, one of the above-listed\n\
|
|
||||||
// licenses.\n\
|
|
||||||
//\n\
|
|
||||||
// To regenerate these test vectors, run:\n\
|
// To regenerate these test vectors, run:\n\
|
||||||
// FULL_TEST_VECTORS_FILE=src/tests/full_test_vectors.rs cargo test --features curve25519,ecdsa,ed25519 -- generate_test_vectors\n\
|
// FULL_TEST_VECTORS_FILE=src/tests/full_test_vectors.rs cargo test --features curve25519,ecdsa,ed25519,kem -- generate_test_vectors\n\
|
||||||
\n\
|
\n\
|
||||||
#![allow(clippy::duplicated_attributes)]\n\
|
#![allow(clippy::duplicated_attributes)]\n\
|
||||||
\n",
|
\n",
|
||||||
|
|||||||
+519
-519
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@ use core::cmp::min;
|
|||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
|
||||||
use core::convert::Infallible;
|
use core::convert::Infallible;
|
||||||
use rand_core::{TryCryptoRng, TryRng};
|
use rand::rand_core::{TryCryptoRng, TryRng};
|
||||||
|
|
||||||
/// A simple implementation of `Rng` for testing purposes.
|
/// A simple implementation of `Rng` for testing purposes.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ use digest::OutputSizeUser;
|
|||||||
use generic_array::typenum::Sum;
|
use generic_array::typenum::Sum;
|
||||||
use generic_array::{ArrayLength, GenericArray};
|
use generic_array::{ArrayLength, GenericArray};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
use rand::rand_core::UnwrapErr;
|
||||||
use rand::rngs::SysRng;
|
use rand::rngs::SysRng;
|
||||||
use rand_core::UnwrapErr;
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|||||||
Reference in New Issue
Block a user