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