Skip to content

Conversation

@alex
Copy link
Member

@alex alex commented Nov 26, 2025

TripleDES now only accepts 24-byte (192-bit) keys. Users needing single DES (1-key) or two-key Triple DES compatibility must expand the key themselves:

  • Single DES (8 bytes): key + key + key
  • Two-key 3DES (16 bytes): key + key[:8]

This change removes the automatic key expansion that was previously done in the TripleDES constructor, making the key length requirement explicit and preventing accidental use of weaker key configurations.

TripleDES now emits a deprecation warning when 8-byte (single DES) or
16-byte (two-key) keys are passed. In a future release, only 24-byte
(192-bit) keys will be accepted.

Users needing single DES or two-key Triple DES compatibility should
expand the key themselves:
- Single DES (8 bytes): key + key + key
- Two-key 3DES (16 bytes): key + key[:8]
@alex alex force-pushed the claude/enforce-tripledes-key-length-016zncCxwMyqoMNViGQ3a9JQ branch from f0177b0 to 1937220 Compare November 26, 2025 15:06
@reaperhulk
Copy link
Member

Have we tagged our downstreams to let them know about this?

@alex
Copy link
Member Author

alex commented Nov 30, 2025

No, I was going to let the warning play that role. (Since this is a warning and not an immediate breakage.)

@alex
Copy link
Member Author

alex commented Nov 30, 2025

FYI @glyph, @gpotter2 -- this appears to trigger warnings in twisted and scapy.

For twisted I think there's some tests that just use a short key for no reason. For scapy I think there's code that really does want Single DES (in which case this behavior can be obtained by concatting the key 3x).

@glyph
Copy link
Contributor

glyph commented Nov 30, 2025

We definitely have a recurring issue where people just generate the default, or sometimes even the shortest available, key for tests. And we don't have good infrastructure for responsiveness to warnings 😬

@alex
Copy link
Member Author

alex commented Nov 30, 2025

@glyph good news, the problem is far dumber: https://github.com/twisted/twisted/blob/506d17fb71abf213dc77cfe7b55eb1fafb5f2437/src/twisted/conch/test/test_transport.py#L702-L705 this assumes all keys have a size of 16 bytes, but that's wrong for 3des, it's key size is 24 bytes. If you fix that, I think twisted will be good.

@glyph
Copy link
Contributor

glyph commented Nov 30, 2025

OK, unless I hear otherwise, I assume Twisted is good now

@gpotter2
Copy link
Contributor

gpotter2 commented Dec 1, 2025

Thanks a lot for the heads up, I've drafted a PR on our side to have this ready.

I think there's code that really does want Single DES

Heh yeah, for compat with ancient IPSEC, Kerberos and TLS cases.

@reaperhulk reaperhulk merged commit 6a7cced into main Dec 1, 2025
68 checks passed
@reaperhulk reaperhulk deleted the claude/enforce-tripledes-key-length-016zncCxwMyqoMNViGQ3a9JQ branch December 1, 2025 00:30
@alex
Copy link
Member Author

alex commented Dec 1, 2025

thanks for jumping on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants