hcrypto: support BCRYPT_HASH_REUSABLE_FLAG
support BCRYPT_HASH_REUSABLE_FLAG in the WinCNG backend on versions of Windows that support it, to avoid destroying and recreating a hash object
This commit is contained in:

committed by
Jeffrey Altman

parent
3daef8a5fd
commit
a17a6bcc54
@@ -33,12 +33,17 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <roken.h>
|
#include <roken.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <versionsupport.h>
|
||||||
|
|
||||||
#include <evp.h>
|
#include <evp.h>
|
||||||
#include <evp-wincng.h>
|
#include <evp-wincng.h>
|
||||||
|
|
||||||
#include <bcrypt.h>
|
#include <bcrypt.h>
|
||||||
|
|
||||||
|
#ifndef BCRYPT_HASH_REUSABLE_FLAG
|
||||||
|
#define BCRYPT_HASH_REUSABLE_FLAG 0x00000020
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CNG cipher provider
|
* CNG cipher provider
|
||||||
*/
|
*/
|
||||||
@@ -575,9 +580,15 @@ wincng_md_hash_init(BCRYPT_ALG_HANDLE hAlgorithm,
|
|||||||
{
|
{
|
||||||
struct wincng_md_ctx *cng = (struct wincng_md_ctx *)ctx;
|
struct wincng_md_ctx *cng = (struct wincng_md_ctx *)ctx;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
ULONG cbData;
|
ULONG cbData, dwFlags = 0;
|
||||||
|
|
||||||
wincng_md_cleanup(ctx);
|
if (IsWindows8OrGreaterCached()) {
|
||||||
|
if (cng->hHash)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
dwFlags |= BCRYPT_HASH_REUSABLE_FLAG;
|
||||||
|
} else
|
||||||
|
wincng_md_cleanup(ctx);
|
||||||
|
|
||||||
status = BCryptGetProperty(hAlgorithm,
|
status = BCryptGetProperty(hAlgorithm,
|
||||||
BCRYPT_OBJECT_LENGTH,
|
BCRYPT_OBJECT_LENGTH,
|
||||||
@@ -594,7 +605,7 @@ wincng_md_hash_init(BCRYPT_ALG_HANDLE hAlgorithm,
|
|||||||
cng->cbHashObject,
|
cng->cbHashObject,
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
0);
|
dwFlags);
|
||||||
|
|
||||||
return BCRYPT_SUCCESS(status);
|
return BCRYPT_SUCCESS(status);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user