summaryrefslogtreecommitdiff
path: root/lib/priority.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-06-21 10:25:32 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2017-07-10 07:25:53 +0000
commit40ca6dc6830450cc02877d4af88e12a07bd6607f (patch)
tree7f56dd01f09daa4a7bf527bb32237ac6e534a076 /lib/priority.c
parent00727c8f208651cddb87fb9024eaf8e1e3f59018 (diff)
downloadgnutls-40ca6dc6830450cc02877d4af88e12a07bd6607f.tar.gz
priority: include a cache of supported ciphersuites
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib/priority.c')
-rw-r--r--lib/priority.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/priority.c b/lib/priority.c
index a56b031d12..214dd89aae 100644
--- a/lib/priority.c
+++ b/lib/priority.c
@@ -33,6 +33,7 @@
#include <extensions.h>
#include "fips.h"
#include "errno.h"
+#include <gnutls/gnutls.h>
#define MAX_ELEMENTS 64
@@ -1107,6 +1108,29 @@ finish:
return ret;
}
+static void set_ciphersuite_list(gnutls_priority_t priority_cache)
+{
+ unsigned i, j, z;
+ const gnutls_cipher_suite_entry_st *ce;
+
+ priority_cache->cs.size = 0;
+
+ for (i = 0; i < priority_cache->kx.algorithms; i++) {
+ for (j=0;j<priority_cache->cipher.algorithms;j++) {
+ for (z=0;z<priority_cache->mac.algorithms;z++) {
+ ce = cipher_suite_get(
+ priority_cache->kx.priority[i],
+ priority_cache->cipher.priority[j],
+ priority_cache->mac.priority[z]);
+
+ if (ce != NULL && priority_cache->cs.size < MAX_CIPHERSUITE_SIZE) {
+ priority_cache->cs.entry[priority_cache->cs.size++] = ce;
+ }
+ }
+ }
+ }
+}
+
/**
* gnutls_priority_init:
* @priority_cache: is a #gnutls_prioritity_t type.
@@ -1400,6 +1424,9 @@ gnutls_priority_init(gnutls_priority_t * priority_cache,
}
free(darg);
+
+ set_ciphersuite_list(*priority_cache);
+
return 0;
error: