[seahorse] Bug 598203 - Generate a new RSA-sign/RSA-encrypt key in one pass



commit 6ef33b44e8546b095c74c8b99762d3fcbcfca28f
Author: nobled <nobled dreamwidth org>
Date:   Sun Nov 29 17:23:10 2009 -0500

    Bug 598203 - Generate a new RSA-sign/RSA-encrypt key in one pass
    
    This adds the option "RSA" to the top of the list of available
    key types.

 pgp/seahorse-gpgme-generate.c |    1 +
 pgp/seahorse-gpgme-key-op.c   |   13 ++++++++-----
 pgp/seahorse-gpgme-key-op.h   |    6 +++++-
 3 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/pgp/seahorse-gpgme-generate.c b/pgp/seahorse-gpgme-generate.c
index 6a03f6b..30721e0 100644
--- a/pgp/seahorse-gpgme-generate.c
+++ b/pgp/seahorse-gpgme-generate.c
@@ -112,6 +112,7 @@ typedef struct _AlgorithmDesc {
 } AlgorithmDesc;
 
 static AlgorithmDesc available_algorithms[] = {
+    { N_("RSA"),             RSA_RSA,     RSA_MIN,     LENGTH_MAX  },
     { N_("DSA Elgamal"),     DSA_ELGAMAL, ELGAMAL_MIN, LENGTH_MAX  },
     { N_("DSA (sign only)"), DSA,         DSA_MIN,     DSA_MAX     },
     { N_("RSA (sign only)"), RSA_SIGN,    RSA_MIN,     LENGTH_MAX  }
diff --git a/pgp/seahorse-gpgme-key-op.c b/pgp/seahorse-gpgme-key-op.c
index af90f4e..8b55548 100644
--- a/pgp/seahorse-gpgme-key-op.c
+++ b/pgp/seahorse-gpgme-key-op.c
@@ -78,7 +78,7 @@
  * @email: Optional user ID email
  * @comment: Optional user ID comment
  * @passphrase: Passphrase for key
- * @type: Key type. Supported types are #DSA_ELGAMAL, #DSA, and #RSA_SIGN
+ * @type: Key type. Supported types are #DSA_ELGAMAL, #DSA, #RSA_SIGN, and #RSA_RSA
  * @length: Length of key, must be within the range of @type specified by #SeahorseKeyLength
  * @expires: Expiration date of key
  * @err: Catches errors in the params
@@ -112,7 +112,7 @@ seahorse_gpgme_key_op_generate (SeahorseGpgmeSource *psrc, const gchar *name,
         if (length < DSA_MIN || length > DSA_MAX)
             *err = GPG_E (GPG_ERR_INV_VALUE);
         break;
-    case RSA_SIGN:
+    case RSA_RSA: RSA_SIGN:
         if (length < RSA_MIN || length > LENGTH_MAX)
             *err = GPG_E (GPG_ERR_INV_VALUE);
         break;
@@ -134,10 +134,10 @@ seahorse_gpgme_key_op_generate (SeahorseGpgmeSource *psrc, const gchar *name,
     if (comment != NULL && strlen (comment) > 0)
         common = g_strdup_printf ("Name-Comment: %s\n%s", comment, common);
 
-    if (type == RSA_SIGN)
-        key_type = "Key-Type: RSA\nKey-Usage: sign";
-    else
+    if (type == DSA || type == DSA_ELGAMAL)
         key_type = "Key-Type: DSA\nKey-Usage: sign";
+    else
+        key_type = "Key-Type: RSA\nKey-Usage: sign";
 
     start = g_strdup_printf ("<GnupgKeyParms format=\"internal\">\n%s\nKey-Length: ", key_type);
 
@@ -145,6 +145,9 @@ seahorse_gpgme_key_op_generate (SeahorseGpgmeSource *psrc, const gchar *name,
     if (type == DSA_ELGAMAL)
         parms = g_strdup_printf ("%s%d\nSubkey-Type: ELG-E\nSubkey-Length: %d\nSubkey-Usage: encrypt\n%s",
                                  start, (length < DSA_MAX) ? length : DSA_MAX, length, common);
+    else if (type == RSA_RSA)
+        parms = g_strdup_printf ("%s%d\nSubkey-Type: RSA\nSubkey-Length: %d\nSubkey-Usage: encrypt\n%s",
+                                 start, length, length, common);
     else
         parms = g_strdup_printf ("%s%d\n%s", start, length, common);
 
diff --git a/pgp/seahorse-gpgme-key-op.h b/pgp/seahorse-gpgme-key-op.h
index f2c434e..be4daea 100644
--- a/pgp/seahorse-gpgme-key-op.h
+++ b/pgp/seahorse-gpgme-key-op.h
@@ -63,7 +63,11 @@ typedef enum {
 	/* RSA subkey, encrypt only. See #RSA_MIN and #RSA_MAX.
 	 * Only used in seahorse_ops_key_add_subkey().
 	 */
-	RSA_ENCRYPT = 6
+	RSA_ENCRYPT = 6,
+	/* RSA sign-only key with RSA encrypt-only subkey. See #RSA_MIN and
+	 * #LENGTH_MAX. Only used in seahorse_ops_key_generate().
+	 */
+	RSA_RSA = 11
 } SeahorseKeyEncType;
 
 #else /* GPG version >=1.4.10 or >=2.0.12 */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]