Skip to content

Commit 1dceeb1

Browse files
committed
hs1-siv: fix max length check for 32 bit targets, also add to decrypt
1 parent 16a883f commit 1dceeb1

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

hs1-siv/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ fn hs1_siv_encrypt<P: Hs1Params>(
283283
a: &[u8],
284284
m: &mut [u8],
285285
) -> Result<Array<u8, P::L>, aead::Error> {
286-
if m.len() > 1 << 38 {
286+
if m.len() as u128 > 1 << 38 {
287287
return Err(aead::Error);
288288
}
289289
let t = hs1_tag::<P>(k, a, n, &*m);
@@ -298,6 +298,9 @@ fn hs1_siv_decrypt<P: Hs1Params>(
298298
m: &mut [u8],
299299
t: &Array<u8, P::L>,
300300
) -> Result<(), aead::Error> {
301+
if m.len() as u128 > 1 << 38 {
302+
return Err(aead::Error);
303+
}
301304
hs1::<P>(k, &[t], n, 64, m);
302305
let t2 = hs1_tag::<P>(k, a, n, m);
303306
let diff = t.iter().zip(t2.iter()).fold(0, |s, (x, y)| s | (x ^ y));

0 commit comments

Comments
 (0)