mirror of
https://github.com/reactos/wine.git
synced 2025-02-16 19:10:35 +00:00
crypt32: Add tests for opening non-detached signed messages, and clarify detached open.
This commit is contained in:
parent
d11ddebc76
commit
19e63d9004
@ -1110,10 +1110,10 @@ static void test_signed_msg_update(void)
|
|||||||
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING,
|
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING,
|
||||||
CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL);
|
CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL);
|
||||||
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
|
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
|
||||||
/* CMSG_SIGNED allows non-final updates. */
|
/* Detached CMSG_SIGNED allows non-final updates. */
|
||||||
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
||||||
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
||||||
/* CMSG_SIGNED also allows non-final updates with no data. */
|
/* Detached CMSG_SIGNED also allows non-final updates with no data. */
|
||||||
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
|
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
|
||||||
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
|
||||||
@ -1139,10 +1139,10 @@ static void test_signed_msg_update(void)
|
|||||||
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING,
|
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING,
|
||||||
CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL);
|
CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL);
|
||||||
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
|
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
|
||||||
/* CMSG_SIGNED allows non-final updates. */
|
/* Detached CMSG_SIGNED allows non-final updates. */
|
||||||
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
||||||
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
|
||||||
/* CMSG_SIGNED also allows non-final updates with no data. */
|
/* Detached CMSG_SIGNED also allows non-final updates with no data. */
|
||||||
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
|
ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
|
||||||
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
|
||||||
@ -1161,6 +1161,26 @@ static void test_signed_msg_update(void)
|
|||||||
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
|
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
|
||||||
CryptMsgClose(msg);
|
CryptMsgClose(msg);
|
||||||
|
|
||||||
|
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
|
||||||
|
NULL, NULL);
|
||||||
|
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
|
||||||
|
/* Non-detached messages don't allow non-final updates.. */
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
|
||||||
|
ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
|
||||||
|
"Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
|
||||||
|
/* but they do allow final ones. */
|
||||||
|
ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
|
||||||
|
ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
|
||||||
|
CryptMsgClose(msg);
|
||||||
|
msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
|
||||||
|
NULL, NULL);
|
||||||
|
ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
|
||||||
|
/* They also allow final updates with no data. */
|
||||||
|
ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
|
||||||
|
ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
|
||||||
|
CryptMsgClose(msg);
|
||||||
|
|
||||||
CryptDestroyKey(key);
|
CryptDestroyKey(key);
|
||||||
CryptReleaseContext(signer.hCryptProv, 0);
|
CryptReleaseContext(signer.hCryptProv, 0);
|
||||||
CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, PROV_RSA_FULL,
|
CryptAcquireContextW(&signer.hCryptProv, cspNameW, NULL, PROV_RSA_FULL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user