[pycrypto] AES, MODE_CTR

Dave Pawson dave.pawson at gmail.com
Thu Dec 5 05:00:30 PST 2013


Thanks Richard. Now working
    def test_AES5(self):
        pt=b' '*10
        ctr=Counter.new(128)
        iv = Random.new().read(AES.block_size)
        cipher = AES.new(b' '*16, AES.MODE_CTR, IV=iv, counter=ctr)
        ct = cipher.encrypt(pt)
        ctrr=Counter.new(128)
        decipher = AES.new(b' '*16, AES.MODE_CTR, IV=iv, counter=ctrr)
        ptr = decipher.decrypt(ct)
        self.assertEqual(pt,ptr)

iv added as suggested.

Does anyone know of any better documentation for Counter and its use please?

TiA



On 4 December 2013 17:01, Richard Moore <richmoore44 at gmail.com> wrote:
> You need to reset the counter (or make a new one) before you start to
> decrypt. You also don't seem to be using an IV which would lead to a
> massive security hole.
>
> Rich.
> _______________________________________________
> 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