summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Laurie <ben@links.org>2014-07-04 15:47:50 +0100
committerBen Laurie <ben@links.org>2014-07-06 10:09:15 +0100
commit704ae1bed5877435825f271a804903b95c98484d (patch)
tree64c5cc0e7b00a10e4c01fa48f74c903056852c60
parentd2ab55eb5ba5ffcca96253224c20ee1269b39b72 (diff)
downloadopenssl-new-704ae1bed5877435825f271a804903b95c98484d.tar.gz
Make TLSEXT_NAMETYPE_host_name an enum.
-rw-r--r--apps/s_client.c2
-rw-r--r--ssl/ssl_lib.c6
-rw-r--r--ssl/tls1.h9
3 files changed, 10 insertions, 7 deletions
diff --git a/apps/s_client.c b/apps/s_client.c
index 9f8e2b8e94..e37971f108 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -387,7 +387,7 @@ static int MS_CALLBACK ssl_servername_cb(SSL *s, int *ad, void *arg)
{
tlsextctx * p = (tlsextctx *) arg;
const char * hn= SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
- if (SSL_get_servername_type(s) != -1)
+ if (SSL_get_servername_type(s) != TLSEXT_NAMETYPE_error)
p->ack = !SSL_session_reused(s) && hn != NULL;
else
BIO_printf(bio_err,"Can't use SSL_get_servername\n");
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 9f4040d701..cb225a2314 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -1617,7 +1617,7 @@ err:
* So far, only host_name types are defined (RFC 3546).
*/
-const char *SSL_get_servername(const SSL *s, const int type)
+const char *SSL_get_servername(const SSL *s, const enum tlsext_nametype type)
{
if (type != TLSEXT_NAMETYPE_host_name)
return NULL;
@@ -1627,11 +1627,11 @@ const char *SSL_get_servername(const SSL *s, const int type)
s->tlsext_hostname;
}
-int SSL_get_servername_type(const SSL *s)
+enum tlsext_nametype SSL_get_servername_type(const SSL *s)
{
if (s->session && (!s->tlsext_hostname ? s->session->tlsext_hostname : s->tlsext_hostname))
return TLSEXT_NAMETYPE_host_name;
- return -1;
+ return TLSEXT_NAMETYPE_error;
}
/* SSL_select_next_proto implements the standard protocol selection. It is
diff --git a/ssl/tls1.h b/ssl/tls1.h
index 3499584bc3..38c3aa74c2 100644
--- a/ssl/tls1.h
+++ b/ssl/tls1.h
@@ -265,7 +265,10 @@ extern "C" {
#endif
/* NameType value from RFC 3546 */
-#define TLSEXT_NAMETYPE_host_name 0
+enum tlsext_nametype {
+ TLSEXT_NAMETYPE_host_name = 0,
+ TLSEXT_NAMETYPE_error = 256
+};
/* status request value from RFC 3546 */
#define TLSEXT_STATUSTYPE_ocsp 1
@@ -310,8 +313,8 @@ extern "C" {
#define TLSEXT_MAXLEN_host_name 255
-const char *SSL_get_servername(const SSL *s, const int type);
-int SSL_get_servername_type(const SSL *s);
+const char *SSL_get_servername(const SSL *s, const enum tlsext_nametype type);
+enum tlsext_nametype SSL_get_servername_type(const SSL *s);
/* SSL_export_keying_material exports a value derived from the master secret,
* as specified in RFC 5705. It writes |olen| bytes to |out| given a label and
* optional context. (Since a zero length context is allowed, the |use_context|