From: Tobias Brunner Date: Tue, 15 Mar 2022 10:59:53 +0000 (+0100) Subject: unit-tests: Hand out an actual shared secret and pubkey in mock KE implementation X-Git-Tag: 5.9.6rc1~2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=743b4861189bef333fe6859cc135af8e167e5d3a;p=thirdparty%2Fstrongswan.git 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. --- 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; }