summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason King <jason.king@joyent.com>2018-05-30 17:19:18 -0500
committerJason King <jason.king@joyent.com>2018-06-14 12:19:45 -0500
commite5c3f3de12c528e4490dc8f63b602902248fb0eb (patch)
tree50549c698efd3fe0a2c9ffb4d0b2cf0ed406a49b
parentc2d375cdcb04122f97908079581dda41a08c0d07 (diff)
downloadillumos-joyent-e5c3f3de12c528e4490dc8f63b602902248fb0eb.tar.gz
OS-6605 pkcs11 C_Digest() is too restrictive in input
Reviewed by: Dan McDonald <danmcd@joyent.com> Reviewed by: Robert Mustacchi <rm@joyent.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/lib/pkcs11/libpkcs11/common/metaDigest.c5
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kernel/common/kernelDigest.c3
-rw-r--r--usr/src/lib/pkcs11/pkcs11_softtoken/common/softDigest.c3
3 files changed, 6 insertions, 5 deletions
diff --git a/usr/src/lib/pkcs11/libpkcs11/common/metaDigest.c b/usr/src/lib/pkcs11/libpkcs11/common/metaDigest.c
index 673b83cbfd..aecf391807 100644
--- a/usr/src/lib/pkcs11/libpkcs11/common/metaDigest.c
+++ b/usr/src/lib/pkcs11/libpkcs11/common/metaDigest.c
@@ -21,10 +21,9 @@
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2018, Joyent, Inc.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Message Digesting Functions
* (as defined in PKCS#11 spec section 11.10)
@@ -70,7 +69,7 @@ meta_Digest(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen,
meta_session_t *session;
- if (pData == NULL || pulDigestLen == NULL)
+ if ((pData == NULL && ulDataLen != 0) || pulDigestLen == NULL)
return (CKR_ARGUMENTS_BAD);
rv = meta_handle2session(hSession, &session);
diff --git a/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelDigest.c b/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelDigest.c
index ec65a97caf..9b9ad981d5 100644
--- a/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelDigest.c
+++ b/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelDigest.c
@@ -22,6 +22,7 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2018, Joyent, Inc.
*/
#include <pthread.h>
@@ -158,7 +159,7 @@ C_Digest(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen,
if (rv != CKR_OK)
return (rv);
- if (pData == NULL || pulDigestLen == NULL) {
+ if ((pData == NULL && ulDataLen != 0) || pulDigestLen == NULL) {
rv = CKR_ARGUMENTS_BAD;
goto clean_exit;
}
diff --git a/usr/src/lib/pkcs11/pkcs11_softtoken/common/softDigest.c b/usr/src/lib/pkcs11/pkcs11_softtoken/common/softDigest.c
index 56d43ba5c9..32b7d24254 100644
--- a/usr/src/lib/pkcs11/pkcs11_softtoken/common/softDigest.c
+++ b/usr/src/lib/pkcs11/pkcs11_softtoken/common/softDigest.c
@@ -21,6 +21,7 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2018, Joyent, Inc.
*/
#include <pthread.h>
@@ -120,7 +121,7 @@ C_Digest(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen,
if (rv != CKR_OK)
return (rv);
- if (pData == NULL || pulDigestLen == NULL) {
+ if ((pData == NULL && ulDataLen != 0) || pulDigestLen == NULL) {
rv = CKR_ARGUMENTS_BAD;
goto clean_exit;
}