]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
gnutls_priority_get_cipher_suite was renamed to gnutls_priority_get_cipher_suite_index.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 12 Dec 2011 17:54:44 +0000 (18:54 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 12 Dec 2011 17:54:44 +0000 (18:54 +0100)
This makes a more consistent API at the cost of requiring gnutls_get_cipher_suite_info().
An advantage however is that more information can now be accessed.

NEWS
doc/manpages/Makefile.am
lib/algorithms/ciphersuites.c
lib/includes/gnutls/gnutls.h.in
lib/libgnutls.map
src/common.c

diff --git a/NEWS b/NEWS
index cf95e504b7e5c1d1a3f32adbd6b6d1157026561e..29127d6fa1510f9db37ac2b5fdb0a661720318c9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,8 +16,9 @@ session, a server will not store that session data into its cache.
 
 ** libgnutls: Added the SECP192R1 curve.
 
-** libgnutls: Added gnutls_priority_get_cipher_suite() to
+** libgnutls: Added gnutls_priority_get_cipher_suite_index() to
 allow listing the ciphersuites enabled in a priority structure.
+It outputs and index to be used in gnutls_get_cipher_suite_info().
 
 ** libgnutls: Optimizations in the elliptic curve code (timing
 attacks resistant code is only used in ECDSA private key operations).
@@ -26,7 +27,7 @@ attacks resistant code is only used in ECDSA private key operations).
 now added again in the distribution.
 
 ** API and ABI modifications:
-gnutls_priority_get_cipher_suite: Added
+gnutls_priority_get_cipher_suite_index: Added
 
 
 * Version 3.0.8 (released 2011-11-12)
index e4010fc296061e80d8418be0b1fb9a7aca03ec3a..4b7baeddc7fe92c2978c0465c116f21132538270 100644 (file)
@@ -215,6 +215,7 @@ APIMANS += gnutls_session_ticket_enable_server.3
 APIMANS += gnutls_key_generate.3
 APIMANS += gnutls_priority_init.3
 APIMANS += gnutls_priority_deinit.3
+APIMANS += gnutls_priority_get_cipher_suite.3
 APIMANS += gnutls_priority_set.3
 APIMANS += gnutls_priority_set_direct.3
 APIMANS += gnutls_set_default_priority.3
index bdffef7131ead07b6ea987cd40495d6b6b24fdda..6b4f034e32992e7347fe6dbad8c6dc95bec58028 100644 (file)
@@ -824,24 +824,24 @@ _gnutls_supported_ciphersuites (gnutls_session_t session,
 /**
  * gnutls_priority_get_cipher_suite:
  * @pcache: is a #gnutls_prioritity_t structure.
- * @idx: is an index number
- * @name: Will point to the ciphersuite name
- * @cs_id: output buffer with room for 2 bytes, indicating cipher suite value
+ * @idx: is an index number.
+ * @sidx: internal index of cipher suite to get information about.
  *
- * Provides ciphersuite information. The index provided is an internal
- * index kept at the priorities structure. It might be that a valid index
- * does not correspond to a ciphersuite and in that case %GNUTLS_E_UNKNOWN_CIPHER_SUITE
- * will be returned. Once the last available index is crossed then 
+ * Provides the internal ciphersuite index to be used with
+ * gnutls_cipher_suite_info(). The index @idx provided is an 
+ * index kept at the priorities structure. It might be that a valid
+ * priorities index does not correspond to a ciphersuite and in 
+ * that case %GNUTLS_E_UNKNOWN_CIPHER_SUITE will be returned. 
+ * Once the last available index is crossed then 
  * %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
  *
  * Returns: On success it returns %GNUTLS_E_SUCCESS (0), or a negative error value otherwise.
  **/
 int
-gnutls_priority_get_cipher_suite (gnutls_priority_t pcache, int idx, const char** name, unsigned char cs_id[2])
+gnutls_priority_get_cipher_suite_index (gnutls_priority_t pcache, unsigned int idx, unsigned int *sidx)
 {
-int mac_idx, cipher_idx, kx_idx;
+int mac_idx, cipher_idx, kx_idx, i;
 int total = pcache->mac.algorithms * pcache->cipher.algorithms * pcache->kx.algorithms;
-const gnutls_cipher_suite_entry * ce;
 
   if (idx >= total)
     return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
@@ -854,26 +854,15 @@ const gnutls_cipher_suite_entry * ce;
   idx /= pcache->cipher.algorithms;
   kx_idx = idx % pcache->kx.algorithms;
 
-  ce = cipher_suite_get(pcache->kx.priority[kx_idx], pcache->cipher.priority[cipher_idx],
-                        pcache->mac.priority[mac_idx]);
-  
-  if (ce == NULL) 
-    {
-      *name = NULL;
-      memset(cs_id, 0, 2);
-    }
-  else 
-    {
-      *name = ce->name;
-      memcpy(cs_id, ce->id.suite, 2);
-    }
-
-  if (*name == NULL) 
+  for (i=0;i<CIPHER_SUITES_COUNT;i++)
     {
-      *name = "(no corresponding ciphersuite)";
-      return GNUTLS_E_UNKNOWN_CIPHER_SUITE;
+      if (cs_algorithms[i].kx_algorithm == pcache->kx.priority[kx_idx] &&
+          cs_algorithms[i].block_algorithm == pcache->cipher.priority[cipher_idx] &&
+          cs_algorithms[i].mac_algorithm == pcache->mac.priority[mac_idx])
+        {
+          *sidx = i;
+          return 0;
+        }
     }
-    
-  return 0;
+  return GNUTLS_E_UNKNOWN_CIPHER_SUITE;
 }
-
index 5b5fa583fc454de7513b47e663104db29629b02d..2906eaad3d659063041c3344ede30c5e1f873d13 100644 (file)
@@ -909,7 +909,7 @@ gnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);
   int gnutls_priority_init (gnutls_priority_t * priority_cache,
                             const char *priorities, const char **err_pos);
   void gnutls_priority_deinit (gnutls_priority_t priority_cache);
-  int gnutls_priority_get_cipher_suite (gnutls_priority_t pcache, int idx, const char** name, unsigned char cs_id[2]);
+  int gnutls_priority_get_cipher_suite_index (gnutls_priority_t pcache, unsigned int idx, unsigned int *sidx);
 
   int gnutls_priority_set (gnutls_session_t session,
                            gnutls_priority_t priority);
index 0abb8009a6624347abc7cfcde2c01f8cebaf656f..24f04f0d7420981e918d2081223908b083565a53 100644 (file)
@@ -725,7 +725,7 @@ GNUTLS_3_0_0 {
        gnutls_srp_4096_group_generator;
        gnutls_srp_4096_group_prime;
        gnutls_x509_privkey_verify_params;
-       gnutls_priority_get_cipher_suite;
+       gnutls_priority_get_cipher_suite_index;
 } GNUTLS_2_12;
 
 GNUTLS_PRIVATE {
index 0cfc0aa0c62491948ec4b8390c078eeed3c5cc87..d00bf5764c135cf18c29966212dbceaa519957c5 100644 (file)
@@ -574,6 +574,7 @@ print_list (const char* priorities, int verbose)
 {
     size_t i;
     int ret;
+    unsigned int idx;
     const char *name;
     const char *err;
     unsigned char id[2];
@@ -596,11 +597,16 @@ print_list (const char* priorities, int verbose)
       
         for (i=0;;i++)
           {
-            ret = gnutls_priority_get_cipher_suite(pcache, i, &name, id);
+            ret = gnutls_priority_get_cipher_suite_index(pcache, i, &idx);
             if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) break;
             if (ret == GNUTLS_E_UNKNOWN_CIPHER_SUITE) continue;
             
-            printf ("%-50s\t0x%02x, 0x%02x\n", name, id[0], id[1]);
+            name = gnutls_cipher_suite_info(idx, id, NULL, NULL, NULL, &version);
+            
+            if (name != NULL)
+              printf ("%-50s\t0x%02x, 0x%02x\t%s\n",
+                      name, (unsigned char) id[0], (unsigned char) id[1],
+                      gnutls_protocol_get_name (version));
           }
           
         return;