/*
- * Copyright (C) 2010-2019 Tobias Brunner
+ * Copyright (C) 2010-2020 Tobias Brunner
* Copyright (C) 2005-2010 Martin Willi
* Copyright (C) 2005 Jan Hutter
*
}
return valid;
}
+
+/*
+ * Described in header
+ */
+bool key_exchange_concat_secrets(array_t *kes, chunk_t *first,
+ chunk_t *others)
+{
+ key_exchange_t *ke;
+ chunk_t secret;
+ int i;
+
+ if (!array_count(kes))
+ {
+ return FALSE;
+ }
+ *first = chunk_empty;
+ *others = chunk_empty;
+ for (i = 0; i < array_count(kes); i++)
+ {
+ if (array_get(kes, i, &ke) &&
+ ke->get_shared_secret(ke, &secret))
+ {
+ if (i == 0)
+ {
+ *first = secret;
+ }
+ else
+ {
+ *others = chunk_cat("ss", *others, secret);
+ }
+ }
+ else
+ {
+ chunk_clear(first);
+ chunk_clear(others);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
/*
- * Copyright (C) 2010-2019 Tobias Brunner
+ * Copyright (C) 2010-2020 Tobias Brunner
* Copyright (C) 2005-2007 Martin Willi
* Copyright (C) 2005 Jan Hutter
*
typedef struct diffie_hellman_params_t diffie_hellman_params_t;
#include <library.h>
+#include <collections/array.h>
/**
* Key exchange method.
*/
bool key_exchange_verify_pubkey(key_exchange_method_t ke, chunk_t value);
+/**
+ * Return the first shared secret plus the concatenated additional shared
+ * secrets of all the key exchange methods in the given array.
+ *
+ * @param kes array of key_exchange_t*
+ * @param secret first shared secret (allocated)
+ * @param add_secret concatenated additional shared secrets (allocated)
+ * @return TRUE on success
+ */
+bool key_exchange_concat_secrets(array_t *kes, chunk_t *secret,
+ chunk_t *add_secret);
+
#endif /** KEY_EXCHANGE_H_ @}*/