905-v2.6-0005-Fix-PTK-rekeying-to-generate-a-new-ANonce.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From 12fac09b437a1dc8a0f253e265934a8aaf4d2f8b Mon Sep 17 00:00:00 2001
  2. From: Jouni Malinen <j@w1.fi>
  3. Date: Sun, 1 Oct 2017 12:32:57 +0300
  4. Subject: [PATCH 5/8] Fix PTK rekeying to generate a new ANonce
  5. The Authenticator state machine path for PTK rekeying ended up bypassing
  6. the AUTHENTICATION2 state where a new ANonce is generated when going
  7. directly to the PTKSTART state since there is no need to try to
  8. determine the PMK again in such a case. This is far from ideal since the
  9. new PTK would depend on a new nonce only from the supplicant.
  10. Fix this by generating a new ANonce when moving to the PTKSTART state
  11. for the purpose of starting new 4-way handshake to rekey PTK.
  12. Signed-off-by: Jouni Malinen <j@w1.fi>
  13. ---
  14. src/ap/wpa_auth.c | 24 +++++++++++++++++++++---
  15. 1 file changed, 21 insertions(+), 3 deletions(-)
  16. diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
  17. index 707971d..bf10cc1 100644
  18. --- a/src/ap/wpa_auth.c
  19. +++ b/src/ap/wpa_auth.c
  20. @@ -1901,6 +1901,21 @@ SM_STATE(WPA_PTK, AUTHENTICATION2)
  21. }
  22. +static int wpa_auth_sm_ptk_update(struct wpa_state_machine *sm)
  23. +{
  24. + if (random_get_bytes(sm->ANonce, WPA_NONCE_LEN)) {
  25. + wpa_printf(MSG_ERROR,
  26. + "WPA: Failed to get random data for ANonce");
  27. + sm->Disconnect = TRUE;
  28. + return -1;
  29. + }
  30. + wpa_hexdump(MSG_DEBUG, "WPA: Assign new ANonce", sm->ANonce,
  31. + WPA_NONCE_LEN);
  32. + sm->TimeoutCtr = 0;
  33. + return 0;
  34. +}
  35. +
  36. +
  37. SM_STATE(WPA_PTK, INITPMK)
  38. {
  39. u8 msk[2 * PMK_LEN];
  40. @@ -2458,9 +2473,12 @@ SM_STEP(WPA_PTK)
  41. SM_ENTER(WPA_PTK, AUTHENTICATION);
  42. else if (sm->ReAuthenticationRequest)
  43. SM_ENTER(WPA_PTK, AUTHENTICATION2);
  44. - else if (sm->PTKRequest)
  45. - SM_ENTER(WPA_PTK, PTKSTART);
  46. - else switch (sm->wpa_ptk_state) {
  47. + else if (sm->PTKRequest) {
  48. + if (wpa_auth_sm_ptk_update(sm) < 0)
  49. + SM_ENTER(WPA_PTK, DISCONNECTED);
  50. + else
  51. + SM_ENTER(WPA_PTK, PTKSTART);
  52. + } else switch (sm->wpa_ptk_state) {
  53. case WPA_PTK_INITIALIZE:
  54. break;
  55. case WPA_PTK_DISCONNECT:
  56. --
  57. 2.7.4