]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add Type-Code context to EAP-TLS 1.3 exported Key_Material and Method-Id
authorErvin Oro <ervin.oro@aalto.fi>
Mon, 15 Apr 2019 17:05:49 +0000 (20:05 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 11 Jul 2019 10:11:59 +0000 (13:11 +0300)
Change to require the Type-Code in context for Key_Material and
Method-Id has now been published as draft-ietf-emu-eap-tls13-04.
https://tools.ietf.org/html/draft-ietf-emu-eap-tls13-04#section-2.3

Signed-off-by: Ervin Oro <ervin.oro@aalto.fi>
src/eap_peer/eap_tls.c
src/eap_peer/eap_tls_common.c
src/eap_server/eap_server_tls.c
src/eap_server/eap_server_tls_common.c

index ffea9d213855fa429b7bd2300a3988a4ab8a2979..b7e76d93ae009944067bed0cfee9458f5f51a47a 100644 (file)
@@ -174,6 +174,9 @@ static void eap_tls_success(struct eap_sm *sm, struct eap_tls_data *data,
                            struct eap_method_ret *ret)
 {
        const char *label;
+       const u8 eap_tls13_context[] = { EAP_TYPE_TLS };
+       const u8 *context = NULL;
+       size_t context_len = 0;
 
        wpa_printf(MSG_DEBUG, "EAP-TLS: Done");
 
@@ -184,6 +187,8 @@ static void eap_tls_success(struct eap_sm *sm, struct eap_tls_data *data,
 
        if (data->ssl.tls_v13) {
                label = "EXPORTER_EAP_TLS_Key_Material";
+               context = eap_tls13_context;
+               context_len = 1;
 
                /* A possible NewSessionTicket may be received before
                 * EAP-Success, so need to allow it to be received. */
@@ -198,7 +203,7 @@ static void eap_tls_success(struct eap_sm *sm, struct eap_tls_data *data,
 
        eap_tls_free_key(data);
        data->key_data = eap_peer_tls_derive_key(sm, &data->ssl, label,
-                                                NULL, 0,
+                                                context, context_len,
                                                 EAP_TLS_KEY_LEN +
                                                 EAP_EMSK_LEN);
        if (data->key_data) {
index f0d580dfa6008f58c1e5148c5bf49626565e7eb9..7e0690c06bf4365fdde73d39d8b58e12b52849b2 100644 (file)
@@ -413,17 +413,18 @@ u8 * eap_peer_tls_derive_session_id(struct eap_sm *sm,
 
        if (eap_type == EAP_TYPE_TLS && data->tls_v13) {
                u8 *id, *method_id;
+               const u8 context[] = { EAP_TYPE_TLS };
 
                /* Session-Id = <EAP-Type> || Method-Id
                 * Method-Id = TLS-Exporter("EXPORTER_EAP_TLS_Method-Id",
-                *                          "", 64)
+                *                          Type-Code, 64)
                 */
                *len = 1 + 64;
                id = os_malloc(*len);
                if (!id)
                        return NULL;
                method_id = eap_peer_tls_derive_key(
-                       sm, data, "EXPORTER_EAP_TLS_Method-Id", NULL, 0, 64);
+                       sm, data, "EXPORTER_EAP_TLS_Method-Id", context, 1, 64);
                if (!method_id) {
                        os_free(id);
                        return NULL;
index 357e72a825f6d0271d6f3187d0b678e971086ab1..9860a36537cad271e9366c3fdb8c095792b51f95 100644 (file)
@@ -322,16 +322,22 @@ static u8 * eap_tls_getKey(struct eap_sm *sm, void *priv, size_t *len)
        struct eap_tls_data *data = priv;
        u8 *eapKeyData;
        const char *label;
+       const u8 eap_tls13_context[] = { EAP_TYPE_TLS };
+       const u8 *context = NULL;
+       size_t context_len = 0;
 
        if (data->state != SUCCESS)
                return NULL;
 
-       if (data->ssl.tls_v13)
+       if (data->ssl.tls_v13) {
                label = "EXPORTER_EAP_TLS_Key_Material";
-       else
+               context = eap_tls13_context;
+               context_len = 1;
+       } else {
                label = "client EAP encryption";
+       }
        eapKeyData = eap_server_tls_derive_key(sm, &data->ssl, label,
-                                              NULL, 0,
+                                              context, context_len,
                                               EAP_TLS_KEY_LEN + EAP_EMSK_LEN);
        if (eapKeyData) {
                *len = EAP_TLS_KEY_LEN;
@@ -351,16 +357,22 @@ static u8 * eap_tls_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
        struct eap_tls_data *data = priv;
        u8 *eapKeyData, *emsk;
        const char *label;
+       const u8 eap_tls13_context[] = { EAP_TYPE_TLS };
+       const u8 *context = NULL;
+       size_t context_len = 0;
 
        if (data->state != SUCCESS)
                return NULL;
 
-       if (data->ssl.tls_v13)
+       if (data->ssl.tls_v13) {
                label = "EXPORTER_EAP_TLS_Key_Material";
-       else
+               context = eap_tls13_context;
+               context_len = 1;
+       } else {
                label = "client EAP encryption";
+       }
        eapKeyData = eap_server_tls_derive_key(sm, &data->ssl, label,
-                                              NULL, 0,
+                                              context, context_len,
                                               EAP_TLS_KEY_LEN + EAP_EMSK_LEN);
        if (eapKeyData) {
                emsk = os_malloc(EAP_EMSK_LEN);
index 281376f01a6bb86eb3dd79407f180307b69d93f2..907101c7e2e338314e28043b8c8ba6ef2e65577c 100644 (file)
@@ -145,20 +145,21 @@ u8 * eap_server_tls_derive_session_id(struct eap_sm *sm,
 {
        struct tls_random keys;
        u8 *out;
+       const u8 context[] = { EAP_TYPE_TLS };
 
        if (eap_type == EAP_TYPE_TLS && data->tls_v13) {
                u8 *id, *method_id;
 
                /* Session-Id = <EAP-Type> || Method-Id
                 * Method-Id = TLS-Exporter("EXPORTER_EAP_TLS_Method-Id",
-                *                          "", 64)
+                *                          Type-Code, 64)
                 */
                *len = 1 + 64;
                id = os_malloc(*len);
                if (!id)
                        return NULL;
                method_id = eap_server_tls_derive_key(
-                       sm, data, "EXPORTER_EAP_TLS_Method-Id", NULL, 0, 64);
+                       sm, data, "EXPORTER_EAP_TLS_Method-Id", context, 1, 64);
                if (!method_id) {
                        os_free(id);
                        return NULL;