summaryrefslogtreecommitdiff
path: root/security/nss/cmd/p7sign/p7sign.c
diff options
context:
space:
mode:
authornelsonb%netscape.com <devnull@localhost>2002-03-07 22:05:43 +0000
committernelsonb%netscape.com <devnull@localhost>2002-03-07 22:05:43 +0000
commit853755ec0bed943f652b88ff42d8d9502a4c5c69 (patch)
treec7978404dd50ad43f5e7c63298c623a16f0e99e5 /security/nss/cmd/p7sign/p7sign.c
parentef1750f23087f8e4b79bfb8c0ff934cc0202c743 (diff)
downloadnss-hg-853755ec0bed943f652b88ff42d8d9502a4c5c69.tar.gz
Add support for new -p option to pass password to PK11 token.
Patch by evanchu@aol.com (Evan Chu). r=nelsonb a=wtc bug 129354.
Diffstat (limited to 'security/nss/cmd/p7sign/p7sign.c')
-rw-r--r--security/nss/cmd/p7sign/p7sign.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/security/nss/cmd/p7sign/p7sign.c b/security/nss/cmd/p7sign/p7sign.c
index 97a69974b..0bff6c1da 100644
--- a/security/nss/cmd/p7sign/p7sign.c
+++ b/security/nss/cmd/p7sign/p7sign.c
@@ -46,6 +46,7 @@
#include "certdb.h"
#include "sechash.h" /* for HASH_GetHashObject() */
#include "nss.h"
+#include "pk11func.h"
#if defined(XP_UNIX)
#include <unistd.h>
@@ -60,6 +61,20 @@ extern int fwrite(char *, size_t, size_t, FILE*);
extern int fprintf(FILE *, char *, ...);
#endif
+char* KeyDbPassword = 0;
+
+
+char* MyPK11PasswordFunc (PK11SlotInfo *slot, PRBool retry, void* arg)
+{
+ char *ret=0;
+
+ if (retry == PR_TRUE)
+ return NULL;
+ ret = PL_strdup (KeyDbPassword);
+ return ret;
+}
+
+
static void
Usage(char *progName)
{
@@ -76,6 +91,7 @@ Usage(char *progName)
"-o output");
fprintf(stderr, "%-20s Encapsulate content in signature message\n",
"-e");
+ fprintf(stderr, "%-20s Password to the key databse\n", "-p");
exit(-1);
}
@@ -84,7 +100,7 @@ SignOut(void *arg, const char *buf, unsigned long len)
{
FILE *out;
- out = arg;
+ out = (FILE*) arg;
fwrite (buf, len, 1, out);
}
@@ -190,7 +206,7 @@ main(int argc, char **argv)
/*
* Parse command line arguments
*/
- optstate = PL_CreateOptState(argc, argv, "ed:k:i:o:");
+ optstate = PL_CreateOptState(argc, argv, "ed:k:i:o:p:");
while ((status = PL_GetNextOpt(optstate)) == PL_OPT_OK) {
switch (optstate->option) {
case '?':
@@ -227,6 +243,9 @@ main(int argc, char **argv)
return -1;
}
break;
+ case 'p':
+ KeyDbPassword = strdup (optstate->value);
+ break;
}
}
@@ -243,6 +262,8 @@ main(int argc, char **argv)
return -1;
}
+ PK11_SetPasswordFunc (MyPK11PasswordFunc);
+
/* open cert database */
certHandle = CERT_GetDefaultCertDB();
if (certHandle == NULL) {