无效参数:AES-128/XTS 不能接受长度为 16 的键

Invalid argument: AES-128/XTS cannot accept a key of length 16

我试图在牡丹中使用 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;
}

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

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