diff options
author | Kurt Roeckx <kurt@roeckx.be> | 2016-02-07 20:56:40 +0100 |
---|---|---|
committer | Kurt Roeckx <kurt@roeckx.be> | 2016-03-09 19:10:28 +0100 |
commit | 7d65007238e86e59fcf31d23fcefa01e3b30cc37 (patch) | |
tree | 31759a4f07e71ff011edfa01ca858fc9fb9d3f95 | |
parent | e4646a8963fa6bc6f475afe7a9b9a46b151cfd1a (diff) |
Make function to convert version to string
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
MR: #1595
-rw-r--r-- | ssl/ssl_lib.c | 37 | ||||
-rw-r--r-- | ssl/ssl_locl.h | 2 | ||||
-rw-r--r-- | ssl/ssl_txt.c | 17 |
3 files changed, 24 insertions, 32 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 94d0a220e5..0571150e60 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -3060,26 +3060,31 @@ SSL_METHOD *ssl_bad_method(int ver) return (NULL); } -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 if (s->version == DTLS1_BAD_VER) - return ("DTLSv0.9"); - else if (s->version == DTLS1_VERSION) - return ("DTLSv1"); - else if (s->version == DTLS1_2_VERSION) - return ("DTLSv1.2"); +const char *version_to_string(int version) +{ + if (version == TLS1_2_VERSION) + return "TLSv1.2"; + else if (version == TLS1_1_VERSION) + return "TLSv1.1"; + else if (version == TLS1_VERSION) + return "TLSv1.0"; + else if (version == SSL3_VERSION) + return "SSLv3"; + else if (version == DTLS1_BAD_VER) + return "DTLSv0.9"; + else if (version == DTLS1_VERSION) + return "DTLSv1"; + else if (version == DTLS1_2_VERSION) + return "DTLSv1.2"; else return ("unknown"); } +const char *SSL_get_version(const SSL *s) +{ + return version_to_string(s->version); +} + SSL *SSL_dup(SSL *s) { STACK_OF(X509_NAME) *sk; diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index 7e8f6a5850..7f85b95d0c 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -1871,6 +1871,8 @@ struct openssl_ssl_test_functions { # endif }; +const char *version_to_string(int version); + # ifndef OPENSSL_UNIT_TEST void ssl_clear_cipher_ctx(SSL *s); diff --git a/ssl/ssl_txt.c b/ssl/ssl_txt.c index bdd802f600..5bc5a72887 100644 --- a/ssl/ssl_txt.c +++ b/ssl/ssl_txt.c @@ -111,22 +111,7 @@ int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x) goto err; if (BIO_puts(bp, "SSL-Session:\n") <= 0) goto err; - if (x->ssl_version == SSL3_VERSION) - s = "SSLv3"; - else if (x->ssl_version == TLS1_2_VERSION) - s = "TLSv1.2"; - else if (x->ssl_version == TLS1_1_VERSION) - s = "TLSv1.1"; - else if (x->ssl_version == TLS1_VERSION) - s = "TLSv1"; - else if (x->ssl_version == DTLS1_VERSION) - s = "DTLSv1"; - else if (x->ssl_version == DTLS1_2_VERSION) - s = "DTLSv1.2"; - else if (x->ssl_version == DTLS1_BAD_VER) - s = "DTLSv1-bad"; - else - s = "unknown"; + s = version_to_string(x->ssl_version); if (BIO_printf(bp, " Protocol : %s\n", s) <= 0) goto err; |