diff options
author | 2014-07-12 19:45:53 +0000 | |
---|---|---|
committer | 2014-07-12 19:45:53 +0000 | |
commit | f6f8cf51ac74ffba17eca4f309978534449d9b00 (patch) | |
tree | 94680a1ba873967b08ded8ca1441366b4cf94fb0 /lib/libssl/ssl_lib.c | |
parent | @endfake died a while ago (diff) | |
download | wireguard-openbsd-f6f8cf51ac74ffba17eca4f309978534449d9b00.tar.xz wireguard-openbsd-f6f8cf51ac74ffba17eca4f309978534449d9b00.zip |
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.c | 34 |
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 * |