aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/tests/utils
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2016-05-17 20:06:24 +0200
committerTobias Brunner <tobias@strongswan.org>2016-06-17 18:48:02 +0200
commitdda5aab0f491d4be64fb04166fc4f4dcb68e4880 (patch)
treea9a93bbe6e19e2f812ee58c16faa2b970bc60cba /src/libcharon/tests/utils
parent990c62cdcccea52f145e53e9f27acd1a66e7c6da (diff)
downloadstrongswan-dda5aab0f491d4be64fb04166fc4f4dcb68e4880.tar.bz2
strongswan-dda5aab0f491d4be64fb04166fc4f4dcb68e4880.tar.xz
unit-tests: Register nonce generator and make first nonce byte configurable
Diffstat (limited to 'src/libcharon/tests/utils')
-rw-r--r--src/libcharon/tests/utils/exchange_test_helper.c14
-rw-r--r--src/libcharon/tests/utils/exchange_test_helper.h6
2 files changed, 19 insertions, 1 deletions
diff --git a/src/libcharon/tests/utils/exchange_test_helper.c b/src/libcharon/tests/utils/exchange_test_helper.c
index 47da9e49a..018804e6c 100644
--- a/src/libcharon/tests/utils/exchange_test_helper.c
+++ b/src/libcharon/tests/utils/exchange_test_helper.c
@@ -14,8 +14,9 @@
*/
#include "exchange_test_helper.h"
-#include "mock_ipsec.h"
#include "mock_dh.h"
+#include "mock_ipsec.h"
+#include "mock_nonce_gen.h"
#include <credentials/sets/mem_cred.h>
@@ -196,6 +197,14 @@ static void initialize_logging()
charon->load_loggers(charon, NULL, TRUE);
}
+/**
+ * Create a nonce generator with the first byte
+ */
+static nonce_gen_t *create_nonce_gen()
+{
+ return mock_nonce_gen_create(exchange_test_helper->nonce_first_byte);
+}
+
/*
* Described in header
*/
@@ -208,6 +217,9 @@ void exchange_test_helper_init(char *plugins)
PLUGIN_PROVIDE(DH, MODP_2048_BIT),
PLUGIN_PROVIDE(DH, MODP_3072_BIT),
PLUGIN_PROVIDE(DH, ECP_256_BIT),
+ PLUGIN_REGISTER(NONCE_GEN, create_nonce_gen),
+ PLUGIN_PROVIDE(NONCE_GEN),
+ PLUGIN_DEPENDS(RNG, RNG_WEAK),
};
INIT(this,
diff --git a/src/libcharon/tests/utils/exchange_test_helper.h b/src/libcharon/tests/utils/exchange_test_helper.h
index 9768d42d0..861ce0d47 100644
--- a/src/libcharon/tests/utils/exchange_test_helper.h
+++ b/src/libcharon/tests/utils/exchange_test_helper.h
@@ -41,6 +41,12 @@ struct exchange_test_helper_t {
mock_sender_t *sender;
/**
+ * Set the initial byte of all nonces generated by future nonce
+ * generators (already instatiated nonce generators are not affected).
+ */
+ u_char nonce_first_byte;
+
+ /**
* Creates an established IKE_SA/CHILD_SA
*
* @param[out] init IKE_SA of the initiator