Repository navigation
crypto.cipher: make Stream.xor_key_stream implementers require a mutable receiver - #21974
Merged
Merged
Conversation
einar-hjortdal
marked this pull request as ready for review
August 1, 2024 08:29
Contributor
Author
|
Please review tests in particular. |
einar-hjortdal
commented
Aug 1, 2024
einar-hjortdal
left a comment
Contributor
Author
There was a problem hiding this comment.
Seems like errors are thrown in des_ofb_test.v, these should be fixed before merge
Contributor
Author
|
Should be ready now |
Contributor
They way you did it is fine. Another approach is having a function, that would not be called, but only checked: fn implements(x cipher.Ctr) cipher.Stream { return x }... which relies that the compiler will then ensure, that |
spytheman
reviewed
Aug 1, 2024
Comment on lines
-66
to
+70
| pub fn (mut x Cfb) xor_key_stream(mut dst_ []u8, src_ []u8) { | ||
| pub fn (mut x Cfb) xor_key_stream(mut dst []u8, src []u8) { | ||
| unsafe { | ||
| mut dst := *dst_ | ||
| mut src := src_ | ||
| if dst.len < src.len { | ||
| mut local_dst := *dst | ||
| mut local_src := src | ||
| if local_dst.len < local_src.len { |
Contributor
There was a problem hiding this comment.
Those are good changes, just a bit unrelated to the topic of the PR.
spytheman
reviewed
Aug 1, 2024
| // xor_key_stream sets dst to the result of XORing src with the key stream. | ||
| // Dst and src must overlap entirely or not at all. | ||
| pub fn (mut c Cipher) xor_key_stream(mut dst []u8, mut src []u8) { | ||
| pub fn (mut c Cipher) xor_key_stream(mut dst []u8, src []u8) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses #21973
This may impact stream ciphers that implement xor_key_stream with immutable implementers, and may therefore be breaking.
Further checks should be made so that all stream ciphers implement xor_key_stream correctly, tests are missing for this scenario in all stream cipher implementations.
I am not sure how to perform such tests, help is needed to add such tests.