summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordoug <>2015-06-20 04:04:36 +0000
committerdoug <>2015-06-20 04:04:36 +0000
commit73cef548cdfd8de314b5aba376df5f39c4bf1b6e (patch)
tree93cc5d2bdea8ae6a303cc4177da840b08097950c
parent7e40cd02570f741c84e7beaf1489fbc7826363c7 (diff)
downloadopenbsd-73cef548cdfd8de314b5aba376df5f39c4bf1b6e.tar.gz
openbsd-73cef548cdfd8de314b5aba376df5f39c4bf1b6e.tar.bz2
openbsd-73cef548cdfd8de314b5aba376df5f39c4bf1b6e.zip
Convert ssl_parse_clienthello_renegotiate_ext to CBS.
ok miod@, tweak + ok jsing@
-rw-r--r--src/lib/libssl/src/ssl/ssl_locl.h4
-rw-r--r--src/lib/libssl/src/ssl/t1_reneg.c25
-rw-r--r--src/lib/libssl/ssl_locl.h4
-rw-r--r--src/lib/libssl/t1_reneg.c25
4 files changed, 28 insertions, 30 deletions
diff --git a/src/lib/libssl/src/ssl/ssl_locl.h b/src/lib/libssl/src/ssl/ssl_locl.h
index 794769b79c..b55e8265af 100644
--- a/src/lib/libssl/src/ssl/ssl_locl.h
+++ b/src/lib/libssl/src/ssl/ssl_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_locl.h,v 1.91 2015/06/18 22:51:05 doug Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.92 2015/06/20 04:04:35 doug Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -839,7 +839,7 @@ int ssl_parse_serverhello_renegotiate_ext(SSL *s, unsigned char *d,
839 int len, int *al); 839 int len, int *al);
840int ssl_add_clienthello_renegotiate_ext(SSL *s, unsigned char *p, 840int ssl_add_clienthello_renegotiate_ext(SSL *s, unsigned char *p,
841 int *len, int maxlen); 841 int *len, int maxlen);
842int ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, 842int ssl_parse_clienthello_renegotiate_ext(SSL *s, const unsigned char *d,
843 int len, int *al); 843 int len, int *al);
844long ssl_get_algorithm2(SSL *s); 844long ssl_get_algorithm2(SSL *s);
845int tls1_process_sigalgs(SSL *s, const unsigned char *data, int dsize); 845int tls1_process_sigalgs(SSL *s, const unsigned char *data, int dsize);
diff --git a/src/lib/libssl/src/ssl/t1_reneg.c b/src/lib/libssl/src/ssl/t1_reneg.c
index c93105ef4d..52d1754d94 100644
--- a/src/lib/libssl/src/ssl/t1_reneg.c
+++ b/src/lib/libssl/src/ssl/t1_reneg.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t1_reneg.c,v 1.9 2014/11/16 14:12:47 jsing Exp $ */ 1/* $OpenBSD: t1_reneg.c,v 1.10 2015/06/20 04:04:36 doug Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -114,6 +114,7 @@
114#include <openssl/objects.h> 114#include <openssl/objects.h>
115 115
116#include "ssl_locl.h" 116#include "ssl_locl.h"
117#include "bytestring.h"
117 118
118/* Add the client's renegotiation binding */ 119/* Add the client's renegotiation binding */
119int 120int
@@ -144,23 +145,22 @@ ssl_add_clienthello_renegotiate_ext(SSL *s, unsigned char *p, int *len,
144/* Parse the client's renegotiation binding and abort if it's not 145/* Parse the client's renegotiation binding and abort if it's not
145 right */ 146 right */
146int 147int
147ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, int len, 148ssl_parse_clienthello_renegotiate_ext(SSL *s, const unsigned char *d, int len,
148 int *al) 149 int *al)
149{ 150{
150 int ilen; 151 CBS cbs, reneg;
151 152
152 /* Parse the length byte */ 153 if (len < 0) {
153 if (len < 1) {
154 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, 154 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,
155 SSL_R_RENEGOTIATION_ENCODING_ERR); 155 SSL_R_RENEGOTIATION_ENCODING_ERR);
156 *al = SSL_AD_ILLEGAL_PARAMETER; 156 *al = SSL_AD_ILLEGAL_PARAMETER;
157 return 0; 157 return 0;
158 } 158 }
159 ilen = *d;
160 d++;
161 159
162 /* Consistency check */ 160 CBS_init(&cbs, d, len);
163 if ((ilen + 1) != len) { 161 if (!CBS_get_u8_length_prefixed(&cbs, &reneg) ||
162 /* Consistency check */
163 CBS_len(&cbs) != 0) {
164 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, 164 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,
165 SSL_R_RENEGOTIATION_ENCODING_ERR); 165 SSL_R_RENEGOTIATION_ENCODING_ERR);
166 *al = SSL_AD_ILLEGAL_PARAMETER; 166 *al = SSL_AD_ILLEGAL_PARAMETER;
@@ -168,22 +168,21 @@ ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, int len,
168 } 168 }
169 169
170 /* Check that the extension matches */ 170 /* Check that the extension matches */
171 if (ilen != s->s3->previous_client_finished_len) { 171 if (CBS_len(&reneg) != s->s3->previous_client_finished_len) {
172 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, 172 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,
173 SSL_R_RENEGOTIATION_MISMATCH); 173 SSL_R_RENEGOTIATION_MISMATCH);
174 *al = SSL_AD_HANDSHAKE_FAILURE; 174 *al = SSL_AD_HANDSHAKE_FAILURE;
175 return 0; 175 return 0;
176 } 176 }
177 177
178 if (timingsafe_memcmp(d, s->s3->previous_client_finished, 178 if (!CBS_mem_equal(&reneg, s->s3->previous_client_finished,
179 s->s3->previous_client_finished_len) != 0) { 179 s->s3->previous_client_finished_len)) {
180 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, 180 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,
181 SSL_R_RENEGOTIATION_MISMATCH); 181 SSL_R_RENEGOTIATION_MISMATCH);
182 *al = SSL_AD_HANDSHAKE_FAILURE; 182 *al = SSL_AD_HANDSHAKE_FAILURE;
183 return 0; 183 return 0;
184 } 184 }
185 185
186
187 s->s3->send_connection_binding = 1; 186 s->s3->send_connection_binding = 1;
188 187
189 return 1; 188 return 1;
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 794769b79c..b55e8265af 100644
--- a/src/lib/libssl/ssl_locl.h
+++ b/src/lib/libssl/ssl_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_locl.h,v 1.91 2015/06/18 22:51:05 doug Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.92 2015/06/20 04:04:35 doug Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -839,7 +839,7 @@ int ssl_parse_serverhello_renegotiate_ext(SSL *s, unsigned char *d,
839 int len, int *al); 839 int len, int *al);
840int ssl_add_clienthello_renegotiate_ext(SSL *s, unsigned char *p, 840int ssl_add_clienthello_renegotiate_ext(SSL *s, unsigned char *p,
841 int *len, int maxlen); 841 int *len, int maxlen);
842int ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, 842int ssl_parse_clienthello_renegotiate_ext(SSL *s, const unsigned char *d,
843 int len, int *al); 843 int len, int *al);
844long ssl_get_algorithm2(SSL *s); 844long ssl_get_algorithm2(SSL *s);
845int tls1_process_sigalgs(SSL *s, const unsigned char *data, int dsize); 845int tls1_process_sigalgs(SSL *s, const unsigned char *data, int dsize);
diff --git a/src/lib/libssl/t1_reneg.c b/src/lib/libssl/t1_reneg.c
index c93105ef4d..52d1754d94 100644
--- a/src/lib/libssl/t1_reneg.c
+++ b/src/lib/libssl/t1_reneg.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t1_reneg.c,v 1.9 2014/11/16 14:12:47 jsing Exp $ */ 1/* $OpenBSD: t1_reneg.c,v 1.10 2015/06/20 04:04:36 doug Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -114,6 +114,7 @@
114#include <openssl/objects.h> 114#include <openssl/objects.h>
115 115
116#include "ssl_locl.h" 116#include "ssl_locl.h"
117#include "bytestring.h"
117 118
118/* Add the client's renegotiation binding */ 119/* Add the client's renegotiation binding */
119int 120int
@@ -144,23 +145,22 @@ ssl_add_clienthello_renegotiate_ext(SSL *s, unsigned char *p, int *len,
144/* Parse the client's renegotiation binding and abort if it's not 145/* Parse the client's renegotiation binding and abort if it's not
145 right */ 146 right */
146int 147int
147ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, int len, 148ssl_parse_clienthello_renegotiate_ext(SSL *s, const unsigned char *d, int len,
148 int *al) 149 int *al)
149{ 150{
150 int ilen; 151 CBS cbs, reneg;
151 152
152 /* Parse the length byte */ 153 if (len < 0) {
153 if (len < 1) {
154 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, 154 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,
155 SSL_R_RENEGOTIATION_ENCODING_ERR); 155 SSL_R_RENEGOTIATION_ENCODING_ERR);
156 *al = SSL_AD_ILLEGAL_PARAMETER; 156 *al = SSL_AD_ILLEGAL_PARAMETER;
157 return 0; 157 return 0;
158 } 158 }
159 ilen = *d;
160 d++;
161 159
162 /* Consistency check */ 160 CBS_init(&cbs, d, len);
163 if ((ilen + 1) != len) { 161 if (!CBS_get_u8_length_prefixed(&cbs, &reneg) ||
162 /* Consistency check */
163 CBS_len(&cbs) != 0) {
164 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, 164 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,
165 SSL_R_RENEGOTIATION_ENCODING_ERR); 165 SSL_R_RENEGOTIATION_ENCODING_ERR);
166 *al = SSL_AD_ILLEGAL_PARAMETER; 166 *al = SSL_AD_ILLEGAL_PARAMETER;
@@ -168,22 +168,21 @@ ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, int len,
168 } 168 }
169 169
170 /* Check that the extension matches */ 170 /* Check that the extension matches */
171 if (ilen != s->s3->previous_client_finished_len) { 171 if (CBS_len(&reneg) != s->s3->previous_client_finished_len) {
172 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, 172 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,
173 SSL_R_RENEGOTIATION_MISMATCH); 173 SSL_R_RENEGOTIATION_MISMATCH);
174 *al = SSL_AD_HANDSHAKE_FAILURE; 174 *al = SSL_AD_HANDSHAKE_FAILURE;
175 return 0; 175 return 0;
176 } 176 }
177 177
178 if (timingsafe_memcmp(d, s->s3->previous_client_finished, 178 if (!CBS_mem_equal(&reneg, s->s3->previous_client_finished,
179 s->s3->previous_client_finished_len) != 0) { 179 s->s3->previous_client_finished_len)) {
180 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT, 180 SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,
181 SSL_R_RENEGOTIATION_MISMATCH); 181 SSL_R_RENEGOTIATION_MISMATCH);
182 *al = SSL_AD_HANDSHAKE_FAILURE; 182 *al = SSL_AD_HANDSHAKE_FAILURE;
183 return 0; 183 return 0;
184 } 184 }
185 185
186
187 s->s3->send_connection_binding = 1; 186 s->s3->send_connection_binding = 1;
188 187
189 return 1; 188 return 1;