]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
When generating private key allow usage of --pkcs-cipher flag.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 26 Jun 2010 19:51:03 +0000 (21:51 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 26 Jun 2010 19:51:25 +0000 (21:51 +0200)
src/certtool.c

index e68f666db03b9e1c6e80c6452c3dacbdb4c5d32c..962268a5bdb2314ed556630f9f77205e2ee408d2 100644 (file)
@@ -260,6 +260,35 @@ generate_private_key_int (void)
   return key;
 }
 
+static int
+cipher_to_flags (const char *cipher)
+{
+  if (strcasecmp (cipher, "3des") == 0)
+    {
+      return GNUTLS_PKCS_USE_PBES2_3DES;
+    }
+  else if (strcasecmp (cipher, "aes-128") == 0)
+    {
+      return GNUTLS_PKCS_USE_PBES2_AES_128;
+    }
+  else if (strcasecmp (cipher, "aes-192") == 0)
+    {
+      return GNUTLS_PKCS_USE_PBES2_AES_192;
+    }
+  else if (strcasecmp (cipher, "aes-256") == 0)
+    {
+      return GNUTLS_PKCS_USE_PBES2_AES_256;
+    }
+  else if (strcasecmp (cipher, "rc2-40") == 0)
+    {
+      return GNUTLS_PKCS_USE_PKCS12_RC2_40;
+    }
+
+  error (EXIT_FAILURE, 0, "Unknown cipher %s\n", cipher);
+  return -1;
+}
+
+
 static void
 print_private_key (gnutls_x509_privkey_t key)
 {
@@ -285,7 +314,7 @@ print_private_key (gnutls_x509_privkey_t key)
       if (info.export)
        flags = GNUTLS_PKCS_USE_PKCS12_RC2_40;
       else
-       flags = GNUTLS_PKCS_USE_PKCS12_3DES;
+       flags = cipher_to_flags (info.pkcs_cipher);
 
       if ((pass = get_confirmed_pass (true)) == NULL || *pass == '\0')
        flags = GNUTLS_PKCS_PLAIN;
@@ -2592,33 +2621,6 @@ verify_crl (void)
   fprintf (outfile, "\n");
 }
 
-static int
-cipher_to_flags (const char *cipher)
-{
-  if (strcasecmp (cipher, "3des") == 0)
-    {
-      return GNUTLS_PKCS_USE_PBES2_3DES;
-    }
-  else if (strcasecmp (cipher, "aes-128") == 0)
-    {
-      return GNUTLS_PKCS_USE_PBES2_AES_128;
-    }
-  else if (strcasecmp (cipher, "aes-192") == 0)
-    {
-      return GNUTLS_PKCS_USE_PBES2_AES_192;
-    }
-  else if (strcasecmp (cipher, "aes-256") == 0)
-    {
-      return GNUTLS_PKCS_USE_PBES2_AES_256;
-    }
-  else if (strcasecmp (cipher, "rc2-40") == 0)
-    {
-      return GNUTLS_PKCS_USE_PKCS12_RC2_40;
-    }
-
-  error (EXIT_FAILURE, 0, "Unknown cipher %s\n", cipher);
-  return -1;
-}
 
 void
 generate_pkcs8 (void)