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