crypt32: Encode public keys with NULL parameters if they're empty (and make tests more restrictive).

This commit is contained in:
Juan Lang 2009-10-20 13:33:15 -07:00 committed by Alexandre Julliard
parent d8ca5bc348
commit e1903dc6e0
2 changed files with 5 additions and 10 deletions

View File

@ -415,7 +415,7 @@ static BOOL WINAPI CRYPT_AsnEncodePubKeyInfo(DWORD dwCertEncodingType,
{
const CERT_PUBLIC_KEY_INFO *info = pvStructInfo;
struct AsnEncodeSequenceItem items[] = {
{ &info->Algorithm, CRYPT_AsnEncodeAlgorithmId, 0 },
{ &info->Algorithm, CRYPT_AsnEncodeAlgorithmIdWithNullParams, 0 },
{ &info->PublicKey, CRYPT_AsnEncodeBits, 0 },
};

View File

@ -2613,8 +2613,8 @@ static void test_decodeExtensions(DWORD dwEncoding)
/* MS encodes public key info with a NULL if the algorithm identifier's
* parameters are empty. However, when encoding an algorithm in a CERT_INFO,
* it encodes them by omitting the algorithm parameters. This latter approach
* seems more correct, so accept either form.
* it encodes them by omitting the algorithm parameters. It accepts either
* form for decoding.
*/
struct encodedPublicKey
{
@ -2692,16 +2692,11 @@ static void test_encodePublicKeyInfo(DWORD dwEncoding)
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
if (buf)
{
ok(bufSize == pubKeys[i].encoded[1] + 2 ||
bufSize == pubKeys[i].encodedNoNull[1] + 2,
"Expected %d or %d bytes, got %d\n", pubKeys[i].encoded[1] + 2,
pubKeys[i].encodedNoNull[1] + 2, bufSize);
ok(bufSize == pubKeys[i].encoded[1] + 2,
"Expected %d bytes, got %d\n", pubKeys[i].encoded[1] + 2, bufSize);
if (bufSize == pubKeys[i].encoded[1] + 2)
ok(!memcmp(buf, pubKeys[i].encoded, pubKeys[i].encoded[1] + 2),
"Unexpected value\n");
else if (bufSize == pubKeys[i].encodedNoNull[1] + 2)
ok(!memcmp(buf, pubKeys[i].encodedNoNull,
pubKeys[i].encodedNoNull[1] + 2), "Unexpected value\n");
LocalFree(buf);
}
}