Update DES and 3DES to use ECB instead of CBC chaining mode #58
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.
Go's DES and 3DES implementations use the ECB chaining mode. Unfortunately, CNG defaults to CBC chaining mode, and we were not overriding that property when instantiating DES and 3DES keys.
This PR fixes this mismatch by honoring Go's chaining mode together with a new extensive test suite that ensures we don't regress.
This a breaking change: data longer than the DES or 3DES block size (8 bytes and 24 bytes respectively) encrypted with the CNG backend won't be decryptable after this fix. Note that the Microsoft Go toolchain has implemented DES and 3DES using the CNG backend since Go 1.22.
To work around this issue, please follow these steps: