rust: Add assertion that input length is at least 0 for AES

It doesn't look like the AES engine can handle 0-sized input. This makes
sense, in a way, as it is an edge case and in most cases a no-op. Only
in GCM mode, where there one might want to compute a tag over a 0-byte
input, would this come up.
This commit is contained in:
Wladimir J. van der Laan 2020-04-27 21:01:01 +00:00
parent 217b00227e
commit fbe528d8b6

View File

@ -53,6 +53,7 @@ pub fn run(
tag: &mut [u8], tag: &mut [u8],
) )
{ {
assert!(ind.len() != 0);
match cipher_mode { match cipher_mode {
cipher_mode::ECB => assert!(iv.len() == 0 && aad.len() == 0), cipher_mode::ECB => assert!(iv.len() == 0 && aad.len() == 0),
cipher_mode::CBC => assert!(iv.len() == 16 && aad.len() == 0), cipher_mode::CBC => assert!(iv.len() == 16 && aad.len() == 0),