Commit 44f25173 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Allow one update to a decode message after the final update if it's a detached message.

parent 85627097
......@@ -52,6 +52,7 @@ BOOL CRYPT_DefaultMsgControl(HCRYPTMSG hCryptMsg, DWORD dwFlags,
typedef enum _CryptMsgState {
MsgStateInit,
MsgStateUpdated,
MsgStateDataFinalized,
MsgStateFinalized
} CryptMsgState;
......@@ -1663,10 +1664,30 @@ static BOOL CDecodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
SetLastError(CRYPT_E_MSG_ERROR);
else if (msg->base.streamed)
{
ret = CDecodeMsg_CopyData(msg, pbData, cbData);
FIXME("(%p, %p, %d, %d): streamed update stub\n", hCryptMsg, pbData,
cbData, fFinal);
msg->base.state = fFinal ? MsgStateFinalized : MsgStateUpdated;
if (fFinal)
{
if (msg->base.open_flags & CMSG_DETACHED_FLAG &&
msg->base.state != MsgStateDataFinalized)
{
ret = CDecodeMsg_CopyData(msg, pbData, cbData);
msg->base.state = MsgStateDataFinalized;
}
else
{
FIXME("(%p, %p, %d, %d): detached update stub\n", hCryptMsg,
pbData, cbData, fFinal);
ret = TRUE;
msg->base.state = MsgStateFinalized;
}
}
else
{
ret = CDecodeMsg_CopyData(msg, pbData, cbData);
if (msg->base.state == MsgStateInit)
msg->base.state = MsgStateUpdated;
}
}
else
{
......@@ -1674,12 +1695,26 @@ static BOOL CDecodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
SetLastError(CRYPT_E_MSG_ERROR);
else
{
if (msg->base.state == MsgStateInit)
{
ret = CDecodeMsg_CopyData(msg, pbData, cbData);
if (ret)
ret = CDecodeMsg_DecodeContent(msg, &msg->msg_data, msg->type);
ret = CDecodeMsg_DecodeContent(msg, &msg->msg_data,
msg->type);
if (msg->base.open_flags & CMSG_DETACHED_FLAG)
msg->base.state = MsgStateDataFinalized;
else
msg->base.state = MsgStateFinalized;
}
else if (msg->base.state == MsgStateDataFinalized)
{
FIXME("(%p, %p, %d, %d): detached update stub\n", hCryptMsg,
pbData, cbData, fFinal);
ret = TRUE;
msg->base.state = MsgStateFinalized;
}
}
}
return ret;
}
......
......@@ -2062,7 +2062,6 @@ static void test_decode_msg_update(void)
/* as does a second (probably to update the detached portion).. */
ret = CryptMsgUpdate(msg, detachedSignedContent,
sizeof(detachedSignedContent), TRUE);
todo_wine
ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
/* while a third fails. */
ret = CryptMsgUpdate(msg, detachedSignedContent,
......
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