Pass list to AES key generator in PyCrypto

纵饮孤独 提交于 2020-01-22 03:20:11

问题


I'm attempting to generate an AES key with Pycrypto but receive the following error:

TypeError: 'list' does not support the buffer interface

for the following statement:

aescipher = AES.new(mykey, AES.MODE_ECB)

mykey, is of type list and contains [1885434739, 825373440, 0, 0]

Does anyone know how I can convert mykey into the correct type for the AES.new function?


回答1:


You should not supply any kind of list/array when creating an AES key. The raw key bytes are normally supplied using a byte array of keysize / 8 bytes. For AES, the only key sizes that are supported are 128, 192 and 256 bits or 16, 24 and 32 bytes respectively.

Note that padding keys until they fit may lead to major cryptographic vulnerabilities. So is using ECB mode instead of a more secure mode like CBC (or one that also provides authentication/integrity protection such as GCM of course).



来源:https://stackoverflow.com/questions/14539360/pass-list-to-aes-key-generator-in-pycrypto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!