rsaenh: Fix the accepted RC2 key length, based on a test case by Dan Kegel.
This commit is contained in:
parent
c7992a8d26
commit
d3c482250a
|
@ -933,17 +933,60 @@ static void test_machine_guid(void)
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define key_length 16
|
||||||
|
|
||||||
|
static const unsigned char key[key_length] =
|
||||||
|
{ 0xbf, 0xf6, 0x83, 0x4b, 0x3e, 0xa3, 0x23, 0xdd,
|
||||||
|
0x96, 0x78, 0x70, 0x8e, 0xa1, 0x9d, 0x3b, 0x40 };
|
||||||
|
|
||||||
|
static void hashtest(void)
|
||||||
|
{
|
||||||
|
struct KeyBlob
|
||||||
|
{
|
||||||
|
BLOBHEADER header;
|
||||||
|
DWORD key_size;
|
||||||
|
BYTE key_data[key_length];
|
||||||
|
} key_blob;
|
||||||
|
|
||||||
|
HCRYPTPROV provider;
|
||||||
|
HCRYPTKEY hkey;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = pCryptAcquireContextA(&provider, NULL, NULL,
|
||||||
|
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||||
|
ok(ret, "CryptAcquireContext error %u\n", GetLastError());
|
||||||
|
|
||||||
|
key_blob.header.bType = PLAINTEXTKEYBLOB;
|
||||||
|
key_blob.header.bVersion = CUR_BLOB_VERSION;
|
||||||
|
key_blob.header.reserved = 0;
|
||||||
|
key_blob.header.aiKeyAlg = CALG_RC2;
|
||||||
|
key_blob.key_size = key_length;
|
||||||
|
memcpy(key_blob.key_data, key, key_length);
|
||||||
|
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = pCryptImportKey(provider, (BYTE*)&key_blob,
|
||||||
|
sizeof(BLOBHEADER)+sizeof(DWORD)+key_length,
|
||||||
|
0, CRYPT_IPSEC_HMAC_KEY, &hkey);
|
||||||
|
ok(ret, "CryptImportKey error %u\n", GetLastError());
|
||||||
|
|
||||||
|
pCryptDestroyKey(hkey);
|
||||||
|
pCryptReleaseContext(provider, 0);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(crypt)
|
START_TEST(crypt)
|
||||||
{
|
{
|
||||||
init_function_pointers();
|
init_function_pointers();
|
||||||
if(pCryptAcquireContextA && pCryptReleaseContext) {
|
if (pCryptAcquireContextA && pCryptReleaseContext)
|
||||||
|
{
|
||||||
|
hashtest();
|
||||||
init_environment();
|
init_environment();
|
||||||
test_acquire_context();
|
test_acquire_context();
|
||||||
test_incorrect_api_usage();
|
test_incorrect_api_usage();
|
||||||
test_verify_sig();
|
test_verify_sig();
|
||||||
test_machine_guid();
|
test_machine_guid();
|
||||||
clean_up_environment();
|
clean_up_environment();
|
||||||
}
|
}
|
||||||
|
|
||||||
test_enum_providers();
|
test_enum_providers();
|
||||||
test_enum_provider_types();
|
test_enum_provider_types();
|
||||||
|
|
|
@ -159,7 +159,7 @@ typedef struct tagKEYCONTAINER
|
||||||
static const PROV_ENUMALGS_EX aProvEnumAlgsEx[5][RSAENH_MAX_ENUMALGS+1] =
|
static const PROV_ENUMALGS_EX aProvEnumAlgsEx[5][RSAENH_MAX_ENUMALGS+1] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
{CALG_RC2, 40, 40, 56,0, 4,"RC2", 24,"RSA Data Security's RC2"},
|
{CALG_RC2, 40, 5, 128,0, 4,"RC2", 24,"RSA Data Security's RC2"},
|
||||||
{CALG_RC4, 40, 40, 56,0, 4,"RC4", 24,"RSA Data Security's RC4"},
|
{CALG_RC4, 40, 40, 56,0, 4,"RC4", 24,"RSA Data Security's RC4"},
|
||||||
{CALG_DES, 56, 56, 56,0, 4,"DES", 31,"Data Encryption Standard (DES)"},
|
{CALG_DES, 56, 56, 56,0, 4,"DES", 31,"Data Encryption Standard (DES)"},
|
||||||
{CALG_SHA, 160,160, 160,CRYPT_FLAG_SIGNING, 6,"SHA-1", 30,"Secure Hash Algorithm (SHA-1)"},
|
{CALG_SHA, 160,160, 160,CRYPT_FLAG_SIGNING, 6,"SHA-1", 30,"Secure Hash Algorithm (SHA-1)"},
|
||||||
|
|
|
@ -80,6 +80,9 @@ typedef struct _SCHANNEL_ALG {
|
||||||
DWORD dwReserved;
|
DWORD dwReserved;
|
||||||
} SCHANNEL_ALG, *PSCHANNEL_ALG;
|
} SCHANNEL_ALG, *PSCHANNEL_ALG;
|
||||||
|
|
||||||
|
|
||||||
|
#define CRYPT_IPSEC_HMAC_KEY 0x0100
|
||||||
|
|
||||||
typedef struct _HMAC_INFO {
|
typedef struct _HMAC_INFO {
|
||||||
ALG_ID HashAlgid;
|
ALG_ID HashAlgid;
|
||||||
BYTE* pbInnerString;
|
BYTE* pbInnerString;
|
||||||
|
|
Loading…
Reference in New Issue