Juan Lang : crypt32:
Test and implement getting the encoded signers from an encoded signed
message .
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jul 25 07:44:11 CDT 2007
Module: wine
Branch: master
Commit: f987ca01d0c30481fae09158ff71d4cf15260691
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f987ca01d0c30481fae09158ff71d4cf15260691
Author: Juan Lang <juan.lang at gmail.com>
Date: Tue Jul 24 11:18:52 2007 -0700
crypt32: Test and implement getting the encoded signers from an encoded signed message.
---
dlls/crypt32/msg.c | 9 ++++++++-
dlls/crypt32/tests/msg.c | 14 +++++++++++---
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index 8a1fea0..ba75cb6 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -865,12 +865,19 @@ static BOOL CSignedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType,
ret = CryptGetHashParam(msg->signerHandles[dwIndex].hash,
HP_HASHVAL, pvData, pcbData, 0);
break;
+ case CMSG_ENCODED_SIGNER:
+ if (dwIndex >= msg->info.cSignerInfo)
+ SetLastError(CRYPT_E_INVALID_INDEX);
+ else
+ ret = CryptEncodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
+ PKCS7_SIGNER_INFO, &msg->info.rgSignerInfo[dwIndex], 0, NULL,
+ pvData, pcbData);
+ break;
case CMSG_VERSION_PARAM:
ret = CRYPT_CopyParam(pvData, pcbData, (const BYTE *)&msg->info.version,
sizeof(msg->info.version));
break;
default:
- FIXME("unimplemented for %d\n", dwParamType);
SetLastError(CRYPT_E_INVALID_MSG_TYPE);
}
return ret;
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 8665594..3bd0882 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -1256,6 +1256,15 @@ static const BYTE signedContent[] = {
static const BYTE signedHash[] = {
0x08,0xd6,0xc0,0x5a,0x21,0x51,0x2a,0x79,0xa1,0xdf,0xeb,0x9d,0x2a,0x8f,0x26,
0x2f };
+static const BYTE signedEncodedSigner[] = {
+0x30,0x75,0x02,0x01,0x01,0x30,0x1a,0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,
+0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00,
+0x02,0x01,0x01,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,
+0x05,0x00,0x30,0x04,0x06,0x00,0x05,0x00,0x04,0x40,0x81,0xa6,0x70,0xb3,0xef,
+0x59,0xd1,0x66,0xd1,0x9b,0xc0,0x9a,0xb6,0x9a,0x5e,0x6d,0x6f,0x6d,0x0d,0x59,
+0xa9,0xaa,0x6e,0xe9,0x2c,0xa0,0x1e,0xee,0xc2,0x60,0xbc,0x59,0xbe,0x3f,0x63,
+0x06,0x8d,0xc9,0x11,0x1d,0x23,0x64,0x92,0xef,0x2e,0xfc,0x57,0x29,0xa4,0xaf,
+0xe0,0xee,0x93,0x19,0x39,0x51,0xe4,0x44,0xb8,0x0b,0x28,0xf4,0xa8,0x0d };
static BYTE cert[] = {
0x30,0x7a,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,0x11,
0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
@@ -1427,6 +1436,8 @@ static void test_signed_msg_encoding(void)
ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size);
ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX,
"Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError());
+ check_param("detached signed encoded signer", msg, CMSG_ENCODED_SIGNER,
+ signedEncodedSigner, sizeof(signedEncodedSigner));
CryptMsgClose(msg);
@@ -1536,7 +1547,6 @@ static void test_signed_msg_get_param(void)
size = 0;
SetLastError(0xdeadbeef);
ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size);
- todo_wine
ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX,
"Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError());
SetLastError(0xdeadbeef);
@@ -1573,14 +1583,12 @@ static void test_signed_msg_get_param(void)
*/
size = 0;
ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size);
- todo_wine
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size);
ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
size = 0;
SetLastError(0xdeadbeef);
ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 1, NULL, &size);
- todo_wine
ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX,
"Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError());
SetLastError(0xdeadbeef);
More information about the wine-cvs
mailing list