Make inputs to recv_mac
and meta_recv_mac
immutable
#8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, you had to pass a mutable slice to
(meta_)recv_mac
. Regardless of the output, the value left in the buffer was the XOR of the expected MAC with the received MAC. This is a pretty leaky abstraction, and one that theoretically allows the user to make their own insecure MAC test by simply checking if the buffer is all-zeros.This PR makes the
(meta_)recv_mac
input immutable, and instead makes a copy internally. To ensure a copy is made, it requires a&[u8; N]
for some constantN
. This is a nontrivial choice for API ergonomics, but the MAC sizes for a system do not usually change, and they certainly won't exceed the quantitiesN
that the useful traits on[u8; N]
are defined for.Separately, this PR makes the encryption example more secure by adding nonces and authentication.