Start integrating the derivable SizedBytes

- just derive it on Key and KeyPair for now
This commit is contained in:
François Garillot
2020-11-03 16:45:37 -05:00
parent 3954cd23b8
commit 230b1bcef6
10 changed files with 84 additions and 100 deletions
+20
View File
@@ -10,6 +10,8 @@ use thiserror::Error;
/// Represents an error in the manipulation of internal cryptographic data
#[derive(Debug, Display, Error)]
pub enum InternalPakeError {
/// Deserializing from a byte sequence failed
InvalidByteSequence,
/// Invalid length for {name}: expected {len}, but is actually {actual_len}.
SizeError {
/// name
@@ -116,6 +118,24 @@ impl From<::std::convert::Infallible> for ProtocolError {
}
}
impl From<generic_bytes::TryFromSizedBytesError> for InternalPakeError {
fn from(_: generic_bytes::TryFromSizedBytesError) -> Self {
InternalPakeError::InvalidByteSequence
}
}
impl From<generic_bytes::TryFromSizedBytesError> for PakeError {
fn from(e: generic_bytes::TryFromSizedBytesError) -> Self {
PakeError::CryptoError(e.into())
}
}
impl From<generic_bytes::TryFromSizedBytesError> for ProtocolError {
fn from(e: generic_bytes::TryFromSizedBytesError) -> Self {
PakeError::CryptoError(e.into()).into()
}
}
pub(crate) mod utils {
use super::*;