Print this page
6862532 "cryptoadm: failed to parse configuration" error
6353443 domestic (crypt) source build leaves stuff it shouldn't
6818180 mac(1) printed "invalid key" error message when user input an invalid passphrase

@@ -17,11 +17,11 @@
  * information: Portions Copyright [yyyy] [name of copyright owner]
  *
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
 /*
  * digest.c

@@ -69,23 +69,24 @@
 
 #define EXIT_USAGE      2       /* usage/syntax error */
 
 #define MAC_NAME        "mac"           /* name of mac command */
 #define MAC_OPTIONS     "lva:k:T:K:"            /* for getopt */
-#define DIGEST_NAME     "digest"        /* name of mac command */
+#define DIGEST_NAME     "digest"        /* name of digest command */
 #define DIGEST_OPTIONS  "lva:"          /* for getopt */
 
+/* Saved command line options */
 static boolean_t vflag = B_FALSE;       /* -v (verbose) flag, optional */
 static boolean_t aflag = B_FALSE;       /* -a <algorithm> flag, required */
 static boolean_t lflag = B_FALSE;       /* -l flag, for mac and digest */
-static boolean_t kflag = B_FALSE;
-static boolean_t Tflag = B_FALSE;
-static boolean_t Kflag = B_FALSE;
+static boolean_t kflag = B_FALSE;       /* -k keyfile */
+static boolean_t Tflag = B_FALSE;       /* -T token_spec */
+static boolean_t Kflag = B_FALSE;       /* -K key_label */
 
-static char *keyfile = NULL;    /* name of keyfile */
-static char *token_label = NULL;
-static char *key_label = NULL;
+static char *keyfile = NULL;     /* name of file containing key value */
+static char *token_label = NULL; /* tokensSpec: tokenName[:manufId[:serial]] */
+static char *key_label = NULL;   /* PKCS#11 symmetric token key label */
 
 static CK_BYTE buf[BUFFERSIZE];
 
 struct mech_alias {
         CK_MECHANISM_TYPE type;

@@ -124,11 +125,10 @@
         int fd, CK_BYTE_PTR *pdigest, CK_ULONG_PTR pdigestlen);
 
 int
 main(int argc, char **argv)
 {
-
         extern char *optarg;
         extern int optind;
         int errflag = 0;        /* We had an optstr parse error */
         char c;                 /* current getopts flag */
         char *algo_str;         /* mechanism/algorithm string */

@@ -428,11 +428,12 @@
                                     0, B_FALSE);
                         }
 
                         if (status != 0 || keylen == 0 || pkeydata == NULL) {
                                 cryptoerror(LOG_STDERR,
-                                    Kflag ? gettext("invalid passphrase.") :
+                                    (Kflag || (keyfile == NULL)) ?
+                                    gettext("invalid passphrase.") :
                                     gettext("invalid key."));
                                 return (EXIT_FAILURE);
                         }
                 }
         }

@@ -448,11 +449,11 @@
 
         /* Get slot count */
         rv = C_GetSlotList(0, NULL_PTR, &slotcount);
         if (rv != CKR_OK || slotcount == 0) {
                 cryptoerror(LOG_STDERR, gettext(
-                    "failed to find any cryptographic provider,"
+                    "failed to find any cryptographic provider; "
                     "please check with your system administrator: %s"),
                     pkcs11_strerror(rv));
                 exitcode = EXIT_FAILURE;
                 goto cleanup;
         }

@@ -468,11 +469,11 @@
         }
 
         /* Get the list of slots */
         if ((rv = C_GetSlotList(0, pSlotList, &slotcount)) != CKR_OK) {
                 cryptoerror(LOG_STDERR, gettext(
-                    "failed to find any cryptographic provider,"
+                    "failed to find any cryptographic provider; "
                     "please check with your system administrator: %s"),
                     pkcs11_strerror(rv));
                 exitcode = EXIT_FAILURE;
                 goto cleanup;
         }