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/softSignUtil.c
          +++ new/usr/src/lib/pkcs11/pkcs11_softtoken/common/softSignUtil.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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 2007 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
       25 + * Copyright (c) 2018, Joyent, Inc.
  25   26   */
  26   27  
  27   28  #include <stdlib.h>
  28   29  #include <strings.h>
  29   30  #include <sys/types.h>
  30   31  #include <security/cryptoki.h>
  31   32  #include "softObject.h"
  32   33  #include "softOps.h"
  33   34  #include "softSession.h"
  34   35  #include "softMAC.h"
↓ open down ↓ 520 lines elided ↑ open up ↑
 555  556          case CKM_MD5_HMAC_GENERAL:
 556  557          case CKM_MD5_HMAC:
 557  558          case CKM_SHA_1_HMAC_GENERAL:
 558  559          case CKM_SHA_1_HMAC:
 559  560          case CKM_SHA256_HMAC_GENERAL:
 560  561          case CKM_SHA256_HMAC:
 561  562          case CKM_SHA384_HMAC_GENERAL:
 562  563          case CKM_SHA384_HMAC:
 563  564          case CKM_SHA512_HMAC_GENERAL:
 564  565          case CKM_SHA512_HMAC:
 565      -                if (active_op->context != NULL)
 566      -                        bzero(active_op->context, sizeof (soft_hmac_ctx_t));
      566 +                if (active_op->context != NULL) {
      567 +                        explicit_bzero(active_op->context,
      568 +                            sizeof (soft_hmac_ctx_t));
      569 +                }
 567  570                  break;
 568  571          case CKM_DES_MAC_GENERAL:
 569  572          case CKM_DES_MAC:
 570  573                  if (session_p->encrypt.context != NULL) {
 571  574                          free(session_p->encrypt.context);
 572  575                          session_p->encrypt.context = NULL;
 573  576                          session_p->encrypt.flags = 0;
 574  577                  }
 575      -                if (active_op->context != NULL)
 576      -                        bzero(active_op->context, sizeof (soft_des_ctx_t));
      578 +                if (active_op->context != NULL) {
      579 +                        explicit_bzero(active_op->context,
      580 +                            sizeof (soft_des_ctx_t));
      581 +                }
 577  582                  break;
 578  583  
 579  584          case CKM_AES_CMAC_GENERAL:
 580  585          case CKM_AES_CMAC:
 581  586                  if (session_p->encrypt.context != NULL) {
 582  587                          free(session_p->encrypt.context);
 583  588                          session_p->encrypt.context = NULL;
 584  589                          session_p->encrypt.flags = 0;
 585  590                  }
 586      -                if (active_op->context != NULL)
 587      -                        bzero(active_op->context, sizeof (soft_aes_ctx_t));
      591 +                if (active_op->context != NULL) {
      592 +                        explicit_bzero(active_op->context,
      593 +                            sizeof (soft_aes_ctx_t));
      594 +                }
 588  595                  break;
 589  596  
 590  597          }
 591  598  
 592  599          if (active_op->context != NULL) {
 593  600                  free(active_op->context);
 594  601                  active_op->context = NULL;
 595  602          }
 596  603  
 597  604          active_op->flags = 0;
 598  605  
 599  606          if (!lock_held)
 600  607                  SES_REFRELE(session_p, lock_true);
 601  608  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX