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/kernelUtil.c
          +++ new/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelUtil.c
↓ open down ↓ 472 lines elided ↑ open up ↑
 473  473   * Free attribute storage in a crypto_key structure.
 474  474   */
 475  475  void
 476  476  free_key_attributes(crypto_key_t *key)
 477  477  {
 478  478          int i;
 479  479  
 480  480          if (key->ck_format == CRYPTO_KEY_ATTR_LIST &&
 481  481              (key->ck_count > 0) && key->ck_attrs != NULL) {
 482  482                  for (i = 0; i < key->ck_count; i++) {
 483      -                        if (key->ck_attrs[i].oa_value != NULL) {
 484      -                                bzero(key->ck_attrs[i].oa_value,
 485      -                                    key->ck_attrs[i].oa_value_len);
 486      -                                free(key->ck_attrs[i].oa_value);
 487      -                        }
      483 +                        freezero(key->ck_attrs[i].oa_value,
      484 +                            key->ck_attrs[i].oa_value_len);
 488  485                  }
 489  486                  free(key->ck_attrs);
 490  487          }
 491  488  }
 492  489  
 493  490  
 494  491  /*
 495  492   * Convert a DSA private key object into a crypto_key structure.
 496  493   * Memory is allocated for each attribute stored in the crypto_key
 497  494   * structure.  Memory for the crypto_key structure is not
↓ open down ↓ 831 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX