Python 3 で pycryptodome を使用した AES-CTR 暗号化に問題があります。データは最大 1000 バイトですが、十分に長くなると壊れます。このエラーの意味や回避方法がわかりません。
from os import urandom
from Crypto.Cipher import AES
cipher = AES.new(urandom(16), AES.MODE_CTR, nonce=urandom(15))
cipher.encrypt(urandom(10000))
---------------------------------------------------------------------------
OverflowError Traceback (most recent call last)
<ipython-input-116-a48990362615> in <module>()
3
4 cipher = AES.new(urandom(16), AES.MODE_CTR, nonce=urandom(15))
----> 5 cipher.encrypt(urandom(10000))
6
/usr/local/lib/python3.5/dist-packages/Crypto/Cipher/_mode_ctr.py in encrypt(self, plaintext)
188 if result:
189 if result == 0x60002:
--> 190 raise OverflowError("The counter has wrapped around in"
191 " CTR mode")
192 raise ValueError("Error %X while encrypting in CTR mode" % result)
OverflowError: The counter has wrapped around in CTR mode