Commit 6bd4bf66 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

crypt32: Fix compilation on systems that don't support nameless unions.

parent 360c164e
......@@ -20,6 +20,7 @@
#include "wine/port.h"
#include <stdarg.h>
#define NONAMELESSUNION
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
......@@ -662,19 +663,19 @@ static BOOL CRYPT_IsValidSigner(CMSG_SIGNER_ENCODE_INFO_WITH_CMS *signer)
}
break;
case CERT_ID_ISSUER_SERIAL_NUMBER:
if (!signer->SignerId.IssuerSerialNumber.SerialNumber.cbData)
if (!signer->SignerId.u.IssuerSerialNumber.SerialNumber.cbData)
{
SetLastError(E_INVALIDARG);
return FALSE;
}
if (!signer->SignerId.IssuerSerialNumber.Issuer.cbData)
if (!signer->SignerId.u.IssuerSerialNumber.Issuer.cbData)
{
SetLastError(E_INVALIDARG);
return FALSE;
}
break;
case CERT_ID_KEY_IDENTIFIER:
if (!signer->SignerId.KeyId.cbData)
if (!signer->SignerId.u.KeyId.cbData)
{
SetLastError(E_INVALIDARG);
return FALSE;
......@@ -808,11 +809,11 @@ static BOOL CSignerInfo_Construct(CMSG_CMS_SIGNER_INFO *info,
if (in->cbSize == sizeof(CMSG_SIGNER_ENCODE_INFO))
{
info->dwVersion = CMSG_SIGNER_INFO_V1;
ret = CRYPT_ConstructBlob(&info->SignerId.IssuerSerialNumber.Issuer,
ret = CRYPT_ConstructBlob(&info->SignerId.u.IssuerSerialNumber.Issuer,
&in->pCertInfo->Issuer);
if (ret)
ret = CRYPT_ConstructBlob(
&info->SignerId.IssuerSerialNumber.SerialNumber,
&info->SignerId.u.IssuerSerialNumber.SerialNumber,
&in->pCertInfo->SerialNumber);
info->SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
}
......@@ -824,11 +825,11 @@ static BOOL CSignerInfo_Construct(CMSG_CMS_SIGNER_INFO *info,
if (!in->SignerId.dwIdChoice)
{
info->dwVersion = CMSG_SIGNER_INFO_V1;
ret = CRYPT_ConstructBlob(&info->SignerId.IssuerSerialNumber.Issuer,
ret = CRYPT_ConstructBlob(&info->SignerId.u.IssuerSerialNumber.Issuer,
&in->pCertInfo->Issuer);
if (ret)
ret = CRYPT_ConstructBlob(
&info->SignerId.IssuerSerialNumber.SerialNumber,
&info->SignerId.u.IssuerSerialNumber.SerialNumber,
&in->pCertInfo->SerialNumber);
info->SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
}
......@@ -836,20 +837,20 @@ static BOOL CSignerInfo_Construct(CMSG_CMS_SIGNER_INFO *info,
{
info->dwVersion = CMSG_SIGNER_INFO_V1;
info->SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
ret = CRYPT_ConstructBlob(&info->SignerId.IssuerSerialNumber.Issuer,
&in->SignerId.IssuerSerialNumber.Issuer);
ret = CRYPT_ConstructBlob(&info->SignerId.u.IssuerSerialNumber.Issuer,
&in->SignerId.u.IssuerSerialNumber.Issuer);
if (ret)
ret = CRYPT_ConstructBlob(
&info->SignerId.IssuerSerialNumber.SerialNumber,
&in->SignerId.IssuerSerialNumber.SerialNumber);
&info->SignerId.u.IssuerSerialNumber.SerialNumber,
&in->SignerId.u.IssuerSerialNumber.SerialNumber);
}
else
{
/* Implicitly dwIdChoice == CERT_ID_KEY_IDENTIFIER */
info->dwVersion = CMSG_SIGNER_INFO_V3;
info->SignerId.dwIdChoice = CERT_ID_KEY_IDENTIFIER;
ret = CRYPT_ConstructBlob(&info->SignerId.KeyId,
&in->SignerId.KeyId);
ret = CRYPT_ConstructBlob(&info->SignerId.u.KeyId,
&in->SignerId.u.KeyId);
}
}
/* Assumption: algorithm IDs will point to static strings, not
......@@ -876,11 +877,11 @@ static void CSignerInfo_Free(CMSG_CMS_SIGNER_INFO *info)
if (info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
{
CryptMemFree(info->SignerId.IssuerSerialNumber.Issuer.pbData);
CryptMemFree(info->SignerId.IssuerSerialNumber.SerialNumber.pbData);
CryptMemFree(info->SignerId.u.IssuerSerialNumber.Issuer.pbData);
CryptMemFree(info->SignerId.u.IssuerSerialNumber.SerialNumber.pbData);
}
else
CryptMemFree(info->SignerId.KeyId.pbData);
CryptMemFree(info->SignerId.u.KeyId.pbData);
CryptMemFree(info->HashAlgorithm.Parameters.pbData);
CryptMemFree(info->EncryptedHash.pbData);
for (i = 0; i < info->AuthAttrs.cAttr; i++)
......@@ -2079,12 +2080,12 @@ static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData,
if (in->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
{
size += in->SignerId.IssuerSerialNumber.Issuer.cbData;
size += in->SignerId.IssuerSerialNumber.SerialNumber.cbData;
size += in->SignerId.u.IssuerSerialNumber.Issuer.cbData;
size += in->SignerId.u.IssuerSerialNumber.SerialNumber.cbData;
}
else
{
rdnSize = CRYPT_SizeOfKeyIdAsIssuerAndSerial(&in->SignerId.KeyId);
rdnSize = CRYPT_SizeOfKeyIdAsIssuerAndSerial(&in->SignerId.u.KeyId);
size += rdnSize;
}
if (in->HashAlgorithm.pszObjId)
......@@ -2120,13 +2121,13 @@ static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData,
if (in->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
{
CRYPT_CopyBlob(&out->Issuer,
&in->SignerId.IssuerSerialNumber.Issuer, &nextData);
&in->SignerId.u.IssuerSerialNumber.Issuer, &nextData);
CRYPT_CopyBlob(&out->SerialNumber,
&in->SignerId.IssuerSerialNumber.SerialNumber, &nextData);
&in->SignerId.u.IssuerSerialNumber.SerialNumber, &nextData);
}
else
ret = CRYPT_CopyKeyIdAsIssuerAndSerial(&out->Issuer, &out->SerialNumber,
&in->SignerId.KeyId, rdnSize, &nextData);
&in->SignerId.u.KeyId, rdnSize, &nextData);
if (ret)
{
CRYPT_CopyAlgorithmId(&out->HashAlgorithm, &in->HashAlgorithm,
......@@ -2155,11 +2156,11 @@ static BOOL CRYPT_CopyCMSSignerInfo(void *pvData, DWORD *pcbData,
if (in->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
{
size += in->SignerId.IssuerSerialNumber.Issuer.cbData;
size += in->SignerId.IssuerSerialNumber.SerialNumber.cbData;
size += in->SignerId.u.IssuerSerialNumber.Issuer.cbData;
size += in->SignerId.u.IssuerSerialNumber.SerialNumber.cbData;
}
else
size += in->SignerId.KeyId.cbData;
size += in->SignerId.u.KeyId.cbData;
if (in->HashAlgorithm.pszObjId)
size += strlen(in->HashAlgorithm.pszObjId) + 1;
size += in->HashAlgorithm.Parameters.cbData;
......@@ -2192,13 +2193,13 @@ static BOOL CRYPT_CopyCMSSignerInfo(void *pvData, DWORD *pcbData,
out->SignerId.dwIdChoice = in->SignerId.dwIdChoice;
if (in->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
{
CRYPT_CopyBlob(&out->SignerId.IssuerSerialNumber.Issuer,
&in->SignerId.IssuerSerialNumber.Issuer, &nextData);
CRYPT_CopyBlob(&out->SignerId.IssuerSerialNumber.SerialNumber,
&in->SignerId.IssuerSerialNumber.SerialNumber, &nextData);
CRYPT_CopyBlob(&out->SignerId.u.IssuerSerialNumber.Issuer,
&in->SignerId.u.IssuerSerialNumber.Issuer, &nextData);
CRYPT_CopyBlob(&out->SignerId.u.IssuerSerialNumber.SerialNumber,
&in->SignerId.u.IssuerSerialNumber.SerialNumber, &nextData);
}
else
CRYPT_CopyBlob(&out->SignerId.KeyId, &in->SignerId.KeyId, &nextData);
CRYPT_CopyBlob(&out->SignerId.u.KeyId, &in->SignerId.u.KeyId, &nextData);
CRYPT_CopyAlgorithmId(&out->HashAlgorithm, &in->HashAlgorithm,
&nextData);
CRYPT_CopyAlgorithmId(&out->HashEncryptionAlgorithm,
......@@ -2225,12 +2226,12 @@ static BOOL CRYPT_CopySignerCertInfo(void *pvData, DWORD *pcbData,
if (in->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
{
size += in->SignerId.IssuerSerialNumber.Issuer.cbData;
size += in->SignerId.IssuerSerialNumber.SerialNumber.cbData;
size += in->SignerId.u.IssuerSerialNumber.Issuer.cbData;
size += in->SignerId.u.IssuerSerialNumber.SerialNumber.cbData;
}
else
{
rdnSize = CRYPT_SizeOfKeyIdAsIssuerAndSerial(&in->SignerId.KeyId);
rdnSize = CRYPT_SizeOfKeyIdAsIssuerAndSerial(&in->SignerId.u.KeyId);
size += rdnSize;
}
if (!pvData)
......@@ -2253,14 +2254,14 @@ static BOOL CRYPT_CopySignerCertInfo(void *pvData, DWORD *pcbData,
if (in->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
{
CRYPT_CopyBlob(&out->Issuer,
&in->SignerId.IssuerSerialNumber.Issuer, &nextData);
&in->SignerId.u.IssuerSerialNumber.Issuer, &nextData);
CRYPT_CopyBlob(&out->SerialNumber,
&in->SignerId.IssuerSerialNumber.SerialNumber, &nextData);
&in->SignerId.u.IssuerSerialNumber.SerialNumber, &nextData);
ret = TRUE;
}
else
ret = CRYPT_CopyKeyIdAsIssuerAndSerial(&out->Issuer, &out->SerialNumber,
&in->SignerId.KeyId, rdnSize, &nextData);
&in->SignerId.u.KeyId, rdnSize, &nextData);
}
TRACE("returning %d\n", ret);
return ret;
......@@ -2563,12 +2564,12 @@ static BOOL CDecodeSignedMsg_VerifySignature(CDecodeMsg *msg, PCERT_INFO info)
if (signerInfo->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
{
ret = CertCompareCertificateName(X509_ASN_ENCODING,
&signerInfo->SignerId.IssuerSerialNumber.Issuer,
&signerInfo->SignerId.u.IssuerSerialNumber.Issuer,
&info->Issuer);
if (ret)
{
ret = CertCompareIntegerBlob(
&signerInfo->SignerId.IssuerSerialNumber.SerialNumber,
&signerInfo->SignerId.u.IssuerSerialNumber.SerialNumber,
&info->SerialNumber);
if (ret)
break;
......
......@@ -4822,7 +4822,7 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding)
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
accessDescription[0].AccessLocation.dwAltNameChoice = CERT_ALT_NAME_URL;
accessDescription[0].AccessLocation.pwszURL = (LPWSTR)url;
U(accessDescription[0].AccessLocation).pwszURL = (LPWSTR)url;
ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia,
CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
......@@ -4838,9 +4838,9 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding)
accessDescription[1].pszAccessMethod = oid2;
accessDescription[1].AccessLocation.dwAltNameChoice =
CERT_ALT_NAME_IP_ADDRESS;
accessDescription[1].AccessLocation.IPAddress.cbData =
U(accessDescription[1].AccessLocation).IPAddress.cbData =
sizeof(encodedIPAddr);
accessDescription[1].AccessLocation.IPAddress.pbData =
U(accessDescription[1].AccessLocation).IPAddress.pbData =
(LPBYTE)encodedIPAddr;
aia.cAccDescr = 2;
ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia,
......@@ -4909,7 +4909,7 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
accessDescription.pszAccessMethod = oid1;
accessDescription.AccessLocation.dwAltNameChoice = CERT_ALT_NAME_URL;
accessDescription.AccessLocation.pwszURL = (LPWSTR)url;
U(accessDescription.AccessLocation).pwszURL = (LPWSTR)url;
aia.cAccDescr = 1;
aia.rgAccDescr = &accessDescription;
compareAuthorityInfoAccess("AIA with URL", &aia,
......@@ -4929,13 +4929,13 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
accessDescription[0].pszAccessMethod = oid1;
accessDescription[0].AccessLocation.dwAltNameChoice = CERT_ALT_NAME_URL;
accessDescription[0].AccessLocation.pwszURL = (LPWSTR)url;
U(accessDescription[0].AccessLocation).pwszURL = (LPWSTR)url;
accessDescription[1].pszAccessMethod = oid2;
accessDescription[1].AccessLocation.dwAltNameChoice =
CERT_ALT_NAME_IP_ADDRESS;
accessDescription[1].AccessLocation.IPAddress.cbData =
U(accessDescription[1].AccessLocation).IPAddress.cbData =
sizeof(encodedIPAddr);
accessDescription[1].AccessLocation.IPAddress.pbData =
U(accessDescription[1].AccessLocation).IPAddress.pbData =
(LPBYTE)encodedIPAddr;
aia.cAccDescr = 2;
aia.rgAccDescr = accessDescription;
......@@ -6395,9 +6395,9 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
* the encoding must include PKCS_7_ASN_ENCODING.
* (That isn't enough to be decoded, see decoding tests.)
*/
info.SignerId.IssuerSerialNumber.Issuer.cbData =
U(info.SignerId).IssuerSerialNumber.Issuer.cbData =
sizeof(encodedCommonNameNoNull);
info.SignerId.IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull;
U(info.SignerId).IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull;
SetLastError(0xdeadbeef);
ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
......@@ -6414,8 +6414,8 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
LocalFree(buf);
}
}
info.SignerId.IssuerSerialNumber.SerialNumber.cbData = sizeof(serialNum);
info.SignerId.IssuerSerialNumber.SerialNumber.pbData = (BYTE *)serialNum;
U(info.SignerId).IssuerSerialNumber.SerialNumber.cbData = sizeof(serialNum);
U(info.SignerId).IssuerSerialNumber.SerialNumber.pbData = (BYTE *)serialNum;
SetLastError(0xdeadbeef);
ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
......@@ -6434,8 +6434,8 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
}
}
info.SignerId.dwIdChoice = CERT_ID_KEY_IDENTIFIER;
info.SignerId.KeyId.cbData = sizeof(serialNum);
info.SignerId.KeyId.pbData = (BYTE *)serialNum;
U(info.SignerId).KeyId.cbData = sizeof(serialNum);
U(info.SignerId).KeyId.pbData = (BYTE *)serialNum;
SetLastError(0xdeadbeef);
ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
......@@ -6458,8 +6458,8 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
* (see RFC 3852, section 5.3.)
*/
info.SignerId.dwIdChoice = CERT_ID_SHA1_HASH;
info.SignerId.HashId.cbData = sizeof(hash);
info.SignerId.HashId.pbData = (BYTE *)hash;
U(info.SignerId).HashId.cbData = sizeof(hash);
U(info.SignerId).HashId.pbData = (BYTE *)hash;
SetLastError(0xdeadbeef);
ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
......@@ -6467,9 +6467,9 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
"Expected E_INVALIDARG, got %08x\n", GetLastError());
/* Now with a hash algo */
info.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
info.SignerId.IssuerSerialNumber.Issuer.cbData =
U(info.SignerId).IssuerSerialNumber.Issuer.cbData =
sizeof(encodedCommonNameNoNull);
info.SignerId.IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull;
U(info.SignerId).IssuerSerialNumber.Issuer.pbData = encodedCommonNameNoNull;
info.HashAlgorithm.pszObjId = oid1;
SetLastError(0xdeadbeef);
ret = CryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info,
......@@ -6556,17 +6556,17 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
"Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n",
info->SignerId.dwIdChoice);
ok(info->SignerId.IssuerSerialNumber.Issuer.cbData ==
ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData ==
sizeof(encodedCommonNameNoNull), "Unexpected size %d\n",
info->SignerId.IssuerSerialNumber.Issuer.cbData);
ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData,
U(info->SignerId).IssuerSerialNumber.Issuer.cbData);
ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData,
encodedCommonNameNoNull,
info->SignerId.IssuerSerialNumber.Issuer.cbData),
U(info->SignerId).IssuerSerialNumber.Issuer.cbData),
"Unexpected value\n");
ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData ==
ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData ==
sizeof(serialNum), "Unexpected size %d\n",
info->SignerId.IssuerSerialNumber.SerialNumber.cbData);
ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData,
U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData);
ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData,
serialNum, sizeof(serialNum)), "Unexpected value\n");
LocalFree(buf);
}
......@@ -6582,17 +6582,17 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
"Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n",
info->SignerId.dwIdChoice);
ok(info->SignerId.IssuerSerialNumber.Issuer.cbData ==
ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData ==
sizeof(encodedCommonNameNoNull), "Unexpected size %d\n",
info->SignerId.IssuerSerialNumber.Issuer.cbData);
ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData,
U(info->SignerId).IssuerSerialNumber.Issuer.cbData);
ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData,
encodedCommonNameNoNull,
info->SignerId.IssuerSerialNumber.Issuer.cbData),
U(info->SignerId).IssuerSerialNumber.Issuer.cbData),
"Unexpected value\n");
ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData ==
ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData ==
sizeof(serialNum), "Unexpected size %d\n",
info->SignerId.IssuerSerialNumber.SerialNumber.cbData);
ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData,
U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData);
ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData,
serialNum, sizeof(serialNum)), "Unexpected value\n");
ok(!strcmp(info->HashAlgorithm.pszObjId, oid1),
"Expected %s, got %s\n", oid1, info->HashAlgorithm.pszObjId);
......@@ -6611,17 +6611,17 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
"Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n",
info->SignerId.dwIdChoice);
ok(info->SignerId.IssuerSerialNumber.Issuer.cbData ==
ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData ==
sizeof(encodedCommonNameNoNull), "Unexpected size %d\n",
info->SignerId.IssuerSerialNumber.Issuer.cbData);
ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData,
U(info->SignerId).IssuerSerialNumber.Issuer.cbData);
ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData,
encodedCommonNameNoNull,
info->SignerId.IssuerSerialNumber.Issuer.cbData),
U(info->SignerId).IssuerSerialNumber.Issuer.cbData),
"Unexpected value\n");
ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData ==
ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData ==
sizeof(serialNum), "Unexpected size %d\n",
info->SignerId.IssuerSerialNumber.SerialNumber.cbData);
ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData,
U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData);
ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData,
serialNum, sizeof(serialNum)), "Unexpected value\n");
ok(!strcmp(info->HashAlgorithm.pszObjId, oid1),
"Expected %s, got %s\n", oid1, info->HashAlgorithm.pszObjId);
......@@ -6641,17 +6641,17 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
"Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n",
info->SignerId.dwIdChoice);
ok(info->SignerId.IssuerSerialNumber.Issuer.cbData ==
ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData ==
sizeof(encodedCommonNameNoNull), "Unexpected size %d\n",
info->SignerId.IssuerSerialNumber.Issuer.cbData);
ok(!memcmp(info->SignerId.IssuerSerialNumber.Issuer.pbData,
U(info->SignerId).IssuerSerialNumber.Issuer.cbData);
ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData,
encodedCommonNameNoNull,
info->SignerId.IssuerSerialNumber.Issuer.cbData),
U(info->SignerId).IssuerSerialNumber.Issuer.cbData),
"Unexpected value\n");
ok(info->SignerId.IssuerSerialNumber.SerialNumber.cbData ==
ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData ==
sizeof(serialNum), "Unexpected size %d\n",
info->SignerId.IssuerSerialNumber.SerialNumber.cbData);
ok(!memcmp(info->SignerId.IssuerSerialNumber.SerialNumber.pbData,
U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData);
ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData,
serialNum, sizeof(serialNum)), "Unexpected value\n");
ok(!strcmp(info->HashAlgorithm.pszObjId, oid1),
"Expected %s, got %s\n", oid1, info->HashAlgorithm.pszObjId);
......@@ -6675,9 +6675,9 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
ok(info->SignerId.dwIdChoice == CERT_ID_KEY_IDENTIFIER,
"Expected CERT_ID_KEY_IDENTIFIER, got %d\n",
info->SignerId.dwIdChoice);
ok(info->SignerId.KeyId.cbData == sizeof(serialNum),
"Unexpected size %d\n", info->SignerId.KeyId.cbData);
ok(!memcmp(info->SignerId.KeyId.pbData, serialNum, sizeof(serialNum)),
ok(U(info->SignerId).KeyId.cbData == sizeof(serialNum),
"Unexpected size %d\n", U(info->SignerId).KeyId.cbData);
ok(!memcmp(U(info->SignerId).KeyId.pbData, serialNum, sizeof(serialNum)),
"Unexpected value\n");
LocalFree(buf);
}
......
......@@ -1112,13 +1112,13 @@ static void test_signed_msg_open(void)
certInfo.Issuer.cbData = 0;
certInfo.SerialNumber.cbData = 0;
signer.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
signer.SignerId.IssuerSerialNumber.Issuer.cbData =
U(signer.SignerId).IssuerSerialNumber.Issuer.cbData =
sizeof(encodedCommonName);
signer.SignerId.IssuerSerialNumber.Issuer.pbData =
U(signer.SignerId).IssuerSerialNumber.Issuer.pbData =
(BYTE *)encodedCommonName;
signer.SignerId.IssuerSerialNumber.SerialNumber.cbData =
U(signer.SignerId).IssuerSerialNumber.SerialNumber.cbData =
sizeof(serialNum);
signer.SignerId.IssuerSerialNumber.SerialNumber.pbData = (BYTE *)serialNum;
U(signer.SignerId).IssuerSerialNumber.SerialNumber.pbData = (BYTE *)serialNum;
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
NULL, NULL);
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
......@@ -1661,8 +1661,8 @@ static void test_signed_msg_encoding(void)
certInfo.SerialNumber.cbData = 0;
certInfo.Issuer.cbData = 0;
signer.SignerId.dwIdChoice = CERT_ID_KEY_IDENTIFIER;
signer.SignerId.KeyId.cbData = sizeof(serialNum);
signer.SignerId.KeyId.pbData = (BYTE *)serialNum;
U(signer.SignerId).KeyId.cbData = sizeof(serialNum);
U(signer.SignerId).KeyId.pbData = (BYTE *)serialNum;
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
NULL, NULL);
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
......@@ -1888,13 +1888,13 @@ static void test_signed_msg_get_param(void)
certInfo.SerialNumber.cbData = 0;
certInfo.Issuer.cbData = 0;
signer.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
signer.SignerId.IssuerSerialNumber.Issuer.cbData =
U(signer.SignerId).IssuerSerialNumber.Issuer.cbData =
sizeof(encodedCommonName);
signer.SignerId.IssuerSerialNumber.Issuer.pbData =
U(signer.SignerId).IssuerSerialNumber.Issuer.pbData =
(BYTE *)encodedCommonName;
signer.SignerId.IssuerSerialNumber.SerialNumber.cbData =
U(signer.SignerId).IssuerSerialNumber.SerialNumber.cbData =
sizeof(serialNum);
signer.SignerId.IssuerSerialNumber.SerialNumber.pbData = (BYTE *)serialNum;
U(signer.SignerId).IssuerSerialNumber.SerialNumber.pbData = (BYTE *)serialNum;
ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL,
PROV_RSA_FULL, CRYPT_NEWKEYSET);
if (!ret && GetLastError() == NTE_EXISTS)
......@@ -1933,8 +1933,8 @@ static void test_signed_msg_get_param(void)
* the CMS version.
*/
signer.SignerId.dwIdChoice = CERT_ID_KEY_IDENTIFIER;
signer.SignerId.KeyId.cbData = sizeof(serialNum);
signer.SignerId.KeyId.pbData = (BYTE *)serialNum;
U(signer.SignerId).KeyId.cbData = sizeof(serialNum);
U(signer.SignerId).KeyId.pbData = (BYTE *)serialNum;
ret = pCryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL,
PROV_RSA_FULL, CRYPT_NEWKEYSET);
if (!ret && GetLastError() == NTE_EXISTS)
......@@ -2291,32 +2291,32 @@ static void compare_cms_signer_info(const CMSG_CMS_SIGNER_INFO *got,
{
if (got->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
{
ok(got->SignerId.IssuerSerialNumber.Issuer.cbData ==
expected->SignerId.IssuerSerialNumber.Issuer.cbData,
ok(U(got->SignerId).IssuerSerialNumber.Issuer.cbData ==
U(expected->SignerId).IssuerSerialNumber.Issuer.cbData,
"Expected issuer size %d, got %d\n",
expected->SignerId.IssuerSerialNumber.Issuer.cbData,
got->SignerId.IssuerSerialNumber.Issuer.cbData);
ok(!memcmp(got->SignerId.IssuerSerialNumber.Issuer.pbData,
expected->SignerId.IssuerSerialNumber.Issuer.pbData,
got->SignerId.IssuerSerialNumber.Issuer.cbData),
U(expected->SignerId).IssuerSerialNumber.Issuer.cbData,
U(got->SignerId).IssuerSerialNumber.Issuer.cbData);
ok(!memcmp(U(got->SignerId).IssuerSerialNumber.Issuer.pbData,
U(expected->SignerId).IssuerSerialNumber.Issuer.pbData,
U(got->SignerId).IssuerSerialNumber.Issuer.cbData),
"Unexpected issuer\n");
ok(got->SignerId.IssuerSerialNumber.SerialNumber.cbData ==
expected->SignerId.IssuerSerialNumber.SerialNumber.cbData,
ok(U(got->SignerId).IssuerSerialNumber.SerialNumber.cbData ==
U(expected->SignerId).IssuerSerialNumber.SerialNumber.cbData,
"Expected serial number size %d, got %d\n",
expected->SignerId.IssuerSerialNumber.SerialNumber.cbData,
got->SignerId.IssuerSerialNumber.SerialNumber.cbData);
ok(!memcmp(got->SignerId.IssuerSerialNumber.SerialNumber.pbData,
expected->SignerId.IssuerSerialNumber.SerialNumber.pbData,
got->SignerId.IssuerSerialNumber.SerialNumber.cbData),
U(expected->SignerId).IssuerSerialNumber.SerialNumber.cbData,
U(got->SignerId).IssuerSerialNumber.SerialNumber.cbData);
ok(!memcmp(U(got->SignerId).IssuerSerialNumber.SerialNumber.pbData,
U(expected->SignerId).IssuerSerialNumber.SerialNumber.pbData,
U(got->SignerId).IssuerSerialNumber.SerialNumber.cbData),
"Unexpected serial number\n");
}
else
{
ok(got->SignerId.KeyId.cbData == expected->SignerId.KeyId.cbData,
ok(U(got->SignerId).KeyId.cbData == U(expected->SignerId).KeyId.cbData,
"expected key id size %d, got %d\n",
expected->SignerId.KeyId.cbData, got->SignerId.KeyId.cbData);
ok(!memcmp(expected->SignerId.KeyId.pbData,
got->SignerId.KeyId.pbData, got->SignerId.KeyId.cbData),
U(expected->SignerId).KeyId.cbData, U(got->SignerId).KeyId.cbData);
ok(!memcmp(U(expected->SignerId).KeyId.pbData,
U(got->SignerId).KeyId.pbData, U(got->SignerId).KeyId.cbData),
"unexpected key id\n");
}
}
......@@ -2429,12 +2429,12 @@ static void test_decode_msg_get_param(void)
signer.dwVersion = 1;
signer.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
signer.SignerId.IssuerSerialNumber.Issuer.cbData =
U(signer.SignerId).IssuerSerialNumber.Issuer.cbData =
sizeof(encodedCommonName);
signer.SignerId.IssuerSerialNumber.Issuer.pbData = encodedCommonName;
signer.SignerId.IssuerSerialNumber.SerialNumber.cbData =
U(signer.SignerId).IssuerSerialNumber.Issuer.pbData = encodedCommonName;
U(signer.SignerId).IssuerSerialNumber.SerialNumber.cbData =
sizeof(serialNum);
signer.SignerId.IssuerSerialNumber.SerialNumber.pbData = serialNum;
U(signer.SignerId).IssuerSerialNumber.SerialNumber.pbData = serialNum;
signer.HashAlgorithm.pszObjId = oid_rsa_md5;
CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, buf, &size);
compare_cms_signer_info((CMSG_CMS_SIGNER_INFO *)buf, &signer);
......@@ -2521,8 +2521,8 @@ static void test_decode_msg_get_param(void)
signer.dwVersion = CMSG_SIGNED_DATA_V3;
signer.SignerId.dwIdChoice = CERT_ID_KEY_IDENTIFIER;
signer.SignerId.KeyId.cbData = sizeof(serialNum);
signer.SignerId.KeyId.pbData = (BYTE *)serialNum;
U(signer.SignerId).KeyId.cbData = sizeof(serialNum);
U(signer.SignerId).KeyId.pbData = (BYTE *)serialNum;
signer.HashAlgorithm.pszObjId = oid_rsa_md5;
CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, buf, &size);
compare_cms_signer_info((CMSG_CMS_SIGNER_INFO *)buf, &signer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment