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_kernel/common/kernelObjectUtil.c
          +++ new/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelObjectUtil.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + * Copyright (c) 2018, Joyent, Inc.
  24   25   */
  25   26  
  26   27  #include <stdio.h>
  27   28  #include <stdlib.h>
  28   29  #include <strings.h>
  29   30  #include <errno.h>
  30   31  #include <security/cryptoki.h>
  31   32  #include <cryptoutil.h>
  32   33  #include "kernelGlobal.h"
  33   34  #include "kernelObject.h"
↓ open down ↓ 36 lines elided ↑ open up ↑
  70   71   * yet (by kernel_build_XXX_object() during creating an object).
  71   72   */
  72   73  void
  73   74  kernel_cleanup_object(kernel_object_t *objp)
  74   75  {
  75   76          /*
  76   77           * Free the storage allocated to a secret key object.
  77   78           */
  78   79          if (objp->class == CKO_SECRET_KEY) {
  79   80                  if (OBJ_SEC(objp) != NULL && OBJ_SEC_VALUE(objp) != NULL) {
  80      -                        bzero(OBJ_SEC_VALUE(objp), OBJ_SEC_VALUE_LEN(objp));
  81      -                        free(OBJ_SEC_VALUE(objp));
       81 +                        freezero(OBJ_SEC_VALUE(objp), OBJ_SEC_VALUE_LEN(objp));
  82   82                          OBJ_SEC_VALUE(objp) = NULL;
  83   83                          OBJ_SEC_VALUE_LEN(objp) = 0;
  84   84                  }
  85   85                  free(OBJ_SEC(objp));
  86   86                  OBJ_SEC(objp) = NULL;
  87   87          } else {
  88   88                  kernel_cleanup_object_bigint_attrs(objp);
  89   89          }
  90   90  
  91   91          /*
↓ open down ↓ 992 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX