From 590be3d7dadb8e17a15261bce9275f37f6dfc917 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Fri, 11 May 2018 13:16:44 +1000 Subject: [PATCH] hcrypto PKCS#11 backend: allow digest update with NULL (#378) Some callers of EVP_DigestUpdate (such as libntlm) pass NULL as the data argument. PKCS#11 returns CKR_ARGUMENTS_BAD which may poison the context. Pass an empty string to C_DigestUpdate work around this. --- lib/hcrypto/evp-pkcs11.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/hcrypto/evp-pkcs11.c b/lib/hcrypto/evp-pkcs11.c index 0f0ffee2f..f605dd8d5 100644 --- a/lib/hcrypto/evp-pkcs11.c +++ b/lib/hcrypto/evp-pkcs11.c @@ -388,7 +388,9 @@ p11_md_update(EVP_MD_CTX *ctx, const void *data, size_t length) assert(p11_module != NULL); - rv = p11_module->C_DigestUpdate(p11ctx->hSession, (unsigned char *)data, length); + rv = p11_module->C_DigestUpdate(p11ctx->hSession, + data ? (CK_BYTE_PTR)data : (CK_BYTE_PTR)"", + length); return rv == CKR_OK; }