File tree 3 files changed +8
-1
lines changed
3 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ macro_rules! shuffle {
37
37
#[ inline( always) ]
38
38
pub ( super ) fn expand ( key : & [ u8 ; 24 ] ) -> ( RoundKeys , RoundKeys ) {
39
39
unsafe {
40
+ // SAFETY: `RoundKeys` is a `[__m128i; 13]` which can be initialized
41
+ // with all zeroes.
40
42
let mut enc_keys: RoundKeys = mem:: zeroed ( ) ;
41
43
let mut dec_keys: RoundKeys = mem:: zeroed ( ) ;
42
44
Original file line number Diff line number Diff line change @@ -62,7 +62,9 @@ macro_rules! expand_round_last {
62
62
63
63
#[ inline( always) ]
64
64
pub ( super ) fn expand ( key : & [ u8 ; 32 ] ) -> ( RoundKeys , RoundKeys ) {
65
- // Safety: `loadu` and `storeu` support unaligned access
65
+ // SAFETY:
66
+ // - `RoundKeys` is a `[__m128i; 15]` which can be initialized with all zeroes.
67
+ // - `loadu` and `storeu` support unaligned access
66
68
#[ allow( clippy:: cast_ptr_alignment) ]
67
69
unsafe {
68
70
let mut enc_keys: RoundKeys = mem:: zeroed ( ) ;
Original file line number Diff line number Diff line change @@ -83,6 +83,8 @@ macro_rules! impl_ctr {
83
83
#[ inline( always) ]
84
84
fn gen_block( & mut self ) {
85
85
let block = self . cipher. encrypt( swap_bytes( self . ctr) ) ;
86
+ // SAFETY: All three expansions of this macro have a `$cipher` whose
87
+ // `encrypt(...)` method returns an `__m128i`, and `BLOCK_SIZE == 16`.
86
88
self . block = unsafe { mem:: transmute( block) }
87
89
}
88
90
@@ -96,6 +98,7 @@ macro_rules! impl_ctr {
96
98
#[ inline( always) ]
97
99
fn next_block8( & mut self ) -> [ __m128i; 8 ] {
98
100
let mut ctr = self . ctr;
101
+ // SAFETY: `[__m128i; 8]` can be initialized with all zeroes.
99
102
let mut block8: [ __m128i; 8 ] = unsafe { mem:: zeroed( ) } ;
100
103
for i in 0 ..8 {
101
104
block8[ i] = swap_bytes( ctr) ;
You can’t perform that action at this time.
0 commit comments