Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d20993872b
|
||
|
|
0d257aaf78
|
||
|
|
0e9eeb10b2
|
||
|
|
09286d34fc
|
||
|
|
b9b8699ee7
|
@@ -16,7 +16,7 @@ jobs:
|
||||
name: cargo fmt
|
||||
runs-on: linux_amd64
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
- uses: dtolnay/rust-toolchain@nightly
|
||||
with:
|
||||
components: rustfmt
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
name: cargo clippy
|
||||
runs-on: linux_amd64
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: clippy
|
||||
@@ -68,7 +68,7 @@ jobs:
|
||||
- stable
|
||||
- "1.90.0"
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
- uses: dtolnay/rust-toolchain@${{ matrix.toolchain }}
|
||||
- name: Cache cargo
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
||||
@@ -87,7 +87,7 @@ jobs:
|
||||
name: test simple_login example
|
||||
runs-on: linux_amd64
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Run expect
|
||||
run: expect -f scripts/simple_login.exp
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
name: test digital_locker example
|
||||
runs-on: linux_amd64
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Run expect
|
||||
run: expect -f scripts/digital_locker.exp
|
||||
@@ -121,7 +121,7 @@ jobs:
|
||||
- argon2
|
||||
- serde
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
@@ -139,7 +139,7 @@ jobs:
|
||||
- --features ristretto255,kem
|
||||
- ""
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Run cargo bench --no-run
|
||||
run: cargo bench --no-default-features ${{ matrix.backend_feature }} --no-run
|
||||
@@ -148,7 +148,7 @@ jobs:
|
||||
name: cargo audit
|
||||
runs-on: linux_amd64
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Install cargo-audit
|
||||
run: cargo install cargo-audit
|
||||
|
||||
@@ -8,7 +8,7 @@ jobs:
|
||||
publish:
|
||||
runs-on: linux_amd64
|
||||
steps:
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
|
||||
+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
|
||||
|
||||
+14
-2
@@ -1,12 +1,24 @@
|
||||
# Changelog
|
||||
|
||||
## 1.0.0-pre.1 (July 1, 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 (June 29, 2026)
|
||||
## 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
+1903
File diff suppressed because it is too large
Load Diff
+8
-8
@@ -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.1"
|
||||
version = "1.0.0-rc.0"
|
||||
|
||||
[features]
|
||||
argon2 = ["dep:argon2"]
|
||||
@@ -38,20 +38,20 @@ 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",
|
||||
@@ -69,7 +69,7 @@ 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"] }
|
||||
@@ -85,13 +85,13 @@ criterion = "0.8"
|
||||
cryptoki = "0.12"
|
||||
elliptic-curve = { version = "0.14", features = ["alloc", "pkcs8"] }
|
||||
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",
|
||||
|
||||
@@ -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,7 +30,7 @@ Installation
|
||||
Add the following line to the dependencies of your `Cargo.toml`:
|
||||
|
||||
```
|
||||
opaque-ke = { package = "opaque-vx", version = "1.0.0-pre.0" }
|
||||
opaque-vx = "1.0.0-rc.0"
|
||||
```
|
||||
|
||||
### Minimum Supported Rust Version
|
||||
|
||||
+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,
|
||||
|
||||
@@ -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;
|
||||
@@ -136,18 +133,16 @@ impl<R: Rng> rand::rand_core::TryRng 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
@@ -7,7 +7,7 @@
|
||||
//!
|
||||
//! ### Minimum Supported Rust Version
|
||||
//!
|
||||
//! Rust **1.87** or higher.
|
||||
//! Rust **1.90** or higher.
|
||||
//!
|
||||
//! # Overview
|
||||
//!
|
||||
|
||||
+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,
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user