summaryrefslogtreecommitdiff
path: root/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2014-07-12 19:45:54 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2014-07-12 19:45:54 +0000
commit30415c48dd85a36c2e3c2bf50146e554fecc1eb7 (patch)
tree8e20e46b2dc7a63f558978cc271dc0bb88f96679 /lib/libssl/ssl_lib.c
parente1410ef852880b85a0c16b11df996af03094c694 (diff)
Provide ssl_version_string() function, which uses one of those modern C
constructs (a switch statement) and returns the appropriate string defined by SSL_TXT_* for the given version, including support for DTLSv1 and DTLSv1-bad. Use this function in SSL_get_version() and SSL_SESSION_print(). ok beck@
Diffstat (limited to 'lib/libssl/ssl_lib.c')
-rw-r--r--lib/libssl/ssl_lib.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c
index db310de881b..b563071cdad 100644
--- a/lib/libssl/ssl_lib.c
+++ b/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_lib.c,v 1.76 2014/07/12 16:03:37 miod Exp $ */
+/* $OpenBSD: ssl_lib.c,v 1.77 2014/07/12 19:45:53 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -2410,18 +2410,30 @@ ssl_bad_method(int ver)
}
const char *
+ssl_version_string(int ver)
+{
+ switch (ver) {
+ case DTLS1_BAD_VER:
+ return (SSL_TXT_DTLS1_BAD);
+ case DTLS1_VERSION:
+ return (SSL_TXT_DTLS1);
+ case SSL3_VERSION:
+ return (SSL_TXT_SSLV3);
+ case TLS1_VERSION:
+ return (SSL_TXT_TLSV1);
+ case TLS1_1_VERSION:
+ return (SSL_TXT_TLSV1_1);
+ case TLS1_2_VERSION:
+ return (SSL_TXT_TLSV1_2);
+ default:
+ return ("unknown");
+ }
+}
+
+const char *
SSL_get_version(const SSL *s)
{
- if (s->version == TLS1_2_VERSION)
- return ("TLSv1.2");
- else if (s->version == TLS1_1_VERSION)
- return ("TLSv1.1");
- else if (s->version == TLS1_VERSION)
- return ("TLSv1");
- else if (s->version == SSL3_VERSION)
- return ("SSLv3");
- else
- return ("unknown");
+ return ssl_version_string(s->version);
}
SSL *