]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - src/common/dpp.h
DPP2: PFS for PTK derivation
[thirdparty/hostap.git] / src / common / dpp.h
index 161ffb94253ba1f0a84b4bb489024b201314a7cf..2a6f72dda17d2611169d6b4fd06fb0bcb0a7a1f7 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * DPP functionality shared between hostapd and wpa_supplicant
  * Copyright (c) 2017, Qualcomm Atheros, Inc.
+ * Copyright (c) 2018-2019, The Linux Foundation
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -15,6 +16,8 @@
 #include "common/wpa_common.h"
 #include "crypto/sha256.h"
 
+struct crypto_ecdh;
+
 #define DPP_HDR_LEN (4 + 2) /* OUI, OUI Type, Crypto Suite, DPP frame type */
 
 enum dpp_public_action_frame_type {
@@ -27,6 +30,7 @@ enum dpp_public_action_frame_type {
        DPP_PA_PKEX_EXCHANGE_RESP = 8,
        DPP_PA_PKEX_COMMIT_REVEAL_REQ = 9,
        DPP_PA_PKEX_COMMIT_REVEAL_RESP = 10,
+       DPP_PA_CONFIGURATION_RESULT = 11,
 };
 
 enum dpp_attribute_id {
@@ -54,7 +58,8 @@ enum dpp_attribute_id {
        DPP_ATTR_TRANSACTION_ID = 0x1016,
        DPP_ATTR_BOOTSTRAP_INFO = 0x1017,
        DPP_ATTR_CHANNEL = 0x1018,
-       DPP_ATTR_TESTING = 0x10ff, /* not defined in the DPP tech spec */
+       DPP_ATTR_PROTOCOL_VERSION = 0x1019,
+       DPP_ATTR_ENVELOPED_DATA = 0x101A,
 };
 
 enum dpp_status_error {
@@ -67,6 +72,7 @@ enum dpp_status_error {
        DPP_STATUS_RESPONSE_PENDING = 6,
        DPP_STATUS_INVALID_CONNECTOR = 7,
        DPP_STATUS_NO_MATCH = 8,
+       DPP_STATUS_CONFIG_REJECTED = 9,
 };
 
 #define DPP_CAPAB_ENROLLEE BIT(0)
@@ -132,31 +138,49 @@ struct dpp_pkex {
        struct wpabuf *exchange_req;
        struct wpabuf *exchange_resp;
        unsigned int t; /* number of failures on code use */
+       unsigned int exch_req_wait_time;
+       unsigned int exch_req_tries;
+       unsigned int freq;
+};
+
+enum dpp_akm {
+       DPP_AKM_UNKNOWN,
+       DPP_AKM_DPP,
+       DPP_AKM_PSK,
+       DPP_AKM_SAE,
+       DPP_AKM_PSK_SAE,
+       DPP_AKM_SAE_DPP,
+       DPP_AKM_PSK_SAE_DPP,
 };
 
 struct dpp_configuration {
        u8 ssid[32];
        size_t ssid_len;
-       int dpp; /* whether to use DPP or legacy configuration */
+       enum dpp_akm akm;
 
        /* For DPP configuration (connector) */
        os_time_t netaccesskey_expiry;
 
        /* TODO: groups */
+       char *group_id;
 
        /* For legacy configuration */
        char *passphrase;
        u8 psk[32];
+       int psk_set;
 };
 
 struct dpp_authentication {
        void *msg_ctx;
+       u8 peer_version;
        const struct dpp_curve_params *curve;
        struct dpp_bootstrap_info *peer_bi;
        struct dpp_bootstrap_info *own_bi;
+       struct dpp_bootstrap_info *tmp_own_bi;
        u8 waiting_pubkey_hash[SHA256_MAC_LEN];
        int response_pending;
        enum dpp_status_error auth_resp_status;
+       enum dpp_status_error conf_resp_status;
        u8 peer_mac_addr[ETH_ALEN];
        u8 i_nonce[DPP_MAX_NONCE_LEN];
        u8 r_nonce[DPP_MAX_NONCE_LEN];
@@ -176,18 +200,27 @@ struct dpp_authentication {
        unsigned int num_freq_iters;
        size_t secret_len;
        u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
+       size_t Mx_len;
        u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
+       size_t Nx_len;
        u8 Lx[DPP_MAX_SHARED_SECRET_LEN];
+       size_t Lx_len;
        u8 k1[DPP_MAX_HASH_LEN];
        u8 k2[DPP_MAX_HASH_LEN];
        u8 ke[DPP_MAX_HASH_LEN];
        int initiator;
        int waiting_auth_resp;
+       int waiting_auth_conf;
+       int auth_req_ack;
+       unsigned int auth_resp_tries;
        u8 allowed_roles;
        int configurator;
        int remove_on_tx_status;
+       int connect_on_tx_status;
+       int waiting_conf_result;
        int auth_success;
        struct wpabuf *conf_req;
+       const struct wpabuf *conf_resp; /* owned by GAS server */
        struct dpp_configuration *conf_ap;
        struct dpp_configuration *conf_sta;
        struct dpp_configurator *conf;
@@ -197,6 +230,7 @@ struct dpp_authentication {
        char passphrase[64];
        u8 psk[PMK_LEN];
        int psk_set;
+       enum dpp_akm akm;
        struct wpabuf *net_access_key;
        os_time_t net_access_key_expiry;
        struct wpabuf *c_sign_key;
@@ -290,9 +324,44 @@ enum dpp_test_behavior {
        DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62,
        DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63,
        DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64,
+       DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65,
+       DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66,
+       DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67,
+       DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 68,
+       DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 69,
+       DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 70,
+       DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 71,
+       DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 72,
+       DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 73,
+       DPP_TEST_INVALID_STATUS_AUTH_RESP = 74,
+       DPP_TEST_INVALID_STATUS_AUTH_CONF = 75,
+       DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76,
+       DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_RESP = 77,
+       DPP_TEST_INVALID_STATUS_PEER_DISC_RESP = 78,
+       DPP_TEST_INVALID_CONNECTOR_PEER_DISC_RESP = 79,
+       DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ = 80,
+       DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81,
+       DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82,
+       DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83,
+       DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84,
+       DPP_TEST_STOP_AT_PKEX_CR_REQ = 85,
+       DPP_TEST_STOP_AT_PKEX_CR_RESP = 86,
+       DPP_TEST_STOP_AT_AUTH_REQ = 87,
+       DPP_TEST_STOP_AT_AUTH_RESP = 88,
+       DPP_TEST_STOP_AT_AUTH_CONF = 89,
+       DPP_TEST_STOP_AT_CONF_REQ = 90,
+       DPP_TEST_REJECT_CONFIG = 91,
 };
 
 extern enum dpp_test_behavior dpp_test;
+extern u8 dpp_pkex_own_mac_override[ETH_ALEN];
+extern u8 dpp_pkex_peer_mac_override[ETH_ALEN];
+extern u8 dpp_pkex_ephemeral_key_override[600];
+extern size_t dpp_pkex_ephemeral_key_override_len;
+extern u8 dpp_protocol_key_override[600];
+extern size_t dpp_protocol_key_override_len;
+extern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN];
+extern size_t dpp_nonce_override_len;
 #endif /* CONFIG_TESTING_OPTIONS */
 
 void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info);
@@ -328,24 +397,40 @@ int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
                     const u8 *attr_start, size_t attr_len);
 int dpp_notify_new_qr_code(struct dpp_authentication *auth,
                           struct dpp_bootstrap_info *peer_bi);
+struct dpp_configuration * dpp_configuration_alloc(const char *type);
+int dpp_akm_psk(enum dpp_akm akm);
+int dpp_akm_sae(enum dpp_akm akm);
+int dpp_akm_legacy(enum dpp_akm akm);
+int dpp_akm_dpp(enum dpp_akm akm);
+int dpp_akm_ver2(enum dpp_akm akm);
+int dpp_configuration_valid(const struct dpp_configuration *conf);
 void dpp_configuration_free(struct dpp_configuration *conf);
+int dpp_configuration_parse(struct dpp_authentication *auth, const char *cmd);
 void dpp_auth_deinit(struct dpp_authentication *auth);
 struct wpabuf *
 dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start,
                size_t attr_len);
 int dpp_conf_resp_rx(struct dpp_authentication *auth,
                     const struct wpabuf *resp);
+enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth,
+                                        const u8 *hdr,
+                                        const u8 *attr_start, size_t attr_len);
+struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth,
+                                     enum dpp_status_error status);
 struct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type,
                              size_t len);
 const u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len);
 int dpp_check_attrs(const u8 *buf, size_t len);
 int dpp_key_expired(const char *timestamp, os_time_t *expiry);
+const char * dpp_akm_str(enum dpp_akm akm);
+int dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf,
+                            size_t buflen);
 void dpp_configurator_free(struct dpp_configurator *conf);
 struct dpp_configurator *
 dpp_keygen_configurator(const char *curve, const u8 *privkey,
                        size_t privkey_len);
 int dpp_configurator_own_config(struct dpp_authentication *auth,
-                               const char *curve);
+                               const char *curve, int ap);
 enum dpp_status_error
 dpp_peer_intro(struct dpp_introduction *intro, const char *own_connector,
               const u8 *net_access_key, size_t net_access_key_len,
@@ -364,6 +449,7 @@ struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx,
                                           const char *code,
                                           const u8 *buf, size_t len);
 struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex,
+                                         const u8 *peer_mac,
                                          const u8 *buf, size_t len);
 struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex,
                                              const u8 *hdr,
@@ -372,4 +458,19 @@ int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr,
                                   const u8 *buf, size_t len);
 void dpp_pkex_free(struct dpp_pkex *pkex);
 
+char * dpp_corrupt_connector_signature(const char *connector);
+
+
+struct dpp_pfs {
+       struct crypto_ecdh *ecdh;
+       const struct dpp_curve_params *curve;
+       struct wpabuf *ie;
+       struct wpabuf *secret;
+};
+
+struct dpp_pfs * dpp_pfs_init(const u8 *net_access_key,
+                             size_t net_access_key_len);
+int dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len);
+void dpp_pfs_free(struct dpp_pfs *pfs);
+
 #endif /* DPP_H */