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

Update DES and 3DES to use ECB instead of CBC chaining mode #58

Merged
merged 1 commit into from
Sep 25, 2024
Merged

Conversation

qmuntal
Copy link
Member

@qmuntal qmuntal commented Sep 25, 2024

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:

  1. Decrypt the existing encrypted data using a Microsoft Go toolchain that doesn't contain the fix.
  2. Encrypt the just-decrypted data using a Microsoft Go toolchain that contains the fix.

@qmuntal qmuntal changed the title Update DES and 3DES to use ECB instead of CBC by default Update DES and 3DES to use ECB instead of CBC Sep 25, 2024
@qmuntal qmuntal changed the title Update DES and 3DES to use ECB instead of CBC Update DES and 3DES to use ECB instead of CBC chainning modes Sep 25, 2024
@qmuntal qmuntal changed the title Update DES and 3DES to use ECB instead of CBC chainning modes Update DES and 3DES to use ECB instead of CBC chaining modes Sep 25, 2024
@qmuntal qmuntal changed the title Update DES and 3DES to use ECB instead of CBC chaining modes Update DES and 3DES to use ECB instead of CBC chaining mode Sep 25, 2024
@qmuntal qmuntal merged commit fdc07be into main Sep 25, 2024
25 checks passed
@qmuntal qmuntal deleted the cipret branch September 25, 2024 15:03
dagood pushed a commit that referenced this pull request Sep 25, 2024
Update DES and 3DES to use ECB instead of CBC chaining mode

(cherry picked from commit fdc07be)
dagood added a commit that referenced this pull request Sep 25, 2024
Update DES and 3DES to use ECB instead of CBC chaining mode

(cherry picked from commit fdc07be)

Co-authored-by: Quim Muntal <[email protected]>
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.

3 participants