Blame SOURCES/gnutls-2.12.21-fips-algorithms.patch

9199b3
diff -up gnutls-2.12.21/lib/gcrypt/init.c.fips gnutls-2.12.21/lib/gcrypt/init.c
9199b3
--- gnutls-2.12.21/lib/gcrypt/init.c.fips	2012-01-06 20:06:23.000000000 +0100
9199b3
+++ gnutls-2.12.21/lib/gcrypt/init.c	2012-11-09 19:57:54.651624659 +0100
9199b3
@@ -43,6 +43,8 @@ static struct gcry_thread_cbs gct = {
9199b3
   .recvmsg = NULL,
9199b3
 };
9199b3
 
9199b3
+int gnutls_gcrypt_fips;
9199b3
+
9199b3
 int
9199b3
 gnutls_crypto_init (void)
9199b3
 {
9199b3
@@ -72,6 +74,8 @@ gnutls_crypto_init (void)
9199b3
           return GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY;
9199b3
         }
9199b3
 
9199b3
+      gnutls_gcrypt_fips = gcry_fips_mode_active();
9199b3
+
9199b3
       /* for gcrypt in order to be able to allocate memory */
9199b3
       gcry_control (GCRYCTL_DISABLE_SECMEM, NULL, 0);
9199b3
 
9199b3
diff -up gnutls-2.12.21/lib/gnutls_algorithms.c.fips gnutls-2.12.21/lib/gnutls_algorithms.c
9199b3
--- gnutls-2.12.21/lib/gnutls_algorithms.c.fips	2012-01-06 20:06:23.000000000 +0100
9199b3
+++ gnutls-2.12.21/lib/gnutls_algorithms.c	2012-11-28 14:19:34.507948036 +0100
9199b3
@@ -44,11 +44,11 @@ typedef struct
9199b3
 } gnutls_sec_params_entry;
9199b3
 
9199b3
 static const gnutls_sec_params_entry sec_params[] = {
9199b3
-  {"Weak", GNUTLS_SEC_PARAM_WEAK, 64, 816, 1024, 128, 128},
9199b3
-  {"Low", GNUTLS_SEC_PARAM_LOW, 80, 1248, 2048, 160, 160},
9199b3
-  {"Normal", GNUTLS_SEC_PARAM_NORMAL, 112, 2432, 3072, 224, 224},
9199b3
-  {"High", GNUTLS_SEC_PARAM_HIGH, 128, 3248, 3072, 256, 256},
9199b3
-  {"Ultra", GNUTLS_SEC_PARAM_ULTRA, 256, 15424, 3072, 512, 512},
9199b3
+  {"Weak", GNUTLS_SEC_PARAM_WEAK, 64, 1024, 1024, 128, 128},
9199b3
+  {"Low", GNUTLS_SEC_PARAM_LOW, 80, 1280, 2048, 160, 160},
9199b3
+  {"Normal", GNUTLS_SEC_PARAM_NORMAL, 112, 2560, 3072, 224, 224},
9199b3
+  {"High", GNUTLS_SEC_PARAM_HIGH, 128, 3328, 3072, 256, 256},
9199b3
+  {"Ultra", GNUTLS_SEC_PARAM_ULTRA, 256, 15616, 3072, 512, 512},
9199b3
   {NULL, 0, 0, 0, 0, 0}
9199b3
 };
9199b3
 
9199b3
diff -up gnutls-2.12.21/lib/gnutls_priority.c.fips gnutls-2.12.21/lib/gnutls_priority.c
9199b3
--- gnutls-2.12.21/lib/gnutls_priority.c.fips	2012-11-08 17:11:11.000000000 +0100
9199b3
+++ gnutls-2.12.21/lib/gnutls_priority.c	2012-11-09 19:57:54.651624659 +0100
9199b3
@@ -30,6 +30,7 @@
9199b3
 #include "gnutls_algorithms.h"
9199b3
 #include "gnutls_errors.h"
9199b3
 #include <gnutls_num.h>
9199b3
+#include <gcrypt.h>
9199b3
 
9199b3
 static void
9199b3
 break_comma_list (char *etag,
9199b3
@@ -223,6 +224,13 @@ static const int protocol_priority[] = {
9199b3
   0
9199b3
 };
9199b3
 
9199b3
+static const int protocol_priority_fips[] = {
9199b3
+  GNUTLS_TLS1_2,
9199b3
+  GNUTLS_TLS1_1,
9199b3
+  GNUTLS_TLS1_0,
9199b3
+  0
9199b3
+};
9199b3
+
9199b3
 static const int kx_priority_performance[] = {
9199b3
   GNUTLS_KX_RSA,
9199b3
   GNUTLS_KX_DHE_RSA,
9199b3
@@ -269,6 +277,13 @@ static const int cipher_priority_perform
9199b3
   0
9199b3
 };
9199b3
 
9199b3
+static const int cipher_priority_performance_fips[] = {
9199b3
+  GNUTLS_CIPHER_AES_128_CBC,
9199b3
+  GNUTLS_CIPHER_3DES_CBC,
9199b3
+  GNUTLS_CIPHER_AES_256_CBC,
9199b3
+  0
9199b3
+};
9199b3
+
9199b3
 static const int cipher_priority_normal[] = {
9199b3
   GNUTLS_CIPHER_AES_128_CBC,
9199b3
 #ifdef	ENABLE_CAMELLIA
9199b3
@@ -284,6 +299,13 @@ static const int cipher_priority_normal[
9199b3
   0
9199b3
 };
9199b3
 
9199b3
+static const int cipher_priority_normal_fips[] = {
9199b3
+  GNUTLS_CIPHER_AES_128_CBC,
9199b3
+  GNUTLS_CIPHER_AES_256_CBC,
9199b3
+  GNUTLS_CIPHER_3DES_CBC,
9199b3
+  0
9199b3
+};
9199b3
+
9199b3
 static const int cipher_priority_secure128[] = {
9199b3
   GNUTLS_CIPHER_AES_128_CBC,
9199b3
 #ifdef	ENABLE_CAMELLIA
9199b3
@@ -295,6 +317,11 @@ static const int cipher_priority_secure1
9199b3
   0
9199b3
 };
9199b3
 
9199b3
+static const int cipher_priority_secure128_fips[] = {
9199b3
+  GNUTLS_CIPHER_AES_128_CBC,
9199b3
+  GNUTLS_CIPHER_3DES_CBC,
9199b3
+  0
9199b3
+};
9199b3
 
9199b3
 static const int cipher_priority_secure256[] = {
9199b3
   GNUTLS_CIPHER_AES_256_CBC,
9199b3
@@ -311,6 +338,13 @@ static const int cipher_priority_secure2
9199b3
   0
9199b3
 };
9199b3
 
9199b3
+static const int cipher_priority_secure256_fips[] = {
9199b3
+  GNUTLS_CIPHER_AES_256_CBC,
9199b3
+  GNUTLS_CIPHER_AES_128_CBC,
9199b3
+  GNUTLS_CIPHER_3DES_CBC,
9199b3
+  0
9199b3
+};
9199b3
+
9199b3
 /* The same as cipher_priority_security_normal + arcfour-40. */
9199b3
 static const int cipher_priority_export[] = {
9199b3
   GNUTLS_CIPHER_AES_128_CBC,
9199b3
@@ -362,6 +396,12 @@ static const int mac_priority_normal[] =
9199b3
   0
9199b3
 };
9199b3
 
9199b3
+static const int mac_priority_normal_fips[] = {
9199b3
+  GNUTLS_MAC_SHA1,
9199b3
+  GNUTLS_MAC_SHA256,
9199b3
+  0
9199b3
+};
9199b3
+
9199b3
 
9199b3
 static const int mac_priority_secure[] = {
9199b3
   GNUTLS_MAC_SHA256,
9199b3
@@ -462,6 +502,8 @@ gnutls_priority_set (gnutls_session_t se
9199b3
 
9199b3
 #define MAX_ELEMENTS 48
9199b3
 
9199b3
+extern int gnutls_gcrypt_fips;
9199b3
+
9199b3
 /**
9199b3
  * gnutls_priority_init:
9199b3
  * @priority_cache: is a #gnutls_prioritity_t structure.
9199b3
@@ -561,7 +603,7 @@ gnutls_priority_init (gnutls_priority_t
9199b3
    */
9199b3
   if (strcasecmp (broken_list[0], "NONE") != 0)
9199b3
     {
9199b3
-      _set_priority (&(*priority_cache)->protocol, protocol_priority);
9199b3
+      _set_priority (&(*priority_cache)->protocol, gnutls_gcrypt_fips?protocol_priority_fips:protocol_priority);
9199b3
       _set_priority (&(*priority_cache)->compression, comp_priority);
9199b3
       _set_priority (&(*priority_cache)->cert_type, cert_type_priority_default);
9199b3
       _set_priority (&(*priority_cache)->sign_algo, sign_priority_default);
9199b3
@@ -577,17 +619,17 @@ gnutls_priority_init (gnutls_priority_t
9199b3
       if (strcasecmp (broken_list[i], "PERFORMANCE") == 0)
9199b3
         {
9199b3
           _set_priority (&(*priority_cache)->cipher,
9199b3
-                         cipher_priority_performance);
9199b3
+                         gnutls_gcrypt_fips?cipher_priority_performance_fips:cipher_priority_performance);
9199b3
           _set_priority (&(*priority_cache)->kx, kx_priority_performance);
9199b3
-          _set_priority (&(*priority_cache)->mac, mac_priority_normal);
9199b3
+          _set_priority (&(*priority_cache)->mac, gnutls_gcrypt_fips?mac_priority_normal_fips:mac_priority_normal);
9199b3
           _set_priority (&(*priority_cache)->sign_algo,
9199b3
                          sign_priority_default);
9199b3
         }
9199b3
       else if (strcasecmp (broken_list[i], "NORMAL") == 0)
9199b3
         {
9199b3
-          _set_priority (&(*priority_cache)->cipher, cipher_priority_normal);
9199b3
+          _set_priority (&(*priority_cache)->cipher, gnutls_gcrypt_fips?cipher_priority_normal_fips:cipher_priority_normal);
9199b3
           _set_priority (&(*priority_cache)->kx, kx_priority_secure);
9199b3
-          _set_priority (&(*priority_cache)->mac, mac_priority_normal);
9199b3
+          _set_priority (&(*priority_cache)->mac, gnutls_gcrypt_fips?mac_priority_normal_fips:mac_priority_normal);
9199b3
           _set_priority (&(*priority_cache)->sign_algo,
9199b3
                          sign_priority_default);
9199b3
         }
9199b3
@@ -595,7 +637,7 @@ gnutls_priority_init (gnutls_priority_t
9199b3
                || strcasecmp (broken_list[i], "SECURE") == 0)
9199b3
         {
9199b3
           _set_priority (&(*priority_cache)->cipher,
9199b3
-                         cipher_priority_secure256);
9199b3
+                         gnutls_gcrypt_fips?cipher_priority_secure256_fips:cipher_priority_secure256);
9199b3
           _set_priority (&(*priority_cache)->kx, kx_priority_secure);
9199b3
           _set_priority (&(*priority_cache)->mac, mac_priority_secure);
9199b3
           _set_priority (&(*priority_cache)->sign_algo,
9199b3
@@ -604,7 +646,7 @@ gnutls_priority_init (gnutls_priority_t
9199b3
       else if (strcasecmp (broken_list[i], "SECURE128") == 0)
9199b3
         {
9199b3
           _set_priority (&(*priority_cache)->cipher,
9199b3
-                         cipher_priority_secure128);
9199b3
+                         gnutls_gcrypt_fips?cipher_priority_secure128_fips:cipher_priority_secure128);
9199b3
           _set_priority (&(*priority_cache)->kx, kx_priority_secure);
9199b3
           _set_priority (&(*priority_cache)->mac, mac_priority_secure);
9199b3
           _set_priority (&(*priority_cache)->sign_algo,
9199b3
@@ -646,7 +688,7 @@ gnutls_priority_init (gnutls_priority_t
9199b3
               if (strncasecmp (&broken_list[i][1], "VERS-TLS-ALL", 12) == 0)
9199b3
                 {
9199b3
                   bulk_fn (&(*priority_cache)->protocol,
9199b3
-                                 protocol_priority);
9199b3
+                                 gnutls_gcrypt_fips?protocol_priority_fips:protocol_priority);
9199b3
                 }
9199b3
               else
9199b3
                 {
9199b3
@@ -718,7 +760,7 @@ gnutls_priority_init (gnutls_priority_t
9199b3
           else if (strncasecmp (&broken_list[i][1], "CIPHER-ALL", 7) == 0)
9199b3
             {
9199b3
                   bulk_fn (&(*priority_cache)->cipher,
9199b3
-                                cipher_priority_normal);
9199b3
+                                gnutls_gcrypt_fips?cipher_priority_normal_fips:cipher_priority_normal);
9199b3
             }
9199b3
           else
9199b3
             goto error;