summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2013-04-02 20:08:42 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2013-04-02 21:51:26 +0200
commit651a98012d64e2a6b12806dcdb60e036083f09c5 (patch)
treeaf14871291ed6834896ae425f8e17dbe22a0239c
parentdd9909b237a42ee38ad0bb0af56828151fa69b0a (diff)
downloadgnutls-651a98012d64e2a6b12806dcdb60e036083f09c5.tar.gz
make a short list of the available PK algorithms
-rw-r--r--lib/gnutls_handshake.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c
index e0dd730c3a..a87e90650f 100644
--- a/lib/gnutls_handshake.c
+++ b/lib/gnutls_handshake.c
@@ -777,8 +777,10 @@ server_find_pk_algos_in_ciphersuites (const uint8_t *
gnutls_pk_algorithm_t * algos,
size_t* algos_size)
{
- unsigned int j;
+ unsigned int j, x;
gnutls_kx_algorithm_t kx;
+ gnutls_pk_algorithm_t pk;
+ unsigned found;
unsigned int max = *algos_size;
if (datalen % 2 != 0)
@@ -793,10 +795,23 @@ server_find_pk_algos_in_ciphersuites (const uint8_t *
kx = _gnutls_cipher_suite_get_kx_algo (&data[j]);
if (_gnutls_map_kx_get_cred (kx, 1) == GNUTLS_CRD_CERTIFICATE)
{
- algos[(*algos_size)++] = _gnutls_map_pk_get_pk (kx);
+ pk = _gnutls_map_pk_get_pk (kx);
+ found = 0;
+ for (x=0;x<*algos_size;x++)
+ {
+ if (algos[x] == pk)
+ {
+ found = 1;
+ break;
+ }
+ }
- if ((*algos_size) >= max)
- return 0;
+ if (found == 0)
+ {
+ algos[(*algos_size)++] = _gnutls_map_pk_get_pk (kx);
+ if ((*algos_size) >= max)
+ return 0;
+ }
}
}
@@ -852,7 +867,7 @@ _gnutls_server_select_suite (gnutls_session_t session, uint8_t * data,
ret = _gnutls_supported_ciphersuites (session, cipher_suites, sizeof(cipher_suites));
if (ret < 0)
return gnutls_assert_val(ret);
-
+
cipher_suites_size = ret;
/* Here we remove any ciphersuite that does not conform
@@ -3138,7 +3153,6 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
* by that certificate and are on the same authentication
* method (CERTIFICATE).
*/
-
cert_cred =
(gnutls_certificate_credentials_t) _gnutls_get_cred (session->key,
GNUTLS_CRD_CERTIFICATE,