Ensure that all public keys are being checked when deserialized

This commit is contained in:
Kevin Lewi
2021-06-14 22:39:13 -07:00
committed by Kevin Lewi
parent 0935bea8ff
commit 30e27a11e2
5 changed files with 70 additions and 67 deletions
+10 -7
View File
@@ -4,22 +4,21 @@
// LICENSE file in the root directory of this source tree.
use crate::{
ciphersuite::CipherSuite,
errors::{PakeError, ProtocolError},
group::Group,
hash::Hash,
keypair::Key,
};
use rand::{CryptoRng, RngCore};
use std::convert::TryFrom;
use zeroize::Zeroize;
pub trait KeyExchange<D: Hash, G: Group> {
type KE1State: for<'r> TryFrom<&'r [u8], Error = PakeError> + ToBytesWithPointers + Zeroize;
type KE2State: for<'r> TryFrom<&'r [u8], Error = PakeError> + ToBytesWithPointers + Zeroize;
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;
type KE1State: FromBytes + ToBytesWithPointers + Zeroize;
type KE2State: FromBytes + ToBytesWithPointers + Zeroize;
type KE1Message: FromBytes + ToBytes;
type KE2Message: FromBytes + ToBytes;
type KE3Message: FromBytes + ToBytes;
fn generate_ke1<R: RngCore + CryptoRng>(
info: Vec<u8>,
@@ -60,6 +59,10 @@ pub trait KeyExchange<D: Hash, G: Group> {
fn ke2_message_size() -> usize;
}
pub trait FromBytes: Sized {
fn from_bytes<CS: CipherSuite>(input: &[u8]) -> Result<Self, PakeError>;
}
pub trait ToBytes {
fn to_bytes(&self) -> Vec<u8>;
}