crypto.cipher des cbc failure

Bug #1260276 reported by adi sis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python-Crypto
New
Undecided
Unassigned

Bug Description

>>> from Crypto.Cipher import DES
>>> DES.new('abcdefghijklmnop', DES.MODE_CBC, '1234567890123456')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/Crypto/Cipher/DES.py", line 108, in new
    return DESCipher(key, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/Crypto/Cipher/DES.py", line 63, in __init__
    blockalgo.BlockAlgo.__init__(self, _DES, key, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/Crypto/Cipher/blockalgo.py", line 401, in __init__
    self._cipher = factory.new(key, *args, **kwargs)
ValueError: Invalid key size (must be either 16 or 24 bytes long)

this should not be happened ?

Revision history for this message
Legrandin (gooksankoo) wrote :

If you really want to use Single DES, the key must be 8 bytes long, not 16 (the exception string is clearly wrong and misleading though).

If you want to actually use Triple DES, use must use the DES3 module, not the DES module.

In either case, the IV (3rd parameter to new() method) must be 8 bytes long, not 16.

Revision history for this message
Richard Mitchell (mitchellrj) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.