[tahoe-dev] [pycryptopp] #18: AES-CTR: easy way to modify the counter for random-access decryption

pycryptopp trac at allmydata.org
Tue Feb 2 07:18:11 UTC 2010


#18: AES-CTR: easy way to modify the counter for random-access decryption
------------------------+---------------------------------------------------
Reporter:  warner       |           Owner:       
    Type:  enhancement  |          Status:  new  
Priority:  major        |         Version:  0.5.1
Keywords:               |   Launchpad_bug:       
------------------------+---------------------------------------------------

Comment(by warner):

 A not-too-unreasonable hack to accomplish most of this is:

 {{{
 def AES(key, offset):
     offset_big = offset // 32
     offset_small = offset % 32
     iv = binascii.unhexlify("%032x" % offset_big)
     decryptor = AES(key, iv=iv)
     decryptor.process("\x00"*offset_small)
     return decryptor
 }}}

 That returns an AES object which is ready for use at the given offset. Any
 seeks have to create a new AES object, but that's not too expensive (27us
 on
 my laptop).

 However, {{{AES(key, iv="0"*LEN)}}} for any LEN other than 16 should throw
 an
 exception. Calling it with iv strings shorter than 14 bytes causes it to
 use
 uninitialized memory as part of the IV, not good.

-- 
Ticket URL: <http://allmydata.org/trac/pycryptopp/ticket/18#comment:2>
pycryptopp <http://allmydata.org/trac/pycryptopp>
Python bindings for the Crypto++ library


More information about the tahoe-dev mailing list