diff --git a/tsp/src/crypto/mod.rs b/tsp/src/crypto/mod.rs index a55625a..f92c2cb 100644 --- a/tsp/src/crypto/mod.rs +++ b/tsp/src/crypto/mod.rs @@ -1,3 +1,4 @@ +use crate::definitions::MessageType; use crate::definitions::{ Digest, NonConfidentialData, Payload, PrivateKeyData, PrivateSigningKeyData, PrivateVid, PublicKeyData, PublicVerificationKeyData, TSPMessage, VerifiedVid, @@ -132,14 +133,7 @@ pub fn sign( pub fn verify<'a>( sender: &dyn VerifiedVid, tsp_message: &'a mut [u8], -) -> Result< - ( - &'a [u8], - crate::cesr::CryptoType, - crate::cesr::SignatureType, - ), - CryptoError, -> { +) -> Result<(&'a [u8], MessageType), CryptoError> { nonconfidential::verify(sender, tsp_message) } diff --git a/tsp/src/crypto/nonconfidential.rs b/tsp/src/crypto/nonconfidential.rs index 99319dc..040b79f 100644 --- a/tsp/src/crypto/nonconfidential.rs +++ b/tsp/src/crypto/nonconfidential.rs @@ -1,6 +1,6 @@ use crate::{ cesr::{CryptoType, DecodedEnvelope, Envelope, SignatureType}, - definitions::{PrivateVid, TSPMessage, VerifiedVid}, + definitions::{MessageType, PrivateVid, TSPMessage, VerifiedVid}, }; use ed25519_dalek::ed25519::signature::Signer; @@ -37,14 +37,7 @@ pub fn sign( pub fn verify<'a>( sender: &dyn VerifiedVid, tsp_message: &'a mut [u8], -) -> Result< - ( - &'a [u8], - crate::cesr::CryptoType, - crate::cesr::SignatureType, - ), - CryptoError, -> { +) -> Result<(&'a [u8], MessageType), CryptoError> { let view = crate::cesr::decode_envelope(tsp_message)?; // verify outer signature @@ -72,5 +65,11 @@ pub fn verify<'a>( return Err(CryptoError::MissingCiphertext); }; - Ok((nonconfidential_data, crypto_type, signature_type)) + Ok(( + nonconfidential_data, + MessageType { + crypto_type, + signature_type, + }, + )) } diff --git a/tsp/src/store.rs b/tsp/src/store.rs index 0f43033..86b2e31 100644 --- a/tsp/src/store.rs +++ b/tsp/src/store.rs @@ -778,17 +778,13 @@ impl Store { return Err(Error::UnverifiedVid(sender.to_string())); }; - let (message, crypto_type, signature_type) = - crate::crypto::verify(&*sender_vid, message)?; + let (message, message_type) = crate::crypto::verify(&*sender_vid, message)?; Ok(ReceivedTspMessage::GenericMessage { sender, nonconfidential_data: None, message, - message_type: MessageType { - crypto_type, - signature_type, - }, + message_type, }) } }