crypt32: Don't keep an unneeded copy of the crypto provider for each signer.
This commit is contained in:
parent
bfbc159d1e
commit
1f9d9be762
|
@ -772,7 +772,6 @@ static void CSignerInfo_Free(CMSG_SIGNER_INFO *info)
|
||||||
|
|
||||||
typedef struct _CSignerHandles
|
typedef struct _CSignerHandles
|
||||||
{
|
{
|
||||||
HCRYPTPROV prov;
|
|
||||||
HCRYPTHASH contentHash;
|
HCRYPTHASH contentHash;
|
||||||
HCRYPTHASH authAttrHash;
|
HCRYPTHASH authAttrHash;
|
||||||
HCRYPTKEY key;
|
HCRYPTKEY key;
|
||||||
|
@ -791,8 +790,7 @@ typedef struct _CSignedEncodeMsg
|
||||||
CSignedMsgData msg_data;
|
CSignedMsgData msg_data;
|
||||||
} CSignedEncodeMsg;
|
} CSignedEncodeMsg;
|
||||||
|
|
||||||
/* Constructs a CSignerHandles with a copy of crypt_prov (not add-ref'ed - the
|
/* Constructs a CSignerHandles with a hash handle based on HashAlgorithm, and
|
||||||
* caller must do this if necessary), a hash handle based on HashAlgorithm, and
|
|
||||||
* an authenticated attributes hash handle if hasAuthAttrs is TRUE.
|
* an authenticated attributes hash handle if hasAuthAttrs is TRUE.
|
||||||
*/
|
*/
|
||||||
static BOOL CSignerHandles_Construct(CSignerHandles *handles,
|
static BOOL CSignerHandles_Construct(CSignerHandles *handles,
|
||||||
|
@ -802,12 +800,10 @@ static BOOL CSignerHandles_Construct(CSignerHandles *handles,
|
||||||
ALG_ID algID;
|
ALG_ID algID;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
handles->prov = crypt_prov;
|
|
||||||
algID = CertOIDToAlgId(HashAlgorithm->pszObjId);
|
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)
|
if (ret && hasAuthAttrs)
|
||||||
ret = CryptCreateHash(handles->prov, algID, 0, 0,
|
ret = CryptCreateHash(crypt_prov, algID, 0, 0, &handles->authAttrHash);
|
||||||
&handles->authAttrHash);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,7 +816,6 @@ static void CSignedMsgData_CloseHandles(CSignedMsgData *msg_data)
|
||||||
CryptDestroyKey(msg_data->signerHandles[i].key);
|
CryptDestroyKey(msg_data->signerHandles[i].key);
|
||||||
CryptDestroyHash(msg_data->signerHandles[i].contentHash);
|
CryptDestroyHash(msg_data->signerHandles[i].contentHash);
|
||||||
CryptDestroyHash(msg_data->signerHandles[i].authAttrHash);
|
CryptDestroyHash(msg_data->signerHandles[i].authAttrHash);
|
||||||
CryptReleaseContext(msg_data->signerHandles[i].prov, 0);
|
|
||||||
}
|
}
|
||||||
CryptMemFree(msg_data->signerHandles);
|
CryptMemFree(msg_data->signerHandles);
|
||||||
}
|
}
|
||||||
|
@ -1214,14 +1209,14 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags,
|
||||||
&info->rgSigners[i]);
|
&info->rgSigners[i]);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
if (!(dwFlags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG))
|
|
||||||
CryptContextAddRef(info->rgSigners[i].hCryptProv,
|
|
||||||
NULL, 0);
|
|
||||||
ret = CSignerHandles_Construct(
|
ret = CSignerHandles_Construct(
|
||||||
&msg->msg_data.signerHandles[i],
|
&msg->msg_data.signerHandles[i],
|
||||||
info->rgSigners[i].hCryptProv,
|
info->rgSigners[i].hCryptProv,
|
||||||
&info->rgSigners[i].HashAlgorithm,
|
&info->rgSigners[i].HashAlgorithm,
|
||||||
info->rgSigners[i].cAuthAttr > 0);
|
info->rgSigners[i].cAuthAttr > 0);
|
||||||
|
if (dwFlags & CMSG_CRYPT_RELEASE_CONTEXT_FLAG)
|
||||||
|
CryptReleaseContext(info->rgSigners[i].hCryptProv,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue