Bump MSRV to v1.83 (#370)

* Fix Clippy warnings for Rust v1.86

* Bump MSRV to v1.83
This commit is contained in:
daxpedda
2025-04-15 13:31:37 -07:00
committed by GitHub
parent ff3a8b960d
commit 6b69e93dc9
17 changed files with 117 additions and 820 deletions
+3 -3
View File
@@ -23,7 +23,7 @@ jobs:
- --features serde - --features serde
toolchain: toolchain:
- stable - stable
- 1.74.0 - 1.83.0
name: test name: test
steps: steps:
- name: Checkout sources - name: Checkout sources
@@ -78,7 +78,7 @@ jobs:
matrix: matrix:
toolchain: toolchain:
- stable - stable
- 1.74.0 - 1.83.0
name: test simple_login command-line example name: test simple_login command-line example
steps: steps:
- name: install expect - name: install expect
@@ -101,7 +101,7 @@ jobs:
matrix: matrix:
toolchain: toolchain:
- stable - stable
- 1.74.0 - 1.83.0
name: test digital_locker command-line example name: test digital_locker command-line example
steps: steps:
- name: install expect - name: install expect
+2 -2
View File
@@ -8,7 +8,7 @@ license = "Apache-2.0 OR MIT"
name = "opaque-ke" name = "opaque-ke"
readme = "README.md" readme = "README.md"
repository = "https://github.com/facebook/opaque-ke" repository = "https://github.com/facebook/opaque-ke"
rust-version = "1.74" rust-version = "1.83"
version = "3.0.0" version = "3.0.0"
[features] [features]
@@ -66,7 +66,7 @@ proptest = "1"
rand = "0.8" rand = "0.8"
regex = "1" regex = "1"
# MSRV # MSRV
rustyline = "14" rustyline = "15"
scrypt = "0.11" scrypt = "0.11"
serde_json = "1" serde_json = "1"
+1 -1
View File
@@ -27,7 +27,7 @@ opaque-ke = "3"
### Minimum Supported Rust Version ### Minimum Supported Rust Version
Rust **1.74** or higher. Rust **1.83** or higher.
Audit Audit
----- -----
+1 -1
View File
@@ -77,7 +77,7 @@ confidence-threshold = 0.95
exceptions = [ exceptions = [
# Each entry is the crate and version constraint, and its specific allow # Each entry is the crate and version constraint, and its specific allow
# list # list
{ allow = ["Unicode-DFS-2016"], name = "unicode-ident", version = "*" }, { allow = ["Unicode-3.0"], name = "unicode-ident", version = "*" },
] ]
# Some crates don't have (easily) machine readable licensing information, # Some crates don't have (easily) machine readable licensing information,
+2 -2
View File
@@ -43,5 +43,5 @@ where
type Ksf: Ksf; type Ksf: Ksf;
} }
pub(crate) type OprfGroup<CS> = <<CS as CipherSuite>::OprfCs as voprf::CipherSuite>::Group; pub(crate) type OprfGroup<CS: CipherSuite> = <CS::OprfCs as voprf::CipherSuite>::Group;
pub(crate) type OprfHash<CS> = <<CS as CipherSuite>::OprfCs as voprf::CipherSuite>::Hash; pub(crate) type OprfHash<CS: CipherSuite> = <CS::OprfCs as voprf::CipherSuite>::Hash;
+12 -58
View File
@@ -10,10 +10,9 @@ use core::convert::TryFrom;
use core::ops::Add; use core::ops::Add;
use derive_where::derive_where; use derive_where::derive_where;
use digest::core_api::{BlockSizeUser, CoreProxy}; use digest::Output;
use digest::{Output, OutputSizeUser};
use generic_array::sequence::Concat; use generic_array::sequence::Concat;
use generic_array::typenum::{IsLess, IsLessOrEqual, Le, NonZero, Sum, Unsigned, U2, U256, U32}; use generic_array::typenum::{Sum, Unsigned, U2, U32};
use generic_array::{ArrayLength, GenericArray}; use generic_array::{ArrayLength, GenericArray};
use hkdf::Hkdf; use hkdf::Hkdf;
use hmac::{Hmac, Mac}; use hmac::{Hmac, Mac};
@@ -23,7 +22,7 @@ use zeroize::{Zeroize, ZeroizeOnDrop};
use crate::ciphersuite::{CipherSuite, OprfHash}; use crate::ciphersuite::{CipherSuite, OprfHash};
use crate::errors::utils::check_slice_size; use crate::errors::utils::check_slice_size;
use crate::errors::{InternalError, ProtocolError}; use crate::errors::{InternalError, ProtocolError};
use crate::hash::{Hash, OutputSize, ProxyHash}; use crate::hash::OutputSize;
use crate::key_exchange::group::KeGroup; use crate::key_exchange::group::KeGroup;
use crate::keypair::{KeyPair, PublicKey}; use crate::keypair::{KeyPair, PublicKey};
use crate::opaque::{bytestrings_from_identifiers, Identifiers}; use crate::opaque::{bytestrings_from_identifiers, Identifiers};
@@ -33,7 +32,7 @@ use crate::serialization::{Input, MacExt};
const STR_AUTH_KEY: [u8; 7] = *b"AuthKey"; const STR_AUTH_KEY: [u8; 7] = *b"AuthKey";
const STR_EXPORT_KEY: [u8; 9] = *b"ExportKey"; const STR_EXPORT_KEY: [u8; 9] = *b"ExportKey";
const STR_PRIVATE_KEY: [u8; 10] = *b"PrivateKey"; const STR_PRIVATE_KEY: [u8; 10] = *b"PrivateKey";
type NonceLen = U32; pub(crate) type NonceLen = U32;
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, ZeroizeOnDrop)] #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, ZeroizeOnDrop)]
@@ -72,15 +71,7 @@ impl TryFrom<u8> for InnerEnvelopeMode {
serde(bound = "") serde(bound = "")
)] )]
#[derive_where(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, ZeroizeOnDrop)] #[derive_where(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, ZeroizeOnDrop)]
pub(crate) struct Envelope<CS: CipherSuite> pub(crate) struct Envelope<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
pub(crate) mode: InnerEnvelopeMode, pub(crate) mode: InnerEnvelopeMode,
nonce: GenericArray<u8, NonceLen>, nonce: GenericArray<u8, NonceLen>,
hmac: Output<OprfHash<CS>>, hmac: Output<OprfHash<CS>>,
@@ -90,28 +81,15 @@ where
// asssociated key. This key is also used to derive the export_key parameter, // asssociated key. This key is also used to derive the export_key parameter,
// which is technically unrelated to the envelope's encrypted and authenticated // which is technically unrelated to the envelope's encrypted and authenticated
// contents. // contents.
pub(crate) struct OpenedEnvelope<'a, CS: CipherSuite> pub(crate) struct OpenedEnvelope<'a, CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
pub(crate) client_static_keypair: KeyPair<CS::KeGroup>, pub(crate) client_static_keypair: KeyPair<CS::KeGroup>,
pub(crate) export_key: Output<OprfHash<CS>>, pub(crate) export_key: Output<OprfHash<CS>>,
pub(crate) id_u: Input<'a, U2, <CS::KeGroup as KeGroup>::PkLen>, pub(crate) id_u: Input<'a, U2, <CS::KeGroup as KeGroup>::PkLen>,
pub(crate) id_s: Input<'a, U2, <CS::KeGroup as KeGroup>::PkLen>, pub(crate) id_s: Input<'a, U2, <CS::KeGroup as KeGroup>::PkLen>,
} }
pub(crate) struct OpenedInnerEnvelope<D: Hash> pub(crate) struct OpenedInnerEnvelope<CS: CipherSuite> {
where pub(crate) export_key: Output<OprfHash<CS>>,
D::Core: ProxyHash,
<D::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<D::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
pub(crate) export_key: Output<D>,
} }
#[cfg(not(test))] #[cfg(not(test))]
@@ -130,15 +108,7 @@ type SealResult<CS: CipherSuite> = (
pub(crate) type EnvelopeLen<CS: CipherSuite> = Sum<NonceLen, OutputSize<OprfHash<CS>>>; pub(crate) type EnvelopeLen<CS: CipherSuite> = Sum<NonceLen, OutputSize<OprfHash<CS>>>;
impl<CS: CipherSuite> Envelope<CS> impl<CS: CipherSuite> Envelope<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
pub(crate) fn seal<R: RngCore + CryptoRng>( pub(crate) fn seal<R: RngCore + CryptoRng>(
rng: &mut R, rng: &mut R,
@@ -249,7 +219,7 @@ where
&self, &self,
randomized_pwd_hasher: Hkdf<OprfHash<CS>>, randomized_pwd_hasher: Hkdf<OprfHash<CS>>,
aad: impl Iterator<Item = &'a [u8]>, aad: impl Iterator<Item = &'a [u8]>,
) -> Result<OpenedInnerEnvelope<OprfHash<CS>>, InternalError> { ) -> Result<OpenedInnerEnvelope<CS>, InternalError> {
let mut hmac_key = Output::<OprfHash<CS>>::default(); let mut hmac_key = Output::<OprfHash<CS>>::default();
let mut export_key = Output::<OprfHash<CS>>::default(); let mut export_key = Output::<OprfHash<CS>>::default();
@@ -327,15 +297,7 @@ where
fn build_inner_envelope_internal<CS: CipherSuite>( fn build_inner_envelope_internal<CS: CipherSuite>(
randomized_pwd_hasher: Hkdf<OprfHash<CS>>, randomized_pwd_hasher: Hkdf<OprfHash<CS>>,
nonce: GenericArray<u8, NonceLen>, nonce: GenericArray<u8, NonceLen>,
) -> Result<PublicKey<CS::KeGroup>, ProtocolError> ) -> Result<PublicKey<CS::KeGroup>, ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut keypair_seed = GenericArray::<_, <CS::KeGroup as KeGroup>::SkLen>::default(); let mut keypair_seed = GenericArray::<_, <CS::KeGroup as KeGroup>::SkLen>::default();
randomized_pwd_hasher randomized_pwd_hasher
.expand(&nonce.concat(STR_PRIVATE_KEY.into()), &mut keypair_seed) .expand(&nonce.concat(STR_PRIVATE_KEY.into()), &mut keypair_seed)
@@ -351,15 +313,7 @@ where
fn recover_keys_internal<CS: CipherSuite>( fn recover_keys_internal<CS: CipherSuite>(
randomized_pwd_hasher: Hkdf<OprfHash<CS>>, randomized_pwd_hasher: Hkdf<OprfHash<CS>>,
nonce: GenericArray<u8, NonceLen>, nonce: GenericArray<u8, NonceLen>,
) -> Result<KeyPair<CS::KeGroup>, ProtocolError> ) -> Result<KeyPair<CS::KeGroup>, ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut keypair_seed = GenericArray::<_, <CS::KeGroup as KeGroup>::SkLen>::default(); let mut keypair_seed = GenericArray::<_, <CS::KeGroup as KeGroup>::SkLen>::default();
randomized_pwd_hasher randomized_pwd_hasher
.expand(&nonce.concat(STR_PRIVATE_KEY.into()), &mut keypair_seed) .expand(&nonce.concat(STR_PRIVATE_KEY.into()), &mut keypair_seed)
+1 -4
View File
@@ -8,9 +8,8 @@
//! A list of error types which are produced during an execution of the protocol //! A list of error types which are produced during an execution of the protocol
use core::convert::Infallible; use core::convert::Infallible;
use core::error::Error;
use core::fmt::Debug; use core::fmt::Debug;
#[cfg(any(feature = "std", test))]
use std::error::Error;
use displaydoc::Display; use displaydoc::Display;
@@ -85,7 +84,6 @@ impl<T: Debug> Debug for InternalError<T> {
} }
} }
#[cfg(any(feature = "std", test))]
impl<T: Error> Error for InternalError<T> {} impl<T: Error> Error for InternalError<T> {}
impl InternalError { impl InternalError {
@@ -165,7 +163,6 @@ impl<T: Debug> Debug for ProtocolError<T> {
} }
} }
#[cfg(any(feature = "std", test))]
impl<T: Error> Error for ProtocolError<T> {} impl<T: Error> Error for ProtocolError<T> {}
// This is meant to express future(ly) non-trivial ways of converting the // This is meant to express future(ly) non-trivial ways of converting the
+4 -10
View File
@@ -6,9 +6,9 @@
// of this source tree. You may select, at your option, one of the above-listed // of this source tree. You may select, at your option, one of the above-listed
// licenses. // licenses.
use digest::core_api::{BlockSizeUser, OutputSizeUser}; use digest::core_api::BlockSizeUser;
use digest::Output; use digest::Output;
use generic_array::typenum::{IsLess, IsLessOrEqual, Le, NonZero, U256}; use generic_array::typenum::{IsLess, Le, NonZero, U256};
use generic_array::{ArrayLength, GenericArray}; use generic_array::{ArrayLength, GenericArray};
use rand::{CryptoRng, RngCore}; use rand::{CryptoRng, RngCore};
use zeroize::ZeroizeOnDrop; use zeroize::ZeroizeOnDrop;
@@ -33,10 +33,7 @@ where
fn generate_ke1<OprfCs: voprf::CipherSuite, R: RngCore + CryptoRng>( fn generate_ke1<OprfCs: voprf::CipherSuite, R: RngCore + CryptoRng>(
rng: &mut R, rng: &mut R,
) -> Result<(Self::KE1State, Self::KE1Message), ProtocolError> ) -> Result<(Self::KE1State, Self::KE1Message), ProtocolError>;
where
<OprfCs::Hash as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfCs::Hash as BlockSizeUser>::BlockSize>;
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
fn generate_ke2< fn generate_ke2<
@@ -57,10 +54,7 @@ where
id_u: impl Iterator<Item = &'c [u8]>, id_u: impl Iterator<Item = &'c [u8]>,
id_s: impl Iterator<Item = &'d [u8]>, id_s: impl Iterator<Item = &'d [u8]>,
context: &[u8], context: &[u8],
) -> Result<GenerateKe2Result<Self, D, G>, ProtocolError<S::Error>> ) -> Result<GenerateKe2Result<Self, D, G>, ProtocolError<S::Error>>;
where
<OprfCs::Hash as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfCs::Hash as BlockSizeUser>::BlockSize>;
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
fn generate_ke3<'a, 'b, 'c, 'd>( fn generate_ke3<'a, 'b, 'c, 'd>(
+7 -17
View File
@@ -12,11 +12,9 @@ use core::ops::Add;
use derive_where::derive_where; use derive_where::derive_where;
use digest::core_api::BlockSizeUser; use digest::core_api::BlockSizeUser;
use digest::{Digest, Output, OutputSizeUser}; use digest::{Digest, Output};
use generic_array::sequence::Concat; use generic_array::sequence::Concat;
use generic_array::typenum::{ use generic_array::typenum::{IsLess, Le, NonZero, Sum, Unsigned, U1, U2, U256, U32};
IsLess, IsLessOrEqual, Le, NonZero, Sum, Unsigned, U1, U2, U256, U32,
};
use generic_array::{ArrayLength, GenericArray}; use generic_array::{ArrayLength, GenericArray};
use hkdf::{Hkdf, HkdfExtract}; use hkdf::{Hkdf, HkdfExtract};
use hmac::{Hmac, Mac}; use hmac::{Hmac, Mac};
@@ -165,11 +163,7 @@ where
fn generate_ke1<OprfCs: voprf::CipherSuite, R: RngCore + CryptoRng>( fn generate_ke1<OprfCs: voprf::CipherSuite, R: RngCore + CryptoRng>(
rng: &mut R, rng: &mut R,
) -> Result<(Self::KE1State, Self::KE1Message), ProtocolError> ) -> Result<(Self::KE1State, Self::KE1Message), ProtocolError> {
where
<OprfCs::Hash as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfCs::Hash as BlockSizeUser>::BlockSize>,
{
let client_e_kp = KeyPair::<KG>::generate_random::<OprfCs, _>(rng); let client_e_kp = KeyPair::<KG>::generate_random::<OprfCs, _>(rng);
let client_nonce = generate_nonce::<R>(rng); let client_nonce = generate_nonce::<R>(rng);
@@ -206,11 +200,7 @@ where
id_u: impl Iterator<Item = &'c [u8]>, id_u: impl Iterator<Item = &'c [u8]>,
id_s: impl Iterator<Item = &'d [u8]>, id_s: impl Iterator<Item = &'d [u8]>,
context: &[u8], context: &[u8],
) -> Result<GenerateKe2Result<Self, D, KG>, ProtocolError<S::Error>> ) -> Result<GenerateKe2Result<Self, D, KG>, ProtocolError<S::Error>> {
where
<OprfCs::Hash as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfCs::Hash as BlockSizeUser>::BlockSize>,
{
let server_e_kp = KeyPair::<KG>::generate_random::<OprfCs, _>(rng); let server_e_kp = KeyPair::<KG>::generate_random::<OprfCs, _>(rng);
let server_nonce = generate_nonce::<R>(rng); let server_nonce = generate_nonce::<R>(rng);
@@ -414,9 +404,9 @@ where
.map_err(ProtocolError::into_custom)?; .map_err(ProtocolError::into_custom)?;
Ok(( Ok((
GenericArray::clone_from_slice(&session_key), session_key,
GenericArray::clone_from_slice(&km2), km2,
GenericArray::clone_from_slice(&km3), km3,
#[cfg(test)] #[cfg(test)]
handshake_secret, handshake_secret,
)) ))
+2 -13
View File
@@ -11,9 +11,6 @@
#![allow(unsafe_code)] #![allow(unsafe_code)]
use derive_where::derive_where; use derive_where::derive_where;
use digest::core_api::BlockSizeUser;
use digest::OutputSizeUser;
use generic_array::typenum::{IsLess, IsLessOrEqual, U256};
use generic_array::{ArrayLength, GenericArray}; use generic_array::{ArrayLength, GenericArray};
use rand::{CryptoRng, RngCore}; use rand::{CryptoRng, RngCore};
@@ -66,15 +63,10 @@ impl<KG: KeGroup> KeyPair<KG> {
/// Generating a random key pair given a cryptographic rng /// Generating a random key pair given a cryptographic rng
pub(crate) fn generate_random<CS: voprf::CipherSuite, R: RngCore + CryptoRng>( pub(crate) fn generate_random<CS: voprf::CipherSuite, R: RngCore + CryptoRng>(
rng: &mut R, rng: &mut R,
) -> Self ) -> Self {
where
<CS::Hash as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
{
let mut scalar_bytes = GenericArray::<_, <KG as KeGroup>::SkLen>::default(); let mut scalar_bytes = GenericArray::<_, <KG as KeGroup>::SkLen>::default();
rng.fill_bytes(&mut scalar_bytes); rng.fill_bytes(&mut scalar_bytes);
let sk = let sk = KG::derive_auth_keypair::<CS>(scalar_bytes).unwrap();
KG::derive_auth_keypair::<CS>(GenericArray::clone_from_slice(&scalar_bytes)).unwrap();
let pk = KG::public_key(sk); let pk = KG::public_key(sk);
Self { Self {
pk: PublicKey(pk), pk: PublicKey(pk),
@@ -92,9 +84,6 @@ where
/// Test-only strategy returning a proptest Strategy based on /// Test-only strategy returning a proptest Strategy based on
/// [`Self::generate_random`] /// [`Self::generate_random`]
fn uniform_keypair_strategy<CS: voprf::CipherSuite>() -> proptest::prelude::BoxedStrategy<Self> fn uniform_keypair_strategy<CS: voprf::CipherSuite>() -> proptest::prelude::BoxedStrategy<Self>
where
<CS::Hash as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
{ {
use proptest::prelude::*; use proptest::prelude::*;
use rand::rngs::StdRng; use rand::rngs::StdRng;
+1 -1
View File
@@ -15,7 +15,7 @@
//! //!
//! ### Minimum Supported Rust Version //! ### Minimum Supported Rust Version
//! //!
//! Rust **1.74** or higher. //! Rust **1.83** or higher.
//! //!
//! # Overview //! # Overview
//! //!
+15 -112
View File
@@ -11,10 +11,9 @@
use core::ops::Add; use core::ops::Add;
use derive_where::derive_where; use derive_where::derive_where;
use digest::core_api::{BlockSizeUser, CoreProxy}; use digest::Output;
use digest::{Output, OutputSizeUser};
use generic_array::sequence::Concat; use generic_array::sequence::Concat;
use generic_array::typenum::{IsLess, IsLessOrEqual, Le, NonZero, Sum, Unsigned, U256}; use generic_array::typenum::{Sum, Unsigned};
use generic_array::{ArrayLength, GenericArray}; use generic_array::{ArrayLength, GenericArray};
use rand::{CryptoRng, RngCore}; use rand::{CryptoRng, RngCore};
use subtle::ConstantTimeEq; use subtle::ConstantTimeEq;
@@ -24,7 +23,7 @@ use crate::ciphersuite::{CipherSuite, OprfGroup, OprfHash};
use crate::envelope::{Envelope, EnvelopeLen}; use crate::envelope::{Envelope, EnvelopeLen};
use crate::errors::utils::{check_slice_size, check_slice_size_atleast}; use crate::errors::utils::{check_slice_size, check_slice_size_atleast};
use crate::errors::ProtocolError; use crate::errors::ProtocolError;
use crate::hash::{Hash, OutputSize, ProxyHash}; use crate::hash::OutputSize;
use crate::key_exchange::group::KeGroup; use crate::key_exchange::group::KeGroup;
use crate::key_exchange::traits::{ use crate::key_exchange::traits::{
Deserialize, Ke1MessageLen, Ke2MessageLen, Ke3MessageLen, KeyExchange, Serialize, Deserialize, Ke1MessageLen, Ke2MessageLen, Ke3MessageLen, KeyExchange, Serialize,
@@ -46,15 +45,7 @@ use crate::opaque::{MaskedResponse, MaskedResponseLen, ServerSetup};
)] )]
#[derive_where(Clone)] #[derive_where(Clone)]
#[derive_where(Debug, Eq, Hash, Ord, PartialEq, PartialOrd; voprf::BlindedElement<CS::OprfCs>)] #[derive_where(Debug, Eq, Hash, Ord, PartialEq, PartialOrd; voprf::BlindedElement<CS::OprfCs>)]
pub struct RegistrationRequest<CS: CipherSuite> pub struct RegistrationRequest<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// blinded password information /// blinded password information
pub(crate) blinded_element: voprf::BlindedElement<CS::OprfCs>, pub(crate) blinded_element: voprf::BlindedElement<CS::OprfCs>,
} }
@@ -68,15 +59,7 @@ where
)] )]
#[derive_where(Clone)] #[derive_where(Clone)]
#[derive_where(Debug, Eq, Hash, Ord, PartialEq, PartialOrd; voprf::EvaluationElement<CS::OprfCs>, <CS::KeGroup as KeGroup>::Pk)] #[derive_where(Debug, Eq, Hash, Ord, PartialEq, PartialOrd; voprf::EvaluationElement<CS::OprfCs>, <CS::KeGroup as KeGroup>::Pk)]
pub struct RegistrationResponse<CS: CipherSuite> pub struct RegistrationResponse<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// The server's oprf output /// The server's oprf output
pub(crate) evaluation_element: voprf::EvaluationElement<CS::OprfCs>, pub(crate) evaluation_element: voprf::EvaluationElement<CS::OprfCs>,
/// Server's static public key /// Server's static public key
@@ -92,15 +75,7 @@ where
)] )]
#[derive_where(Clone, ZeroizeOnDrop)] #[derive_where(Clone, ZeroizeOnDrop)]
#[derive_where(Debug, Eq, Hash, Ord, PartialEq, PartialOrd; <CS::KeGroup as KeGroup>::Pk)] #[derive_where(Debug, Eq, Hash, Ord, PartialEq, PartialOrd; <CS::KeGroup as KeGroup>::Pk)]
pub struct RegistrationUpload<CS: CipherSuite> pub struct RegistrationUpload<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// The "envelope" generated by the user, containing sealed cryptographic /// The "envelope" generated by the user, containing sealed cryptographic
/// identifiers /// identifiers
pub(crate) envelope: Envelope<CS>, pub(crate) envelope: Envelope<CS>,
@@ -127,15 +102,7 @@ where
voprf::BlindedElement<CS::OprfCs>, voprf::BlindedElement<CS::OprfCs>,
<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1Message, <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1Message,
)] )]
pub struct CredentialRequest<CS: CipherSuite> pub struct CredentialRequest<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
pub(crate) blinded_element: voprf::BlindedElement<CS::OprfCs>, pub(crate) blinded_element: voprf::BlindedElement<CS::OprfCs>,
pub(crate) ke1_message: <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1Message, pub(crate) ke1_message: <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1Message,
} }
@@ -158,15 +125,7 @@ where
voprf::EvaluationElement<CS::OprfCs>, voprf::EvaluationElement<CS::OprfCs>,
<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2Message, <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2Message,
)] )]
pub struct CredentialResponse<CS: CipherSuite> pub struct CredentialResponse<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// the server's oprf output /// the server's oprf output
pub(crate) evaluation_element: voprf::EvaluationElement<CS::OprfCs>, pub(crate) evaluation_element: voprf::EvaluationElement<CS::OprfCs>,
pub(crate) masking_nonce: GenericArray<u8, NonceLen>, pub(crate) masking_nonce: GenericArray<u8, NonceLen>,
@@ -191,15 +150,7 @@ where
Debug, Eq, Hash, PartialEq; Debug, Eq, Hash, PartialEq;
<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE3Message, <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE3Message,
)] )]
pub struct CredentialFinalization<CS: CipherSuite> pub struct CredentialFinalization<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
pub(crate) ke3_message: <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE3Message, pub(crate) ke3_message: <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE3Message,
} }
@@ -211,15 +162,7 @@ where
/// Length of [`RegistrationRequest`] in bytes for serialization. /// Length of [`RegistrationRequest`] in bytes for serialization.
pub type RegistrationRequestLen<CS: CipherSuite> = <OprfGroup<CS> as Group>::ElemLen; pub type RegistrationRequestLen<CS: CipherSuite> = <OprfGroup<CS> as Group>::ElemLen;
impl<CS: CipherSuite> RegistrationRequest<CS> impl<CS: CipherSuite> RegistrationRequest<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Only used for testing purposes /// Only used for testing purposes
#[cfg(test)] #[cfg(test)]
pub fn get_blinded_element_for_testing(&self) -> voprf::BlindedElement<CS::OprfCs> { pub fn get_blinded_element_for_testing(&self) -> voprf::BlindedElement<CS::OprfCs> {
@@ -243,15 +186,7 @@ where
pub type RegistrationResponseLen<CS: CipherSuite> = pub type RegistrationResponseLen<CS: CipherSuite> =
Sum<<OprfGroup<CS> as Group>::ElemLen, <CS::KeGroup as KeGroup>::PkLen>; Sum<<OprfGroup<CS> as Group>::ElemLen, <CS::KeGroup as KeGroup>::PkLen>;
impl<CS: CipherSuite> RegistrationResponse<CS> impl<CS: CipherSuite> RegistrationResponse<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Serialization into bytes /// Serialization into bytes
pub fn serialize(&self) -> GenericArray<u8, RegistrationResponseLen<CS>> pub fn serialize(&self) -> GenericArray<u8, RegistrationResponseLen<CS>>
where where
@@ -294,15 +229,7 @@ where
pub type RegistrationUploadLen<CS: CipherSuite> = pub type RegistrationUploadLen<CS: CipherSuite> =
Sum<Sum<<CS::KeGroup as KeGroup>::PkLen, OutputSize<OprfHash<CS>>>, EnvelopeLen<CS>>; Sum<Sum<<CS::KeGroup as KeGroup>::PkLen, OutputSize<OprfHash<CS>>>, EnvelopeLen<CS>>;
impl<CS: CipherSuite> RegistrationUpload<CS> impl<CS: CipherSuite> RegistrationUpload<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Serialization into bytes /// Serialization into bytes
pub fn serialize(&self) -> GenericArray<u8, RegistrationUploadLen<CS>> pub fn serialize(&self) -> GenericArray<u8, RegistrationUploadLen<CS>>
where where
@@ -357,15 +284,7 @@ where
pub type CredentialRequestLen<CS: CipherSuite> = pub type CredentialRequestLen<CS: CipherSuite> =
Sum<<OprfGroup<CS> as Group>::ElemLen, Ke1MessageLen<CS>>; Sum<<OprfGroup<CS> as Group>::ElemLen, Ke1MessageLen<CS>>;
impl<CS: CipherSuite> CredentialRequest<CS> impl<CS: CipherSuite> CredentialRequest<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Serialization into bytes /// Serialization into bytes
pub fn serialize(&self) -> GenericArray<u8, CredentialRequestLen<CS>> pub fn serialize(&self) -> GenericArray<u8, CredentialRequestLen<CS>>
where where
@@ -425,15 +344,7 @@ pub type CredentialResponseLen<CS: CipherSuite> =
pub(crate) type CredentialResponseWithoutKeLen<CS: CipherSuite> = pub(crate) type CredentialResponseWithoutKeLen<CS: CipherSuite> =
Sum<Sum<<OprfGroup<CS> as Group>::ElemLen, NonceLen>, MaskedResponseLen<CS>>; Sum<Sum<<OprfGroup<CS> as Group>::ElemLen, NonceLen>, MaskedResponseLen<CS>>;
impl<CS: CipherSuite> CredentialResponse<CS> impl<CS: CipherSuite> CredentialResponse<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Serialization into bytes /// Serialization into bytes
pub fn serialize(&self) -> GenericArray<u8, CredentialResponseLen<CS>> pub fn serialize(&self) -> GenericArray<u8, CredentialResponseLen<CS>>
where where
@@ -527,15 +438,7 @@ where
/// Length of [`CredentialFinalization`] in bytes for serialization. /// Length of [`CredentialFinalization`] in bytes for serialization.
pub type CredentialFinalizationLen<CS: CipherSuite> = Ke3MessageLen<CS>; pub type CredentialFinalizationLen<CS: CipherSuite> = Ke3MessageLen<CS>;
impl<CS: CipherSuite> CredentialFinalization<CS> impl<CS: CipherSuite> CredentialFinalization<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Serialization into bytes /// Serialization into bytes
pub fn serialize(&self) -> GenericArray<u8, CredentialFinalizationLen<CS>> { pub fn serialize(&self) -> GenericArray<u8, CredentialFinalizationLen<CS>> {
self.ke3_message.serialize() self.ke3_message.serialize()
+42 -277
View File
@@ -11,10 +11,9 @@
use core::ops::Add; use core::ops::Add;
use derive_where::derive_where; use derive_where::derive_where;
use digest::core_api::{BlockSizeUser, CoreProxy}; use digest::Output;
use digest::{Output, OutputSizeUser};
use generic_array::sequence::Concat; use generic_array::sequence::Concat;
use generic_array::typenum::{IsLess, IsLessOrEqual, Le, NonZero, Sum, Unsigned, U2, U256}; use generic_array::typenum::{Sum, Unsigned, U2};
use generic_array::{ArrayLength, GenericArray}; use generic_array::{ArrayLength, GenericArray};
use hkdf::{Hkdf, HkdfExtract}; use hkdf::{Hkdf, HkdfExtract};
use rand::{CryptoRng, RngCore}; use rand::{CryptoRng, RngCore};
@@ -25,7 +24,7 @@ use crate::ciphersuite::{CipherSuite, OprfGroup, OprfHash};
use crate::envelope::{Envelope, EnvelopeLen}; use crate::envelope::{Envelope, EnvelopeLen};
use crate::errors::utils::check_slice_size; use crate::errors::utils::check_slice_size;
use crate::errors::{InternalError, ProtocolError}; use crate::errors::{InternalError, ProtocolError};
use crate::hash::{Hash, OutputSize, ProxyHash}; use crate::hash::OutputSize;
use crate::key_exchange::group::KeGroup; use crate::key_exchange::group::KeGroup;
use crate::key_exchange::traits::{ use crate::key_exchange::traits::{
Deserialize, Ke1MessageLen, Ke1StateLen, Ke2StateLen, KeyExchange, Serialize, Deserialize, Ke1MessageLen, Ke1StateLen, Ke2StateLen, KeyExchange, Serialize,
@@ -69,14 +68,7 @@ const STR_OPAQUE_DERIVE_KEY_PAIR: &[u8; 20] = b"OPAQUE-DeriveKeyPair";
pub struct ServerSetup< pub struct ServerSetup<
CS: CipherSuite, CS: CipherSuite,
S: SecretKey<CS::KeGroup> = PrivateKey<<CS as CipherSuite>::KeGroup>, S: SecretKey<CS::KeGroup> = PrivateKey<<CS as CipherSuite>::KeGroup>,
> where > {
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
oprf_seed: Output<OprfHash<CS>>, oprf_seed: Output<OprfHash<CS>>,
keypair: KeyPair<CS::KeGroup, S>, keypair: KeyPair<CS::KeGroup, S>,
pub(crate) fake_keypair: KeyPair<CS::KeGroup>, pub(crate) fake_keypair: KeyPair<CS::KeGroup>,
@@ -94,15 +86,7 @@ pub struct ServerSetup<
voprf::OprfClient<CS::OprfCs>, voprf::OprfClient<CS::OprfCs>,
voprf::BlindedElement<CS::OprfCs>, voprf::BlindedElement<CS::OprfCs>,
)] )]
pub struct ClientRegistration<CS: CipherSuite> pub struct ClientRegistration<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
pub(crate) oprf_client: voprf::OprfClient<CS::OprfCs>, pub(crate) oprf_client: voprf::OprfClient<CS::OprfCs>,
pub(crate) blinded_element: voprf::BlindedElement<CS::OprfCs>, pub(crate) blinded_element: voprf::BlindedElement<CS::OprfCs>,
} }
@@ -115,14 +99,7 @@ where
)] )]
#[derive_where(Clone, ZeroizeOnDrop)] #[derive_where(Clone, ZeroizeOnDrop)]
#[derive_where(Debug, Eq, Hash, Ord, PartialEq, PartialOrd; <CS::KeGroup as KeGroup>::Pk)] #[derive_where(Debug, Eq, Hash, Ord, PartialEq, PartialOrd; <CS::KeGroup as KeGroup>::Pk)]
pub struct ServerRegistration<CS: CipherSuite>(pub(crate) RegistrationUpload<CS>) pub struct ServerRegistration<CS: CipherSuite>(pub(crate) RegistrationUpload<CS>);
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero;
/// The state elements the client holds to perform a login /// The state elements the client holds to perform a login
#[cfg_attr( #[cfg_attr(
@@ -144,15 +121,7 @@ where
<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1State, <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1State,
CredentialRequest<CS>, CredentialRequest<CS>,
)] )]
pub struct ClientLogin<CS: CipherSuite> pub struct ClientLogin<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
pub(crate) oprf_client: voprf::OprfClient<CS::OprfCs>, pub(crate) oprf_client: voprf::OprfClient<CS::OprfCs>,
pub(crate) ke1_state: <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1State, pub(crate) ke1_state: <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1State,
pub(crate) credential_request: CredentialRequest<CS>, pub(crate) credential_request: CredentialRequest<CS>,
@@ -174,15 +143,7 @@ where
Debug, Eq, Hash, PartialEq; Debug, Eq, Hash, PartialEq;
<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2State, <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2State,
)] )]
pub struct ServerLogin<CS: CipherSuite> pub struct ServerLogin<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
ke2_state: <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2State, ke2_state: <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2State,
} }
@@ -194,15 +155,7 @@ where
// Server Setup // Server Setup
// ============ // ============
impl<CS: CipherSuite> ServerSetup<CS, PrivateKey<CS::KeGroup>> impl<CS: CipherSuite> ServerSetup<CS, PrivateKey<CS::KeGroup>> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Generate a new instance of server setup /// Generate a new instance of server setup
pub fn new<R: CryptoRng + RngCore>(rng: &mut R) -> Self { pub fn new<R: CryptoRng + RngCore>(rng: &mut R) -> Self {
let keypair = KeyPair::generate_random::<CS::OprfCs, _>(rng); let keypair = KeyPair::generate_random::<CS::OprfCs, _>(rng);
@@ -214,15 +167,7 @@ where
pub type ServerSetupLen<CS: CipherSuite, S: SecretKey<CS::KeGroup>> = pub type ServerSetupLen<CS: CipherSuite, S: SecretKey<CS::KeGroup>> =
Sum<Sum<OutputSize<OprfHash<CS>>, S::Len>, <CS::KeGroup as KeGroup>::SkLen>; Sum<Sum<OutputSize<OprfHash<CS>>, S::Len>, <CS::KeGroup as KeGroup>::SkLen>;
impl<CS: CipherSuite, S: SecretKey<CS::KeGroup>> ServerSetup<CS, S> impl<CS: CipherSuite, S: SecretKey<CS::KeGroup>> ServerSetup<CS, S> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Create [`ServerSetup`] with the given keypair /// Create [`ServerSetup`] with the given keypair
/// ///
/// This function should not be used to restore a previously-existing /// This function should not be used to restore a previously-existing
@@ -283,15 +228,7 @@ where
pub(crate) type ClientRegistrationLen<CS: CipherSuite> = pub(crate) type ClientRegistrationLen<CS: CipherSuite> =
Sum<<OprfGroup<CS> as Group>::ScalarLen, <OprfGroup<CS> as Group>::ElemLen>; Sum<<OprfGroup<CS> as Group>::ScalarLen, <OprfGroup<CS> as Group>::ElemLen>;
impl<CS: CipherSuite> ClientRegistration<CS> impl<CS: CipherSuite> ClientRegistration<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Serialization into bytes /// Serialization into bytes
pub fn serialize(&self) -> GenericArray<u8, ClientRegistrationLen<CS>> pub fn serialize(&self) -> GenericArray<u8, ClientRegistrationLen<CS>>
where where
@@ -407,15 +344,7 @@ where
/// Length of [`ServerRegistration`] in bytes for serialization. /// Length of [`ServerRegistration`] in bytes for serialization.
pub type ServerRegistrationLen<CS> = RegistrationUploadLen<CS>; pub type ServerRegistrationLen<CS> = RegistrationUploadLen<CS>;
impl<CS: CipherSuite> ServerRegistration<CS> impl<CS: CipherSuite> ServerRegistration<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Serialization into bytes /// Serialization into bytes
pub fn serialize(&self) -> GenericArray<u8, ServerRegistrationLen<CS>> pub fn serialize(&self) -> GenericArray<u8, ServerRegistrationLen<CS>>
where where
@@ -444,8 +373,7 @@ where
message: RegistrationRequest<CS>, message: RegistrationRequest<CS>,
credential_identifier: &[u8], credential_identifier: &[u8],
) -> Result<ServerRegistrationStartResult<CS>, ProtocolError> { ) -> Result<ServerRegistrationStartResult<CS>, ProtocolError> {
let oprf_key = let oprf_key = oprf_key_from_seed::<CS>(&server_setup.oprf_seed, credential_identifier)?;
oprf_key_from_seed::<CS::OprfCs>(&server_setup.oprf_seed, credential_identifier)?;
let server = voprf::OprfServer::new_with_key(&oprf_key)?; let server = voprf::OprfServer::new_with_key(&oprf_key)?;
let evaluation_element = server.blind_evaluate(&message.blinded_element); let evaluation_element = server.blind_evaluate(&message.blinded_element);
@@ -481,15 +409,7 @@ where
pub(crate) type ClientLoginLen<CS: CipherSuite> = pub(crate) type ClientLoginLen<CS: CipherSuite> =
Sum<Sum<<OprfGroup<CS> as Group>::ScalarLen, CredentialRequestLen<CS>>, Ke1StateLen<CS>>; Sum<Sum<<OprfGroup<CS> as Group>::ScalarLen, CredentialRequestLen<CS>>, Ke1StateLen<CS>>;
impl<CS: CipherSuite> ClientLogin<CS> impl<CS: CipherSuite> ClientLogin<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Serialization into bytes /// Serialization into bytes
pub fn serialize(&self) -> GenericArray<u8, ClientLoginLen<CS>> pub fn serialize(&self) -> GenericArray<u8, ClientLoginLen<CS>>
where where
@@ -530,15 +450,7 @@ where
} }
} }
impl<CS: CipherSuite> ClientLogin<CS> impl<CS: CipherSuite> ClientLogin<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Returns an initial "blinded" password request to send to the server, as /// Returns an initial "blinded" password request to send to the server, as
/// well as a [`ClientLogin`] /// well as a [`ClientLogin`]
pub fn start<R: RngCore + CryptoRng>( pub fn start<R: RngCore + CryptoRng>(
@@ -666,15 +578,7 @@ where
} }
} }
impl<CS: CipherSuite> ServerLogin<CS> impl<CS: CipherSuite> ServerLogin<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Serialization into bytes /// Serialization into bytes
pub fn serialize(&self) -> GenericArray<u8, Ke2StateLen<CS>> { pub fn serialize(&self) -> GenericArray<u8, Ke2StateLen<CS>> {
self.ke2_state.serialize() self.ke2_state.serialize()
@@ -744,9 +648,8 @@ where
let credential_request_bytes = let credential_request_bytes =
CredentialRequest::<CS>::serialize_iter(&blinded_element, &ke1_message); CredentialRequest::<CS>::serialize_iter(&blinded_element, &ke1_message);
let oprf_key = let oprf_key = oprf_key_from_seed::<CS>(&server_setup.oprf_seed, credential_identifier)
oprf_key_from_seed::<CS::OprfCs>(&server_setup.oprf_seed, credential_identifier) .map_err(ProtocolError::into_custom)?;
.map_err(ProtocolError::into_custom)?;
let server = voprf::OprfServer::new_with_key(&oprf_key) let server = voprf::OprfServer::new_with_key(&oprf_key)
.map_err(|e| ProtocolError::into_custom(e.into()))?; .map_err(|e| ProtocolError::into_custom(e.into()))?;
let evaluation_element = server.blind_evaluate(&credential_request.blinded_element); let evaluation_element = server.blind_evaluate(&credential_request.blinded_element);
@@ -784,7 +687,7 @@ where
#[cfg(test)] #[cfg(test)]
server_mac_key: result.3, server_mac_key: result.3,
#[cfg(test)] #[cfg(test)]
oprf_key: GenericArray::clone_from_slice(&oprf_key), oprf_key,
}) })
} }
@@ -823,30 +726,14 @@ pub struct Identifiers<'a> {
/// Optional parameters for client registration finish /// Optional parameters for client registration finish
#[derive_where(Clone, Default)] #[derive_where(Clone, Default)]
pub struct ClientRegistrationFinishParameters<'i, 'h, CS: CipherSuite> pub struct ClientRegistrationFinishParameters<'i, 'h, CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Specifying the identifiers idU and idS /// Specifying the identifiers idU and idS
pub identifiers: Identifiers<'i>, pub identifiers: Identifiers<'i>,
/// Specifying a configuration for the key stretching function /// Specifying a configuration for the key stretching function
pub ksf: Option<&'h CS::Ksf>, pub ksf: Option<&'h CS::Ksf>,
} }
impl<'i, 'h, CS: CipherSuite> ClientRegistrationFinishParameters<'i, 'h, CS> impl<'i, 'h, CS: CipherSuite> ClientRegistrationFinishParameters<'i, 'h, CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Create a new [`ClientRegistrationFinishParameters`] /// Create a new [`ClientRegistrationFinishParameters`]
pub fn new(identifiers: Identifiers<'i>, ksf: Option<&'h CS::Ksf>) -> Self { pub fn new(identifiers: Identifiers<'i>, ksf: Option<&'h CS::Ksf>) -> Self {
Self { identifiers, ksf } Self { identifiers, ksf }
@@ -855,15 +742,7 @@ where
/// Contains the fields that are returned by a client registration start /// Contains the fields that are returned by a client registration start
#[derive_where(Clone)] #[derive_where(Clone)]
pub struct ClientRegistrationStartResult<CS: CipherSuite> pub struct ClientRegistrationStartResult<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// The registration request message to be sent to the server /// The registration request message to be sent to the server
pub message: RegistrationRequest<CS>, pub message: RegistrationRequest<CS>,
/// The client state that must be persisted in order to complete /// The client state that must be persisted in order to complete
@@ -873,15 +752,7 @@ where
/// Contains the fields that are returned by a client registration finish /// Contains the fields that are returned by a client registration finish
#[derive_where(Clone)] #[derive_where(Clone)]
pub struct ClientRegistrationFinishResult<CS: CipherSuite> pub struct ClientRegistrationFinishResult<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// The registration upload message to be sent to the server /// The registration upload message to be sent to the server
pub message: RegistrationUpload<CS>, pub message: RegistrationUpload<CS>,
/// The export key output by client registration /// The export key output by client registration
@@ -903,15 +774,7 @@ where
/// Contains the fields that are returned by a server registration start. Note /// Contains the fields that are returned by a server registration start. Note
/// that there is no state output in this step /// that there is no state output in this step
#[derive_where(Clone)] #[derive_where(Clone)]
pub struct ServerRegistrationStartResult<CS: CipherSuite> pub struct ServerRegistrationStartResult<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// The registration resposne message to send to the client /// The registration resposne message to send to the client
pub message: RegistrationResponse<CS>, pub message: RegistrationResponse<CS>,
/// OPRF key, only used in tests /// OPRF key, only used in tests
@@ -921,15 +784,7 @@ where
/// Contains the fields that are returned by a client login start /// Contains the fields that are returned by a client login start
#[derive_where(Clone)] #[derive_where(Clone)]
pub struct ClientLoginStartResult<CS: CipherSuite> pub struct ClientLoginStartResult<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// The message to send to the server to begin the login protocol /// The message to send to the server to begin the login protocol
pub message: CredentialRequest<CS>, pub message: CredentialRequest<CS>,
/// The state that the client must keep in order to complete the protocol /// The state that the client must keep in order to complete the protocol
@@ -938,15 +793,7 @@ where
/// Optional parameters for client login finish /// Optional parameters for client login finish
#[derive_where(Clone, Default)] #[derive_where(Clone, Default)]
pub struct ClientLoginFinishParameters<'c, 'i, 'h, CS: CipherSuite> pub struct ClientLoginFinishParameters<'c, 'i, 'h, CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Specifying a context field that the server must agree on /// Specifying a context field that the server must agree on
pub context: Option<&'c [u8]>, pub context: Option<&'c [u8]>,
/// Specifying a user identifier and server identifier that will be matched /// Specifying a user identifier and server identifier that will be matched
@@ -956,15 +803,7 @@ where
pub ksf: Option<&'h CS::Ksf>, pub ksf: Option<&'h CS::Ksf>,
} }
impl<'c, 'i, 'h, CS: CipherSuite> ClientLoginFinishParameters<'c, 'i, 'h, CS> impl<'c, 'i, 'h, CS: CipherSuite> ClientLoginFinishParameters<'c, 'i, 'h, CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// Create a new [`ClientLoginFinishParameters`] /// Create a new [`ClientLoginFinishParameters`]
pub fn new( pub fn new(
context: Option<&'c [u8]>, context: Option<&'c [u8]>,
@@ -981,15 +820,7 @@ where
/// Contains the fields that are returned by a client login finish /// Contains the fields that are returned by a client login finish
#[derive_where(Clone)] #[derive_where(Clone)]
pub struct ClientLoginFinishResult<CS: CipherSuite> pub struct ClientLoginFinishResult<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// The message to send to the server to complete the protocol /// The message to send to the server to complete the protocol
pub message: CredentialFinalization<CS>, pub message: CredentialFinalization<CS>,
/// The session key /// The session key
@@ -1013,15 +844,7 @@ where
#[derive_where(Clone)] #[derive_where(Clone)]
#[cfg_attr(not(test), derive_where(Debug))] #[cfg_attr(not(test), derive_where(Debug))]
#[cfg_attr(test, derive_where(Debug; ServerLogin<CS>))] #[cfg_attr(test, derive_where(Debug; ServerLogin<CS>))]
pub struct ServerLoginFinishResult<CS: CipherSuite> pub struct ServerLoginFinishResult<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// The session key between client and server /// The session key between client and server
pub session_key: Output<OprfHash<CS>>, pub session_key: Output<OprfHash<CS>>,
/// Instance of the ClientRegistration, only used in tests for checking /// Instance of the ClientRegistration, only used in tests for checking
@@ -1048,15 +871,7 @@ pub struct ServerLoginStartParameters<'c, 'i> {
<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2Message, <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2Message,
<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2State, <CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2State,
)] )]
pub struct ServerLoginStartResult<CS: CipherSuite> pub struct ServerLoginStartResult<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// The message to send back to the client /// The message to send back to the client
pub message: CredentialResponse<CS>, pub message: CredentialResponse<CS>,
/// The state that the server must keep in order to finish the protocl /// The state that the server must keep in order to finish the protocl
@@ -1084,15 +899,7 @@ fn get_password_derived_key<CS: CipherSuite>(
oprf_client: voprf::OprfClient<CS::OprfCs>, oprf_client: voprf::OprfClient<CS::OprfCs>,
evaluation_element: voprf::EvaluationElement<CS::OprfCs>, evaluation_element: voprf::EvaluationElement<CS::OprfCs>,
ksf: Option<&CS::Ksf>, ksf: Option<&CS::Ksf>,
) -> Result<(Output<OprfHash<CS>>, Hkdf<OprfHash<CS>>), ProtocolError> ) -> Result<(Output<OprfHash<CS>>, Hkdf<OprfHash<CS>>), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let oprf_output = oprf_client.finalize(input, &evaluation_element)?; let oprf_output = oprf_client.finalize(input, &evaluation_element)?;
let hardened_output = if let Some(ksf) = ksf { let hardened_output = if let Some(ksf) = ksf {
@@ -1108,20 +915,12 @@ where
Ok(hkdf.finalize()) Ok(hkdf.finalize())
} }
fn oprf_key_from_seed<CS: voprf::CipherSuite>( fn oprf_key_from_seed<CS: CipherSuite>(
oprf_seed: &Output<CS::Hash>, oprf_seed: &Output<OprfHash<CS>>,
credential_identifier: &[u8], credential_identifier: &[u8],
) -> Result<GenericArray<u8, <CS::Group as Group>::ScalarLen>, ProtocolError> ) -> Result<GenericArray<u8, <OprfGroup<CS> as Group>::ScalarLen>, ProtocolError> {
where let mut ikm = GenericArray::<_, <OprfGroup<CS> as Group>::ScalarLen>::default();
<CS::Hash as OutputSizeUser>::OutputSize: Hkdf::<OprfHash<CS>>::from_prk(oprf_seed)
IsLess<U256> + IsLessOrEqual<<CS::Hash as BlockSizeUser>::BlockSize>,
CS::Hash: Hash,
<CS::Hash as CoreProxy>::Core: ProxyHash,
<<CS::Hash as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<CS::Hash as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut ikm = GenericArray::<_, <CS::Group as Group>::ScalarLen>::default();
Hkdf::<CS::Hash>::from_prk(oprf_seed)
.ok() .ok()
.and_then(|hkdf| { .and_then(|hkdf| {
hkdf.expand_multi_info(&[credential_identifier, STR_OPRF_KEY], &mut ikm) hkdf.expand_multi_info(&[credential_identifier, STR_OPRF_KEY], &mut ikm)
@@ -1129,7 +928,9 @@ where
}) })
.ok_or(InternalError::HkdfError)?; .ok_or(InternalError::HkdfError)?;
Ok(CS::Group::serialize_scalar(voprf::derive_key::<CS>( Ok(OprfGroup::<CS>::serialize_scalar(voprf::derive_key::<
CS::OprfCs,
>(
ikm.as_slice(), ikm.as_slice(),
&GenericArray::from(*STR_OPAQUE_DERIVE_KEY_PAIR), &GenericArray::from(*STR_OPAQUE_DERIVE_KEY_PAIR),
voprf::Mode::Oprf, voprf::Mode::Oprf,
@@ -1143,15 +944,7 @@ where
)] )]
#[derive_where(Clone)] #[derive_where(Clone)]
#[derive_where(Debug, Eq, Hash, PartialEq)] #[derive_where(Debug, Eq, Hash, PartialEq)]
pub(crate) struct MaskedResponse<CS: CipherSuite> pub(crate) struct MaskedResponse<CS: CipherSuite> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
pub(crate) nonce: GenericArray<u8, NonceLen>, pub(crate) nonce: GenericArray<u8, NonceLen>,
pub(crate) hash: Output<OprfHash<CS>>, pub(crate) hash: Output<OprfHash<CS>>,
pub(crate) pk: GenericArray<u8, <CS::KeGroup as KeGroup>::PkLen>, pub(crate) pk: GenericArray<u8, <CS::KeGroup as KeGroup>::PkLen>,
@@ -1160,15 +953,7 @@ where
pub(crate) type MaskedResponseLen<CS: CipherSuite> = pub(crate) type MaskedResponseLen<CS: CipherSuite> =
Sum<Sum<NonceLen, OutputSize<OprfHash<CS>>>, <CS::KeGroup as KeGroup>::PkLen>; Sum<Sum<NonceLen, OutputSize<OprfHash<CS>>>, <CS::KeGroup as KeGroup>::PkLen>;
impl<CS: CipherSuite> MaskedResponse<CS> impl<CS: CipherSuite> MaskedResponse<CS> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
pub(crate) fn serialize(&self) -> GenericArray<u8, MaskedResponseLen<CS>> pub(crate) fn serialize(&self) -> GenericArray<u8, MaskedResponseLen<CS>>
where where
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
@@ -1204,12 +989,6 @@ fn mask_response<CS: CipherSuite>(
envelope: &Envelope<CS>, envelope: &Envelope<CS>,
) -> Result<MaskedResponse<CS>, ProtocolError> ) -> Result<MaskedResponse<CS>, ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
Sum<NonceLen, OutputSize<OprfHash<CS>>>: ArrayLength<u8> + Add<<CS::KeGroup as KeGroup>::PkLen>, Sum<NonceLen, OutputSize<OprfHash<CS>>>: ArrayLength<u8> + Add<<CS::KeGroup as KeGroup>::PkLen>,
@@ -1241,12 +1020,6 @@ fn unmask_response<CS: CipherSuite>(
masked_response: &MaskedResponse<CS>, masked_response: &MaskedResponse<CS>,
) -> Result<(PublicKey<CS::KeGroup>, Envelope<CS>), ProtocolError> ) -> Result<(PublicKey<CS::KeGroup>, Envelope<CS>), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
Sum<NonceLen, OutputSize<OprfHash<CS>>>: ArrayLength<u8> + Add<<CS::KeGroup as KeGroup>::PkLen>, Sum<NonceLen, OutputSize<OprfHash<CS>>>: ArrayLength<u8> + Add<<CS::KeGroup as KeGroup>::PkLen>,
@@ -1297,15 +1070,7 @@ pub(crate) fn bytestrings_from_identifiers<KG: KeGroup>(
fn blind<CS: CipherSuite, R: RngCore + CryptoRng>( fn blind<CS: CipherSuite, R: RngCore + CryptoRng>(
rng: &mut R, rng: &mut R,
password: &[u8], password: &[u8],
) -> Result<voprf::OprfClientBlindResult<CS::OprfCs>, voprf::Error> ) -> Result<voprf::OprfClientBlindResult<CS::OprfCs>, voprf::Error> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
#[cfg(not(test))] #[cfg(not(test))]
let result = voprf::OprfClient::blind(password, rng)?; let result = voprf::OprfClient::blind(password, rng)?;
+2 -2
View File
@@ -105,7 +105,7 @@ impl<'a, L1: ArrayLength<u8>, L2: ArrayLength<u8>, L3: ArrayLength<u8>> Input<'a
} }
} }
impl<'a, L1: ArrayLength<u8>, L2: ArrayLength<u8>> Input<'a, L1, L2, U0> { impl<L1: ArrayLength<u8>, L2: ArrayLength<u8>> Input<'_, L1, L2, U0> {
pub(crate) fn to_array_2(&self) -> [&[u8]; 2] { pub(crate) fn to_array_2(&self) -> [&[u8]; 2] {
let input = match &self.input { let input = match &self.input {
InnerInput::Borrowed(value) => value, InnerInput::Borrowed(value) => value,
@@ -117,7 +117,7 @@ impl<'a, L1: ArrayLength<u8>, L2: ArrayLength<u8>> Input<'a, L1, L2, U0> {
} }
} }
impl<'a, L1: ArrayLength<u8>, L2: ArrayLength<u8>> Input<'a, L1, L2, U2> { impl<L1: ArrayLength<u8>, L2: ArrayLength<u8>> Input<'_, L1, L2, U2> {
pub(crate) fn to_array_3(&self) -> [&[u8]; 3] { pub(crate) fn to_array_3(&self) -> [&[u8]; 3] {
match self.input { match self.input {
InnerInput::Label((label, _)) => [self.octet.as_slice(), label[0], label[1]], InnerInput::Label((label, _)) => [self.octet.as_slice(), label[0], label[1]],
+9 -100
View File
@@ -10,9 +10,8 @@ use core::ops::Add;
use std::vec; use std::vec;
use std::vec::Vec; use std::vec::Vec;
use digest::core_api::{BlockSizeUser, CoreProxy}; use digest::Output;
use digest::{Output, OutputSizeUser}; use generic_array::typenum::{Sum, Unsigned};
use generic_array::typenum::{IsLess, IsLessOrEqual, Le, NonZero, Sum, Unsigned, U256};
use generic_array::ArrayLength; use generic_array::ArrayLength;
use proptest::collection::vec; use proptest::collection::vec;
use proptest::prelude::*; use proptest::prelude::*;
@@ -23,7 +22,7 @@ use voprf::Group;
use crate::ciphersuite::{CipherSuite, OprfGroup, OprfHash}; use crate::ciphersuite::{CipherSuite, OprfGroup, OprfHash};
use crate::envelope::{Envelope, EnvelopeLen, InnerEnvelopeMode}; use crate::envelope::{Envelope, EnvelopeLen, InnerEnvelopeMode};
use crate::errors::*; use crate::errors::*;
use crate::hash::{Hash, OutputSize, ProxyHash}; use crate::hash::OutputSize;
use crate::key_exchange::group::KeGroup; use crate::key_exchange::group::KeGroup;
use crate::key_exchange::traits::{ use crate::key_exchange::traits::{
Deserialize, Ke1MessageLen, Ke1StateLen, Ke2MessageLen, KeyExchange, Serialize, Deserialize, Ke1MessageLen, Ke1StateLen, Ke2MessageLen, KeyExchange, Serialize,
@@ -73,15 +72,7 @@ impl CipherSuite for P521 {
type Ksf = crate::ksf::Identity; type Ksf = crate::ksf::Identity;
} }
fn random_point<CS: CipherSuite>() -> <CS::KeGroup as KeGroup>::Pk fn random_point<CS: CipherSuite>() -> <CS::KeGroup as KeGroup>::Pk {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut rng = OsRng; let mut rng = OsRng;
let sk = CS::KeGroup::random_sk(&mut rng); let sk = CS::KeGroup::random_sk(&mut rng);
CS::KeGroup::public_key(sk) CS::KeGroup::public_key(sk)
@@ -91,12 +82,6 @@ where
fn client_registration_roundtrip() -> Result<(), ProtocolError> { fn client_registration_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// ClientRegistration: KgSk + KgPk // ClientRegistration: KgSk + KgPk
<OprfGroup<CS> as Group>::ScalarLen: Add<<OprfGroup<CS> as Group>::ElemLen>, <OprfGroup<CS> as Group>::ScalarLen: Add<<OprfGroup<CS> as Group>::ElemLen>,
ClientRegistrationLen<CS>: ArrayLength<u8>, ClientRegistrationLen<CS>: ArrayLength<u8>,
@@ -133,12 +118,6 @@ fn client_registration_roundtrip() -> Result<(), ProtocolError> {
fn server_registration_roundtrip() -> Result<(), ProtocolError> { fn server_registration_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// Envelope: Nonce + Hash // Envelope: Nonce + Hash
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
EnvelopeLen<CS>: ArrayLength<u8>, EnvelopeLen<CS>: ArrayLength<u8>,
@@ -186,15 +165,7 @@ fn server_registration_roundtrip() -> Result<(), ProtocolError> {
#[test] #[test]
fn registration_request_roundtrip() -> Result<(), ProtocolError> { fn registration_request_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let pt = random_point::<CS>(); let pt = random_point::<CS>();
let pt_bytes = CS::KeGroup::serialize_pk(pt); let pt_bytes = CS::KeGroup::serialize_pk(pt);
@@ -232,12 +203,6 @@ fn registration_request_roundtrip() -> Result<(), ProtocolError> {
fn registration_response_roundtrip() -> Result<(), ProtocolError> { fn registration_response_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// RegistrationResponse: KgPk + KePk // RegistrationResponse: KgPk + KePk
<OprfGroup<CS> as Group>::ElemLen: Add<<CS::KeGroup as KeGroup>::PkLen>, <OprfGroup<CS> as Group>::ElemLen: Add<<CS::KeGroup as KeGroup>::PkLen>,
RegistrationResponseLen<CS>: ArrayLength<u8>, RegistrationResponseLen<CS>: ArrayLength<u8>,
@@ -285,12 +250,6 @@ fn registration_response_roundtrip() -> Result<(), ProtocolError> {
fn registration_upload_roundtrip() -> Result<(), ProtocolError> { fn registration_upload_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// Envelope: Nonce + Hash // Envelope: Nonce + Hash
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
EnvelopeLen<CS>: ArrayLength<u8>, EnvelopeLen<CS>: ArrayLength<u8>,
@@ -348,12 +307,6 @@ fn registration_upload_roundtrip() -> Result<(), ProtocolError> {
fn credential_request_roundtrip() -> Result<(), ProtocolError> { fn credential_request_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// CredentialRequest: KgPk + Ke1Message // CredentialRequest: KgPk + Ke1Message
<OprfGroup<CS> as Group>::ElemLen: Add<Ke1MessageLen<CS>>, <OprfGroup<CS> as Group>::ElemLen: Add<Ke1MessageLen<CS>>,
CredentialRequestLen<CS>: ArrayLength<u8>, CredentialRequestLen<CS>: ArrayLength<u8>,
@@ -407,12 +360,6 @@ fn credential_request_roundtrip() -> Result<(), ProtocolError> {
fn credential_response_roundtrip() -> Result<(), ProtocolError> { fn credential_response_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// CredentialResponseWithoutKeLen: (KgPk + Nonce) + MaskedResponse // CredentialResponseWithoutKeLen: (KgPk + Nonce) + MaskedResponse
<OprfGroup<CS> as Group>::ElemLen: Add<NonceLen>, <OprfGroup<CS> as Group>::ElemLen: Add<NonceLen>,
Sum<<OprfGroup<CS> as Group>::ElemLen, NonceLen>: Sum<<OprfGroup<CS> as Group>::ElemLen, NonceLen>:
@@ -495,15 +442,7 @@ fn credential_response_roundtrip() -> Result<(), ProtocolError> {
#[test] #[test]
fn credential_finalization_roundtrip() -> Result<(), ProtocolError> { fn credential_finalization_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut rng = OsRng; let mut rng = OsRng;
let mut mac = Output::<OprfHash<CS>>::default(); let mut mac = Output::<OprfHash<CS>>::default();
rng.fill_bytes(&mut mac); rng.fill_bytes(&mut mac);
@@ -530,12 +469,6 @@ fn credential_finalization_roundtrip() -> Result<(), ProtocolError> {
fn client_login_roundtrip() -> Result<(), ProtocolError> { fn client_login_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// CredentialRequest: KgPk + Ke1Message // CredentialRequest: KgPk + Ke1Message
<OprfGroup<CS> as Group>::ElemLen: Add<Ke1MessageLen<CS>>, <OprfGroup<CS> as Group>::ElemLen: Add<Ke1MessageLen<CS>>,
CredentialRequestLen<CS>: ArrayLength<u8>, CredentialRequestLen<CS>: ArrayLength<u8>,
@@ -597,15 +530,7 @@ fn client_login_roundtrip() -> Result<(), ProtocolError> {
#[test] #[test]
fn ke1_message_roundtrip() -> Result<(), ProtocolError> { fn ke1_message_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut rng = OsRng; let mut rng = OsRng;
let client_e_kp = KeyPair::<CS::KeGroup>::generate_random::<CS::OprfCs, _>(&mut rng); let client_e_kp = KeyPair::<CS::KeGroup>::generate_random::<CS::OprfCs, _>(&mut rng);
@@ -638,15 +563,7 @@ fn ke1_message_roundtrip() -> Result<(), ProtocolError> {
#[test] #[test]
fn ke2_message_roundtrip() -> Result<(), ProtocolError> { fn ke2_message_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut rng = OsRng; let mut rng = OsRng;
let server_e_kp = KeyPair::<CS::KeGroup>::generate_random::<CS::OprfCs, _>(&mut rng); let server_e_kp = KeyPair::<CS::KeGroup>::generate_random::<CS::OprfCs, _>(&mut rng);
@@ -683,15 +600,7 @@ fn ke2_message_roundtrip() -> Result<(), ProtocolError> {
#[test] #[test]
fn ke3_message_roundtrip() -> Result<(), ProtocolError> { fn ke3_message_roundtrip() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> fn inner<CS: CipherSuite>() -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut rng = OsRng; let mut rng = OsRng;
let mut mac = Output::<OprfHash<CS>>::default(); let mut mac = Output::<OprfHash<CS>>::default();
rng.fill_bytes(&mut mac); rng.fill_bytes(&mut mac);
+9 -148
View File
@@ -13,9 +13,8 @@ use std::string::String;
use std::vec::Vec; use std::vec::Vec;
use std::{format, println, ptr, vec}; use std::{format, println, ptr, vec};
use digest::core_api::{BlockSizeUser, CoreProxy}; use digest::Output;
use digest::{Output, OutputSizeUser}; use generic_array::typenum::{Sum, Unsigned};
use generic_array::typenum::{IsLess, IsLessOrEqual, Le, NonZero, Sum, Unsigned, U256};
use generic_array::ArrayLength; use generic_array::ArrayLength;
use rand::rngs::OsRng; use rand::rngs::OsRng;
use serde_json::Value; use serde_json::Value;
@@ -25,7 +24,7 @@ use voprf::Group;
use crate::ciphersuite::{CipherSuite, OprfGroup, OprfHash}; use crate::ciphersuite::{CipherSuite, OprfGroup, OprfHash};
use crate::envelope::EnvelopeLen; use crate::envelope::EnvelopeLen;
use crate::errors::*; use crate::errors::*;
use crate::hash::{Hash, OutputSize, ProxyHash}; use crate::hash::OutputSize;
use crate::key_exchange::group::KeGroup; use crate::key_exchange::group::KeGroup;
use crate::key_exchange::traits::{Ke1MessageLen, Ke1StateLen, Ke2MessageLen}; use crate::key_exchange::traits::{Ke1MessageLen, Ke1StateLen, Ke2MessageLen};
use crate::key_exchange::tripledh::{NonceLen, TripleDh}; use crate::key_exchange::tripledh::{NonceLen, TripleDh};
@@ -546,12 +545,6 @@ fn stringify_test_vectors(p: &TestVectorParameters) -> String {
fn generate_parameters<CS: CipherSuite>() -> Result<TestVectorParameters, ProtocolError> fn generate_parameters<CS: CipherSuite>() -> Result<TestVectorParameters, ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// ClientRegistration: KgSk + KgPk // ClientRegistration: KgSk + KgPk
<OprfGroup<CS> as Group>::ScalarLen: Add<<OprfGroup<CS> as Group>::ElemLen>, <OprfGroup<CS> as Group>::ScalarLen: Add<<OprfGroup<CS> as Group>::ElemLen>,
ClientRegistrationLen<CS>: ArrayLength<u8>, ClientRegistrationLen<CS>: ArrayLength<u8>,
@@ -958,12 +951,6 @@ fn generate_test_vectors() -> Result<(), ProtocolError> {
fn test_registration_request() -> Result<(), ProtocolError> { fn test_registration_request() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// ClientRegistration: KgSk + KgPk // ClientRegistration: KgSk + KgPk
<OprfGroup<CS> as Group>::ScalarLen: Add<<OprfGroup<CS> as Group>::ElemLen>, <OprfGroup<CS> as Group>::ScalarLen: Add<<OprfGroup<CS> as Group>::ElemLen>,
ClientRegistrationLen<CS>: ArrayLength<u8>, ClientRegistrationLen<CS>: ArrayLength<u8>,
@@ -991,15 +978,7 @@ fn test_registration_request() -> Result<(), ProtocolError> {
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[test] #[test]
fn test_serialization() -> Result<(), ProtocolError> { fn test_serialization() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let parameters = populate_test_vectors(&serde_json::from_str(test_vector).unwrap()); let parameters = populate_test_vectors(&serde_json::from_str(test_vector).unwrap());
let mut rng = CycleRng::new(parameters.blinding_factor.to_vec()); let mut rng = CycleRng::new(parameters.blinding_factor.to_vec());
let client_registration_start_result = let client_registration_start_result =
@@ -1031,12 +1010,6 @@ fn test_serialization() -> Result<(), ProtocolError> {
fn test_registration_response() -> Result<(), ProtocolError> { fn test_registration_response() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// RegistrationResponse: KgPk + KePk // RegistrationResponse: KgPk + KePk
<OprfGroup<CS> as Group>::ElemLen: Add<<CS::KeGroup as KeGroup>::PkLen>, <OprfGroup<CS> as Group>::ElemLen: Add<<CS::KeGroup as KeGroup>::PkLen>,
RegistrationResponseLen<CS>: ArrayLength<u8>, RegistrationResponseLen<CS>: ArrayLength<u8>,
@@ -1075,12 +1048,6 @@ fn test_registration_response() -> Result<(), ProtocolError> {
fn test_registration_upload() -> Result<(), ProtocolError> { fn test_registration_upload() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// Envelope: Nonce + Hash // Envelope: Nonce + Hash
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
EnvelopeLen<CS>: ArrayLength<u8>, EnvelopeLen<CS>: ArrayLength<u8>,
@@ -1132,12 +1099,6 @@ fn test_registration_upload() -> Result<(), ProtocolError> {
fn test_password_file() -> Result<(), ProtocolError> { fn test_password_file() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// Envelope: Nonce + Hash // Envelope: Nonce + Hash
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
EnvelopeLen<CS>: ArrayLength<u8>, EnvelopeLen<CS>: ArrayLength<u8>,
@@ -1170,12 +1131,6 @@ fn test_password_file() -> Result<(), ProtocolError> {
fn test_credential_request() -> Result<(), ProtocolError> { fn test_credential_request() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// CredentialRequest: KgPk + Ke1Message // CredentialRequest: KgPk + Ke1Message
<OprfGroup<CS> as Group>::ElemLen: Add<Ke1MessageLen<CS>>, <OprfGroup<CS> as Group>::ElemLen: Add<Ke1MessageLen<CS>>,
CredentialRequestLen<CS>: ArrayLength<u8>, CredentialRequestLen<CS>: ArrayLength<u8>,
@@ -1216,12 +1171,6 @@ fn test_credential_request() -> Result<(), ProtocolError> {
fn test_credential_response() -> Result<(), ProtocolError> { fn test_credential_response() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
Sum<NonceLen, OutputSize<OprfHash<CS>>>: Sum<NonceLen, OutputSize<OprfHash<CS>>>:
@@ -1289,12 +1238,6 @@ fn test_credential_response() -> Result<(), ProtocolError> {
fn test_credential_finalization() -> Result<(), ProtocolError> { fn test_credential_finalization() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
Sum<NonceLen, OutputSize<OprfHash<CS>>>: Sum<NonceLen, OutputSize<OprfHash<CS>>>:
@@ -1344,15 +1287,7 @@ fn test_credential_finalization() -> Result<(), ProtocolError> {
#[test] #[test]
fn test_server_login_finish() -> Result<(), ProtocolError> { fn test_server_login_finish() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(test_vector: &str) -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let parameters = populate_test_vectors(&serde_json::from_str(test_vector).unwrap()); let parameters = populate_test_vectors(&serde_json::from_str(test_vector).unwrap());
let server_login_result = ServerLogin::<CS>::deserialize(&parameters.server_login_state)? let server_login_result = ServerLogin::<CS>::deserialize(&parameters.server_login_state)?
@@ -1379,12 +1314,6 @@ fn test_complete_flow<CS: CipherSuite>(
login_password: &[u8], login_password: &[u8],
) -> Result<(), ProtocolError> ) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
Sum<NonceLen, OutputSize<OprfHash<CS>>>: ArrayLength<u8> + Add<<CS::KeGroup as KeGroup>::PkLen>, Sum<NonceLen, OutputSize<OprfHash<CS>>>: ArrayLength<u8> + Add<<CS::KeGroup as KeGroup>::PkLen>,
@@ -1464,15 +1393,7 @@ fn test_complete_flow_fail() -> Result<(), ProtocolError> {
#[test] #[test]
fn test_zeroize_client_registration_start() -> Result<(), ProtocolError> { fn test_zeroize_client_registration_start() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut client_rng = OsRng; let mut client_rng = OsRng;
let client_registration_start_result = let client_registration_start_result =
ClientRegistration::<CS>::start(&mut client_rng, STR_PASSWORD.as_bytes())?; ClientRegistration::<CS>::start(&mut client_rng, STR_PASSWORD.as_bytes())?;
@@ -1493,15 +1414,7 @@ fn test_zeroize_client_registration_start() -> Result<(), ProtocolError> {
#[test] #[test]
fn test_zeroize_client_registration_finish() -> Result<(), ProtocolError> { fn test_zeroize_client_registration_finish() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut client_rng = OsRng; let mut client_rng = OsRng;
let mut server_rng = OsRng; let mut server_rng = OsRng;
let server_setup = ServerSetup::<CS>::new(&mut server_rng); let server_setup = ServerSetup::<CS>::new(&mut server_rng);
@@ -1537,12 +1450,6 @@ fn test_zeroize_client_registration_finish() -> Result<(), ProtocolError> {
fn test_zeroize_server_registration_finish() -> Result<(), ProtocolError> { fn test_zeroize_server_registration_finish() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// Envelope: Nonce + Hash // Envelope: Nonce + Hash
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
EnvelopeLen<CS>: ArrayLength<u8>, EnvelopeLen<CS>: ArrayLength<u8>,
@@ -1590,12 +1497,6 @@ fn test_zeroize_client_login_start() -> Result<(), ProtocolError> {
_test_vector: &str, _test_vector: &str,
) -> Result<(), ProtocolError> ) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// CredentialRequest: KgPk + Ke1Message // CredentialRequest: KgPk + Ke1Message
<OprfGroup<CS> as Group>::ElemLen: Add<Sum<NonceLen, <CS::KeGroup as KeGroup>::PkLen>>, <OprfGroup<CS> as Group>::ElemLen: Add<Sum<NonceLen, <CS::KeGroup as KeGroup>::PkLen>>,
CredentialRequestLen<CS>: ArrayLength<u8>, CredentialRequestLen<CS>: ArrayLength<u8>,
@@ -1640,12 +1541,6 @@ fn test_zeroize_client_login_start() -> Result<(), ProtocolError> {
fn test_zeroize_server_login_start() -> Result<(), ProtocolError> { fn test_zeroize_server_login_start() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
Sum<NonceLen, OutputSize<OprfHash<CS>>>: Sum<NonceLen, OutputSize<OprfHash<CS>>>:
@@ -1700,12 +1595,6 @@ fn test_zeroize_client_login_finish() -> Result<(), ProtocolError> {
_test_vector: &str, _test_vector: &str,
) -> Result<(), ProtocolError> ) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
Sum<NonceLen, OutputSize<OprfHash<CS>>>: Sum<NonceLen, OutputSize<OprfHash<CS>>>:
@@ -1784,12 +1673,6 @@ fn test_zeroize_client_login_finish() -> Result<(), ProtocolError> {
fn test_zeroize_server_login_finish() -> Result<(), ProtocolError> { fn test_zeroize_server_login_finish() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
Sum<NonceLen, OutputSize<OprfHash<CS>>>: Sum<NonceLen, OutputSize<OprfHash<CS>>>:
@@ -1848,15 +1731,7 @@ fn test_zeroize_server_login_finish() -> Result<(), ProtocolError> {
#[test] #[test]
fn test_scalar_always_nonzero() -> Result<(), ProtocolError> { fn test_scalar_always_nonzero() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
// Start out with a bunch of zeros to force resampling of scalar // Start out with a bunch of zeros to force resampling of scalar
let mut client_registration_rng = CycleRng::new([vec![0u8; 128], vec![1u8; 128]].concat()); let mut client_registration_rng = CycleRng::new([vec![0u8; 128], vec![1u8; 128]].concat());
let client_registration_start_result = let client_registration_start_result =
@@ -1895,15 +1770,7 @@ fn test_scalar_always_nonzero() -> Result<(), ProtocolError> {
#[test] #[test]
fn test_reflected_value_error_registration() -> Result<(), ProtocolError> { fn test_reflected_value_error_registration() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let credential_identifier = b"credentialIdentifier"; let credential_identifier = b"credentialIdentifier";
let password = b"password"; let password = b"password";
let mut client_rng = OsRng; let mut client_rng = OsRng;
@@ -1949,12 +1816,6 @@ fn test_reflected_value_error_registration() -> Result<(), ProtocolError> {
fn test_reflected_value_error_login() -> Result<(), ProtocolError> { fn test_reflected_value_error_login() -> Result<(), ProtocolError> {
fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError> fn inner<CS: CipherSuite>(_test_vector: &str) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
Sum<NonceLen, OutputSize<OprfHash<CS>>>: Sum<NonceLen, OutputSize<OprfHash<CS>>>:
+4 -69
View File
@@ -10,9 +10,8 @@ use core::ops::Add;
use std::vec; use std::vec;
use std::vec::Vec; use std::vec::Vec;
use digest::core_api::{BlockSizeUser, CoreProxy};
use digest::OutputSizeUser; use digest::OutputSizeUser;
use generic_array::typenum::{IsLess, IsLessOrEqual, Le, NonZero, Sum, U256}; use generic_array::typenum::Sum;
use generic_array::{ArrayLength, GenericArray}; use generic_array::{ArrayLength, GenericArray};
use rand::rngs::OsRng; use rand::rngs::OsRng;
use rand::RngCore; use rand::RngCore;
@@ -22,7 +21,7 @@ use voprf::Group;
use crate::ciphersuite::{CipherSuite, OprfGroup, OprfHash}; use crate::ciphersuite::{CipherSuite, OprfGroup, OprfHash};
use crate::envelope::EnvelopeLen; use crate::envelope::EnvelopeLen;
use crate::errors::*; use crate::errors::*;
use crate::hash::{Hash, OutputSize, ProxyHash}; use crate::hash::OutputSize;
use crate::key_exchange::group::KeGroup; use crate::key_exchange::group::KeGroup;
use crate::key_exchange::traits::{Ke1MessageLen, Ke2MessageLen}; use crate::key_exchange::traits::{Ke1MessageLen, Ke2MessageLen};
use crate::key_exchange::tripledh::{NonceLen, TripleDh}; use crate::key_exchange::tripledh::{NonceLen, TripleDh};
@@ -93,15 +92,7 @@ fn decode(values: &Value, key: &str) -> Option<Vec<u8>> {
values[key].as_str().and_then(|s| hex::decode(s).ok()) values[key].as_str().and_then(|s| hex::decode(s).ok())
} }
fn populate_test_vectors<CS: CipherSuite>(values: &Value) -> OpaqueTestVectorParameters fn populate_test_vectors<CS: CipherSuite>(values: &Value) -> OpaqueTestVectorParameters {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut rng = OsRng; let mut rng = OsRng;
OpaqueTestVectorParameters { OpaqueTestVectorParameters {
@@ -158,12 +149,6 @@ where
fn get_password_file_bytes<CS: CipherSuite>(parameters: &OpaqueTestVectorParameters) -> Vec<u8> fn get_password_file_bytes<CS: CipherSuite>(parameters: &OpaqueTestVectorParameters) -> Vec<u8>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// Envelope: Nonce + Hash // Envelope: Nonce + Hash
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
EnvelopeLen<CS>: ArrayLength<u8>, EnvelopeLen<CS>: ArrayLength<u8>,
@@ -322,15 +307,7 @@ fn tests() -> Result<(), ProtocolError> {
fn test_registration_request<CS: CipherSuite>( fn test_registration_request<CS: CipherSuite>(
tvs: &[OpaqueTestVectorParameters], tvs: &[OpaqueTestVectorParameters],
) -> Result<(), ProtocolError> ) -> Result<(), ProtocolError> {
where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
for parameters in tvs { for parameters in tvs {
let mut rng = CycleRng::new(parameters.blind_registration.to_vec()); let mut rng = CycleRng::new(parameters.blind_registration.to_vec());
let client_registration_start_result = let client_registration_start_result =
@@ -347,12 +324,6 @@ fn test_registration_response<CS: CipherSuite>(
tvs: &[OpaqueTestVectorParameters], tvs: &[OpaqueTestVectorParameters],
) -> Result<(), ProtocolError> ) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// RegistrationResponse: KgPk + KePk // RegistrationResponse: KgPk + KePk
<OprfGroup<CS> as Group>::ElemLen: Add<<CS::KeGroup as KeGroup>::PkLen>, <OprfGroup<CS> as Group>::ElemLen: Add<<CS::KeGroup as KeGroup>::PkLen>,
RegistrationResponseLen<CS>: ArrayLength<u8>, RegistrationResponseLen<CS>: ArrayLength<u8>,
@@ -391,12 +362,6 @@ fn test_registration_upload<CS: CipherSuite>(
tvs: &[OpaqueTestVectorParameters], tvs: &[OpaqueTestVectorParameters],
) -> Result<(), ProtocolError> ) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// Envelope: Nonce + Hash // Envelope: Nonce + Hash
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
EnvelopeLen<CS>: ArrayLength<u8>, EnvelopeLen<CS>: ArrayLength<u8>,
@@ -447,12 +412,6 @@ where
fn test_ke1<CS: CipherSuite>(tvs: &[OpaqueTestVectorParameters]) -> Result<(), ProtocolError> fn test_ke1<CS: CipherSuite>(tvs: &[OpaqueTestVectorParameters]) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// CredentialRequest: KgPk + Ke1Message // CredentialRequest: KgPk + Ke1Message
<OprfGroup<CS> as Group>::ElemLen: Add<Ke1MessageLen<CS>>, <OprfGroup<CS> as Group>::ElemLen: Add<Ke1MessageLen<CS>>,
CredentialRequestLen<CS>: ArrayLength<u8>, CredentialRequestLen<CS>: ArrayLength<u8>,
@@ -478,12 +437,6 @@ where
fn test_ke2<CS: CipherSuite>(tvs: &[OpaqueTestVectorParameters]) -> Result<(), ProtocolError> fn test_ke2<CS: CipherSuite>(tvs: &[OpaqueTestVectorParameters]) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// Envelope: Nonce + Hash // Envelope: Nonce + Hash
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
EnvelopeLen<CS>: ArrayLength<u8>, EnvelopeLen<CS>: ArrayLength<u8>,
@@ -566,12 +519,6 @@ where
fn test_ke3<CS: CipherSuite>(tvs: &[OpaqueTestVectorParameters]) -> Result<(), ProtocolError> fn test_ke3<CS: CipherSuite>(tvs: &[OpaqueTestVectorParameters]) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
Sum<NonceLen, OutputSize<OprfHash<CS>>>: ArrayLength<u8> + Add<<CS::KeGroup as KeGroup>::PkLen>, Sum<NonceLen, OutputSize<OprfHash<CS>>>: ArrayLength<u8> + Add<<CS::KeGroup as KeGroup>::PkLen>,
@@ -629,12 +576,6 @@ fn test_server_login_finish<CS: CipherSuite>(
tvs: &[OpaqueTestVectorParameters], tvs: &[OpaqueTestVectorParameters],
) -> Result<(), ProtocolError> ) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// Envelope: Nonce + Hash // Envelope: Nonce + Hash
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
EnvelopeLen<CS>: ArrayLength<u8>, EnvelopeLen<CS>: ArrayLength<u8>,
@@ -701,12 +642,6 @@ fn test_fake_vectors<CS: CipherSuite>(
tvs: &[OpaqueTestVectorParameters], tvs: &[OpaqueTestVectorParameters],
) -> Result<(), ProtocolError> ) -> Result<(), ProtocolError>
where where
<OprfHash<CS> as OutputSizeUser>::OutputSize:
IsLess<U256> + IsLessOrEqual<<OprfHash<CS> as BlockSizeUser>::BlockSize>,
OprfHash<CS>: Hash,
<OprfHash<CS> as CoreProxy>::Core: ProxyHash,
<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<OprfHash<CS> as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
// MaskedResponse: (Nonce + Hash) + KePk // MaskedResponse: (Nonce + Hash) + KePk
NonceLen: Add<OutputSize<OprfHash<CS>>>, NonceLen: Add<OutputSize<OprfHash<CS>>>,
Sum<NonceLen, OutputSize<OprfHash<CS>>>: ArrayLength<u8> + Add<<CS::KeGroup as KeGroup>::PkLen>, Sum<NonceLen, OutputSize<OprfHash<CS>>>: ArrayLength<u8> + Add<<CS::KeGroup as KeGroup>::PkLen>,