Print this page
9642 PKCS#11 softtoken should use explicit_bzero
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Alex Wilson <alex.wilson@joyent.com>

@@ -20,14 +20,13 @@
  * CDDL HEADER END
  */
 /*
  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright (c) 2018, Joyent, Inc.
  */
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
-
 #include <pthread.h>
 #include <sys/md5.h>
 #include <sys/sha1.h>
 #include <sys/sha2.h>
 #include <stdlib.h>

@@ -560,16 +559,14 @@
 clean_exit:
 
         (void) pthread_mutex_lock(&session_p->session_mutex);
 
         if (sign_op) {
-                bzero(session_p->sign.context, sizeof (soft_hmac_ctx_t));
-                free(session_p->sign.context);
+                freezero(session_p->sign.context, sizeof (soft_hmac_ctx_t));
                 session_p->sign.context = NULL;
         } else {
-                bzero(session_p->verify.context, sizeof (soft_hmac_ctx_t));
-                free(session_p->verify.context);
+                freezero(session_p->verify.context, sizeof (soft_hmac_ctx_t));
                 session_p->verify.context = NULL;
         }
 
         (void) pthread_mutex_unlock(&session_p->session_mutex);