proposal: Add method to move a given DH group to the front
This way a responder (like strongSwan) selecting a proposal first and then checking if the KE payload matches sees the peer's preferred group first.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2016 Tobias Brunner
|
||||
* Copyright (C) 2008-2018 Tobias Brunner
|
||||
* Copyright (C) 2006-2010 Martin Willi
|
||||
* Copyright (C) 2013-2015 Andreas Steffen
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@@ -171,6 +171,36 @@ METHOD(proposal_t, has_dh_group, bool,
|
||||
return found;
|
||||
}
|
||||
|
||||
METHOD(proposal_t, promote_dh_group, bool,
|
||||
private_proposal_t *this, diffie_hellman_group_t group)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry;
|
||||
bool found = FALSE;
|
||||
|
||||
enumerator = array_create_enumerator(this->transforms);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (entry->type == DIFFIE_HELLMAN_GROUP &&
|
||||
entry->alg == group)
|
||||
{
|
||||
array_remove_at(this->transforms, enumerator);
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
if (found)
|
||||
{
|
||||
entry_t entry = {
|
||||
.type = DIFFIE_HELLMAN_GROUP,
|
||||
.alg = group,
|
||||
};
|
||||
array_insert(this->transforms, ARRAY_HEAD, &entry);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
METHOD(proposal_t, strip_dh, void,
|
||||
private_proposal_t *this, diffie_hellman_group_t keep)
|
||||
{
|
||||
@@ -716,6 +746,7 @@ proposal_t *proposal_create(protocol_id_t protocol, u_int number)
|
||||
.create_enumerator = _create_enumerator,
|
||||
.get_algorithm = _get_algorithm,
|
||||
.has_dh_group = _has_dh_group,
|
||||
.promote_dh_group = _promote_dh_group,
|
||||
.strip_dh = _strip_dh,
|
||||
.select = _select_proposal,
|
||||
.get_protocol = _get_protocol,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2016 Tobias Brunner
|
||||
* Copyright (C) 2009-2018 Tobias Brunner
|
||||
* Copyright (C) 2006 Martin Willi
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
@@ -108,7 +108,16 @@ struct proposal_t {
|
||||
* @param group group to check for
|
||||
* @return TRUE if algorithm included
|
||||
*/
|
||||
bool (*has_dh_group) (proposal_t *this, diffie_hellman_group_t group);
|
||||
bool (*has_dh_group)(proposal_t *this, diffie_hellman_group_t group);
|
||||
|
||||
/**
|
||||
* Move the given DH group to the front of the list if it was contained in
|
||||
* the proposal.
|
||||
*
|
||||
* @param group group to promote
|
||||
* @return TRUE if algorithm included
|
||||
*/
|
||||
bool (*promote_dh_group)(proposal_t *this, diffie_hellman_group_t group);
|
||||
|
||||
/**
|
||||
* Strip DH groups from proposal to use it without PFS.
|
||||
|
||||
Reference in New Issue
Block a user