0

我正在尝试使用 Pycrypto 生成 AES 密钥,但收到以下错误:

TypeError: 'list' 不支持缓冲区接口

对于以下声明:

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

mykey, 是类型list并且包含[1885434739, 825373440, 0, 0]

有谁知道我如何转换mykey为正确的AES.new函数类型?

4

1 回答 1

2

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).

于 2013-01-26T18:10:39.497 回答