]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
unit-tests: Hand out an actual shared secret and pubkey in mock KE implementation
authorTobias Brunner <tobias@strongswan.org>
Tue, 15 Mar 2022 10:59:53 +0000 (11:59 +0100)
committerTobias Brunner <tobias@strongswan.org>
Thu, 14 Apr 2022 17:02:56 +0000 (19:02 +0200)
Makes this a bit more realistic and makes key derivation via OpenSSL's
HKDF work during tests.

src/libcharon/tests/utils/mock_dh.c

index 153bf1166455b2ccf14bbdbc3e391a8df2df95a6..f11679f0b60301d2bcbc1c23e4902cbcc6185a91 100644 (file)
 
 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;
 }