2

我正在尝试在 Botan 中使用 AES-128/XTS,但会引发以下异常:

terminate called after throwing an instance of 'Botan::Invalid_Key_Length'    
what():  Invalid argument AES-128/XTS cannot accept a key of length 16

我的程序是这样的(头文件省略):

using namespace Botan;
int main()
{
    SymmetricKey key_t(hex_decode("13232453fa2343432453de2adfedf2fa"));
    InitializationVector iv_t(hex_decode("0b0c7fc670656e36a7637b4e209885a9"));
    Pipe encryptor(get_cipher("AES-128/XTS", key_t, iv_t, Botan::ENCRYPTION));
    encryptor.process_msg((uint8_t *)s.data(), s.size());
    return 0;
}

我真的很想知道这里出了什么问题。

4

1 回答 1

2

AES-XTS 有一个怪癖,即提供的密钥长度必须是两倍。128 为 256 位,256 为 512。如果您好奇为什么,请查看https://en.m.wikipedia.org/wiki/Disk_encryption_theory的 XTS 部分。

于 2017-05-12T05:28:10.290 回答