Skip to content

Commit

Permalink
aes: Assert precondition required for soundness (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshlf committed Feb 13, 2024
1 parent 46462cc commit 3e1e83f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aes/src/armv8/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub unsafe fn expand_key<const L: usize, const N: usize>(key: &[u8; L]) -> [uint

let mut expanded_keys: [uint8x16_t; N] = mem::zeroed();

// Sanity check, as this is required in order for the following line to be sound.
// We'd rather panic than exhibit undefined behavior.
assert!(mem::align_of::<uint8x16_t>() >= mem::align_of::<u32>());
let columns =
slice::from_raw_parts_mut(expanded_keys.as_mut_ptr() as *mut u32, N * BLOCK_WORDS);

Expand Down

0 comments on commit 3e1e83f

Please sign in to comment.