TLS: Add support for tls_get_version()

This allows wpa_supplicant to return eap_tls_version STATUS information
when using the internal TLS client implementation.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-11-29 19:41:37 +02:00
parent bb0a72ab46
commit 20804fe844
3 changed files with 31 additions and 1 deletions

View file

@ -635,7 +635,12 @@ int tls_connection_set_cipher_list(void *tls_ctx, struct tls_connection *conn,
int tls_get_version(void *ssl_ctx, struct tls_connection *conn,
char *buf, size_t buflen)
{
/* TODO */
if (conn == NULL)
return -1;
#ifdef CONFIG_TLS_INTERNAL_CLIENT
if (conn->client)
return tlsv1_client_get_version(conn->client, buf, buflen);
#endif /* CONFIG_TLS_INTERNAL_CLIENT */
return -1;
}

View file

@ -838,3 +838,26 @@ void tlsv1_client_set_cb(struct tlsv1_client *conn,
conn->cb_ctx = cb_ctx;
conn->cert_in_cb = !!cert_in_cb;
}
int tlsv1_client_get_version(struct tlsv1_client *conn, char *buf,
size_t buflen)
{
if (!conn)
return -1;
switch (conn->rl.tls_version) {
case TLS_VERSION_1:
os_strlcpy(buf, "TLSv1", buflen);
break;
case TLS_VERSION_1_1:
os_strlcpy(buf, "TLSv1.1", buflen);
break;
case TLS_VERSION_1_2:
os_strlcpy(buf, "TLSv1.2", buflen);
break;
default:
return -1;
}
return 0;
}

View file

@ -56,5 +56,7 @@ void tlsv1_client_set_cb(struct tlsv1_client *conn,
union tls_event_data *data),
void *cb_ctx,
int cert_in_cb);
int tlsv1_client_get_version(struct tlsv1_client *conn, char *buf,
size_t buflen);
#endif /* TLSV1_CLIENT_H */