SUPPORT-8941. Устранение замечаний от лаборатории ФИНТЕХ
This commit is contained in:
parent
e351409288
commit
9f0a9efa11
3 changed files with 29 additions and 20 deletions
|
|
@ -24,7 +24,6 @@ capi_function_list_init(library_t *lib, capi_function_list_t *fl)
|
||||||
LIBRARY_RESOLVE(fl->CryptDestroyHash, lib, "CryptDestroyHash");
|
LIBRARY_RESOLVE(fl->CryptDestroyHash, lib, "CryptDestroyHash");
|
||||||
LIBRARY_RESOLVE(fl->CryptHashData, lib, "CryptHashData");
|
LIBRARY_RESOLVE(fl->CryptHashData, lib, "CryptHashData");
|
||||||
LIBRARY_RESOLVE(fl->CryptReleaseContext, lib, "CryptReleaseContext");
|
LIBRARY_RESOLVE(fl->CryptReleaseContext, lib, "CryptReleaseContext");
|
||||||
LIBRARY_RESOLVE(fl->CryptSignMessage, lib, "CryptSignMessage");
|
|
||||||
LIBRARY_RESOLVE(fl->GetLastError, lib, "GetLastError");
|
LIBRARY_RESOLVE(fl->GetLastError, lib, "GetLastError");
|
||||||
LIBRARY_RESOLVE(fl->CryptImportPublicKeyInfo, lib, "CryptImportPublicKeyInfo");
|
LIBRARY_RESOLVE(fl->CryptImportPublicKeyInfo, lib, "CryptImportPublicKeyInfo");
|
||||||
LIBRARY_RESOLVE(fl->CryptDestroyKey, lib, "CryptDestroyKey");
|
LIBRARY_RESOLVE(fl->CryptDestroyKey, lib, "CryptDestroyKey");
|
||||||
|
|
|
||||||
|
|
@ -15,16 +15,6 @@ typedef struct library_s library_t;
|
||||||
|
|
||||||
DECLARE_FN(WINBASEAPI, DWORD, GET_LAST_ERROR, (void));
|
DECLARE_FN(WINBASEAPI, DWORD, GET_LAST_ERROR, (void));
|
||||||
DECLARE_FN(WINADVAPI, BOOL, CRYPT_RELEASE_CONTEXT, (HCRYPTPROV hProv, DWORD dwFlags));
|
DECLARE_FN(WINADVAPI, BOOL, CRYPT_RELEASE_CONTEXT, (HCRYPTPROV hProv, DWORD dwFlags));
|
||||||
DECLARE_FN(WINCRYPT32API,
|
|
||||||
BOOL,
|
|
||||||
CRYPT_SIGN_MESSAGE,
|
|
||||||
(IN PCRYPT_SIGN_MESSAGE_PARA pSignPara,
|
|
||||||
IN BOOL fDetachedSignature,
|
|
||||||
IN DWORD cToBeSigned,
|
|
||||||
IN const BYTE *rgpbToBeSigned[],
|
|
||||||
IN DWORD rgcbToBeSigned[],
|
|
||||||
OUT BYTE *pbSignedBlob,
|
|
||||||
IN OUT DWORD *pcbSignedBlob));
|
|
||||||
|
|
||||||
DECLARE_FN(WINCRYPT32API,
|
DECLARE_FN(WINCRYPT32API,
|
||||||
BOOL,
|
BOOL,
|
||||||
|
|
@ -227,7 +217,6 @@ DECLARE_FN(WINADVAPI,
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
CRYPT_SIGN_MESSAGE_FN CryptSignMessage;
|
|
||||||
CERT_FREE_CERTIFICATE_CONTEXT_FN CertFreeCertificateContext;
|
CERT_FREE_CERTIFICATE_CONTEXT_FN CertFreeCertificateContext;
|
||||||
CERT_OPEN_STORE_FN CertOpenStore;
|
CERT_OPEN_STORE_FN CertOpenStore;
|
||||||
CERT_CLOSE_STORE_FN CertCloseStore;
|
CERT_CLOSE_STORE_FN CertCloseStore;
|
||||||
|
|
|
||||||
|
|
@ -376,11 +376,17 @@ sign_hash_data(const cryptopro_context_t *ctx, const str_t *data, /*out*/ str_t
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if (hash) {
|
if (hash) {
|
||||||
cp_function_list.CryptDestroyHash(hash);
|
if (!cp_function_list.CryptDestroyHash(hash)) {
|
||||||
|
LOG_ERROR("CryptDestroyHash() failed");
|
||||||
|
rc = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bReleaseContext) {
|
if (bReleaseContext) {
|
||||||
cp_function_list.CryptReleaseContext(hCryptProv, 0);
|
if (!cp_function_list.CryptReleaseContext(hCryptProv, 0)) {
|
||||||
|
LOG_ERROR("CryptReleaseContext() failed");
|
||||||
|
rc = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -763,15 +769,24 @@ exit:
|
||||||
str_t_clear(&sign_reversed);
|
str_t_clear(&sign_reversed);
|
||||||
|
|
||||||
if (hash) {
|
if (hash) {
|
||||||
cp_function_list.CryptDestroyHash(hash);
|
if (!cp_function_list.CryptDestroyHash(hash)) {
|
||||||
|
LOG_ERROR("CryptDestroyHash() failed");
|
||||||
|
rc = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hPubKey) {
|
if (hPubKey) {
|
||||||
cp_function_list.CryptDestroyKey(hPubKey);
|
if (!cp_function_list.CryptDestroyKey(hPubKey)) {
|
||||||
|
LOG_ERROR("CryptDestroyKey() failed");
|
||||||
|
rc = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hCryptProv) {
|
if (hCryptProv) {
|
||||||
cp_function_list.CryptReleaseContext(hCryptProv, 0);
|
if (!cp_function_list.CryptReleaseContext(hCryptProv, 0)) {
|
||||||
|
LOG_ERROR("CryptReleaseContext() failed");
|
||||||
|
rc = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (certificate) {
|
if (certificate) {
|
||||||
|
|
@ -796,7 +811,7 @@ exit:
|
||||||
int
|
int
|
||||||
cryptopro_gen_random(unsigned char* data, size_t len)
|
cryptopro_gen_random(unsigned char* data, size_t len)
|
||||||
{
|
{
|
||||||
HCRYPTPROV hCryptProv = 0;
|
HCRYPTPROV hCryptProv = 0;
|
||||||
|
|
||||||
LOG_TRACE("cryptopro_gen_random enter");
|
LOG_TRACE("cryptopro_gen_random enter");
|
||||||
|
|
||||||
|
|
@ -811,14 +826,20 @@ cryptopro_gen_random(unsigned char* data, size_t len)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
cp_function_list.CryptReleaseContext(hCryptProv, 0);
|
if (!cp_function_list.CryptReleaseContext(hCryptProv, 0)) {
|
||||||
|
LOG_ERROR("CryptReleaseContext() failed");
|
||||||
|
hCryptProv = 0;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_TRACE("cryptopro_gen_random exit");
|
LOG_TRACE("cryptopro_gen_random exit");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (hCryptProv) {
|
if (hCryptProv) {
|
||||||
cp_function_list.CryptReleaseContext(hCryptProv, 0);
|
if (!cp_function_list.CryptReleaseContext(hCryptProv, 0)) {
|
||||||
|
LOG_ERROR("CryptReleaseContext() failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_ERROR("cryptopro_gen_random exit with error. Last error code: 0x%08x",
|
LOG_ERROR("cryptopro_gen_random exit with error. Last error code: 0x%08x",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue