Skip to content

Conversation

@baloo
Copy link
Member

@baloo baloo commented Mar 14, 2025

No description provided.

@tarcieri
Copy link
Member

Nice, thanks

@baloo baloo force-pushed the baloo/inout branch 3 times, most recently from bcd2cac to 13bea12 Compare March 14, 2025 18:53
init_ctr(&self.enc_cipher, tag).apply_keystream_partial(buffer.into());
self.polyval.update_padded(buffer);
init_ctr(&self.enc_cipher, tag).apply_keystream_partial(buffer.reborrow());
self.polyval.update_padded(buffer.get_in());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one needs to be get_out, since it's authenticating the decrypted plaintext (since the "SIV" tag is calculated from the plaintext)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, in case it's not the same backing buffer for in and out?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@tarcieri
Copy link
Member

tarcieri commented Mar 14, 2025

It might be good to add some basic smoke tests of the AeadInOut impls, since using them indirectly through the Aead/AeadInPlace APIs doesn't expose bugs where in/out are swapped

ctr.apply_keystream_partial(buffer.reborrow());

let full_tag = self.compute_tag(mask, associated_data, buffer);
let full_tag = self.compute_tag(mask, associated_data, buffer.get_in());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one probably needs to be get_out, to compute a MAC over the ciphertext

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah there is probably a whole slew of those, I assumed the backing buffer was unique.

let siv_tag = s2v(&mut self.mac, headers, plaintext)?;
self.xor_with_keystream(siv_tag, plaintext);
let siv_tag = s2v(&mut self.mac, headers, plaintext.get_in())?;
self.xor_with_keystream(siv_tag, plaintext.get_out());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs to pass plaintext and the receiver needs to load plaintext from in and write to out

@baloo
Copy link
Member Author

baloo commented Mar 14, 2025

Need to remake this PR from scratch.

@baloo baloo closed this Mar 14, 2025
@tarcieri
Copy link
Member

@baloo you can just open a new complete PR to master if you want and I can close #663, that would make for a simpler history

@baloo
Copy link
Member Author

baloo commented Mar 14, 2025

I think I need a util for inout to duplicate the backing buffer from the original slice to flush out the misuse of get_in()

@tarcieri
Copy link
Member

@baloo that's what I was suggesting re: smoke tests, which can use separate buffers for input and output. Once you have a basic framework for them you can put them in aead::dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants