From 43ca69c38ab86dc0a2a39a3edb26f30fee46543f Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Sat, 15 Jan 2011 17:35:19 +0000
Subject: [PATCH] - Added function for stringified SSL/TLS version
---
ChangeLog | 6 ++----
include/polarssl/ssl.h | 9 +++++++++
library/ssl_tls.c | 19 +++++++++++++++++++
3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 48ab5aefa7..bb15887b2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,10 +4,8 @@ PolarSSL ChangeLog
Features
Note: Most of these features have been donated by Fox-IT
* Added Doxygen source code documentation parts
- * Added generic message digest wrapper for integration
- with OpenVPN
- * Added generic cipher wrapper for integration
- with OpenVPN
+ * Added generic message digest and cipher wrapper
+ for integration with OpenVPN
* Added reading of DHM context from memory and file
* Added verification callback on certificate chain
verification to allow external blacklisting.
diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h
index 3d3c020b12..6d7b4952d4 100644
--- a/include/polarssl/ssl.h
+++ b/include/polarssl/ssl.h
@@ -525,6 +525,15 @@ int ssl_get_verify_result( const ssl_context *ssl );
*/
const char *ssl_get_cipher( const ssl_context *ssl );
+/**
+ * \brief Return the current SSL version (SSLv3/TLSv1/etc)
+ *
+ * \param ssl SSL context
+ *
+ * \return a string containing the SSL version
+ */
+const char *ssl_get_version( const ssl_context *ssl );
+
/**
* \brief Perform the SSL handshake
*
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index a0be84f680..74e51a3a5a 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -1918,6 +1918,25 @@ const char *ssl_get_cipher( const ssl_context *ssl )
return( "unknown" );
}
+const char *ssl_get_version( const ssl_context *ssl )
+{
+ switch( ssl->minor_ver )
+ {
+ case SSL_MINOR_VERSION_0:
+ return( "SSLv3.0" );
+
+ case SSL_MINOR_VERSION_1:
+ return( "TLSv1.0" );
+
+ case SSL_MINOR_VERSION_2:
+ return( "TLSv1.1" );
+
+ default:
+ break;
+ }
+ return( "unknown" );
+}
+
int ssl_default_ciphers[] =
{
#if defined(POLARSSL_DHM_C)