summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2011-12-12 18:54:44 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2011-12-12 18:54:44 +0100
commit3360065611857d43b7619684755f262e8cc9c0e4 (patch)
treed67e259618c091474824fd73ecdffc49121bb33e /lib
parent55968012dcefc50590925b4ddcf556f8ca67a8b5 (diff)
downloadgnutls-3360065611857d43b7619684755f262e8cc9c0e4.tar.gz
gnutls_priority_get_cipher_suite was renamed to gnutls_priority_get_cipher_suite_index.
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/algorithms/ciphersuites.c49
-rw-r--r--lib/includes/gnutls/gnutls.h.in2
-rw-r--r--lib/libgnutls.map2
3 files changed, 21 insertions, 32 deletions
diff --git a/lib/algorithms/ciphersuites.c b/lib/algorithms/ciphersuites.c
index bdffef7131..6b4f034e32 100644
--- a/lib/algorithms/ciphersuites.c
+++ b/lib/algorithms/ciphersuites.c
@@ -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;
}
-
diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in
index 5b5fa583fc..2906eaad3d 100644
--- a/lib/includes/gnutls/gnutls.h.in
+++ b/lib/includes/gnutls/gnutls.h.in
@@ -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);
diff --git a/lib/libgnutls.map b/lib/libgnutls.map
index 0abb8009a6..24f04f0d74 100644
--- a/lib/libgnutls.map
+++ b/lib/libgnutls.map
@@ -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 {