Module: wine Branch: master Commit: ad975f672bf713da7c2af4d97f4ca68f191ca2c8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=ad975f672bf713da7c2af4d97f...
Author: Juan Lang juan.lang@gmail.com Date: Thu Jul 12 14:26:47 2007 -0700
crypt32: Add tests for updating hash messages opened to encode.
---
dlls/crypt32/tests/msg.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 60bfe0b..f5b2fc5 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -680,9 +680,71 @@ static void test_hash_msg_open(void) CryptMsgClose(msg); }
+static void test_hash_msg_update(void) +{ + HCRYPTMSG msg; + BOOL ret; + static char oid_rsa_md5[] = szOID_RSA_MD5; + CMSG_HASHED_ENCODE_INFO hashInfo = { sizeof(hashInfo), 0, + { oid_rsa_md5, { 0, NULL } }, NULL }; + CMSG_STREAM_INFO streamInfo = { 0, nop_stream_output, NULL }; + + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, + CMSG_HASHED, &hashInfo, NULL, NULL); + /* Detached hashed messages opened in non-streaming mode allow non-final + * updates.. + */ + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* including non-final updates with no data.. */ + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + /* and final updates 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); + ret = CryptMsgUpdate(msg, NULL, 0, FALSE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + CryptMsgClose(msg); + /* Non-detached messages, in contrast, don't allow non-final updates in + * non-streaming mode. + */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, + NULL, NULL); + SetLastError(0xdeadbeef); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + todo_wine + ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR, + "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError()); + /* Final updates (including empty ones) are allowed. */ + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + CryptMsgClose(msg); + /* And, of course, streaming mode allows non-final updates */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, + NULL, &streamInfo); + ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE); + todo_wine + ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError()); + CryptMsgClose(msg); +} + static void test_hash_msg(void) { test_hash_msg_open(); + test_hash_msg_update(); }
static CRYPT_DATA_BLOB b4 = { 0, NULL };