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>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/pkcs11/pkcs11_softtoken/common/softMAC.c
          +++ new/usr/src/lib/pkcs11/pkcs11_softtoken/common/softMAC.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16   16   * If applicable, add the following below this CDDL HEADER, with the
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
       25 + * Copyright (c) 2018, Joyent, Inc.
  25   26   */
  26   27  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   28  #include <pthread.h>
  30   29  #include <sys/md5.h>
  31   30  #include <sys/sha1.h>
  32   31  #include <sys/sha2.h>
  33   32  #include <stdlib.h>
  34   33  #include <string.h>
  35   34  #include <strings.h>
  36   35  #include <sys/types.h>
  37   36  #include <security/cryptoki.h>
  38   37  #include "softObject.h"
↓ open down ↓ 516 lines elided ↑ open up ↑
 555  554          };
 556  555  
 557  556          *pulSignedLen = hmac_ctx->hmac_len;
 558  557  
 559  558  
 560  559  clean_exit:
 561  560  
 562  561          (void) pthread_mutex_lock(&session_p->session_mutex);
 563  562  
 564  563          if (sign_op) {
 565      -                bzero(session_p->sign.context, sizeof (soft_hmac_ctx_t));
 566      -                free(session_p->sign.context);
      564 +                freezero(session_p->sign.context, sizeof (soft_hmac_ctx_t));
 567  565                  session_p->sign.context = NULL;
 568  566          } else {
 569      -                bzero(session_p->verify.context, sizeof (soft_hmac_ctx_t));
 570      -                free(session_p->verify.context);
      567 +                freezero(session_p->verify.context, sizeof (soft_hmac_ctx_t));
 571  568                  session_p->verify.context = NULL;
 572  569          }
 573  570  
 574  571          (void) pthread_mutex_unlock(&session_p->session_mutex);
 575  572  
 576  573          return (CKR_OK);
 577  574  }
 578  575  
 579  576  
 580  577  /*
↓ open down ↓ 109 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX