diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2014-07-11 07:23:31 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2014-07-11 07:23:31 +0200 |
commit | 81c63b0eed39432878f78727f60a1e7499645199 (patch) | |
tree | 82387d8fecd1c20788fd8bd784a9b0bde091fb6b /src/libstrongswan/crypto | |
parent | c5ebfc7b9c16551fe825dc1d79c3f7e2f096f6c9 (diff) | |
download | vyos-strongswan-81c63b0eed39432878f78727f60a1e7499645199.tar.gz vyos-strongswan-81c63b0eed39432878f78727f60a1e7499645199.zip |
Imported Upstream version 5.2.0
Diffstat (limited to 'src/libstrongswan/crypto')
-rw-r--r-- | src/libstrongswan/crypto/crypto_factory.c | 18 | ||||
-rw-r--r-- | src/libstrongswan/crypto/crypto_tester.c | 8 | ||||
-rw-r--r-- | src/libstrongswan/crypto/transform.h | 2 |
3 files changed, 19 insertions, 9 deletions
diff --git a/src/libstrongswan/crypto/crypto_factory.c b/src/libstrongswan/crypto/crypto_factory.c index 6dea30ee3..96fbc0d87 100644 --- a/src/libstrongswan/crypto/crypto_factory.c +++ b/src/libstrongswan/crypto/crypto_factory.c @@ -392,10 +392,10 @@ METHOD(crypto_factory_t, create_dh, diffie_hellman_t*, /** * Insert an algorithm entry to a list * - * Entries are sorted by algorithm identifier (which is important for RNGs) - * while maintaining the order in which algorithms were added, unless they were + * Entries maintain the order in which algorithms were added, unless they were * benchmarked and speed is provided, which then is used to order entries of * the same algorithm. + * An exception are RNG entries, which are sorted by algorithm identifier. */ static void add_entry(private_crypto_factory_t *this, linked_list_t *list, int algo, const char *plugin_name, @@ -403,6 +403,7 @@ static void add_entry(private_crypto_factory_t *this, linked_list_t *list, { enumerator_t *enumerator; entry_t *entry, *current; + bool sort = (list == this->rngs), found = FALSE; INIT(entry, .algo = algo, @@ -415,12 +416,19 @@ static void add_entry(private_crypto_factory_t *this, linked_list_t *list, enumerator = list->create_enumerator(list); while (enumerator->enumerate(enumerator, ¤t)) { - if (current->algo > algo) + if (sort && current->algo > algo) { break; } - else if (current->algo == algo && speed && - current->speed < speed) + else if (current->algo == algo) + { + if (speed > current->speed) + { + break; + } + found = TRUE; + } + else if (found) { break; } diff --git a/src/libstrongswan/crypto/crypto_tester.c b/src/libstrongswan/crypto/crypto_tester.c index c6780daf1..d09844bfa 100644 --- a/src/libstrongswan/crypto/crypto_tester.c +++ b/src/libstrongswan/crypto/crypto_tester.c @@ -14,8 +14,10 @@ * for more details. */ -#define _GNU_SOURCE -#include <dlfcn.h> +#ifdef HAVE_DLADDR +# define _GNU_SOURCE +# include <dlfcn.h> +#endif #include <time.h> #include "crypto_tester.h" @@ -102,7 +104,7 @@ static const char* get_name(void *sym) return "unknown"; } -#ifdef CLOCK_THREAD_CPUTIME_ID +#if defined(CLOCK_THREAD_CPUTIME_ID) && defined(HAVE_CLOCK_GETTIME) /** * Start a benchmark timer diff --git a/src/libstrongswan/crypto/transform.h b/src/libstrongswan/crypto/transform.h index 4a98f81e9..a585e9784 100644 --- a/src/libstrongswan/crypto/transform.h +++ b/src/libstrongswan/crypto/transform.h @@ -23,7 +23,7 @@ typedef enum transform_type_t transform_type_t; -#include <utils/enum.h> +#include <utils/utils.h> /** * Type of a transform, as in IKEv2 RFC 3.3.2. |