[pycrypto] DES3 problem

Dave Pawson dave.pawson at gmail.com
Mon Dec 2 00:18:06 PST 2013


On 1 December 2013 21:26, Legrandin <helderijs at gmail.com> wrote:
>>> Since a cipher object is stateful, it can be used for either
>>> encryption or decryption but not both.
>>
>> I don't understand that. In what way does it maintain state please?
>
> If the data to encrypt is very long, you may need to invoke the method
> encrypt() of a cipher on one smaller piece at a time. The object
> maintains the state of the last encryption performed, so that it can
> correctly process the data that will come next. If you call decrypt()
> after encrypt(), the cipher will interpret its state as if it was a
> "decryption" state, even though it is actually an "encryption" state.
>
> Same applies if you start with decrypt() and then use encrypt().
>
> That is really a flaw of the pycrypto API: it shouldn't allow one to
> switch mid air between encryption and decryption.


Wow. Is this documented in pycrypto?
What is the limit to the text length I can send to any one encrypt function?

(very personal, ill informed view) That seems quite illogical to me?


>
>>> The only exception is the ECB mode. Being it stateless, it lets you
>>> intermix encryption and decryption.
>>
>> Thanks.
>> (Nothing that I've found in the docs explains this?)
>
> A little bit hidden here:
>
> https://www.dlitz.net/software/pycrypto/api/current/Crypto.Cipher.blockalgo.BlockAlgo-class.html#encrypt

Thanks.
IMHO the statefulness of the software really should be documented?


regards






-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk


More information about the pycrypto mailing list