From 246830a3d2b55a59b26f1a95b4cd659d6458d2a2 Mon Sep 17 00:00:00 2001 From: Bobbin Threadbare Date: Thu, 14 Mar 2024 17:54:56 -0700 Subject: [PATCH] fix: validate signature header on deserialization --- src/dsa/rpo_falcon512/signature.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/dsa/rpo_falcon512/signature.rs b/src/dsa/rpo_falcon512/signature.rs index 7f6f7abf..d9c7adc3 100644 --- a/src/dsa/rpo_falcon512/signature.rs +++ b/src/dsa/rpo_falcon512/signature.rs @@ -136,26 +136,18 @@ impl Serializable for Signature { impl Deserializable for Signature { fn read_from(source: &mut R) -> Result { // decode public key - let pk: PubKeyPoly = source.read()?; + let h: PubKeyPoly = source.read()?; // decode hash-to-point algorithm let htp = source.read()?; // decode signature - let header = source.read_u8()?; - let (encoding, log_n) = (header >> 4, header & 0b00001111); - if encoding != 0b0011 { - // TODO return error - } - - if log_n as usize != LOG_N { - // TODO: return error - } + let header: SignatureHeader = source.read()?; let nonce = source.read()?; let s2 = source.read()?; - Ok(Self::new(pk, s2, nonce, htp)) + Ok(Self { header, s2, nonce, h, htp }) } }