summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrelyea%netscape.com <devnull@localhost>2001-11-16 02:52:31 +0000
committerrelyea%netscape.com <devnull@localhost>2001-11-16 02:52:31 +0000
commit7ff71e6d974be1a16d61f0005906f9db034573a3 (patch)
tree3b2bfae8dee80e7c3bbe4911e82b0963902c24c0
parenta0a9227c73e629a74dc1e20e4466d18faf0f876b (diff)
downloadnss-hg-7ff71e6d974be1a16d61f0005906f9db034573a3.tar.gz
'Back port' nss 3.4 version of SDR test which actually does test sdr to
3.3 branch. (really just copy the 3.4 version here).
-rw-r--r--security/nss/cmd/sdrtest/sdrtest.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/security/nss/cmd/sdrtest/sdrtest.c b/security/nss/cmd/sdrtest/sdrtest.c
index 6c352d7ed..3124ef6cf 100644
--- a/security/nss/cmd/sdrtest/sdrtest.c
+++ b/security/nss/cmd/sdrtest/sdrtest.c
@@ -160,8 +160,15 @@ main (int argc, char **argv)
*/
PK11_SetPasswordFunc(SECU_GetModulePassword);
- rv = NSS_Init(SECU_ConfigDirectory(NULL));
- if (rv != SECSuccess) goto prdone;
+ if (output_file) {
+ rv = NSS_InitReadWrite(SECU_ConfigDirectory(NULL));
+ } else {
+ rv = NSS_Init(SECU_ConfigDirectory(NULL));
+ }
+ if (rv != SECSuccess) {
+ retval = -1;
+ goto prdone;
+ }
/* Convert value into an item */
data.data = (unsigned char *)value;
@@ -215,6 +222,19 @@ file_loser:
else
{
SECItem keyid = { 0, 0, 0 };
+ PK11SlotInfo *slot = NULL;
+
+ /* sigh, initialize the key database */
+ slot = PK11_GetInternalKeySlot();
+ if (slot && PK11_NeedUserInit(slot)) {
+ rv = SECU_ChangePW(slot, "", 0);
+ if (rv != SECSuccess) {
+ SECU_PrintError(program_name, "Failed to initialize slot \"%s\"",
+ PK11_GetSlotName(slot));
+ return SECFailure;
+ }
+ PK11_FreeSlot(slot);
+ }
rv = PK11SDR_Encrypt(&keyid, &data, &result, 0);
if (rv != SECSuccess) {