Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c231be1217
|
||
|
|
0d257aaf78
|
||
|
|
0e9eeb10b2
|
||
|
|
09286d34fc
|
||
|
|
b9b8699ee7
|
||
|
|
2e1bcfe4c2
|
+11
-5
@@ -1,6 +1,12 @@
|
||||
.vs
|
||||
.vscode/
|
||||
src/.DS_Store
|
||||
/target
|
||||
Cargo.lock
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
pkg/
|
||||
demo/
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
+19
-1
@@ -1,6 +1,24 @@
|
||||
# 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`.
|
||||
|
||||
|
||||
Generated
+1914
File diff suppressed because it is too large
Load Diff
+14
-14
@@ -14,7 +14,7 @@ name = "opaque-vx"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/vexahub/opaque-vx"
|
||||
rust-version = "1.90"
|
||||
version = "1.0.0-pre.0"
|
||||
version = "1.0.0-rc.0"
|
||||
|
||||
[features]
|
||||
argon2 = ["dep:argon2"]
|
||||
@@ -22,7 +22,7 @@ curve25519 = ["dep:curve25519-dalek"]
|
||||
default = ["ristretto255", "serde"]
|
||||
ecdsa = ["dep:ecdsa"]
|
||||
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"]
|
||||
serde = [
|
||||
"dep:serde",
|
||||
@@ -38,19 +38,21 @@ serde = [
|
||||
std = ["dep:getrandom", "rand/std"]
|
||||
|
||||
[dependencies]
|
||||
argon2 = { version = "0.6.0-rc", default-features = false, features = [
|
||||
argon2 = { version = "0.6.0-rc.8", default-features = false, features = [
|
||||
"zeroize",
|
||||
"alloc",
|
||||
], optional = true }
|
||||
curve25519-dalek = { version = "5.0.0-rc", default-features = false, features = [
|
||||
curve25519-dalek = { version = "5", default-features = false, features = [
|
||||
"zeroize",
|
||||
], optional = true }
|
||||
derive-where = { version = "1.6", features = ["zeroize-on-drop"] }
|
||||
digest = { version = "0.11", features = ["zeroize"] }
|
||||
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",
|
||||
], optional = true }
|
||||
ed25519-dalek = { version = "3.0.0-rc", default-features = false, features = [
|
||||
ed25519-dalek = { version = "3", default-features = false, features = [
|
||||
"zeroize",
|
||||
"digest",
|
||||
"hazmat",
|
||||
], optional = true }
|
||||
@@ -58,17 +60,16 @@ elliptic-curve = { version = "0.14", features = ["sec1"] }
|
||||
generic-array = { version = "1.4", features = ["hybrid-array-0_4", "zeroize"] }
|
||||
hybrid-array = { version = "0.4", features = ["extra-sizes", "zeroize"] }
|
||||
hkdf = "0.13"
|
||||
hmac = "0.13"
|
||||
hmac = { version = "0.13", features = ["zeroize"] }
|
||||
ml-kem = { version = "0.3", default-features = false, features = [
|
||||
"zeroize",
|
||||
], optional = true }
|
||||
rand = { version = "0.10", default-features = false }
|
||||
rand_core = { version = "0.10", default-features = false, optional = true }
|
||||
serde = { version = "1", default-features = false, features = [
|
||||
"derive",
|
||||
], optional = true }
|
||||
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",
|
||||
] }
|
||||
zeroize = { version = "1.9", features = ["zeroize_derive"] }
|
||||
@@ -79,19 +80,18 @@ getrandom = { version = "0.4", features = ["wasm_js"], optional = true }
|
||||
[dev-dependencies]
|
||||
anyhow = "1"
|
||||
bincode-next = { version = "3", features = ["serde", "alloc"] }
|
||||
chacha20poly1305 = "0.11"
|
||||
chacha20poly1305 = { version = "0.11", features = ["zeroize"] }
|
||||
criterion = "0.8"
|
||||
cryptoki = "0.12"
|
||||
elliptic-curve = { version = "0.14", features = ["alloc", "pkcs8"] }
|
||||
rand_core = { version = "0.10", default-features = false }
|
||||
hex = "0.4"
|
||||
p256 = { version = "0.14.0-rc.15", default-features = false, features = [
|
||||
p256 = { version = "0.14", default-features = false, features = [
|
||||
"ecdsa",
|
||||
"hash2curve",
|
||||
"pkcs8",
|
||||
"oprf",
|
||||
] }
|
||||
p384 = { version = "0.14.0-rc.15", default-features = false, features = [
|
||||
p384 = { version = "0.14", default-features = false, features = [
|
||||
"hash2curve",
|
||||
"pkcs8",
|
||||
"oprf",
|
||||
@@ -106,7 +106,7 @@ proptest = "1"
|
||||
rand = "0.10"
|
||||
rand_chacha = "0.10"
|
||||
regex = "1"
|
||||
sha2 = { version = "0.11", default-features = false }
|
||||
sha2 = { version = "0.11", default-features = false, features = ["zeroize"] }
|
||||
thiserror = "2"
|
||||
# MSRV
|
||||
rustyline = "18"
|
||||
|
||||
@@ -20,7 +20,7 @@ OPAQUE is a PKI-free aPAKE that is secure against pre-computation attacks and ca
|
||||
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
|
||||
the [examples](./examples) directory.
|
||||
|
||||
@@ -30,12 +30,12 @@ Installation
|
||||
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
|
||||
|
||||
Rust **1.89** or higher.
|
||||
Rust **1.90** or higher.
|
||||
|
||||
Audit
|
||||
-----
|
||||
|
||||
+1
-1
@@ -7,8 +7,8 @@ extern crate criterion;
|
||||
|
||||
use criterion::Criterion;
|
||||
use opaque_vx::*;
|
||||
use rand::rand_core::UnwrapErr;
|
||||
use rand::rngs::SysRng;
|
||||
use rand_core::UnwrapErr;
|
||||
|
||||
#[cfg(feature = "ristretto255")]
|
||||
static SUFFIX: &str = "ristretto255";
|
||||
|
||||
@@ -35,7 +35,7 @@ use opaque_vx::{
|
||||
CredentialResponse, RegistrationRequest, RegistrationResponse, RegistrationUpload, ServerLogin,
|
||||
ServerLoginParameters, ServerRegistration, ServerSetup,
|
||||
};
|
||||
use rand_core::UnwrapErr;
|
||||
use rand::rand_core::UnwrapErr;
|
||||
use rustyline::Editor;
|
||||
use rustyline::error::ReadlineError;
|
||||
use rustyline::history::DefaultHistory;
|
||||
|
||||
@@ -28,7 +28,7 @@ use opaque_vx::{
|
||||
CredentialResponse, RegistrationRequest, RegistrationResponse, RegistrationUpload, ServerLogin,
|
||||
ServerLoginParameters, ServerRegistration, ServerRegistrationLen, ServerSetup,
|
||||
};
|
||||
use rand_core::UnwrapErr;
|
||||
use rand::rand_core::UnwrapErr;
|
||||
use rustyline::Editor;
|
||||
use rustyline::error::ReadlineError;
|
||||
use rustyline::history::DefaultHistory;
|
||||
|
||||
+3
-1
@@ -48,6 +48,7 @@ pub trait Hash:
|
||||
+ FixedOutputReset
|
||||
+ CoreProxy
|
||||
+ Clone
|
||||
+ zeroize::ZeroizeOnDrop
|
||||
where
|
||||
<Self as CoreProxy>::Core: ProxyHash,
|
||||
<<Self as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize: IsLess<U256>,
|
||||
@@ -64,7 +65,8 @@ impl<
|
||||
+ BlockSizeUser
|
||||
+ FixedOutputReset
|
||||
+ CoreProxy
|
||||
+ Clone,
|
||||
+ Clone
|
||||
+ zeroize::ZeroizeOnDrop,
|
||||
> Hash for T
|
||||
where
|
||||
<T as CoreProxy>::Core: ProxyHash,
|
||||
|
||||
@@ -429,8 +429,8 @@ mod test {
|
||||
use std::iter;
|
||||
|
||||
use ed25519_dalek::{Signer, SigningKey, Verifier, VerifyingKey};
|
||||
use rand::rand_core::UnwrapErr;
|
||||
use rand::rngs::SysRng;
|
||||
use rand_core::UnwrapErr;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
||||
@@ -111,8 +111,8 @@ fn ecdsa() {
|
||||
use p256::ecdsa::signature::RandomizedDigestSigner;
|
||||
use p256::ecdsa::{Signature, SigningKey, VerifyingKey};
|
||||
use p256::{NistP256, PublicKey};
|
||||
use rand::rand_core::UnwrapErr;
|
||||
use rand::rngs::SysRng;
|
||||
use rand_core::UnwrapErr;
|
||||
use sha2::Sha256;
|
||||
|
||||
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 rand::{CryptoRng, Rng};
|
||||
use subtle::{ConstantTimeEq, CtOption};
|
||||
use zeroize::{Zeroize, ZeroizeOnDrop};
|
||||
|
||||
use super::{
|
||||
Deserialize, GenerateKe1Result, GenerateKe2Result, GenerateKe3Result, KeyExchange, Serialize,
|
||||
@@ -69,7 +68,7 @@ pub struct Ke2State<H: OutputSizeUser> {
|
||||
serialize = "H: serde::Serialize, PublicKey<G>: serde::Serialize",
|
||||
))
|
||||
)]
|
||||
#[derive_where(Clone)]
|
||||
#[derive_where(Clone, ZeroizeOnDrop)]
|
||||
#[derive_where(Debug, Eq, Hash, PartialEq; H, PublicKey<G>)]
|
||||
pub struct Ke2Builder<G: Group, H: Hash>
|
||||
where
|
||||
@@ -80,7 +79,9 @@ where
|
||||
{
|
||||
server_nonce: GenericArray<u8, NonceLen>,
|
||||
transcript_hasher: H,
|
||||
#[derive_where(skip(Zeroize))]
|
||||
client_e_pk: PublicKey<G>,
|
||||
#[derive_where(skip(Zeroize))]
|
||||
server_e_pk: PublicKey<G>,
|
||||
shared_secret_1: 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>
|
||||
where
|
||||
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::{ArrayLength, GenericArray};
|
||||
use hybrid_array::ArraySize;
|
||||
#[allow(deprecated)]
|
||||
use ml_kem::ExpandedKeyEncoding;
|
||||
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,
|
||||
};
|
||||
use rand::{CryptoRng, Rng};
|
||||
use subtle::{ConstantTimeEq, CtOption};
|
||||
use zeroize::{Zeroize, ZeroizeOnDrop};
|
||||
|
||||
use super::shared::{self, Ke1Message, Ke1State, NonceLen};
|
||||
use super::{
|
||||
@@ -55,7 +52,7 @@ pub trait KemCoreWrapper {
|
||||
type EncapsulationKey: Clone;
|
||||
|
||||
/// Secret key type used for decapsulation operations.
|
||||
type DecapsulationKey: Clone + ZeroizeOnDrop;
|
||||
type DecapsulationKey: Clone + zeroize::ZeroizeOnDrop;
|
||||
|
||||
/// Length (in bytes) of the serialized public key.
|
||||
type EncapsulationKeyLen: ArrayLength + ArraySize;
|
||||
@@ -116,7 +113,7 @@ pub trait KemCoreWrapper {
|
||||
/// which is required by `ml-kem 0.3.x`.
|
||||
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;
|
||||
|
||||
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;
|
||||
#[allow(deprecated)]
|
||||
type RcDecapsulationKeyLen<K> =
|
||||
<<K as MlKemTrait>::DecapsulationKey as ExpandedKeyEncoding>::EncodedSize;
|
||||
type RcDecapsulationKeyLen<K> = <<K as MlKemTrait>::DecapsulationKey as KeySizeUser>::KeySize;
|
||||
type RcCiphertextLen<K> = <K as MlKemTrait>::CiphertextSize;
|
||||
type RcSharedSecretLen<K> = <K as MlKemTrait>::SharedKeySize;
|
||||
|
||||
#[allow(deprecated)]
|
||||
impl<K> KemCoreWrapper for K
|
||||
where
|
||||
K: MlKemTrait,
|
||||
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,
|
||||
RcDecapsulationKeyLen<K>: ArrayLength + ArraySize,
|
||||
RcCiphertextLen<K>: ArrayLength + ArraySize,
|
||||
@@ -185,7 +180,7 @@ where
|
||||
fn serialize_decapsulation_key(
|
||||
key: &Self::DecapsulationKey,
|
||||
) -> 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(
|
||||
@@ -193,10 +188,9 @@ where
|
||||
) -> Result<Self::DecapsulationKey, ProtocolError> {
|
||||
let bytes: GenericArray<u8, RcDecapsulationKeyLen<K>> =
|
||||
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)?;
|
||||
K::DecapsulationKey::from_expanded_bytes(&key)
|
||||
.map_err(|_| ProtocolError::SerializationError)
|
||||
Ok(KeyInit::new(&seed))
|
||||
}
|
||||
|
||||
fn encapsulate<R: Rng + CryptoRng>(
|
||||
@@ -289,7 +283,7 @@ where
|
||||
|
||||
/// Server builder placeholder capturing the data needed to finish the KEM
|
||||
/// exchange.
|
||||
#[derive_where(Clone)]
|
||||
#[derive_where(Clone, ZeroizeOnDrop)]
|
||||
pub struct KemKe2Builder<G: Group, H: Hash, K: KemCoreWrapper>
|
||||
where
|
||||
H::Core: ProxyHash,
|
||||
@@ -300,10 +294,13 @@ where
|
||||
{
|
||||
server_nonce: GenericArray<u8, NonceLen>,
|
||||
transcript_hasher: H,
|
||||
#[derive_where(skip(Zeroize))]
|
||||
client_e_pk: PublicKey<G>,
|
||||
#[derive_where(skip(Zeroize))]
|
||||
server_e_pk: PublicKey<G>,
|
||||
shared_secret_1: GenericArray<u8, G::PkLen>,
|
||||
shared_secret_3: GenericArray<u8, G::PkLen>,
|
||||
#[derive_where(skip(Zeroize))]
|
||||
kem_encapsulation_key: GenericArray<u8, K::EncapsulationKeyLen>,
|
||||
kem_ciphertext: GenericArray<u8, K::CiphertextLen>,
|
||||
kem_shared_secret: GenericArray<u8, K::SharedSecretLen>,
|
||||
@@ -335,40 +332,6 @@ where
|
||||
/// Third message remains the same as `TripleDH`.
|
||||
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>
|
||||
where
|
||||
G: Group + 'static,
|
||||
|
||||
+1
-1
@@ -307,8 +307,8 @@ mod tests {
|
||||
ServerRegistrationStartResult, ServerSetup,
|
||||
};
|
||||
use hkdf::Hkdf;
|
||||
use rand::rand_core::UnwrapErr;
|
||||
use rand::rngs::SysRng;
|
||||
use rand_core::UnwrapErr;
|
||||
|
||||
macro_rules! test {
|
||||
($mod:ident, $point:ty) => {
|
||||
|
||||
+19
-19
@@ -7,7 +7,7 @@
|
||||
//!
|
||||
//! ### Minimum Supported Rust Version
|
||||
//!
|
||||
//! Rust **1.87** or higher.
|
||||
//! Rust **1.90** or higher.
|
||||
//!
|
||||
//! # Overview
|
||||
//!
|
||||
@@ -64,7 +64,7 @@
|
||||
//! # }
|
||||
//! use rand::Rng;
|
||||
//! use rand::rngs::SysRng;
|
||||
//! use rand_core::UnwrapErr;
|
||||
//! use rand::rand_core::UnwrapErr;
|
||||
//!
|
||||
//! let mut rng = UnwrapErr(SysRng);
|
||||
//! let server_setup = ServerSetup::<Default>::new(&mut rng);
|
||||
@@ -122,7 +122,7 @@
|
||||
//! use opaque_vx::ClientRegistration;
|
||||
//! use rand::Rng;
|
||||
//! use rand::rngs::SysRng;
|
||||
//! use rand_core::UnwrapErr;
|
||||
//! use rand::rand_core::UnwrapErr;
|
||||
//!
|
||||
//! let mut client_rng = UnwrapErr(SysRng);
|
||||
//! let client_registration_start_result =
|
||||
@@ -159,7 +159,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -207,7 +207,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -256,7 +256,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -308,7 +308,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! use opaque_vx::ClientLogin;
|
||||
//!
|
||||
//! let mut client_rng = UnwrapErr(SysRng);
|
||||
@@ -345,7 +345,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -416,7 +416,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -474,7 +474,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -572,7 +572,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -670,7 +670,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -783,7 +783,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -830,7 +830,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -888,7 +888,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -948,7 +948,7 @@
|
||||
//! # type Ksf = opaque_vx::ksf::Identity;
|
||||
//! # }
|
||||
//! # use rand::{rngs::SysRng, Rng};
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # let mut client_rng = UnwrapErr(SysRng);
|
||||
//! # let client_registration_start_result = ClientRegistration::<Default>::start(
|
||||
//! # &mut client_rng,
|
||||
@@ -1021,7 +1021,7 @@
|
||||
//! # 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 rand::rngs::SysRng;
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//!
|
||||
//! type Ristretto255 = <<Default as CipherSuite>::KeyExchange as KeyExchange>::Group;
|
||||
//! # struct Default;
|
||||
@@ -1118,7 +1118,7 @@
|
||||
//! # use opaque_vx::{CipherSuite, ClientLogin, ClientRegistration, ClientRegistrationFinishParameters, keypair::{PrivateKey, PublicKey}, key_exchange::{KeyExchange, group::Group, tripledh::DiffieHellman}};
|
||||
//! # use rand::rngs::SysRng;
|
||||
//! # use rand::Rng;
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//!
|
||||
//! type Ristretto255 = <<Default as CipherSuite>::KeyExchange as KeyExchange>::Group;
|
||||
//! # type Hash = <<Default as CipherSuite>::KeyExchange as KeyExchange>::Hash;
|
||||
@@ -1277,7 +1277,7 @@
|
||||
//! # use opaque_vx::errors::ProtocolError;
|
||||
//! # use rand::rngs::SysRng;
|
||||
//! # use rand::Rng;
|
||||
//! # use rand_core::UnwrapErr;
|
||||
//! # use rand::rand_core::UnwrapErr;
|
||||
//! # use std::default::Default;
|
||||
//! # #[cfg(feature = "argon2")]
|
||||
//! # {
|
||||
|
||||
+22
-6
@@ -233,6 +233,10 @@ impl<CS: CipherSuite> RegistrationRequest<CS> {
|
||||
|
||||
/// Deserialization from bytes
|
||||
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 {
|
||||
blinded_element: BlindedElement::deserialize(input)?,
|
||||
})
|
||||
@@ -260,8 +264,12 @@ impl<CS: CipherSuite> RegistrationResponse<CS> {
|
||||
|
||||
/// Deserialization from bytes
|
||||
pub fn deserialize(mut input: &[u8]) -> Result<Self, ProtocolError> {
|
||||
let evaluation_element = EvaluationElement::deserialize(input)?;
|
||||
input = &input[EvaluationElementLen::<CS::OprfCs>::USIZE..];
|
||||
let elem_len = 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 {
|
||||
evaluation_element,
|
||||
@@ -360,8 +368,12 @@ impl<CS: CipherSuite> CredentialRequest<CS> {
|
||||
where
|
||||
<CS::KeyExchange as KeyExchange>::KE1Message: Deserialize,
|
||||
{
|
||||
let blinded_element = BlindedElement::deserialize(input)?;
|
||||
*input = &input[BlindedElementLen::<CS::OprfCs>::USIZE..];
|
||||
let elem_len = 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 {
|
||||
blinded_element,
|
||||
@@ -415,8 +427,12 @@ impl<CS: CipherSuite> CredentialResponse<CS> {
|
||||
where
|
||||
<CS::KeyExchange as KeyExchange>::KE2Message: Deserialize,
|
||||
{
|
||||
let evaluation_element = EvaluationElement::deserialize(input)?;
|
||||
input = &input[EvaluationElementLen::<CS::OprfCs>::USIZE..];
|
||||
let elem_len = 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 {
|
||||
evaluation_element,
|
||||
|
||||
+12
-4
@@ -289,8 +289,12 @@ impl<CS: CipherSuite> ClientRegistration<CS> {
|
||||
|
||||
/// Deserialization from bytes
|
||||
pub fn deserialize(mut input: &[u8]) -> Result<Self, ProtocolError> {
|
||||
let oprf_client = OprfClient::deserialize(input)?;
|
||||
input = &input[OprfClientLen::<CS::OprfCs>::USIZE..];
|
||||
let client_len = 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)?;
|
||||
|
||||
@@ -486,8 +490,12 @@ impl<CS: CipherSuite> ClientLogin<CS> {
|
||||
<CS::KeyExchange as KeyExchange>::KE1Message: Deserialize + Serialize,
|
||||
<CS::KeyExchange as KeyExchange>::KE1State: Deserialize + Serialize,
|
||||
{
|
||||
let oprf_client = OprfClient::deserialize(input)?;
|
||||
input = &input[OprfClientLen::<CS::OprfCs>::USIZE..];
|
||||
let client_len = 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 {
|
||||
oprf_client,
|
||||
|
||||
@@ -12,8 +12,8 @@ use generic_array::typenum::{Sum, Unsigned};
|
||||
use proptest::collection::vec;
|
||||
use proptest::prelude::*;
|
||||
use rand::Rng;
|
||||
use rand::rand_core::UnwrapErr;
|
||||
use rand::rngs::SysRng;
|
||||
use rand_core::UnwrapErr;
|
||||
use voprf::Group as _;
|
||||
|
||||
use crate::ciphersuite::{CipherSuite, KeGroup, OprfGroup, OprfHash};
|
||||
|
||||
@@ -15,9 +15,9 @@ use generic_array::{ArrayLength, GenericArray};
|
||||
#[cfg(feature = "kem")]
|
||||
use ml_kem::MlKem768;
|
||||
use rand::SeedableRng;
|
||||
use rand::rand_core::UnwrapErr;
|
||||
use rand::rngs::SysRng;
|
||||
use rand_chacha::ChaCha20Rng;
|
||||
use rand_core::UnwrapErr;
|
||||
use serde_json::Value;
|
||||
use subtle::ConstantTimeEq;
|
||||
use voprf::Group as _;
|
||||
@@ -738,16 +738,12 @@ fn generate_test_vectors() -> Result<(), ProtocolError> {
|
||||
#[rustfmt::skip]
|
||||
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\
|
||||
//\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\
|
||||
// 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\
|
||||
#![allow(clippy::duplicated_attributes)]\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 core::convert::Infallible;
|
||||
use rand_core::{TryCryptoRng, TryRng};
|
||||
use rand::rand_core::{TryCryptoRng, TryRng};
|
||||
|
||||
/// A simple implementation of `Rng` for testing purposes.
|
||||
///
|
||||
|
||||
@@ -26,8 +26,8 @@ use digest::OutputSizeUser;
|
||||
use generic_array::typenum::Sum;
|
||||
use generic_array::{ArrayLength, GenericArray};
|
||||
use rand::Rng;
|
||||
use rand::rand_core::UnwrapErr;
|
||||
use rand::rngs::SysRng;
|
||||
use rand_core::UnwrapErr;
|
||||
use serde_json::Value;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
|
||||
Reference in New Issue
Block a user