From: Tobias Brunner Date: Tue, 17 May 2016 18:06:24 +0000 (+0200) Subject: unit-tests: Register nonce generator and make first nonce byte configurable X-Git-Tag: 5.5.0dr1~4^2~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dda5aab0f491d4be64fb04166fc4f4dcb68e4880;p=thirdparty%2Fstrongswan.git unit-tests: Register nonce generator and make first nonce byte configurable --- diff --git a/src/libcharon/tests/utils/exchange_test_helper.c b/src/libcharon/tests/utils/exchange_test_helper.c index 47da9e49a7..018804e6c8 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 @@ -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 9768d42d0f..861ce0d475 100644 --- a/src/libcharon/tests/utils/exchange_test_helper.h +++ b/src/libcharon/tests/utils/exchange_test_helper.h @@ -40,6 +40,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 *