[pycrypto] DES3 problem
Dave Pawson
dave.pawson at gmail.com
Fri Nov 29 07:29:49 PST 2013
On 29 November 2013 15:16, Legrandin <helderijs at gmail.com> wrote:
> Hi Dave,
>
> DES3 (which is TripleDES) works correctly.
> It just happens that the examples for DES (Single DES) and DES3
> modules got swapped by mistake.
> The DES3 example you are looking for is actually here:
>
> https://www.dlitz.net/software/pycrypto/api/current/Crypto.Cipher.DES-module.html
thanks. I'll move on a bit.
(My goal is a unit test for all the algo's, I'll post it if I finish it)
>
> It was a while back but I recall docs have been fixed in the meanwhile
> and they are on git.
... downloadable as a package or some other way?
regards
>
> 2013/11/27 Dave Pawson <dave.pawson at gmail.com>:
>> From the lack of response, should I assume that DES3 isn't yet working?
>>
>> TiA, DaveP
>>
>> On 24 November 2013 14:50, Dave Pawson <dave.pawson at gmail.com> wrote:
>>> https://www.dlitz.net/software/pycrypto/api/current/ states DES3 requires an iv.
>>>
>>> in the api docs the example uses DES not DES3?
>>>
>>> As an example, encryption can be done as follows:
>>>
>>>>>> from Crypto.Cipher import DES
>>>>>> from Crypto import Random
>>>>>> from Crypto.Util import Counter
>>>>>>
>>>>>> key = b'-8B key-'
>>>>>> nonce = Random.new().read(DES.block_size/2)
>>>>>> ctr = Counter.new(DES.block_size*8/2, prefix=nonce)
>>>>>> cipher = DES.new(key, DES.MODE_CTR, counter=ctr)
>>>>>> plaintext = b'We are no longer the knights who say ni!'
>>>>>> msg = nonce + cipher.encrypt(plaintext)
>>>
>>> Using
>>> iv=Random.new().read(DES3.block_size)
>>> ciphere = DES3.new(key,mode,IV=iv)
>>>
>>> I'm getting
>>> Traceback (most recent call last):
>>> File "./tester.py", line 405, in testBlock5
>>> ciphere = DES3.new(key,mode,IV=iv)
>>> File "/usr/lib64/python3.3/site-packages/Crypto/Cipher/DES3.py",
>>> line 114, in new
>>> return DES3Cipher(key, *args, **kwargs)
>>> File "/usr/lib64/python3.3/site-packages/Crypto/Cipher/DES3.py",
>>> line 76, in __init__
>>> blockalgo.BlockAlgo.__init__(self, _DES3, key, *args, **kwargs)
>>> File "/usr/lib64/python3.3/site-packages/Crypto/Cipher/blockalgo.py",
>>> line 155, in __init__
>>> raise ValueError("MODE_OPENPGP requires an IV")
>>> ValueError: MODE_OPENPGP requires an IV
>>>
>>> Am I wrong in my usage or is the code incorrect please
>>> wrt iv parameter?
>>>
>>>
>>> Tia
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Dave Pawson
>>> XSLT XSL-FO FAQ.
>>> Docbook FAQ.
>>> http://www.dpawson.co.uk
>>
>>
>>
>> --
>> Dave Pawson
>> XSLT XSL-FO FAQ.
>> Docbook FAQ.
>> http://www.dpawson.co.uk
>> _______________________________________________
>> pycrypto mailing list
>> pycrypto at lists.dlitz.net
>> http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto
> _______________________________________________
> pycrypto mailing list
> pycrypto at lists.dlitz.net
> http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto
--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk
More information about the pycrypto
mailing list