]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
When generating ECDSA keys, generate 256-bit keys by default.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 4 May 2014 11:54:58 +0000 (13:54 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 4 May 2014 11:54:58 +0000 (13:54 +0200)
Curves with less than 256 bits (i.e., SECP192R1 and SECP224R1) are
not widely supported.

src/certtool-common.c
src/certtool.c

index d1e3212a313d3917abddd4a0997cb2461539f6ec..31b55297460f1646bc116c40c7cdb44f255f2199 100644 (file)
@@ -629,15 +629,17 @@ get_bits(gnutls_pk_algorithm_t key_type, int info_bits,
                }
                bits = info_bits;
        } else {
-               if (info_sec_param) {
-                       bits =
-                           gnutls_sec_param_to_pk_bits(key_type,
-                                                       str_to_sec_param
-                                                       (info_sec_param));
-               } else
-                       bits =
-                           gnutls_sec_param_to_pk_bits(key_type,
-                                                       GNUTLS_SEC_PARAM_MEDIUM);
+               if (info_sec_param == 0) {
+                       /* For ECDSA keys use 256 bits or better, as they are widely supported */
+                       if (key_type == GNUTLS_PK_EC)
+                               info_sec_param = "HIGH";
+                       else
+                               info_sec_param = "MEDIUM";
+               }
+               bits =
+                   gnutls_sec_param_to_pk_bits(key_type,
+                                               str_to_sec_param
+                                               (info_sec_param));
        }
 
        return bits;
index d4e165cade413a6ef6fd574312d14e2206775fa5..a5b5e9f2626c72cdd69e182fcfc0fa822c229def 100644 (file)
@@ -116,6 +116,10 @@ generate_private_key_int(common_info_st * cinfo)
        fprintf(stderr, "Generating a %d bit %s private key...\n",
                bits, gnutls_pk_algorithm_get_name(key_type));
 
+       if (bits < 256 && key_type == GNUTLS_PK_EC)
+               fprintf(stderr,
+                       "Note that ECDSA keys with size less than 256 are not widely supported.\n\n");
+
        if (bits > 1024 && key_type == GNUTLS_PK_DSA)
                fprintf(stderr,
                        "Note that DSA keys with size over 1024 may cause incompatibility problems when used with earlier than TLS 1.2 versions.\n\n");