eap_eke_common.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * EAP server/peer: EAP-EKE shared routines
  3. * Copyright (c) 2011-2013, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #ifndef EAP_EKE_COMMON_H
  9. #define EAP_EKE_COMMON_H
  10. /* EKE Exchange */
  11. #define EAP_EKE_ID 1
  12. #define EAP_EKE_COMMIT 2
  13. #define EAP_EKE_CONFIRM 3
  14. #define EAP_EKE_FAILURE 4
  15. /* Diffie-Hellman Group Registry */
  16. #define EAP_EKE_DHGROUP_EKE_2 1
  17. #define EAP_EKE_DHGROUP_EKE_5 2
  18. #define EAP_EKE_DHGROUP_EKE_14 3 /* mandatory to implement */
  19. #define EAP_EKE_DHGROUP_EKE_15 4
  20. #define EAP_EKE_DHGROUP_EKE_16 5
  21. /* Encryption Algorithm Registry */
  22. #define EAP_EKE_ENCR_AES128_CBC 1 /* mandatory to implement */
  23. /* Pseudo Random Function Registry */
  24. #define EAP_EKE_PRF_HMAC_SHA1 1 /* mandatory to implement */
  25. #define EAP_EKE_PRF_HMAC_SHA2_256 2
  26. /* Keyed Message Digest (MAC) Registry */
  27. #define EAP_EKE_MAC_HMAC_SHA1 1 /* mandatory to implement */
  28. #define EAP_EKE_MAC_HMAC_SHA2_256 2
  29. /* Identity Type Registry */
  30. #define EAP_EKE_ID_OPAQUE 1
  31. #define EAP_EKE_ID_NAI 2
  32. #define EAP_EKE_ID_IPv4 3
  33. #define EAP_EKE_ID_IPv6 4
  34. #define EAP_EKE_ID_FQDN 5
  35. #define EAP_EKE_ID_DN 6
  36. /* Failure-Code */
  37. #define EAP_EKE_FAIL_NO_ERROR 1
  38. #define EAP_EKE_FAIL_PROTO_ERROR 2
  39. #define EAP_EKE_FAIL_PASSWD_NOT_FOUND 3
  40. #define EAP_EKE_FAIL_AUTHENTICATION_FAIL 4
  41. #define EAP_EKE_FAIL_AUTHORIZATION_FAIL 5
  42. #define EAP_EKE_FAIL_NO_PROPOSAL_CHOSEN 6
  43. #define EAP_EKE_FAIL_PRIVATE_INTERNAL_ERROR 0xffffffff
  44. #define EAP_EKE_MAX_DH_LEN 512
  45. #define EAP_EKE_MAX_HASH_LEN 32
  46. #define EAP_EKE_MAX_KEY_LEN 16
  47. #define EAP_EKE_MAX_KE_LEN 16
  48. #define EAP_EKE_MAX_KI_LEN 32
  49. #define EAP_EKE_MAX_KA_LEN 32
  50. #define EAP_EKE_MAX_NONCE_LEN 16
  51. struct eap_eke_session {
  52. /* Selected proposal */
  53. u8 dhgroup;
  54. u8 encr;
  55. u8 prf;
  56. u8 mac;
  57. u8 shared_secret[EAP_EKE_MAX_HASH_LEN];
  58. u8 ke[EAP_EKE_MAX_KE_LEN];
  59. u8 ki[EAP_EKE_MAX_KI_LEN];
  60. u8 ka[EAP_EKE_MAX_KA_LEN];
  61. int prf_len;
  62. int nonce_len;
  63. int auth_len;
  64. int dhcomp_len;
  65. int pnonce_len;
  66. int pnonce_ps_len;
  67. };
  68. int eap_eke_session_init(struct eap_eke_session *sess, u8 dhgroup, u8 encr,
  69. u8 prf, u8 mac);
  70. void eap_eke_session_clean(struct eap_eke_session *sess);
  71. int eap_eke_dh_init(u8 group, u8 *ret_priv, u8 *ret_pub);
  72. int eap_eke_derive_key(struct eap_eke_session *sess,
  73. const u8 *password, size_t password_len,
  74. const u8 *id_s, size_t id_s_len, const u8 *id_p,
  75. size_t id_p_len, u8 *key);
  76. int eap_eke_dhcomp(struct eap_eke_session *sess, const u8 *key, const u8 *dhpub,
  77. u8 *ret_dhcomp);
  78. int eap_eke_shared_secret(struct eap_eke_session *sess, const u8 *key,
  79. const u8 *dhpriv, const u8 *peer_dhcomp);
  80. int eap_eke_derive_ke_ki(struct eap_eke_session *sess,
  81. const u8 *id_s, size_t id_s_len,
  82. const u8 *id_p, size_t id_p_len);
  83. int eap_eke_derive_ka(struct eap_eke_session *sess,
  84. const u8 *id_s, size_t id_s_len,
  85. const u8 *id_p, size_t id_p_len,
  86. const u8 *nonce_p, const u8 *nonce_s);
  87. int eap_eke_derive_msk(struct eap_eke_session *sess,
  88. const u8 *id_s, size_t id_s_len,
  89. const u8 *id_p, size_t id_p_len,
  90. const u8 *nonce_p, const u8 *nonce_s,
  91. u8 *msk, u8 *emsk);
  92. int eap_eke_prot(struct eap_eke_session *sess,
  93. const u8 *data, size_t data_len,
  94. u8 *prot, size_t *prot_len);
  95. int eap_eke_decrypt_prot(struct eap_eke_session *sess,
  96. const u8 *prot, size_t prot_len,
  97. u8 *data, size_t *data_len);
  98. int eap_eke_auth(struct eap_eke_session *sess, const char *label,
  99. const struct wpabuf *msgs, u8 *auth);
  100. #endif /* EAP_EKE_COMMON_H */