Print this page
6658907 digest(1) and mac(1) could benefit from being 64-bit programs

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/cmd-crypto/digest/digest.c
          +++ new/usr/src/cmd/cmd-crypto/digest/digest.c
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  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      - * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
       22 + * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26      -#pragma ident   "@(#)digest.c   1.11    07/10/04 SMI"
       26 +#pragma ident   "@(#)digest.c   1.12    08/03/20 SMI"
  27   27  
  28   28  /*
  29   29   * digest.c
  30   30   *
  31   31   * Implements digest(1) and mac(1) commands
  32   32   * If command name is mac, performs mac operation
  33   33   * else perform digest operation
  34   34   *
  35   35   * See the man pages for digest and mac for details on
  36   36   * how these commands work.
↓ open down ↓ 327 lines elided ↑ open up ↑
 364  364          CK_SLOT_ID slotID;
 365  365          CK_SLOT_ID_PTR pSlotList = NULL;
 366  366          CK_MECHANISM_TYPE mech_type;
 367  367          CK_MECHANISM_INFO info;
 368  368          CK_MECHANISM mech;
 369  369          CK_SESSION_HANDLE hSession = CK_INVALID_HANDLE;
 370  370          CK_BYTE_PTR resultbuf = NULL;
 371  371          CK_ULONG resultlen;
 372  372          CK_BYTE_PTR     pkeydata = NULL;
 373  373          CK_OBJECT_HANDLE key = (CK_OBJECT_HANDLE) 0;
 374      -        int keylen = 0;         /* key length */
      374 +        size_t keylen = 0;              /* key length */
 375  375          char *resultstr = NULL; /* result in hex string */
 376  376          int resultstrlen;       /* result string length */
 377  377          int i;
 378  378          int exitcode = EXIT_SUCCESS;            /* return code */
 379  379          int slot, mek;                  /* index variables */
 380  380          int mech_match = 0;
 381  381          CK_BYTE         salt[CK_PKCS5_PBKD2_SALT_SIZE];
 382  382          CK_ULONG        keysize;
 383  383          CK_ULONG        iterations = CK_PKCS5_PBKD2_ITERATIONS;
 384  384          CK_KEY_TYPE keytype;
↓ open down ↓ 25 lines elided ↑ open up ↑
 410  410                          int status;
 411  411  
 412  412                          if (Kflag) {
 413  413                                  /* get the pin of the token */
 414  414                                  if (token_label == NULL ||
 415  415                                      !strlen(token_label)) {
 416  416                                          token_label = pkcs11_default_token();
 417  417                                  }
 418  418  
 419  419                                  status = pkcs11_get_pass(token_label,
 420      -                                    (char **)&pkeydata, (size_t *)&keylen,
      420 +                                    (char **)&pkeydata, &keylen,
 421  421                                      0, B_FALSE);
 422  422                          } else if (keyfile != NULL) {
 423  423                                  /* get the key file */
 424  424                                  status = pkcs11_read_data(keyfile,
 425      -                                    (void **)&pkeydata, (size_t *)&keylen);
      425 +                                    (void **)&pkeydata, &keylen);
 426  426                          } else {
 427  427                                  /* get the key from input */
 428  428                                  status = pkcs11_get_pass(NULL,
 429      -                                    (char **)&pkeydata, (size_t *)&keylen,
      429 +                                    (char **)&pkeydata, &keylen,
 430  430                                      0, B_FALSE);
 431  431                          }
 432  432  
 433  433                          if (status == -1 || keylen == 0 || pkeydata == NULL) {
 434  434                                  cryptoerror(LOG_STDERR,
 435  435                                      Kflag ? gettext("invalid passphrase.") :
 436  436                                      gettext("invalid key."));
 437  437                                  return (EXIT_FAILURE);
 438  438                          }
 439  439                  }
↓ open down ↓ 506 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX