winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
August 2007
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
3 participants
1085 discussions
Start a n
N
ew thread
Juan Lang : crypt32: Implement verifying a decoded signed message' s signature.
by Alexandre Julliard
21 Aug '07
21 Aug '07
Module: wine Branch: master Commit: b7e420429db8e3a2eab503f49ce0b04a4ac7f551 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b7e420429db8e3a2eab503f49…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Tue Aug 21 07:34:47 2007 -0700 crypt32: Implement verifying a decoded signed message's signature. --- dlls/crypt32/msg.c | 43 ++++++++++++++++++++++++++++++++++++++++++- dlls/crypt32/tests/msg.c | 9 ++++----- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index ace5e51..c9226ad 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -2084,6 +2084,47 @@ static BOOL CDecodeHashMsg_VerifyHash(CDecodeMsg *msg) return ret; } +static BOOL CDecodeSignedMsg_VerifySignature(CDecodeMsg *msg, PCERT_INFO info) +{ + BOOL ret = FALSE; + DWORD i; + + for (i = 0; !ret && i < msg->u.signed_data.info->cSignerInfo; i++) + { + ret = CertCompareCertificateName(X509_ASN_ENCODING, + &msg->u.signed_data.info->rgSignerInfo[i].Issuer, &info->Issuer); + if (ret) + ret = CertCompareIntegerBlob( + &msg->u.signed_data.info->rgSignerInfo[i].SerialNumber, + &info->SerialNumber); + } + if (ret) + { + HCRYPTKEY key; + + ret = CryptImportPublicKeyInfo(msg->crypt_prov, X509_ASN_ENCODING, + &info->SubjectPublicKeyInfo, &key); + if (ret) + { + HCRYPTHASH hash; + + if (msg->u.signed_data.info->rgSignerInfo[i].AuthAttrs.cAttr) + hash = msg->u.signed_data.signerHandles[i].authAttrHash; + else + hash = msg->u.signed_data.signerHandles[i].contentHash; + ret = CryptVerifySignatureW(hash, + msg->u.signed_data.info->rgSignerInfo[i].EncryptedHash.pbData, + msg->u.signed_data.info->rgSignerInfo[i].EncryptedHash.cbData, + key, NULL, 0); + CryptDestroyKey(key); + } + } + else + SetLastError(CRYPT_E_SIGNER_NOT_FOUND); + + return ret; +} + static BOOL CDecodeMsg_Control(HCRYPTMSG hCryptMsg, DWORD dwFlags, DWORD dwCtrlType, const void *pvCtrlPara) { @@ -2096,7 +2137,7 @@ static BOOL CDecodeMsg_Control(HCRYPTMSG hCryptMsg, DWORD dwFlags, switch (msg->type) { case CMSG_SIGNED: - FIXME("CMSG_CTRL_VERIFY_SIGNATURE: stub\n"); + ret = CDecodeSignedMsg_VerifySignature(msg, (PCERT_INFO)pvCtrlPara); break; default: SetLastError(CRYPT_E_INVALID_MSG_TYPE); diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index f079916..b1e6c94 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -2291,7 +2291,6 @@ static void test_msg_control(void) */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - todo_wine ok(!ret && GetLastError() == CRYPT_E_SIGNER_NOT_FOUND, "Expected CRYPT_E_SIGNER_NOT_FOUND, got %08x\n", GetLastError()); /* The cert info is expected to have an issuer, serial number, and public @@ -2303,7 +2302,6 @@ static void test_msg_control(void) certInfo.Issuer.pbData = encodedCommonName; SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - todo_wine ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); CryptMsgClose(msg); @@ -2315,7 +2313,6 @@ static void test_msg_control(void) /* Again, cert info needs to have a public key set */ SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - todo_wine ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); /* The public key is supposed to be in encoded form.. */ @@ -2324,7 +2321,6 @@ static void test_msg_control(void) certInfo.SubjectPublicKeyInfo.PublicKey.pbData = aKey; SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - todo_wine ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); /* but not as a X509_PUBLIC_KEY_INFO.. */ @@ -2333,7 +2329,6 @@ static void test_msg_control(void) certInfo.SubjectPublicKeyInfo.PublicKey.pbData = encodedPubKey; SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); - todo_wine ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); /* This decodes successfully, but it doesn't match any key in the message */ @@ -2341,6 +2336,10 @@ static void test_msg_control(void) certInfo.SubjectPublicKeyInfo.PublicKey.pbData = mod_encoded; SetLastError(0xdeadbeef); ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo); + /* In Wine's rsaenh, this fails to decode because the key length is too + * small. Not sure if that's a bug in rsaenh, so leaving todo_wine for + * now. + */ todo_wine ok(!ret && GetLastError() == NTE_BAD_SIGNATURE, "Expected NTE_BAD_SIGNATURE, got %08x\n", GetLastError());
1
0
0
0
Juan Lang : crypt32: Test and implement getting the computed hash from a decoded signed message .
by Alexandre Julliard
21 Aug '07
21 Aug '07
Module: wine Branch: master Commit: d3431271faf13454f278ace4950d41caab68e428 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d3431271faf13454f278ace49…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Tue Aug 21 07:09:24 2007 -0700 crypt32: Test and implement getting the computed hash from a decoded signed message. --- dlls/crypt32/msg.c | 13 +++++++++++++ dlls/crypt32/tests/msg.c | 7 +++++++ 2 files changed, 20 insertions(+), 0 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 76bb055..ace5e51 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -1975,6 +1975,19 @@ static BOOL CDecodeSignedMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType, else SetLastError(CRYPT_E_INVALID_MSG_TYPE); break; + case CMSG_COMPUTED_HASH_PARAM: + if (msg->u.signed_data.info) + { + if (dwIndex >= msg->u.signed_data.info->cSignerInfo) + SetLastError(CRYPT_E_INVALID_INDEX); + else + ret = CryptGetHashParam( + msg->u.signed_data.signerHandles[dwIndex].contentHash, + HP_HASHVAL, pvData, pcbData, 0); + } + else + SetLastError(CRYPT_E_INVALID_MSG_TYPE); + break; case CMSG_ATTR_CERT_COUNT_PARAM: if (msg->u.signed_data.info) { diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index 72932fe..f079916 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -1989,6 +1989,10 @@ static void compare_signer_info(const CMSG_SIGNER_INFO *got, /* FIXME: check more things */ } +static const BYTE signedWithCertAndCrlComputedHash[] = { +0x08,0xd6,0xc0,0x5a,0x21,0x51,0x2a,0x79,0xa1,0xdf,0xeb,0x9d,0x2a,0x8f,0x26, +0x2f }; + static void test_decode_msg_get_param(void) { HCRYPTMSG msg; @@ -2099,6 +2103,9 @@ static void test_decode_msg_get_param(void) ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError()); ok(value == 1, "Expected 1 CRL, got %d\n", value); check_param("crl", msg, CMSG_CRL_PARAM, crl, sizeof(crl)); + check_param("signed with cert and CRL computed hash", msg, + CMSG_COMPUTED_HASH_PARAM, signedWithCertAndCrlComputedHash, + sizeof(signedWithCertAndCrlComputedHash)); CryptMsgClose(msg); }
1
0
0
0
Juan Lang : crypt32: Update a hash message's hash handles when decoding it.
by Alexandre Julliard
21 Aug '07
21 Aug '07
Module: wine Branch: master Commit: ed6fbb2712206e671500debbd9946c3ef91ddf34 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ed6fbb2712206e671500debbd…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Tue Aug 21 07:07:43 2007 -0700 crypt32: Update a hash message's hash handles when decoding it. --- dlls/crypt32/msg.c | 88 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 70 insertions(+), 18 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 8c01c76..76bb055 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -902,8 +902,13 @@ static BOOL CSignedMsgData_AppendMessageDigestAttribute( return ret; } +typedef enum { + Sign, + Verify +} SignOrVerify; + static BOOL CSignedMsgData_UpdateAuthenticatedAttributes( - CSignedMsgData *msg_data) + CSignedMsgData *msg_data, SignOrVerify flag) { DWORD i; BOOL ret = TRUE; @@ -914,18 +919,22 @@ static BOOL CSignedMsgData_UpdateAuthenticatedAttributes( { if (msg_data->info->rgSignerInfo[i].AuthAttrs.cAttr) { - BYTE oid_rsa_data_encoded[] = { 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7, - 0x0d,0x01,0x07,0x01 }; - CRYPT_DATA_BLOB content = { sizeof(oid_rsa_data_encoded), - oid_rsa_data_encoded }; - char contentType[] = szOID_RSA_contentType; - CRYPT_ATTRIBUTE contentTypeAttr = { contentType, 1, &content }; - - /* FIXME: does this depend on inner OID? */ - ret = CRYPT_AppendAttribute( - &msg_data->info->rgSignerInfo[i].AuthAttrs, &contentTypeAttr); - if (ret) - ret = CSignedMsgData_AppendMessageDigestAttribute(msg_data, i); + if (flag == Sign) + { + BYTE oid_rsa_data_encoded[] = { 0x06,0x09,0x2a,0x86,0x48,0x86, + 0xf7,0x0d,0x01,0x07,0x01 }; + CRYPT_DATA_BLOB content = { sizeof(oid_rsa_data_encoded), + oid_rsa_data_encoded }; + char contentType[] = szOID_RSA_contentType; + CRYPT_ATTRIBUTE contentTypeAttr = { contentType, 1, &content }; + + /* FIXME: does this depend on inner OID? */ + ret = CRYPT_AppendAttribute( + &msg_data->info->rgSignerInfo[i].AuthAttrs, &contentTypeAttr); + if (ret) + ret = CSignedMsgData_AppendMessageDigestAttribute(msg_data, + i); + } if (ret) { LPBYTE encodedAttrs; @@ -1000,14 +1009,14 @@ static BOOL CSignedMsgData_Sign(CSignedMsgData *msg_data) } static BOOL CSignedMsgData_Update(CSignedMsgData *msg_data, - const BYTE *pbData, DWORD cbData, BOOL fFinal) + const BYTE *pbData, DWORD cbData, BOOL fFinal, SignOrVerify flag) { BOOL ret = CSignedMsgData_UpdateHash(msg_data, pbData, cbData); if (ret && fFinal) { - ret = CSignedMsgData_UpdateAuthenticatedAttributes(msg_data); - if (ret) + ret = CSignedMsgData_UpdateAuthenticatedAttributes(msg_data, flag); + if (ret && flag == Sign) ret = CSignedMsgData_Sign(msg_data); } return ret; @@ -1137,7 +1146,8 @@ static BOOL CSignedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, if (msg->base.streamed || (msg->base.open_flags & CMSG_DETACHED_FLAG)) { - ret = CSignedMsgData_Update(&msg->msg_data, pbData, cbData, fFinal); + ret = CSignedMsgData_Update(&msg->msg_data, pbData, cbData, fFinal, + Sign); if (msg->base.streamed) FIXME("streamed partial stub\n"); } @@ -1161,7 +1171,7 @@ static BOOL CSignedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, ret = TRUE; if (ret) ret = CSignedMsgData_Update(&msg->msg_data, pbData, cbData, - fFinal); + fFinal, Sign); } } return ret; @@ -1337,7 +1347,10 @@ static void CDecodeMsg_Close(HCRYPTMSG hCryptMsg) break; case CMSG_SIGNED: if (msg->u.signed_data.info) + { LocalFree(msg->u.signed_data.info); + CSignedMsgData_CloseHandles(&msg->u.signed_data); + } break; } CryptMemFree(msg->msg_data.pbData); @@ -1472,7 +1485,46 @@ static BOOL CDecodeMsg_DecodeSignedContent(CDecodeMsg *msg, CRYPT_DECODE_ALLOC_FLAG, NULL, (CRYPT_SIGNED_INFO *)&signedInfo, &size); if (ret) + { + DWORD i; + msg->u.signed_data.info = signedInfo; + ret = CSignedMsgData_AllocateHandles(&msg->u.signed_data); + for (i = 0; ret && i < msg->u.signed_data.info->cSignerInfo; i++) + ret = CSignedMsgData_ConstructSignerHandles(&msg->u.signed_data, i, + msg->crypt_prov); + if (ret) + { + /* Now that we have all the content, update the hash handles with + * it. Have to decode it if the type is szOID_RSA_data. + */ + if (msg->u.signed_data.info->content.Content.cbData) + { + if (!strcmp(msg->u.signed_data.info->content.pszObjId, + szOID_RSA_data)) + { + CRYPT_DATA_BLOB *blob; + + ret = CryptDecodeObjectEx(X509_ASN_ENCODING, + X509_OCTET_STRING, + msg->u.signed_data.info->content.Content.pbData, + msg->u.signed_data.info->content.Content.cbData, + CRYPT_DECODE_ALLOC_FLAG, NULL, (LPBYTE)&blob, &size); + if (ret) + { + ret = CSignedMsgData_Update(&msg->u.signed_data, + blob->pbData, blob->cbData, TRUE, Verify); + LocalFree(blob); + } + } + else + ret = CSignedMsgData_Update(&msg->u.signed_data, + msg->u.signed_data.info->content.Content.pbData, + msg->u.signed_data.info->content.Content.cbData, TRUE, + Verify); + } + } + } return ret; } /* Decodes the content in blob as the type given, and updates the value
1
0
0
0
Juan Lang : crypt32: Move signed message data functions together.
by Alexandre Julliard
21 Aug '07
21 Aug '07
Module: wine Branch: master Commit: d2dc7d78a9e6f6e7c925cc254961849132634d12 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d2dc7d78a9e6f6e7c925cc254…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Aug 20 17:49:53 2007 -0700 crypt32: Move signed message data functions together. --- dlls/crypt32/msg.c | 232 ++++++++++++++++++++++++++-------------------------- 1 files changed, 116 insertions(+), 116 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 7507e13..8c01c76 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -783,13 +783,6 @@ typedef struct _CSignedMsgData CSignerHandles *signerHandles; } CSignedMsgData; -typedef struct _CSignedEncodeMsg -{ - CryptMsgBase base; - CRYPT_DATA_BLOB data; - CSignedMsgData msg_data; -} CSignedEncodeMsg; - /* Constructs the signer handles for the signerIndex'th signer of msg_data. * Assumes signerIndex is a valid idnex, and that msg_data's info has already * been constructed. @@ -857,115 +850,6 @@ static BOOL CSignedMsgData_UpdateHash(CSignedMsgData *msg_data, return ret; } -static void CSignedEncodeMsg_Close(HCRYPTMSG hCryptMsg) -{ - CSignedEncodeMsg *msg = (CSignedEncodeMsg *)hCryptMsg; - DWORD i; - - CryptMemFree(msg->data.pbData); - CRYPT_FreeBlobArray((BlobArray *)&msg->msg_data.info->cCertEncoded); - CRYPT_FreeBlobArray((BlobArray *)&msg->msg_data.info->cCrlEncoded); - for (i = 0; i < msg->msg_data.info->cSignerInfo; i++) - CSignerInfo_Free(&msg->msg_data.info->rgSignerInfo[i]); - CSignedMsgData_CloseHandles(&msg->msg_data); - CryptMemFree(msg->msg_data.info->rgSignerInfo); - CryptMemFree(msg->msg_data.info); -} - -static BOOL CSignedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, - DWORD dwIndex, void *pvData, DWORD *pcbData) -{ - CSignedEncodeMsg *msg = (CSignedEncodeMsg *)hCryptMsg; - BOOL ret = FALSE; - - switch (dwParamType) - { - case CMSG_CONTENT_PARAM: - { - CRYPT_CONTENT_INFO info; - - ret = CryptMsgGetParam(hCryptMsg, CMSG_BARE_CONTENT_PARAM, 0, NULL, - &info.Content.cbData); - if (ret) - { - info.Content.pbData = CryptMemAlloc(info.Content.cbData); - if (info.Content.pbData) - { - ret = CryptMsgGetParam(hCryptMsg, CMSG_BARE_CONTENT_PARAM, 0, - info.Content.pbData, &info.Content.cbData); - if (ret) - { - char oid_rsa_signed[] = szOID_RSA_signedData; - - info.pszObjId = oid_rsa_signed; - ret = CryptEncodeObjectEx(X509_ASN_ENCODING, - PKCS_CONTENT_INFO, &info, 0, NULL, pvData, pcbData); - } - CryptMemFree(info.Content.pbData); - } - else - ret = FALSE; - } - break; - } - case CMSG_BARE_CONTENT_PARAM: - { - CRYPT_SIGNED_INFO info; - char oid_rsa_data[] = szOID_RSA_data; - - memcpy(&info, msg->msg_data.info, sizeof(info)); - /* Quirk: OID is only encoded messages if an update has happened */ - if (msg->base.state != MsgStateInit) - info.content.pszObjId = oid_rsa_data; - else - info.content.pszObjId = NULL; - if (msg->data.cbData) - { - CRYPT_DATA_BLOB blob = { msg->data.cbData, msg->data.pbData }; - - ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_OCTET_STRING, - &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, - &info.content.Content.pbData, &info.content.Content.cbData); - } - else - { - info.content.Content.cbData = 0; - info.content.Content.pbData = NULL; - ret = TRUE; - } - if (ret) - { - ret = CRYPT_AsnEncodePKCSSignedInfo(&info, pvData, pcbData); - LocalFree(info.content.Content.pbData); - } - break; - } - case CMSG_COMPUTED_HASH_PARAM: - if (dwIndex >= msg->msg_data.info->cSignerInfo) - SetLastError(CRYPT_E_INVALID_INDEX); - else - ret = CryptGetHashParam( - msg->msg_data.signerHandles[dwIndex].contentHash, HP_HASHVAL, - pvData, pcbData, 0); - break; - case CMSG_ENCODED_SIGNER: - if (dwIndex >= msg->msg_data.info->cSignerInfo) - SetLastError(CRYPT_E_INVALID_INDEX); - else - ret = CryptEncodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, - PKCS7_SIGNER_INFO, &msg->msg_data.info->rgSignerInfo[dwIndex], 0, - NULL, pvData, pcbData); - break; - case CMSG_VERSION_PARAM: - ret = CRYPT_CopyParam(pvData, pcbData, &msg->msg_data.info->version, - sizeof(msg->msg_data.info->version)); - break; - default: - SetLastError(CRYPT_E_INVALID_MSG_TYPE); - } - return ret; -} - static BOOL CRYPT_AppendAttribute(CRYPT_ATTRIBUTES *out, const CRYPT_ATTRIBUTE *in) { @@ -1129,6 +1013,122 @@ static BOOL CSignedMsgData_Update(CSignedMsgData *msg_data, return ret; } +typedef struct _CSignedEncodeMsg +{ + CryptMsgBase base; + CRYPT_DATA_BLOB data; + CSignedMsgData msg_data; +} CSignedEncodeMsg; + +static void CSignedEncodeMsg_Close(HCRYPTMSG hCryptMsg) +{ + CSignedEncodeMsg *msg = (CSignedEncodeMsg *)hCryptMsg; + DWORD i; + + CryptMemFree(msg->data.pbData); + CRYPT_FreeBlobArray((BlobArray *)&msg->msg_data.info->cCertEncoded); + CRYPT_FreeBlobArray((BlobArray *)&msg->msg_data.info->cCrlEncoded); + for (i = 0; i < msg->msg_data.info->cSignerInfo; i++) + CSignerInfo_Free(&msg->msg_data.info->rgSignerInfo[i]); + CSignedMsgData_CloseHandles(&msg->msg_data); + CryptMemFree(msg->msg_data.info->rgSignerInfo); + CryptMemFree(msg->msg_data.info); +} + +static BOOL CSignedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, + DWORD dwIndex, void *pvData, DWORD *pcbData) +{ + CSignedEncodeMsg *msg = (CSignedEncodeMsg *)hCryptMsg; + BOOL ret = FALSE; + + switch (dwParamType) + { + case CMSG_CONTENT_PARAM: + { + CRYPT_CONTENT_INFO info; + + ret = CryptMsgGetParam(hCryptMsg, CMSG_BARE_CONTENT_PARAM, 0, NULL, + &info.Content.cbData); + if (ret) + { + info.Content.pbData = CryptMemAlloc(info.Content.cbData); + if (info.Content.pbData) + { + ret = CryptMsgGetParam(hCryptMsg, CMSG_BARE_CONTENT_PARAM, 0, + info.Content.pbData, &info.Content.cbData); + if (ret) + { + char oid_rsa_signed[] = szOID_RSA_signedData; + + info.pszObjId = oid_rsa_signed; + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, + PKCS_CONTENT_INFO, &info, 0, NULL, pvData, pcbData); + } + CryptMemFree(info.Content.pbData); + } + else + ret = FALSE; + } + break; + } + case CMSG_BARE_CONTENT_PARAM: + { + CRYPT_SIGNED_INFO info; + char oid_rsa_data[] = szOID_RSA_data; + + memcpy(&info, msg->msg_data.info, sizeof(info)); + /* Quirk: OID is only encoded messages if an update has happened */ + if (msg->base.state != MsgStateInit) + info.content.pszObjId = oid_rsa_data; + else + info.content.pszObjId = NULL; + if (msg->data.cbData) + { + CRYPT_DATA_BLOB blob = { msg->data.cbData, msg->data.pbData }; + + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_OCTET_STRING, + &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, + &info.content.Content.pbData, &info.content.Content.cbData); + } + else + { + info.content.Content.cbData = 0; + info.content.Content.pbData = NULL; + ret = TRUE; + } + if (ret) + { + ret = CRYPT_AsnEncodePKCSSignedInfo(&info, pvData, pcbData); + LocalFree(info.content.Content.pbData); + } + break; + } + case CMSG_COMPUTED_HASH_PARAM: + if (dwIndex >= msg->msg_data.info->cSignerInfo) + SetLastError(CRYPT_E_INVALID_INDEX); + else + ret = CryptGetHashParam( + msg->msg_data.signerHandles[dwIndex].contentHash, HP_HASHVAL, + pvData, pcbData, 0); + break; + case CMSG_ENCODED_SIGNER: + if (dwIndex >= msg->msg_data.info->cSignerInfo) + SetLastError(CRYPT_E_INVALID_INDEX); + else + ret = CryptEncodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, + PKCS7_SIGNER_INFO, &msg->msg_data.info->rgSignerInfo[dwIndex], 0, + NULL, pvData, pcbData); + break; + case CMSG_VERSION_PARAM: + ret = CRYPT_CopyParam(pvData, pcbData, &msg->msg_data.info->version, + sizeof(msg->msg_data.info->version)); + break; + default: + SetLastError(CRYPT_E_INVALID_MSG_TYPE); + } + return ret; +} + static BOOL CSignedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal) {
1
0
0
0
Juan Lang : crypt32: Make constructing handles a member of signed msg data.
by Alexandre Julliard
21 Aug '07
21 Aug '07
Module: wine Branch: master Commit: f1f8e87b332489fb710c90d9473d668223f7e424 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f1f8e87b332489fb710c90d94…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Aug 20 17:49:15 2007 -0700 crypt32: Make constructing handles a member of signed msg data. --- dlls/crypt32/msg.c | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 6a9acb4..7507e13 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -790,20 +790,23 @@ typedef struct _CSignedEncodeMsg CSignedMsgData msg_data; } CSignedEncodeMsg; -/* Constructs a CSignerHandles with a hash handle based on HashAlgorithm, and - * an authenticated attributes hash handle if hasAuthAttrs is TRUE. +/* Constructs the signer handles for the signerIndex'th signer of msg_data. + * Assumes signerIndex is a valid idnex, and that msg_data's info has already + * been constructed. */ -static BOOL CSignerHandles_Construct(CSignerHandles *handles, - HCRYPTPROV crypt_prov, CRYPT_ALGORITHM_IDENTIFIER *HashAlgorithm, - BOOL hasAuthAttrs) +static BOOL CSignedMsgData_ConstructSignerHandles(CSignedMsgData *msg_data, + DWORD signerIndex, HCRYPTPROV crypt_prov) { ALG_ID algID; BOOL ret; - algID = CertOIDToAlgId(HashAlgorithm->pszObjId); - ret = CryptCreateHash(crypt_prov, algID, 0, 0, &handles->contentHash); - if (ret && hasAuthAttrs) - ret = CryptCreateHash(crypt_prov, algID, 0, 0, &handles->authAttrHash); + algID = CertOIDToAlgId( + msg_data->info->rgSignerInfo[signerIndex].HashAlgorithm.pszObjId); + ret = CryptCreateHash(crypt_prov, algID, 0, 0, + &msg_data->signerHandles->contentHash); + if (ret && msg_data->info->rgSignerInfo[signerIndex].AuthAttrs.cAttr > 0) + ret = CryptCreateHash(crypt_prov, algID, 0, 0, + &msg_data->signerHandles->authAttrHash); return ret; } @@ -1222,11 +1225,8 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags, &info->rgSigners[i]); if (ret) { - ret = CSignerHandles_Construct( - &msg->msg_data.signerHandles[i], - info->rgSigners[i].hCryptProv, - &info->rgSigners[i].HashAlgorithm, - info->rgSigners[i].cAuthAttr > 0); + ret = CSignedMsgData_ConstructSignerHandles( + &msg->msg_data, i, info->rgSigners[i].hCryptProv); if (dwFlags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG) CryptReleaseContext(info->rgSigners[i].hCryptProv, 0);
1
0
0
0
Juan Lang : crypt32: Use a helper function to allocate signer handles.
by Alexandre Julliard
21 Aug '07
21 Aug '07
Module: wine Branch: master Commit: 07ba16c291e3933037f75bb2ca5cdbab7639ff16 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=07ba16c291e3933037f75bb2c…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Aug 20 17:48:38 2007 -0700 crypt32: Use a helper function to allocate signer handles. --- dlls/crypt32/msg.c | 37 +++++++++++++++++++++++++------------ 1 files changed, 25 insertions(+), 12 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index a50fc3f..6a9acb4 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -807,6 +807,28 @@ static BOOL CSignerHandles_Construct(CSignerHandles *handles, return ret; } +/* Allocates a CSignedMsgData's handles. Assumes its info has already been + * constructed. + */ +static BOOL CSignedMsgData_AllocateHandles(CSignedMsgData *msg_data) +{ + BOOL ret = TRUE; + + if (msg_data->info->cSignerInfo) + { + msg_data->signerHandles = + CryptMemAlloc(msg_data->info->cSignerInfo * sizeof(CSignerHandles)); + if (msg_data->signerHandles) + memset(msg_data->signerHandles, 0, + msg_data->info->cSignerInfo * sizeof(CSignerHandles)); + else + ret = FALSE; + } + else + msg_data->signerHandles = NULL; + return ret; +} + static void CSignedMsgData_CloseHandles(CSignedMsgData *msg_data) { DWORD i; @@ -1185,23 +1207,14 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags, ret = FALSE; if (ret && info->cSigners) { - msg->msg_data.signerHandles = - CryptMemAlloc(info->cSigners * sizeof(CSignerHandles)); - if (msg->msg_data.signerHandles) - msg->msg_data.info->rgSignerInfo = - CryptMemAlloc(info->cSigners * sizeof(CMSG_SIGNER_INFO)); - else - { - ret = FALSE; - msg->msg_data.info->rgSignerInfo = NULL; - } + msg->msg_data.info->rgSignerInfo = + CryptMemAlloc(info->cSigners * sizeof(CMSG_SIGNER_INFO)); if (msg->msg_data.info->rgSignerInfo) { msg->msg_data.info->cSignerInfo = info->cSigners; - memset(msg->msg_data.signerHandles, 0, - msg->msg_data.info->cSignerInfo * sizeof(CSignerHandles)); memset(msg->msg_data.info->rgSignerInfo, 0, msg->msg_data.info->cSignerInfo * sizeof(CMSG_SIGNER_INFO)); + ret = CSignedMsgData_AllocateHandles(&msg->msg_data); for (i = 0; ret && i < msg->msg_data.info->cSignerInfo; i++) { ret = CSignerInfo_Construct(
1
0
0
0
Juan Lang : crypt32: Don' t keep an unneeded copy of the crypto provider for each signer.
by Alexandre Julliard
21 Aug '07
21 Aug '07
Module: wine Branch: master Commit: 1f9d9be7625fca4917916fdd334a254dd78ffb85 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1f9d9be7625fca4917916fdd3…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Aug 20 17:48:02 2007 -0700 crypt32: Don't keep an unneeded copy of the crypto provider for each signer. --- dlls/crypt32/msg.c | 17 ++++++----------- 1 files changed, 6 insertions(+), 11 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 2d0299c..a50fc3f 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -772,7 +772,6 @@ static void CSignerInfo_Free(CMSG_SIGNER_INFO *info) typedef struct _CSignerHandles { - HCRYPTPROV prov; HCRYPTHASH contentHash; HCRYPTHASH authAttrHash; HCRYPTKEY key; @@ -791,8 +790,7 @@ typedef struct _CSignedEncodeMsg CSignedMsgData msg_data; } CSignedEncodeMsg; -/* Constructs a CSignerHandles with a copy of crypt_prov (not add-ref'ed - the - * caller must do this if necessary), a hash handle based on HashAlgorithm, and +/* Constructs a CSignerHandles with a hash handle based on HashAlgorithm, and * an authenticated attributes hash handle if hasAuthAttrs is TRUE. */ static BOOL CSignerHandles_Construct(CSignerHandles *handles, @@ -802,12 +800,10 @@ static BOOL CSignerHandles_Construct(CSignerHandles *handles, ALG_ID algID; BOOL ret; - handles->prov = crypt_prov; algID = CertOIDToAlgId(HashAlgorithm->pszObjId); - ret = CryptCreateHash(handles->prov, algID, 0, 0, &handles->contentHash); + ret = CryptCreateHash(crypt_prov, algID, 0, 0, &handles->contentHash); if (ret && hasAuthAttrs) - ret = CryptCreateHash(handles->prov, algID, 0, 0, - &handles->authAttrHash); + ret = CryptCreateHash(crypt_prov, algID, 0, 0, &handles->authAttrHash); return ret; } @@ -820,7 +816,6 @@ static void CSignedMsgData_CloseHandles(CSignedMsgData *msg_data) CryptDestroyKey(msg_data->signerHandles[i].key); CryptDestroyHash(msg_data->signerHandles[i].contentHash); CryptDestroyHash(msg_data->signerHandles[i].authAttrHash); - CryptReleaseContext(msg_data->signerHandles[i].prov, 0); } CryptMemFree(msg_data->signerHandles); } @@ -1214,14 +1209,14 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags, &info->rgSigners[i]); if (ret) { - if (!(dwFlags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)) - CryptContextAddRef(info->rgSigners[i].hCryptProv, - NULL, 0); ret = CSignerHandles_Construct( &msg->msg_data.signerHandles[i], info->rgSigners[i].hCryptProv, &info->rgSigners[i].HashAlgorithm, info->rgSigners[i].cAuthAttr > 0); + if (dwFlags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG) + CryptReleaseContext(info->rgSigners[i].hCryptProv, + 0); } } }
1
0
0
0
Juan Lang : crypt32: Separate construction of signer handles from signer info.
by Alexandre Julliard
21 Aug '07
21 Aug '07
Module: wine Branch: master Commit: bfbc159d1e0bb55de630748c65c98a22a3fc8a61 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=bfbc159d1e0bb55de630748c6…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Aug 20 17:47:02 2007 -0700 crypt32: Separate construction of signer handles from signer info. --- dlls/crypt32/msg.c | 128 +++++++++++++++++++++++++++------------------------- 1 files changed, 66 insertions(+), 62 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 27d0007..2d0299c 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -617,14 +617,6 @@ static BOOL CRYPT_IsValidSigner(CMSG_SIGNER_ENCODE_INFO_WITH_CMS *signer) return TRUE; } -typedef struct _CSignerHandles -{ - HCRYPTPROV prov; - HCRYPTHASH contentHash; - HCRYPTHASH authAttrHash; - HCRYPTKEY key; -} CSignerHandles; - static BOOL CRYPT_ConstructBlob(CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in) { BOOL ret = TRUE; @@ -722,62 +714,33 @@ static BOOL CRYPT_ConstructAttributes(CRYPT_ATTRIBUTES *out, return ret; } -/* Constructs a CSignerHandles with a copy of crypt_prov (not add-ref'ed - the - * caller must do this if necessary), a hash handle based on HashAlgorithm, and - * an authenticated attributes hash handle if hasAuthAttrs is TRUE. - */ -static BOOL CSignerHandles_Construct(CSignerHandles *handles, - HCRYPTPROV crypt_prov, CRYPT_ALGORITHM_IDENTIFIER *HashAlgorithm, - BOOL hasAuthAttrs) -{ - ALG_ID algID; - BOOL ret; - - handles->prov = crypt_prov; - algID = CertOIDToAlgId(HashAlgorithm->pszObjId); - ret = CryptCreateHash(handles->prov, algID, 0, 0, &handles->contentHash); - if (ret && hasAuthAttrs) - ret = CryptCreateHash(handles->prov, algID, 0, 0, - &handles->authAttrHash); - return ret; -} - -/* Constructs both a CSignerHandles and a CMSG_SIGNER_INFO from a - * CMSG_SIGNER_ENCODE_INFO_WITH_CMS. - */ -static BOOL CSignerInfo_Construct(CSignerHandles *handles, - CMSG_SIGNER_INFO *info, CMSG_SIGNER_ENCODE_INFO_WITH_CMS *in, DWORD open_flags) +/* Constructs a CMSG_SIGNER_INFO from a CMSG_SIGNER_ENCODE_INFO_WITH_CMS. */ +static BOOL CSignerInfo_Construct(CMSG_SIGNER_INFO *info, + CMSG_SIGNER_ENCODE_INFO_WITH_CMS *in) { BOOL ret; - if (!(open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)) - CryptContextAddRef(in->hCryptProv, NULL, 0); - ret = CSignerHandles_Construct(handles, in->hCryptProv, &in->HashAlgorithm, - in->cAuthAttr > 0); + /* Note: needs to change if CMS fields are supported */ + info->dwVersion = CMSG_SIGNER_INFO_V1; + ret = CRYPT_ConstructBlob(&info->Issuer, &in->pCertInfo->Issuer); if (ret) - { - /* Note: needs to change if CMS fields are supported */ - info->dwVersion = CMSG_SIGNER_INFO_V1; - ret = CRYPT_ConstructBlob(&info->Issuer, &in->pCertInfo->Issuer); - if (ret) - ret = CRYPT_ConstructBlob(&info->SerialNumber, - &in->pCertInfo->SerialNumber); - /* Assumption: algorithm IDs will point to static strings, not - * stack-based ones, so copying the pointer values is safe. - */ - info->HashAlgorithm.pszObjId = in->HashAlgorithm.pszObjId; - if (ret) - ret = CRYPT_ConstructBlob(&info->HashAlgorithm.Parameters, - &in->HashAlgorithm.Parameters); - memset(&info->HashEncryptionAlgorithm, 0, - sizeof(info->HashEncryptionAlgorithm)); - if (ret) - ret = CRYPT_ConstructAttributes(&info->AuthAttrs, - (CRYPT_ATTRIBUTES *)&in->cAuthAttr); - if (ret) - ret = CRYPT_ConstructAttributes(&info->UnauthAttrs, - (CRYPT_ATTRIBUTES *)&in->cUnauthAttr); - } + ret = CRYPT_ConstructBlob(&info->SerialNumber, + &in->pCertInfo->SerialNumber); + /* Assumption: algorithm IDs will point to static strings, not + * stack-based ones, so copying the pointer values is safe. + */ + info->HashAlgorithm.pszObjId = in->HashAlgorithm.pszObjId; + if (ret) + ret = CRYPT_ConstructBlob(&info->HashAlgorithm.Parameters, + &in->HashAlgorithm.Parameters); + memset(&info->HashEncryptionAlgorithm, 0, + sizeof(info->HashEncryptionAlgorithm)); + if (ret) + ret = CRYPT_ConstructAttributes(&info->AuthAttrs, + (CRYPT_ATTRIBUTES *)&in->cAuthAttr); + if (ret) + ret = CRYPT_ConstructAttributes(&info->UnauthAttrs, + (CRYPT_ATTRIBUTES *)&in->cUnauthAttr); return ret; } @@ -807,6 +770,14 @@ static void CSignerInfo_Free(CMSG_SIGNER_INFO *info) CryptMemFree(info->UnauthAttrs.rgAttr); } +typedef struct _CSignerHandles +{ + HCRYPTPROV prov; + HCRYPTHASH contentHash; + HCRYPTHASH authAttrHash; + HCRYPTKEY key; +} CSignerHandles; + typedef struct _CSignedMsgData { CRYPT_SIGNED_INFO *info; @@ -820,6 +791,26 @@ typedef struct _CSignedEncodeMsg CSignedMsgData msg_data; } CSignedEncodeMsg; +/* Constructs a CSignerHandles with a copy of crypt_prov (not add-ref'ed - the + * caller must do this if necessary), a hash handle based on HashAlgorithm, and + * an authenticated attributes hash handle if hasAuthAttrs is TRUE. + */ +static BOOL CSignerHandles_Construct(CSignerHandles *handles, + HCRYPTPROV crypt_prov, CRYPT_ALGORITHM_IDENTIFIER *HashAlgorithm, + BOOL hasAuthAttrs) +{ + ALG_ID algID; + BOOL ret; + + handles->prov = crypt_prov; + algID = CertOIDToAlgId(HashAlgorithm->pszObjId); + ret = CryptCreateHash(handles->prov, algID, 0, 0, &handles->contentHash); + if (ret && hasAuthAttrs) + ret = CryptCreateHash(handles->prov, algID, 0, 0, + &handles->authAttrHash); + return ret; +} + static void CSignedMsgData_CloseHandles(CSignedMsgData *msg_data) { DWORD i; @@ -1217,9 +1208,22 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags, memset(msg->msg_data.info->rgSignerInfo, 0, msg->msg_data.info->cSignerInfo * sizeof(CMSG_SIGNER_INFO)); for (i = 0; ret && i < msg->msg_data.info->cSignerInfo; i++) - ret = CSignerInfo_Construct(&msg->msg_data.signerHandles[i], + { + ret = CSignerInfo_Construct( &msg->msg_data.info->rgSignerInfo[i], - &info->rgSigners[i], dwFlags); + &info->rgSigners[i]); + if (ret) + { + if (!(dwFlags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)) + CryptContextAddRef(info->rgSigners[i].hCryptProv, + NULL, 0); + ret = CSignerHandles_Construct( + &msg->msg_data.signerHandles[i], + info->rgSigners[i].hCryptProv, + &info->rgSigners[i].HashAlgorithm, + info->rgSigners[i].cAuthAttr > 0); + } + } } else ret = FALSE;
1
0
0
0
Juan Lang : crypt32: Add a helper function to construct a signer handles structure.
by Alexandre Julliard
21 Aug '07
21 Aug '07
Module: wine Branch: master Commit: c4dd74d84c8bf2f52532ae76eb7e32a61d682dcc URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c4dd74d84c8bf2f52532ae76e…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Aug 20 17:46:13 2007 -0700 crypt32: Add a helper function to construct a signer handles structure. --- dlls/crypt32/msg.c | 31 +++++++++++++++++++++++-------- 1 files changed, 23 insertions(+), 8 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 9eab762..27d0007 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -722,23 +722,38 @@ static BOOL CRYPT_ConstructAttributes(CRYPT_ATTRIBUTES *out, return ret; } +/* Constructs a CSignerHandles with a copy of crypt_prov (not add-ref'ed - the + * caller must do this if necessary), a hash handle based on HashAlgorithm, and + * an authenticated attributes hash handle if hasAuthAttrs is TRUE. + */ +static BOOL CSignerHandles_Construct(CSignerHandles *handles, + HCRYPTPROV crypt_prov, CRYPT_ALGORITHM_IDENTIFIER *HashAlgorithm, + BOOL hasAuthAttrs) +{ + ALG_ID algID; + BOOL ret; + + handles->prov = crypt_prov; + algID = CertOIDToAlgId(HashAlgorithm->pszObjId); + ret = CryptCreateHash(handles->prov, algID, 0, 0, &handles->contentHash); + if (ret && hasAuthAttrs) + ret = CryptCreateHash(handles->prov, algID, 0, 0, + &handles->authAttrHash); + return ret; +} + /* Constructs both a CSignerHandles and a CMSG_SIGNER_INFO from a * CMSG_SIGNER_ENCODE_INFO_WITH_CMS. */ static BOOL CSignerInfo_Construct(CSignerHandles *handles, CMSG_SIGNER_INFO *info, CMSG_SIGNER_ENCODE_INFO_WITH_CMS *in, DWORD open_flags) { - ALG_ID algID; BOOL ret; - handles->prov = in->hCryptProv; if (!(open_flags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)) - CryptContextAddRef(handles->prov, NULL, 0); - algID = CertOIDToAlgId(in->HashAlgorithm.pszObjId); - ret = CryptCreateHash(handles->prov, algID, 0, 0, &handles->contentHash); - if (ret && in->cAuthAttr) - ret = CryptCreateHash(handles->prov, algID, 0, 0, - &handles->authAttrHash); + CryptContextAddRef(in->hCryptProv, NULL, 0); + ret = CSignerHandles_Construct(handles, in->hCryptProv, &in->HashAlgorithm, + in->cAuthAttr > 0); if (ret) { /* Note: needs to change if CMS fields are supported */
1
0
0
0
Juan Lang : crypt32: Add helper function to update signed message data.
by Alexandre Julliard
21 Aug '07
21 Aug '07
Module: wine Branch: master Commit: de88fedcce46fa51e3b84e8819882c1faa75c386 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=de88fedcce46fa51e3b84e881…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Mon Aug 20 17:45:33 2007 -0700 crypt32: Add helper function to update signed message data. --- dlls/crypt32/msg.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 6c33941..9eab762 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -1089,6 +1089,20 @@ static BOOL CSignedMsgData_Sign(CSignedMsgData *msg_data) return ret; } +static BOOL CSignedMsgData_Update(CSignedMsgData *msg_data, + const BYTE *pbData, DWORD cbData, BOOL fFinal) +{ + BOOL ret = CSignedMsgData_UpdateHash(msg_data, pbData, cbData); + + if (ret && fFinal) + { + ret = CSignedMsgData_UpdateAuthenticatedAttributes(msg_data); + if (ret) + ret = CSignedMsgData_Sign(msg_data); + } + return ret; +} + static BOOL CSignedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal) { @@ -1097,14 +1111,7 @@ static BOOL CSignedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, if (msg->base.streamed || (msg->base.open_flags & CMSG_DETACHED_FLAG)) { - ret = CSignedMsgData_UpdateHash(&msg->msg_data, pbData, cbData); - if (ret && fFinal) - { - ret = CSignedMsgData_UpdateAuthenticatedAttributes( - &msg->msg_data); - if (ret) - ret = CSignedMsgData_Sign(&msg->msg_data); - } + ret = CSignedMsgData_Update(&msg->msg_data, pbData, cbData, fFinal); if (msg->base.streamed) FIXME("streamed partial stub\n"); } @@ -1127,12 +1134,8 @@ static BOOL CSignedEncodeMsg_Update(HCRYPTMSG hCryptMsg, const BYTE *pbData, else ret = TRUE; if (ret) - ret = CSignedMsgData_UpdateHash(&msg->msg_data, pbData, cbData); - if (ret) - ret = CSignedMsgData_UpdateAuthenticatedAttributes( - &msg->msg_data); - if (ret) - ret = CSignedMsgData_Sign(&msg->msg_data); + ret = CSignedMsgData_Update(&msg->msg_data, pbData, cbData, + fFinal); } } return ret;
1
0
0
0
← Newer
1
...
29
30
31
32
33
34
35
...
109
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Results per page:
10
25
50
100
200