Print this page
6723237 libcryptoutil should allow mechanism number "0x80000000" (the value of marker CKM_VENDOR_DEFINED)

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 ↓ 15 lines elided ↑ open up ↑
  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 2008 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26      -#pragma ident   "@(#)kernelUtil.c       1.17    08/06/30 SMI"
       26 +#pragma ident   "@(#)kernelUtil.c       1.18    08/07/07 SMI"
  27   27  
  28   28  #include <stdlib.h>
  29   29  #include <string.h>
  30   30  #include <strings.h>
  31   31  #include <stdio.h>
  32   32  #include <cryptoutil.h>
  33   33  #include <errno.h>
  34   34  #include <security/cryptoki.h>
  35   35  #include <sys/crypto/common.h>
  36   36  #include <sys/crypto/ioctl.h>
↓ open down ↓ 168 lines elided ↑ open up ↑
 205  205           * just a reader and we never free the entries in the hash table.
 206  206           */
 207  207          h = MECH_HASH(type);
 208  208          for (elem = kernel_mechhash[h]; elem != NULL; elem = elem->knext) {
 209  209                  if (type == elem->type) {
 210  210                          *k_number = elem->kmech;
 211  211                          return (CKR_OK);
 212  212                  }
 213  213          }
 214  214  
 215      -        if (type > CKM_VENDOR_DEFINED) {
      215 +        if (type >= CKM_VENDOR_DEFINED) {
 216  216                  (void) snprintf(buf, sizeof (buf), "%#lx", type);
 217  217                  string = buf;
 218  218          } else {
 219  219                  string = pkcs11_mech2str(type);
 220  220          }
 221  221  
 222  222          if (string == NULL)
 223  223                  return (CKR_MECHANISM_INVALID);
 224  224  
 225  225          get_number.pn_mechanism_string = (char *)string;
↓ open down ↓ 1001 lines elided ↑ open up ↑
1227 1227  get_mechanism_info(kernel_slot_t *pslot, CK_MECHANISM_TYPE type,
1228 1228      CK_MECHANISM_INFO_PTR pInfo, uint32_t *k_mi_flags)
1229 1229  {
1230 1230          crypto_get_provider_mechanism_info_t mechanism_info;
1231 1231          const char *string;
1232 1232          CK_FLAGS flags, mi_flags;
1233 1233          CK_RV rv;
1234 1234          int r;
1235 1235          char buf[11];   /* Num chars for representing ulong in ASCII */
1236 1236  
1237      -        if (type > CKM_VENDOR_DEFINED) {
     1237 +        if (type >= CKM_VENDOR_DEFINED) {
1238 1238                  /* allocate/build a string containing the mechanism number */
1239 1239                  (void) snprintf(buf, sizeof (buf), "%#lx", type);
1240 1240                  string = buf;
1241 1241          } else {
1242 1242                  string = pkcs11_mech2str(type);
1243 1243          }
1244 1244  
1245 1245          if (string == NULL)
1246 1246                  return (CKR_MECHANISM_INVALID);
1247 1247  
↓ open down ↓ 81 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX