From 743b4861189bef333fe6859cc135af8e167e5d3a Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 15 Mar 2022 11:59:53 +0100 Subject: [PATCH] unit-tests: Hand out an actual shared secret and pubkey in mock KE implementation Makes this a bit more realistic and makes key derivation via OpenSSL's HKDF work during tests. --- src/libcharon/tests/utils/mock_dh.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libcharon/tests/utils/mock_dh.c b/src/libcharon/tests/utils/mock_dh.c index 153bf11664..f11679f0b6 100644 --- a/src/libcharon/tests/utils/mock_dh.c +++ b/src/libcharon/tests/utils/mock_dh.c @@ -18,6 +18,13 @@ typedef struct private_diffie_hellman_t private_diffie_hellman_t; +/** Mock DH public and shared key */ +static chunk_t mock_key = chunk_from_chars( + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08, + 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08); + /** * Private data */ @@ -37,7 +44,7 @@ struct private_diffie_hellman_t { METHOD(diffie_hellman_t, get_my_public_value, bool, private_diffie_hellman_t *this, chunk_t *value) { - *value = chunk_empty; + *value = chunk_clone(mock_key); return TRUE; } @@ -50,7 +57,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool, METHOD(diffie_hellman_t, get_shared_secret, bool, private_diffie_hellman_t *this, chunk_t *secret) { - *secret = chunk_empty; + *secret = chunk_clone(mock_key); return TRUE; }