|
|
83c29f |
From 2054eb771ea29378f90d3a77c2f4015b17de702d Mon Sep 17 00:00:00 2001
|
|
|
83c29f |
From: "Dr. Stephen Henson" <steve@openssl.org>
|
|
|
83c29f |
Date: Tue, 15 Jul 2014 12:20:30 +0100
|
|
|
83c29f |
Subject: [PATCH] Add ECC extensions with DTLS.
|
|
|
83c29f |
|
|
|
83c29f |
PR#3449
|
|
|
83c29f |
---
|
|
|
83c29f |
ssl/d1_clnt.c | 8 +++++++-
|
|
|
83c29f |
ssl/d1_srvr.c | 5 +++++
|
|
|
83c29f |
ssl/t1_lib.c | 18 ++++++------------
|
|
|
83c29f |
3 files changed, 18 insertions(+), 13 deletions(-)
|
|
|
83c29f |
|
|
|
83c29f |
diff --git a/ssl/d1_clnt.c b/ssl/d1_clnt.c
|
|
|
83c29f |
index 48e5e06..65dbb4a 100644
|
|
|
83c29f |
--- a/ssl/d1_clnt.c
|
|
|
83c29f |
+++ b/ssl/d1_clnt.c
|
|
|
83c29f |
@@ -876,12 +876,18 @@ int dtls1_client_hello(SSL *s)
|
|
|
83c29f |
*(p++)=0; /* Add the NULL method */
|
|
|
83c29f |
|
|
|
83c29f |
#ifndef OPENSSL_NO_TLSEXT
|
|
|
83c29f |
+ /* TLS extensions*/
|
|
|
83c29f |
+ if (ssl_prepare_clienthello_tlsext(s) <= 0)
|
|
|
83c29f |
+ {
|
|
|
83c29f |
+ SSLerr(SSL_F_DTLS1_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT);
|
|
|
83c29f |
+ goto err;
|
|
|
83c29f |
+ }
|
|
|
83c29f |
if ((p = ssl_add_clienthello_tlsext(s, p, buf+SSL3_RT_MAX_PLAIN_LENGTH)) == NULL)
|
|
|
83c29f |
{
|
|
|
83c29f |
SSLerr(SSL_F_DTLS1_CLIENT_HELLO,ERR_R_INTERNAL_ERROR);
|
|
|
83c29f |
goto err;
|
|
|
83c29f |
}
|
|
|
83c29f |
-#endif
|
|
|
83c29f |
+#endif
|
|
|
83c29f |
|
|
|
83c29f |
l=(p-d);
|
|
|
83c29f |
d=buf;
|
|
|
83c29f |
diff --git a/ssl/d1_srvr.c b/ssl/d1_srvr.c
|
|
|
83c29f |
index 1384ab0..ef9c347 100644
|
|
|
83c29f |
--- a/ssl/d1_srvr.c
|
|
|
83c29f |
+++ b/ssl/d1_srvr.c
|
|
|
83c29f |
@@ -980,6 +980,11 @@ int dtls1_send_server_hello(SSL *s)
|
|
|
83c29f |
#endif
|
|
|
83c29f |
|
|
|
83c29f |
#ifndef OPENSSL_NO_TLSEXT
|
|
|
83c29f |
+ if (ssl_prepare_serverhello_tlsext(s) <= 0)
|
|
|
83c29f |
+ {
|
|
|
83c29f |
+ SSLerr(SSL_F_DTLS1_SEND_SERVER_HELLO,SSL_R_SERVERHELLO_TLSEXT);
|
|
|
83c29f |
+ return -1;
|
|
|
83c29f |
+ }
|
|
|
83c29f |
if ((p = ssl_add_serverhello_tlsext(s, p, buf+SSL3_RT_MAX_PLAIN_LENGTH)) == NULL)
|
|
|
83c29f |
{
|
|
|
83c29f |
SSLerr(SSL_F_DTLS1_SEND_SERVER_HELLO,ERR_R_INTERNAL_ERROR);
|
|
|
83c29f |
diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
|
|
|
83c29f |
index f6a480d..8167a51 100644
|
|
|
83c29f |
--- a/ssl/t1_lib.c
|
|
|
83c29f |
+++ b/ssl/t1_lib.c
|
|
|
83c29f |
@@ -453,8 +453,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, unsigned c
|
|
|
83c29f |
#endif
|
|
|
83c29f |
|
|
|
83c29f |
#ifndef OPENSSL_NO_EC
|
|
|
83c29f |
- if (s->tlsext_ecpointformatlist != NULL &&
|
|
|
83c29f |
- s->version != DTLS1_VERSION)
|
|
|
83c29f |
+ if (s->tlsext_ecpointformatlist != NULL)
|
|
|
83c29f |
{
|
|
|
83c29f |
/* Add TLS extension ECPointFormats to the ClientHello message */
|
|
|
83c29f |
long lenmax;
|
|
|
83c29f |
@@ -473,8 +472,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, unsigned c
|
|
|
83c29f |
memcpy(ret, s->tlsext_ecpointformatlist, s->tlsext_ecpointformatlist_length);
|
|
|
83c29f |
ret+=s->tlsext_ecpointformatlist_length;
|
|
|
83c29f |
}
|
|
|
83c29f |
- if (s->tlsext_ellipticcurvelist != NULL &&
|
|
|
83c29f |
- s->version != DTLS1_VERSION)
|
|
|
83c29f |
+ if (s->tlsext_ellipticcurvelist != NULL)
|
|
|
83c29f |
{
|
|
|
83c29f |
/* Add TLS extension EllipticCurves to the ClientHello message */
|
|
|
83c29f |
long lenmax;
|
|
|
83c29f |
@@ -750,8 +748,7 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, unsigned c
|
|
|
83c29f |
}
|
|
|
83c29f |
|
|
|
83c29f |
#ifndef OPENSSL_NO_EC
|
|
|
83c29f |
- if (s->tlsext_ecpointformatlist != NULL &&
|
|
|
83c29f |
- s->version != DTLS1_VERSION)
|
|
|
83c29f |
+ if (s->tlsext_ecpointformatlist != NULL)
|
|
|
83c29f |
{
|
|
|
83c29f |
/* Add TLS extension ECPointFormats to the ServerHello message */
|
|
|
83c29f |
long lenmax;
|
|
|
83c29f |
@@ -1154,8 +1151,7 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, in
|
|
|
83c29f |
#endif
|
|
|
83c29f |
|
|
|
83c29f |
#ifndef OPENSSL_NO_EC
|
|
|
83c29f |
- else if (type == TLSEXT_TYPE_ec_point_formats &&
|
|
|
83c29f |
- s->version != DTLS1_VERSION)
|
|
|
83c29f |
+ else if (type == TLSEXT_TYPE_ec_point_formats)
|
|
|
83c29f |
{
|
|
|
83c29f |
unsigned char *sdata = data;
|
|
|
83c29f |
int ecpointformatlist_length = *(sdata++);
|
|
|
83c29f |
@@ -1189,8 +1185,7 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, in
|
|
|
83c29f |
fprintf(stderr,"\n");
|
|
|
83c29f |
#endif
|
|
|
83c29f |
}
|
|
|
83c29f |
- else if (type == TLSEXT_TYPE_elliptic_curves &&
|
|
|
83c29f |
- s->version != DTLS1_VERSION)
|
|
|
83c29f |
+ else if (type == TLSEXT_TYPE_elliptic_curves)
|
|
|
83c29f |
{
|
|
|
83c29f |
unsigned char *sdata = data;
|
|
|
83c29f |
int ellipticcurvelist_length = (*(sdata++) << 8);
|
|
|
83c29f |
@@ -1549,8 +1544,7 @@ int ssl_parse_serverhello_tlsext(SSL *s, unsigned char **p, unsigned char *d, in
|
|
|
83c29f |
}
|
|
|
83c29f |
|
|
|
83c29f |
#ifndef OPENSSL_NO_EC
|
|
|
83c29f |
- else if (type == TLSEXT_TYPE_ec_point_formats &&
|
|
|
83c29f |
- s->version != DTLS1_VERSION)
|
|
|
83c29f |
+ else if (type == TLSEXT_TYPE_ec_point_formats)
|
|
|
83c29f |
{
|
|
|
83c29f |
unsigned char *sdata = data;
|
|
|
83c29f |
int ecpointformatlist_length = *(sdata++);
|
|
|
83c29f |
--
|
|
|
83c29f |
1.8.3.1
|
|
|
83c29f |
|