Updating AKE message format (#85)

This commit is contained in:
Kevin Lewi
2020-11-16 11:49:27 -08:00
committed by GitHub
parent f18eaea8cf
commit 51b3781e5c
7 changed files with 300 additions and 107 deletions
+12 -6
View File
@@ -4,7 +4,7 @@
// LICENSE file in the root directory of this source tree.
use crate::{
errors::{InternalPakeError, ProtocolError},
errors::{PakeError, ProtocolError},
hash::Hash,
keypair::KeyPair,
};
@@ -13,17 +13,19 @@ use rand_core::{CryptoRng, RngCore};
use std::convert::TryFrom;
pub trait KeyExchange<D: Hash, KeyFormat: KeyPair> {
type KE1State: for<'r> TryFrom<&'r [u8], Error = InternalPakeError> + ToBytes;
type KE2State: for<'r> TryFrom<&'r [u8], Error = InternalPakeError> + ToBytes;
type KE1Message: for<'r> TryFrom<&'r [u8], Error = InternalPakeError> + ToBytes;
type KE2Message: for<'r> TryFrom<&'r [u8], Error = InternalPakeError> + ToBytes;
type KE3Message: for<'r> TryFrom<&'r [u8], Error = InternalPakeError> + ToBytes;
type KE1State: for<'r> TryFrom<&'r [u8], Error = PakeError> + ToBytes;
type KE2State: for<'r> TryFrom<&'r [u8], Error = PakeError> + ToBytes;
type KE1Message: for<'r> TryFrom<&'r [u8], Error = PakeError> + ToBytes;
type KE2Message: for<'r> TryFrom<&'r [u8], Error = PakeError> + ToBytes;
type KE3Message: for<'r> TryFrom<&'r [u8], Error = PakeError> + ToBytes;
fn generate_ke1<R: RngCore + CryptoRng>(
l1_component: Vec<u8>,
info: Vec<u8>,
rng: &mut R,
) -> Result<(Self::KE1State, Self::KE1Message), ProtocolError>;
#[allow(clippy::too_many_arguments)]
fn generate_ke2<R: RngCore + CryptoRng>(
rng: &mut R,
l1_bytes: Vec<u8>,
@@ -31,6 +33,8 @@ pub trait KeyExchange<D: Hash, KeyFormat: KeyPair> {
ke1_message: Self::KE1Message,
client_s_pk: KeyFormat::Repr,
server_s_sk: KeyFormat::Repr,
info: Vec<u8>,
e_info: Vec<u8>,
) -> Result<(Self::KE2State, Self::KE2Message), ProtocolError>;
fn generate_ke3(
@@ -39,6 +43,8 @@ pub trait KeyExchange<D: Hash, KeyFormat: KeyPair> {
ke1_state: &Self::KE1State,
server_s_pk: KeyFormat::Repr,
client_s_sk: KeyFormat::Repr,
info: Vec<u8>,
e_info: Vec<u8>,
) -> Result<(Vec<u8>, Self::KE3Message), ProtocolError>;
fn finish_ke(