Commit 595bae3e authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Test and correct encoding of signed CMS messages.

parent 282eb73b
......@@ -1381,6 +1381,9 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags,
ret = CSignedMsgData_AllocateHandles(&msg->msg_data);
for (i = 0; ret && i < msg->msg_data.info->cSignerInfo; i++)
{
if (info->rgSigners[i].SignerId.dwIdChoice ==
CERT_ID_KEY_IDENTIFIER)
msg->msg_data.info->version = CMSG_SIGNED_DATA_V3;
ret = CSignerInfo_Construct(
&msg->msg_data.info->rgSignerInfo[i],
&info->rgSigners[i]);
......
......@@ -1341,6 +1341,12 @@ static const BYTE signedContent[] = {
static const BYTE signedHash[] = {
0x08,0xd6,0xc0,0x5a,0x21,0x51,0x2a,0x79,0xa1,0xdf,0xeb,0x9d,0x2a,0x8f,0x26,
0x2f };
static const BYTE signedKeyIdEmptyContent[] = {
0x30,0x46,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,0xa0,0x39,
0x30,0x37,0x02,0x01,0x03,0x31,0x0e,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,
0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x02,0x06,0x00,0x31,0x1e,0x30,0x1c,0x02,
0x01,0x03,0x80,0x01,0x01,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,
0x02,0x05,0x05,0x00,0x30,0x04,0x06,0x00,0x05,0x00,0x04,0x00 };
static const BYTE signedEncodedSigner[] = {
0x30,0x75,0x02,0x01,0x01,0x30,0x1a,0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,
0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,
......@@ -1652,6 +1658,23 @@ static void test_signed_msg_encoding(void)
CryptMsgClose(msg);
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;
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
NULL, NULL);
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
check_param("signed key id empty content", msg, CMSG_CONTENT_PARAM,
signedKeyIdEmptyContent, sizeof(signedKeyIdEmptyContent));
CryptMsgClose(msg);
certInfo.SerialNumber.cbData = sizeof(serialNum);
certInfo.SerialNumber.pbData = serialNum;
certInfo.Issuer.cbData = sizeof(encodedCommonName);
certInfo.Issuer.pbData = encodedCommonName;
signer.SignerId.dwIdChoice = 0;
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
NULL, NULL);
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
......
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