Skip to content

Commit

Permalink
Test for bad AAD input
Browse files Browse the repository at this point in the history
  • Loading branch information
cygnusv committed Aug 1, 2023
1 parent 1c814b8 commit cc830bf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tpke/src/ciphertext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl<E: Pairing> Ciphertext<E> {
}
}

// FIXME: Remove?
pub fn serialized_length(&self) -> usize {
self.commitment.serialized_size(Compress::No)
+ self.auth_tag.serialized_size(Compress::No)
Expand Down Expand Up @@ -201,6 +202,7 @@ fn hash_to_g2<T: ark_serialize::CanonicalDeserialize>(
) -> Result<T> {
let point = htp_bls12381_g2(message);
let mut point_ser: Vec<u8> = Vec::new();
// TODO: ????
point.serialize_compressed(&mut point_ser)?;
T::deserialize_compressed(&point_ser[..]).map_err(Error::ArkSerializeError)
}
Expand Down Expand Up @@ -244,7 +246,11 @@ mod tests {
let plaintext =
decrypt_symmetric(&ciphertext, aad, &privkey, g_inv).unwrap();

assert_eq!(msg, plaintext)
assert_eq!(msg, plaintext);

let bad: &[u8] = "bad-aad".as_bytes();

assert!(decrypt_symmetric(&ciphertext, bad, &privkey, g_inv).is_err());
}

#[test]
Expand Down

0 comments on commit cc830bf

Please sign in to comment.