Commit d11ddebc authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Add a partial stub for updating a signed encoded message.

parent 014f282b
......@@ -592,12 +592,15 @@ static BOOL CRYPT_IsValidSigner(CMSG_SIGNER_ENCODE_INFO_WITH_CMS *signer)
typedef struct _CSignedEncodeMsg
{
CryptMsgBase base;
CryptMsgBase base;
CRYPT_DATA_BLOB data;
} CSignedEncodeMsg;
static void CSignedEncodeMsg_Close(HCRYPTMSG hCryptMsg)
{
FIXME("(%p)\n", hCryptMsg);
CSignedEncodeMsg *msg = (CSignedEncodeMsg *)hCryptMsg;
CryptMemFree(msg->data.pbData);
}
static BOOL CSignedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
......@@ -611,8 +614,37 @@ static BOOL CSignedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
static BOOL CSignedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
DWORD cbData, BOOL fFinal)
{
FIXME("(%p, %p, %d, %d)\n", hCryptMsg, pbData, cbData, fFinal);
return FALSE;
CSignedEncodeMsg *msg = (CSignedEncodeMsg *)hCryptMsg;
BOOL ret = FALSE;
if (msg->base.streamed || (msg->base.open_flags & CMSG_DETACHED_FLAG))
{
FIXME("streamed / detached update unimplemented\n");
ret = TRUE;
}
else
{
if (!fFinal)
SetLastError(CRYPT_E_MSG_ERROR);
else
{
if (cbData)
{
msg->data.pbData = CryptMemAlloc(cbData);
if (msg->data.pbData)
{
memcpy(msg->data.pbData, pbData, cbData);
msg->data.cbData = cbData;
ret = TRUE;
}
}
else
ret = TRUE;
if (ret)
FIXME("non-streamed final update: partial stub\n");
}
}
return ret;
}
static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags,
......@@ -644,6 +676,8 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags,
CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo,
CSignedEncodeMsg_Close, CSignedEncodeMsg_GetParam,
CSignedEncodeMsg_Update);
msg->data.cbData = 0;
msg->data.pbData = NULL;
}
return msg;
}
......
......@@ -1112,11 +1112,9 @@ static void test_signed_msg_update(void)
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
/* CMSG_SIGNED allows non-final updates. */
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
/* CMSG_SIGNED also allows non-final updates with no data. */
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
/* The final update requires a private key in the hCryptProv, in order to
* generate the signature.
......@@ -1143,17 +1141,14 @@ static void test_signed_msg_update(void)
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
/* CMSG_SIGNED allows non-final updates. */
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
/* CMSG_SIGNED also allows non-final updates with no data. */
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
/* Now that the private key exists, the final update can succeed (even
* with no data.)
*/
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
/* But no updates are allowed after the final update. */
SetLastError(0xdeadbeef);
......@@ -1282,7 +1277,6 @@ static void test_signed_msg_encoding(void)
check_param("detached signed empty content", msg, CMSG_CONTENT_PARAM,
signedEmptyContent, sizeof(signedEmptyContent));
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
todo_wine
check_param("detached signed hash", msg, CMSG_COMPUTED_HASH_PARAM,
......@@ -1312,7 +1306,6 @@ static void test_signed_msg_encoding(void)
check_param("signed empty content", msg, CMSG_CONTENT_PARAM,
signedEmptyContent, sizeof(signedEmptyContent));
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
todo_wine
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
todo_wine
check_param("signed bare content", msg, CMSG_BARE_CONTENT_PARAM,
......
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