* Add Rustfmt

* Add Taplo
This commit is contained in:
daxpedda
2022-01-05 21:19:02 -08:00
committed by GitHub
parent 36f0a55518
commit 47a26a19c5
30 changed files with 698 additions and 554 deletions
+30 -34
View File
@@ -7,34 +7,30 @@
//! Contains the messages used for OPAQUE
use crate::{
ciphersuite::CipherSuite,
envelope::{Envelope, EnvelopeLen},
errors::{
utils::{check_slice_size, check_slice_size_atleast},
ProtocolError,
},
hash::{OutputSize, ProxyHash},
key_exchange::{
group::KeGroup,
traits::{FromBytes, Ke1MessageLen, Ke2MessageLen, Ke3MessageLen, KeyExchange, ToBytes},
tripledh::NonceLen,
},
keypair::{KeyPair, PublicKey, SecretKey},
opaque::{MaskedResponse, MaskedResponseLen, ServerSetup},
};
use core::ops::Add;
use derive_where::DeriveWhere;
use digest::core_api::{BlockSizeUser, CoreProxy};
use digest::Output;
use generic_array::sequence::Concat;
use generic_array::{
typenum::{IsLess, Le, NonZero, Sum, Unsigned, U256},
ArrayLength, GenericArray,
};
use generic_array::typenum::{IsLess, Le, NonZero, Sum, Unsigned, U256};
use generic_array::{ArrayLength, GenericArray};
use rand::{CryptoRng, RngCore};
use voprf::Group;
use crate::ciphersuite::CipherSuite;
use crate::envelope::{Envelope, EnvelopeLen};
use crate::errors::utils::{check_slice_size, check_slice_size_atleast};
use crate::errors::ProtocolError;
use crate::hash::{OutputSize, ProxyHash};
use crate::key_exchange::group::KeGroup;
use crate::key_exchange::traits::{
FromBytes, Ke1MessageLen, Ke2MessageLen, Ke3MessageLen, KeyExchange, ToBytes,
};
use crate::key_exchange::tripledh::NonceLen;
use crate::keypair::{KeyPair, PublicKey, SecretKey};
use crate::opaque::{MaskedResponse, MaskedResponseLen, ServerSetup};
////////////////////////////
// High-level API Structs //
// ====================== //
@@ -91,8 +87,8 @@ where
<<CS::Hash as CoreProxy>::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<<CS::Hash as CoreProxy>::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
/// The "envelope" generated by the user, containing sealed
/// cryptographic identifiers
/// The "envelope" generated by the user, containing sealed cryptographic
/// identifiers
pub(crate) envelope: Envelope<CS>,
/// The masking key used to mask the envelope
pub(crate) masking_key: Output<CS::Hash>,
@@ -139,8 +135,8 @@ impl_serialize_and_deserialize_for!(
CredentialRequestLen<CS>: ArrayLength<u8>,
);
/// The answer sent by the server to the user, upon reception of the
/// login attempt
/// The answer sent by the server to the user, upon reception of the login
/// attempt
#[derive(DeriveWhere)]
#[derive_where(Clone)]
#[derive_where(
@@ -179,8 +175,8 @@ impl_serialize_and_deserialize_for!(
CredentialResponseLen<CS>: ArrayLength<u8>,
);
/// The answer sent by the client to the server, upon reception of the
/// sealed envelope
/// The answer sent by the client to the server, upon reception of the sealed
/// envelope
#[derive(DeriveWhere)]
#[derive_where(Clone)]
#[derive_where(
@@ -275,8 +271,8 @@ where
}
#[cfg(test)]
/// Only used for tests, where we can set the beta value to test for the reflection
/// error case
/// Only used for tests, where we can set the beta value to test for the
/// reflection error case
pub fn set_evaluation_element_for_testing(&self, beta: CS::OprfGroup) -> Self {
Self {
evaluation_element: voprf::EvaluationElement::from_value_unchecked(beta),
@@ -383,8 +379,8 @@ where
let checked_slice = check_slice_size_atleast(input, elem_len, "login_first_message_bytes")?;
// Check that the message is actually containing an element of the
// correct subgroup
// Check that the message is actually containing an element of the correct
// subgroup
let blinded_element = voprf::BlindedElement::<CS::OprfGroup, CS::Hash>::deserialize(
&checked_slice[..elem_len],
)?;
@@ -476,8 +472,8 @@ where
"credential_response_bytes",
)?;
// Check that the message is actually containing an element of the
// correct subgroup
// Check that the message is actually containing an element of the correct
// subgroup
let beta_bytes = &checked_slice[..elem_len];
let evaluation_element =
voprf::EvaluationElement::<CS::OprfGroup, CS::Hash>::deserialize(beta_bytes)?;
@@ -506,8 +502,8 @@ where
}
#[cfg(test)]
/// Only used for tests, where we can set the beta value to test for the reflection
/// error case
/// Only used for tests, where we can set the beta value to test for the
/// reflection error case
pub fn set_evaluation_element_for_testing(&self, beta: CS::OprfGroup) -> Self {
Self {
evaluation_element: voprf::EvaluationElement::from_value_unchecked(beta),