crypt32: Fix encoding cert issuer/subject unique ids.

This commit is contained in:
Juan Lang 2009-11-06 11:21:51 -08:00 committed by Alexandre Julliard
parent acfa433f15
commit 4ccafdcb6f
2 changed files with 19 additions and 23 deletions

View File

@ -506,37 +506,37 @@ static BOOL WINAPI CRYPT_AsnEncodeCertInfo(DWORD dwCertEncodingType,
{ &info->SubjectPublicKeyInfo, CRYPT_AsnEncodePubKeyInfoNoNull, 0 },
{ 0 }
};
struct AsnConstructedItem constructed[3] = { { 0 } };
DWORD cItem = 7, cConstructed = 0;
struct AsnConstructedItem constructed = { 0 };
struct AsnEncodeTagSwappedItem swapped[2] = { { 0 } };
DWORD cItem = 7, cSwapped = 0;
if (info->IssuerUniqueId.cbData)
{
constructed[cConstructed].tag = 1;
constructed[cConstructed].pvStructInfo = &info->IssuerUniqueId;
constructed[cConstructed].encodeFunc = CRYPT_AsnEncodeBits;
items[cItem].pvStructInfo = &constructed[cConstructed];
items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
cConstructed++;
swapped[cSwapped].tag = ASN_CONTEXT | 1;
swapped[cSwapped].pvStructInfo = &info->IssuerUniqueId;
swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeBits;
items[cItem].pvStructInfo = &swapped[cSwapped];
items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
cSwapped++;
cItem++;
}
if (info->SubjectUniqueId.cbData)
{
constructed[cConstructed].tag = 2;
constructed[cConstructed].pvStructInfo = &info->SubjectUniqueId;
constructed[cConstructed].encodeFunc = CRYPT_AsnEncodeBits;
items[cItem].pvStructInfo = &constructed[cConstructed];
items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
cConstructed++;
swapped[cSwapped].tag = ASN_CONTEXT | 2;
swapped[cSwapped].pvStructInfo = &info->SubjectUniqueId;
swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeBits;
items[cItem].pvStructInfo = &swapped[cSwapped];
items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
cSwapped++;
cItem++;
}
if (info->cExtension)
{
constructed[cConstructed].tag = 3;
constructed[cConstructed].pvStructInfo = &info->cExtension;
constructed[cConstructed].encodeFunc = CRYPT_AsnEncodeExtensions;
items[cItem].pvStructInfo = &constructed[cConstructed];
constructed.tag = 3;
constructed.pvStructInfo = &info->cExtension;
constructed.encodeFunc = CRYPT_AsnEncodeExtensions;
items[cItem].pvStructInfo = &constructed;
items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
cConstructed++;
cItem++;
}

View File

@ -2979,11 +2979,9 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
if (buf)
{
todo_wine {
ok(size == sizeof(v1CertWithIssuerUniqueId), "Wrong size %d\n", size);
ok(!memcmp(buf, v1CertWithIssuerUniqueId, size),
"Got unexpected value\n");
}
LocalFree(buf);
}
/* Test v1 cert with an issuer name, a subject name, and a serial number */
@ -3031,7 +3029,6 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
ok(size == sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueId) ||
size == sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueIdNoNull),
"Wrong size %d\n", size);
todo_wine {
if (size == sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueId))
ok(!memcmp(buf, v1CertWithSubjectIssuerSerialAndIssuerUniqueId,
size), "unexpected value\n");
@ -3040,7 +3037,6 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
ok(!memcmp(buf,
v1CertWithSubjectIssuerSerialAndIssuerUniqueIdNoNull, size),
"unexpected value\n");
}
LocalFree(buf);
}
/* Remove the public key, and add a subject key identifier extension */