Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CFB8 non-overlapping decrypt #275

Merged
merged 2 commits into from
Mar 9, 2024
Merged

Conversation

layou233
Copy link
Contributor

@layou233 layou233 commented Mar 9, 2024

#265 introduced a new optimization to use SIMD, however, I found it does not work in some cases recently. It requires the dst and the src to be non-overlapping at all (the case in the test), but we can only ensure that "dst and src does not overlap in first block size". (see code comment)

Another frustrating thing is that in the cipher.StreamReader scenario (the case in go-mc net package), dst and src are completely overlapping, meaning they are not subject to the optimization in #265. So this PR does not actually affect the performance for go-mc net/bot package users, since they do not ever got benefited from #265, they got benefited only from #256. See https://go.dev/src/crypto/cipher/io.go#L21

I may try to optimize decryption in overlapping cases later this year (focusing on parallelism), for now I will only make small fixes.

@Tnze Tnze merged commit 2445ff3 into Tnze:master Mar 9, 2024
4 checks passed
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