Skip to content

Commit e83e618

Browse files
committed
aes_gcm: Change InOut semantics.
We convert an `InOut` to pointers only immediately prior to calling a function that will immediately invalidate the input. Therefore, it makes more sense for the conversion to consume the `InOut`.
1 parent a8619bc commit e83e618

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/aead/aes/ffi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ impl AES_KEY {
167167
key: &AES_KEY,
168168
ivec: &Counter,
169169
),
170-
mut in_out: InOut<'_>,
170+
in_out: InOut<'_>,
171171
ctr: &mut Counter,
172172
) {
173-
let (input, output, len) = in_out.input_output_len();
173+
let (input, output, len) = in_out.into_input_output_len();
174174
debug_assert_eq!(len % BLOCK_LEN, 0);
175175

176176
let blocks = match NonZeroUsize::new(len / BLOCK_LEN) {

src/aead/inout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl InOut<'_> {
4242
pub fn len(&self) -> usize {
4343
self.in_out[self.src.clone()].len()
4444
}
45-
pub fn input_output_len(&mut self) -> (*const u8, *mut u8, usize) {
45+
pub fn into_input_output_len(self) -> (*const u8, *mut u8, usize) {
4646
let len = self.len();
4747
let output = self.in_out.as_mut_ptr();
4848
// TODO: MSRV(1.65): use `output.cast_const()`

0 commit comments

Comments
 (0)