-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
DES-CTR workaround for an upstream bug #647
Conversation
I've removed the workarounds as forge has released version 0.9.1 and DES-CTR works correctly now; however the tests still need to be corrected. Forge's version needs to be updated as well. In addition, forge now enforces IV to be the same size as block size (as it should): digitalbazaar/forge@9979169. This broke a lot of tests. I may do another PR to fix them |
I'll close this and consolidate the all tests' changes resulting from forge 0.9.1 into another PR. |
The upstream project forge has a pretty bad issue (digitalbazaar/forge#721) which causes block ciphers with block size smaller than 16 bytes to produce wrong outputs with CTR mode. DES has a block size of 8 bytes so DES-CTR is affected (but other modes are still correct). The upstream maintainer has made a fix (digitalbazaar/forge#722)
but we don't know when the fixed version will be released to npm.This means that CyberChef's DES-CTR outputs are wrong (and vulnerable. See Consequences section in digitalbazaar/forge#721).
This PR provides a workaround by implementing DES-CTR mode manually.Forge didn't have unit tests for DES-CTR so this problem went unnoticed. While there are unit tests for DES-CTR in this repo, the ground truths were presumably produced by forge, and therefore incorrect. This PR corrects these test using outputs from GoLang's standard library. These are also reproducible by pyCryptoDome:
CyberChef/tests/operations/tests/Crypt.mjs
Lines 539 to 553 in 928f1c3
https://play.golang.org/p/4Qm2hfLGsqc produces
09015087e15b0937c462fd5974af0c4b5880de136a5680453c99f4500628cbeca769623515d836985110b93eacfea7fa4a7b2b3cb4f67acbb5f7e8ddb5a5d445da74bf6572b0a874befa3888c81110776388e400afd8dc908dcc0c018c7753355f8a1c9f
. Diff in CyberChefCyberChef/tests/operations/tests/Crypt.mjs
Lines 1162 to 1176 in 928f1c3
https://play.golang.org/p/FpvqncmPk7R produces
7a0e643132750e96b76dc9efa7810bea2b8feaa5b97887e44f96c0e6d506cc4dd4665683c6f63139221f8d887fd0a05b39741f8a67d87d6ac6f8dc6b668bd3e4a97b8bd3a19eafd5cdf50c3e1b3f17d61087d0b67cf6db31fec338b75f5954942c852829
. Diff in CyberChef