summaryrefslogtreecommitdiff
path: root/lib/algorithms
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-06-23 11:55:23 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2017-07-10 07:25:55 +0000
commitde0d864239268fbf7418528d090f22d52601386b (patch)
tree5082b6e949a28a2358b0268a92d058d055c7221a /lib/algorithms
parent5ab58b7fc5f1e9646ea8b94b48d35a179457c861 (diff)
downloadgnutls-de0d864239268fbf7418528d090f22d52601386b.tar.gz
Eliminated access to obsolete priority cache fields
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib/algorithms')
-rw-r--r--lib/algorithms/ciphers.c16
-rw-r--r--lib/algorithms/ciphersuites.c47
-rw-r--r--lib/algorithms/kx.c13
-rw-r--r--lib/algorithms/mac.c13
4 files changed, 15 insertions, 74 deletions
diff --git a/lib/algorithms/ciphers.c b/lib/algorithms/ciphers.c
index 6143467bcd..04d675acda 100644
--- a/lib/algorithms/ciphers.c
+++ b/lib/algorithms/ciphers.c
@@ -294,22 +294,6 @@ unsigned gnutls_cipher_get_iv_size(gnutls_cipher_algorithm_t algorithm)
return ret;
}
-
- /* returns the priority */
-int
-_gnutls_cipher_priority(gnutls_session_t session,
- gnutls_cipher_algorithm_t algorithm)
-{
- unsigned int i;
- for (i = 0; i < session->internals.priorities.cipher.algorithms;
- i++) {
- if (session->internals.priorities.cipher.priority[i] ==
- algorithm)
- return i;
- }
- return -1;
-}
-
/**
* gnutls_cipher_get_key_size:
* @algorithm: is an encryption algorithm
diff --git a/lib/algorithms/ciphersuites.c b/lib/algorithms/ciphersuites.c
index 0bbd87dd19..9ea7371dd8 100644
--- a/lib/algorithms/ciphersuites.c
+++ b/lib/algorithms/ciphersuites.c
@@ -1567,25 +1567,13 @@ gnutls_priority_get_cipher_suite_index(gnutls_priority_t pcache,
unsigned int idx,
unsigned int *sidx)
{
- int mac_idx, cipher_idx, kx_idx;
unsigned int i, j;
- unsigned int total =
- pcache->mac.algorithms * pcache->cipher.algorithms *
- pcache->kx.algorithms;
unsigned max_tls = 0;
unsigned max_dtls = 0;
- if (idx >= total)
+ if (idx >= pcache->cs.size)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
- mac_idx = idx % pcache->mac.algorithms;
-
- idx /= pcache->mac.algorithms;
- cipher_idx = idx % pcache->cipher.algorithms;
-
- idx /= pcache->cipher.algorithms;
- kx_idx = idx % pcache->kx.algorithms;
-
/* find max_tls and max_dtls */
for (j=0;j<pcache->protocol.algorithms;j++) {
if (pcache->protocol.priority[j] <= GNUTLS_TLS_VERSION_MAX &&
@@ -1598,25 +1586,20 @@ gnutls_priority_get_cipher_suite_index(gnutls_priority_t pcache,
}
for (i = 0; i < CIPHER_SUITES_COUNT; i++) {
- 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;
-
- if (_gnutls_cipher_exists(cs_algorithms[i].block_algorithm) &&
- _gnutls_mac_exists(cs_algorithms[i].mac_algorithm)) {
-
- if (max_tls >= cs_algorithms[i].min_version) {
- return 0;
- } else if (max_dtls >= cs_algorithms[i].min_dtls_version) {
- return 0;
- }
- } else
- break;
- }
+ if (pcache->cs.entry[idx] != &cs_algorithms[i])
+ continue;
+
+ *sidx = i;
+ if (_gnutls_cipher_exists(cs_algorithms[i].block_algorithm) &&
+ _gnutls_mac_exists(cs_algorithms[i].mac_algorithm)) {
+ if (max_tls >= cs_algorithms[i].min_version) {
+ return 0;
+ } else if (max_dtls >= cs_algorithms[i].min_dtls_version) {
+ return 0;
+ }
+ } else
+ break;
}
+
return GNUTLS_E_UNKNOWN_CIPHER_SUITE;
}
diff --git a/lib/algorithms/kx.c b/lib/algorithms/kx.c
index f03ae84bc7..276f56f118 100644
--- a/lib/algorithms/kx.c
+++ b/lib/algorithms/kx.c
@@ -146,19 +146,6 @@ mod_auth_st *_gnutls_kx_auth_struct(gnutls_kx_algorithm_t algorithm)
}
-int
-_gnutls_kx_priority(gnutls_session_t session,
- gnutls_kx_algorithm_t algorithm)
-{
- unsigned int i;
- for (i = 0; i < session->internals.priorities.kx.algorithms; i++) {
- if (session->internals.priorities.kx.priority[i] ==
- algorithm)
- return i;
- }
- return -1;
-}
-
/**
* gnutls_kx_get_name:
* @algorithm: is a key exchange algorithm
diff --git a/lib/algorithms/mac.c b/lib/algorithms/mac.c
index f9b3537403..ce2d18c154 100644
--- a/lib/algorithms/mac.c
+++ b/lib/algorithms/mac.c
@@ -82,19 +82,6 @@ const mac_entry_st *_gnutls_mac_to_entry(gnutls_mac_algorithm_t c)
return NULL;
}
-int
-_gnutls_mac_priority(gnutls_session_t session,
- gnutls_mac_algorithm_t algorithm)
-{ /* actually returns the priority */
- unsigned int i;
- for (i = 0; i < session->internals.priorities.mac.algorithms; i++) {
- if (session->internals.priorities.mac.priority[i] ==
- algorithm)
- return i;
- }
- return -1;
-}
-
/**
* gnutls_mac_get_name:
* @algorithm: is a MAC algorithm