Add a helper function to normalize the current version.
We have need to normalize other versions during version negotiation, but
almost all will be post-negotiation. Hopefully later this can be
replaced with a value explicitly stored on the object and we do away
with ssl->version.
Change-Id: I595db9163d0af2e7c083b9a09310179aaa9ac812
Reviewed-on: https://boringssl-review.googlesource.com/6841
Reviewed-by: Adam Langley <alangley@gmail.com>
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 3e2b156..483e386 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -2469,7 +2469,7 @@
}
}
-uint16_t ssl3_version_from_wire(SSL *ssl, uint16_t wire_version) {
+uint16_t ssl3_version_from_wire(const SSL *ssl, uint16_t wire_version) {
if (!SSL_IS_DTLS(ssl)) {
return wire_version;
}
@@ -2490,6 +2490,11 @@
return version;
}
+uint16_t ssl3_protocol_version(const SSL *ssl) {
+ assert(ssl->s3->have_version);
+ return ssl3_version_from_wire(ssl, ssl->version);
+}
+
int SSL_cache_hit(SSL *ssl) { return SSL_session_reused(ssl); }
int SSL_is_server(SSL *ssl) { return ssl->server; }