* [PATCH] sae: support default group for H2E
@ 2024-08-12 17:16 James Prestwood
2024-08-12 18:14 ` Denis Kenzior
0 siblings, 1 reply; 3+ messages in thread
From: James Prestwood @ 2024-08-12 17:16 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
This was seemingly trivial at face value but doing so ended up
pointing out a bug with how group_retry is set when forcing
the default group. Since group_retry is initialized to -1 the
increment in the force_default_group block results in it being
set to zero, which is actually group 20, not 19. This did not
matter for hunt and peck, but H2E actually uses the retry value
to index its pre-generated points which then breaks SAE if
forcing the default group with H2E.
To handle H2E and force_default_group, the group selection
logic will always begin iterating the group array regardless of
SAE type.
---
src/sae.c | 41 ++++++++++++++++++-----------------------
1 file changed, 18 insertions(+), 23 deletions(-)
diff --git a/src/sae.c b/src/sae.c
index 9bce8faa..97c0af05 100644
--- a/src/sae.c
+++ b/src/sae.c
@@ -152,39 +152,34 @@ static int sae_choose_next_group(struct sae_sm *sm)
{
const unsigned int *ecc_groups = l_ecc_supported_ike_groups();
bool reset = sm->group_retry >= 0;
+ unsigned int group;
- /*
- * If this is a buggy AP in which group negotiation is broken use the
- * default group 19 and fail if this is a retry.
- */
- if (sm->sae_type == CRYPTO_SAE_LOOPING && sm->force_default_group) {
- if (sm->group_retry != -1) {
- l_warn("Forced default group but was rejected!");
- return -ENOENT;
- }
-
- sae_debug("Forcing default SAE group 19");
+ /* Find the next group in the list */
+ while ((group = ecc_groups[++sm->group_retry])) {
+ /*
+ * Forcing the default group; only choose group 19. If we have
+ * already passed 19 (due to a retry) we will exhaust all other
+ * groups and should fail.
+ */
+ if (sm->force_default_group && group != 19)
+ continue;
- sm->group_retry++;
- sm->group = 19;
+ /* Ensure the PT was derived for this group */
+ if (sm->sae_type == CRYPTO_SAE_HASH_TO_ELEMENT &&
+ !sm->handshake->ecc_sae_pts[sm->group_retry])
+ continue;
- goto get_curve;
+ break;
}
- do {
- sm->group_retry++;
+ if (!group)
+ return -ENOENT;
- if (ecc_groups[sm->group_retry] == 0)
- return -ENOENT;
- } while (sm->sae_type != CRYPTO_SAE_LOOPING &&
- !sm->handshake->ecc_sae_pts[sm->group_retry]);
+ sm->group = group;
if (reset)
sae_reset_state(sm);
- sm->group = ecc_groups[sm->group_retry];
-
-get_curve:
sae_debug("Using group %u", sm->group);
sm->curve = l_ecc_curve_from_ike_group(sm->group);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] sae: support default group for H2E
2024-08-12 17:16 [PATCH] sae: support default group for H2E James Prestwood
@ 2024-08-12 18:14 ` Denis Kenzior
2024-08-12 18:30 ` James Prestwood
0 siblings, 1 reply; 3+ messages in thread
From: Denis Kenzior @ 2024-08-12 18:14 UTC (permalink / raw)
To: James Prestwood, iwd
Hi James,
On 8/12/24 12:16 PM, James Prestwood wrote:
> This was seemingly trivial at face value but doing so ended up
> pointing out a bug with how group_retry is set when forcing
> the default group. Since group_retry is initialized to -1 the
> increment in the force_default_group block results in it being
> set to zero, which is actually group 20, not 19. This did not
> matter for hunt and peck, but H2E actually uses the retry value
> to index its pre-generated points which then breaks SAE if
> forcing the default group with H2E.
>
> To handle H2E and force_default_group, the group selection
> logic will always begin iterating the group array regardless of
> SAE type.
> ---
> src/sae.c | 41 ++++++++++++++++++-----------------------
> 1 file changed, 18 insertions(+), 23 deletions(-)
Applied. Do we have test for H2E & force behavior?
Regards,
-Denis
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sae: support default group for H2E
2024-08-12 18:14 ` Denis Kenzior
@ 2024-08-12 18:30 ` James Prestwood
0 siblings, 0 replies; 3+ messages in thread
From: James Prestwood @ 2024-08-12 18:30 UTC (permalink / raw)
To: Denis Kenzior, iwd
Hi Denis,
On 8/12/24 11:14 AM, Denis Kenzior wrote:
> Hi James,
>
> On 8/12/24 12:16 PM, James Prestwood wrote:
>> This was seemingly trivial at face value but doing so ended up
>> pointing out a bug with how group_retry is set when forcing
>> the default group. Since group_retry is initialized to -1 the
>> increment in the force_default_group block results in it being
>> set to zero, which is actually group 20, not 19. This did not
>> matter for hunt and peck, but H2E actually uses the retry value
>> to index its pre-generated points which then breaks SAE if
>> forcing the default group with H2E.
>>
>> To handle H2E and force_default_group, the group selection
>> logic will always begin iterating the group array regardless of
>> SAE type.
>> ---
>> src/sae.c | 41 ++++++++++++++++++-----------------------
>> 1 file changed, 18 insertions(+), 23 deletions(-)
>
> Applied. Do we have test for H2E & force behavior?
Meant to send that, its on the list now.
>
> Regards,
> -Denis
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-12 18:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-12 17:16 [PATCH] sae: support default group for H2E James Prestwood
2024-08-12 18:14 ` Denis Kenzior
2024-08-12 18:30 ` James Prestwood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox