0

Is there a 112-bits Triple DES example implementation in Python?

I've found pydes, but it works only with 16 or 24 bytes for Triple DES.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
yegorov-p
  • 133
  • 1
  • 2
  • 14

1 Answers1

3

In DES keys, the least significant bit of each byte is used for a parity check. So, in 16 bytes there are only 16 * 7 = 112 independent bits. 112 bits is commonly known as the effective key size/length for TDEA (the official NIST name of triple DES) keying option #2. 112 bit keys for TDEA are also known as DES ABA keys as the 1st and 3rd keys are identical within the scheme.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
Janne Karila
  • 24,266
  • 6
  • 53
  • 94
  • Could you explain that a little bit? I'm playing with network protocol that uses encrypted tcp connections. The encryption used is Triple-DES in outer cipher block chaining mode (CBC) where keys are 14 bytes (112 bits). Typical key looks like 0102030405060708091011121314, it's 14 bytes, not 16. How to make it work with pydes, that wants 16 bytes, or some other python module it it exists? – yegorov-p Jun 17 '12 at 13:25
  • You would read 7 bits at a time from the key, shift left and emit a byte. If pydes checks the parity bit, you need to set that too. I found a reasonably clear implementation of this in http://code.google.com/p/passlib/source/browse/passlib/utils/des.py?name=release-1.5#574 It is for normal DES, so you need to pass in 7 bytes at a time. – Janne Karila Jun 17 '12 at 14:18