CryptImportKey Windows 8.1 Using AES_256 PLAINTEXTKEYBLOB

CryptImportKey Windows 8.1 Using AES_256 PLAINTEXTKEYBLOB

本文关键字:PLAINTEXTKEYBLOB AES Using Windows CryptImportKey      更新时间:2023-10-16
context->last_error = NULL;
const BYTE key[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// BLOBHEADER
    0x00, 0x00, 0x00, 0x00,//   Key size
    0x23, 0x31, 0xb1, 0x24, 0x7b, 0x15, 0xdf, 0xb0,//   AES KEY
    0xc9, 0x92, 0xaa, 0xc4, 0x2e, 0x02, 0x9b, 0x07,
    0xdf, 0x21, 0x12, 0x53, 0xba, 0x28, 0x77, 0xd2,
    0x99, 0x74, 0x96, 0xa4, 0x54, 0x54, 0x0d, 0xf1 }; 
BLOBHEADER* hdr = (BLOBHEADER*)key;
hdr->aiKeyAlg = CALG_AES_256;
hdr->bType = PLAINTEXTKEYBLOB;
hdr->bVersion = CUR_BLOB_VERSION;//default value
hdr->reserved = NULL;//reserved, default value
LPDWORD key_size = (LPDWORD)&key[sizeof(BLOBHEADER)];
//*(DWORD *)(key + 0x14) = 0;
*key_size = AES_KEY_SIZE_;
if (!CryptImportKey(context->context, key, 32, 0, CRYPT_EXPORTABLE, &context->aes_hKey))
{
    return context->last_error = GetLastError();
}
return context->last_error;

适用于 Windows 7,这不是导出的密钥,但在 Windows 8.1 上失败

如果有人找到了解决方案,这将有助于整个互联网。

用于 CryptImportKey 的 dwDataLen 参数设置为 32,应该是字节数组的总大小。

问题是这适用于窗口 7 :\

对不起,伙计们