summaryrefslogtreecommitdiff
path: root/src/certtool-cfg.c
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2008-05-16 14:03:19 +0200
committerSimon Josefsson <simon@josefsson.org>2008-05-16 14:03:19 +0200
commit6f774053240717cac8ec2d0b475e3e33dd89444d (patch)
tree2cf4035ac4391ca8fb001f3ccbcd82b1af119c93 /src/certtool-cfg.c
parentc57f119c666de217efbcb1e81d387f71ce050e37 (diff)
downloadgnutls-6f774053240717cac8ec2d0b475e3e33dd89444d.tar.gz
certtool: Encrypting a private key now require a confirmed password.
Before, './certtool -k -8' would merely ask for a password once. Reported by Daniel 'NebuchadnezzaR' Dehennin <nebuchadnezzar@asgardr.info> see <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=364287>.
Diffstat (limited to 'src/certtool-cfg.c')
-rw-r--r--src/certtool-cfg.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/certtool-cfg.c b/src/certtool-cfg.c
index bdb61b9a83..ca3431508c 100644
--- a/src/certtool-cfg.c
+++ b/src/certtool-cfg.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation
*
* This file is part of GNUTLS.
*
@@ -308,6 +308,36 @@ get_pass (void)
}
const char *
+get_confirmed_pass (bool empty_ok)
+{
+ if (batch)
+ return cfg.password;
+ else
+ {
+ const char *pass = NULL;
+ char *copy = NULL;
+
+ do
+ {
+ if (pass)
+ printf ("Password missmatch, try again.\n");
+
+ if (copy)
+ free (copy);
+
+ pass = getpass ("Enter password: ");
+ copy = strdup (pass);
+ pass = getpass ("Confirm password: ");
+ }
+ while (strcmp (pass, copy) != 0 && !(empty_ok && *pass == '\0'));
+
+ free (copy);
+
+ return pass;
+ }
+}
+
+const char *
get_challenge_pass (void)
{
if (batch)