Add |SSL_get_min_proto_version| and |SSL_get_max_proto_version|

This makes it possible to fetch the min and max versions configured
directly on SSL objects (as opposed to SSL_CTX ones).

This is useful when configuring supported TLS versions on per-connection
basis.

Change-Id: Ibccc92c5f7668e9a7be5a01d6f84089608382407
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38104
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/ssl/ssl_versions.cc b/ssl/ssl_versions.cc
index df5ffd2..e63a189 100644
--- a/ssl/ssl_versions.cc
+++ b/ssl/ssl_versions.cc
@@ -335,11 +335,11 @@
   return set_max_version(ctx->method, &ctx->conf_max_version, version);
 }
 
-uint16_t SSL_CTX_get_min_proto_version(SSL_CTX *ctx) {
+uint16_t SSL_CTX_get_min_proto_version(const SSL_CTX *ctx) {
   return ctx->conf_min_version;
 }
 
-uint16_t SSL_CTX_get_max_proto_version(SSL_CTX *ctx) {
+uint16_t SSL_CTX_get_max_proto_version(const SSL_CTX *ctx) {
   return ctx->conf_max_version;
 }
 
@@ -357,6 +357,20 @@
   return set_max_version(ssl->method, &ssl->config->conf_max_version, version);
 }
 
+uint16_t SSL_get_min_proto_version(const SSL *ssl) {
+  if (!ssl->config) {
+    return 0;
+  }
+  return ssl->config->conf_min_version;
+}
+
+uint16_t SSL_get_max_proto_version(const SSL *ssl) {
+  if (!ssl->config) {
+    return 0;
+  }
+  return ssl->config->conf_max_version;
+}
+
 int SSL_version(const SSL *ssl) {
   return wire_version_to_api(ssl_version(ssl));
 }