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

This commit is contained in:
Juan Lang 2008-03-25 11:44:54 -07:00 committed by Alexandre Julliard
parent 856270972f
commit 44f2517335
2 changed files with 41 additions and 7 deletions

View File

@ -52,6 +52,7 @@ BOOL CRYPT_DefaultMsgControl(HCRYPTMSG hCryptMsg, DWORD dwFlags,
typedef enum _CryptMsgState { typedef enum _CryptMsgState {
MsgStateInit, MsgStateInit,
MsgStateUpdated, MsgStateUpdated,
MsgStateDataFinalized,
MsgStateFinalized MsgStateFinalized
} CryptMsgState; } CryptMsgState;
@ -1663,10 +1664,30 @@ static BOOL CDecodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
SetLastError(CRYPT_E_MSG_ERROR); SetLastError(CRYPT_E_MSG_ERROR);
else if (msg->base.streamed) else if (msg->base.streamed)
{ {
ret = CDecodeMsg_CopyData(msg, pbData, cbData);
FIXME("(%p, %p, %d, %d): streamed update stub\n", hCryptMsg, pbData, FIXME("(%p, %p, %d, %d): streamed update stub\n", hCryptMsg, pbData,
cbData, fFinal); 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 else
{ {
@ -1674,10 +1695,24 @@ static BOOL CDecodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData,
SetLastError(CRYPT_E_MSG_ERROR); SetLastError(CRYPT_E_MSG_ERROR);
else else
{ {
ret = CDecodeMsg_CopyData(msg, pbData, cbData); if (msg->base.state == MsgStateInit)
if (ret) {
ret = CDecodeMsg_DecodeContent(msg, &msg->msg_data, msg->type); ret = CDecodeMsg_CopyData(msg, pbData, cbData);
msg->base.state = MsgStateFinalized; if (ret)
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; return ret;

View File

@ -2062,7 +2062,6 @@ static void test_decode_msg_update(void)
/* as does a second (probably to update the detached portion).. */ /* as does a second (probably to update the detached portion).. */
ret = CryptMsgUpdate(msg, detachedSignedContent, ret = CryptMsgUpdate(msg, detachedSignedContent,
sizeof(detachedSignedContent), TRUE); sizeof(detachedSignedContent), TRUE);
todo_wine
ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError()); ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
/* while a third fails. */ /* while a third fails. */
ret = CryptMsgUpdate(msg, detachedSignedContent, ret = CryptMsgUpdate(msg, detachedSignedContent,