GnuTLS: Implement tls_get_version()

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2017-12-28 00:29:18 +02:00
parent 6e6651d02e
commit f8697e8109

View file

@ -1,6 +1,6 @@
/*
* SSL/TLS interface functions for GnuTLS
* Copyright (c) 2004-2011, Jouni Malinen <j@w1.fi>
* Copyright (c) 2004-2017, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@ -1501,8 +1501,18 @@ 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 */
return -1;
gnutls_protocol_t ver;
ver = gnutls_protocol_get_version(conn->session);
if (ver == GNUTLS_TLS1_0)
os_strlcpy(buf, "TLSv1", buflen);
else if (ver == GNUTLS_TLS1_1)
os_strlcpy(buf, "TLSv1.1", buflen);
else if (ver == GNUTLS_TLS1_2)
os_strlcpy(buf, "TLSv1.2", buflen);
else
return -1;
return 0;
}