diff options
| author | jsing <> | 2014-08-11 01:10:42 +0000 |
|---|---|---|
| committer | jsing <> | 2014-08-11 01:10:42 +0000 |
| commit | eef0721a3a0f7f67e03b910246980b6e1ba7dd12 (patch) | |
| tree | 9fd6149f4d3a9002ac5f1b6affe7cef8609d5e3b | |
| parent | a4ce4dfd66a0d1623edb622cd4153d529d5bcbba (diff) | |
| download | openbsd-eef0721a3a0f7f67e03b910246980b6e1ba7dd12.tar.gz openbsd-eef0721a3a0f7f67e03b910246980b6e1ba7dd12.tar.bz2 openbsd-eef0721a3a0f7f67e03b910246980b6e1ba7dd12.zip | |
Currently, ssl3_put_char_by_bytes(NULL, NULL) is just a long handed way
of writing "2". Add a define for the SSL3_CIPHER_VALUE_SIZE (rather than
using a less-readable hardcoded constant everywhere) and replace the
ssl3_put_char_by_bytes(NULL, NULL) calls with it.
ok bcook@ miod@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/s3_clnt.c | 4 | ||||
| -rw-r--r-- | src/lib/libssl/src/ssl/s3_clnt.c | 4 | ||||
| -rw-r--r-- | src/lib/libssl/src/ssl/ssl3.h | 3 | ||||
| -rw-r--r-- | src/lib/libssl/src/ssl/ssl_lib.c | 18 | ||||
| -rw-r--r-- | src/lib/libssl/ssl3.h | 3 | ||||
| -rw-r--r-- | src/lib/libssl/ssl_lib.c | 18 |
6 files changed, 24 insertions, 26 deletions
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c index 63e8135185..848de8c268 100644 --- a/src/lib/libssl/s3_clnt.c +++ b/src/lib/libssl/s3_clnt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: s3_clnt.c,v 1.86 2014/08/10 14:42:56 jsing Exp $ */ | 1 | /* $OpenBSD: s3_clnt.c,v 1.87 2014/08/11 01:10:42 jsing 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 | * |
| @@ -904,7 +904,7 @@ ssl3_get_server_hello(SSL *s) | |||
| 904 | SSL_R_WRONG_CIPHER_RETURNED); | 904 | SSL_R_WRONG_CIPHER_RETURNED); |
| 905 | goto f_err; | 905 | goto f_err; |
| 906 | } | 906 | } |
| 907 | p += ssl3_put_cipher_by_char(NULL, NULL); | 907 | p += SSL3_CIPHER_VALUE_SIZE; |
| 908 | 908 | ||
| 909 | sk = ssl_get_ciphers_by_id(s); | 909 | sk = ssl_get_ciphers_by_id(s); |
| 910 | i = sk_SSL_CIPHER_find(sk, c); | 910 | i = sk_SSL_CIPHER_find(sk, c); |
diff --git a/src/lib/libssl/src/ssl/s3_clnt.c b/src/lib/libssl/src/ssl/s3_clnt.c index 63e8135185..848de8c268 100644 --- a/src/lib/libssl/src/ssl/s3_clnt.c +++ b/src/lib/libssl/src/ssl/s3_clnt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: s3_clnt.c,v 1.86 2014/08/10 14:42:56 jsing Exp $ */ | 1 | /* $OpenBSD: s3_clnt.c,v 1.87 2014/08/11 01:10:42 jsing 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 | * |
| @@ -904,7 +904,7 @@ ssl3_get_server_hello(SSL *s) | |||
| 904 | SSL_R_WRONG_CIPHER_RETURNED); | 904 | SSL_R_WRONG_CIPHER_RETURNED); |
| 905 | goto f_err; | 905 | goto f_err; |
| 906 | } | 906 | } |
| 907 | p += ssl3_put_cipher_by_char(NULL, NULL); | 907 | p += SSL3_CIPHER_VALUE_SIZE; |
| 908 | 908 | ||
| 909 | sk = ssl_get_ciphers_by_id(s); | 909 | sk = ssl_get_ciphers_by_id(s); |
| 910 | i = sk_SSL_CIPHER_find(sk, c); | 910 | i = sk_SSL_CIPHER_find(sk, c); |
diff --git a/src/lib/libssl/src/ssl/ssl3.h b/src/lib/libssl/src/ssl/ssl3.h index 4bf36c5006..9a28b4701f 100644 --- a/src/lib/libssl/src/ssl/ssl3.h +++ b/src/lib/libssl/src/ssl/ssl3.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl3.h,v 1.25 2014/07/10 09:26:08 jsing Exp $ */ | 1 | /* $OpenBSD: ssl3.h,v 1.26 2014/08/11 01:10:42 jsing 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 | * |
| @@ -232,6 +232,7 @@ extern "C" { | |||
| 232 | #define SSL3_SEQUENCE_SIZE 8 | 232 | #define SSL3_SEQUENCE_SIZE 8 |
| 233 | #define SSL3_SESSION_ID_SIZE 32 | 233 | #define SSL3_SESSION_ID_SIZE 32 |
| 234 | #define SSL3_RT_HEADER_LENGTH 5 | 234 | #define SSL3_RT_HEADER_LENGTH 5 |
| 235 | #define SSL3_CIPHER_VALUE_SIZE 2 | ||
| 235 | 236 | ||
| 236 | #ifndef SSL3_ALIGN_PAYLOAD | 237 | #ifndef SSL3_ALIGN_PAYLOAD |
| 237 | /* Some will argue that this increases memory footprint, but it's | 238 | /* Some will argue that this increases memory footprint, but it's |
diff --git a/src/lib/libssl/src/ssl/ssl_lib.c b/src/lib/libssl/src/ssl/ssl_lib.c index bf94321eea..b3f4210266 100644 --- a/src/lib/libssl/src/ssl/ssl_lib.c +++ b/src/lib/libssl/src/ssl/ssl_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_lib.c,v 1.79 2014/08/10 14:42:56 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.80 2014/08/11 01:10:42 jsing 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 | * |
| @@ -1407,13 +1407,12 @@ ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, int num, | |||
| 1407 | { | 1407 | { |
| 1408 | const SSL_CIPHER *c; | 1408 | const SSL_CIPHER *c; |
| 1409 | STACK_OF(SSL_CIPHER) *sk; | 1409 | STACK_OF(SSL_CIPHER) *sk; |
| 1410 | int i, n; | 1410 | int i; |
| 1411 | 1411 | ||
| 1412 | if (s->s3) | 1412 | if (s->s3) |
| 1413 | s->s3->send_connection_binding = 0; | 1413 | s->s3->send_connection_binding = 0; |
| 1414 | 1414 | ||
| 1415 | n = ssl3_put_cipher_by_char(NULL, NULL); | 1415 | if ((num % SSL3_CIPHER_VALUE_SIZE) != 0) { |
| 1416 | if ((num % n) != 0) { | ||
| 1417 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, | 1416 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, |
| 1418 | SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST); | 1417 | SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST); |
| 1419 | return (NULL); | 1418 | return (NULL); |
| @@ -1425,11 +1424,10 @@ ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, int num, | |||
| 1425 | sk_SSL_CIPHER_zero(sk); | 1424 | sk_SSL_CIPHER_zero(sk); |
| 1426 | } | 1425 | } |
| 1427 | 1426 | ||
| 1428 | for (i = 0; i < num; i += n) { | 1427 | for (i = 0; i < num; i += SSL3_CIPHER_VALUE_SIZE) { |
| 1429 | /* Check for SCSV */ | 1428 | /* Check for SCSV */ |
| 1430 | if (s->s3 && (n != 3 || !p[0]) && | 1429 | if (s->s3 && (p[0] == ((SSL3_CK_SCSV >> 8) & 0xff)) && |
| 1431 | (p[n - 2] == ((SSL3_CK_SCSV >> 8) & 0xff)) && | 1430 | (p[1] == (SSL3_CK_SCSV & 0xff))) { |
| 1432 | (p[n - 1] == (SSL3_CK_SCSV & 0xff))) { | ||
| 1433 | /* SCSV fatal if renegotiating */ | 1431 | /* SCSV fatal if renegotiating */ |
| 1434 | if (s->renegotiate) { | 1432 | if (s->renegotiate) { |
| 1435 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, | 1433 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, |
| @@ -1440,12 +1438,12 @@ ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, int num, | |||
| 1440 | goto err; | 1438 | goto err; |
| 1441 | } | 1439 | } |
| 1442 | s->s3->send_connection_binding = 1; | 1440 | s->s3->send_connection_binding = 1; |
| 1443 | p += n; | 1441 | p += SSL3_CIPHER_VALUE_SIZE; |
| 1444 | continue; | 1442 | continue; |
| 1445 | } | 1443 | } |
| 1446 | 1444 | ||
| 1447 | c = ssl3_get_cipher_by_char(p); | 1445 | c = ssl3_get_cipher_by_char(p); |
| 1448 | p += n; | 1446 | p += SSL3_CIPHER_VALUE_SIZE; |
| 1449 | if (c != NULL) { | 1447 | if (c != NULL) { |
| 1450 | if (!sk_SSL_CIPHER_push(sk, c)) { | 1448 | if (!sk_SSL_CIPHER_push(sk, c)) { |
| 1451 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, | 1449 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, |
diff --git a/src/lib/libssl/ssl3.h b/src/lib/libssl/ssl3.h index 4bf36c5006..9a28b4701f 100644 --- a/src/lib/libssl/ssl3.h +++ b/src/lib/libssl/ssl3.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl3.h,v 1.25 2014/07/10 09:26:08 jsing Exp $ */ | 1 | /* $OpenBSD: ssl3.h,v 1.26 2014/08/11 01:10:42 jsing 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 | * |
| @@ -232,6 +232,7 @@ extern "C" { | |||
| 232 | #define SSL3_SEQUENCE_SIZE 8 | 232 | #define SSL3_SEQUENCE_SIZE 8 |
| 233 | #define SSL3_SESSION_ID_SIZE 32 | 233 | #define SSL3_SESSION_ID_SIZE 32 |
| 234 | #define SSL3_RT_HEADER_LENGTH 5 | 234 | #define SSL3_RT_HEADER_LENGTH 5 |
| 235 | #define SSL3_CIPHER_VALUE_SIZE 2 | ||
| 235 | 236 | ||
| 236 | #ifndef SSL3_ALIGN_PAYLOAD | 237 | #ifndef SSL3_ALIGN_PAYLOAD |
| 237 | /* Some will argue that this increases memory footprint, but it's | 238 | /* Some will argue that this increases memory footprint, but it's |
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index bf94321eea..b3f4210266 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_lib.c,v 1.79 2014/08/10 14:42:56 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.80 2014/08/11 01:10:42 jsing 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 | * |
| @@ -1407,13 +1407,12 @@ ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, int num, | |||
| 1407 | { | 1407 | { |
| 1408 | const SSL_CIPHER *c; | 1408 | const SSL_CIPHER *c; |
| 1409 | STACK_OF(SSL_CIPHER) *sk; | 1409 | STACK_OF(SSL_CIPHER) *sk; |
| 1410 | int i, n; | 1410 | int i; |
| 1411 | 1411 | ||
| 1412 | if (s->s3) | 1412 | if (s->s3) |
| 1413 | s->s3->send_connection_binding = 0; | 1413 | s->s3->send_connection_binding = 0; |
| 1414 | 1414 | ||
| 1415 | n = ssl3_put_cipher_by_char(NULL, NULL); | 1415 | if ((num % SSL3_CIPHER_VALUE_SIZE) != 0) { |
| 1416 | if ((num % n) != 0) { | ||
| 1417 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, | 1416 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, |
| 1418 | SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST); | 1417 | SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST); |
| 1419 | return (NULL); | 1418 | return (NULL); |
| @@ -1425,11 +1424,10 @@ ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, int num, | |||
| 1425 | sk_SSL_CIPHER_zero(sk); | 1424 | sk_SSL_CIPHER_zero(sk); |
| 1426 | } | 1425 | } |
| 1427 | 1426 | ||
| 1428 | for (i = 0; i < num; i += n) { | 1427 | for (i = 0; i < num; i += SSL3_CIPHER_VALUE_SIZE) { |
| 1429 | /* Check for SCSV */ | 1428 | /* Check for SCSV */ |
| 1430 | if (s->s3 && (n != 3 || !p[0]) && | 1429 | if (s->s3 && (p[0] == ((SSL3_CK_SCSV >> 8) & 0xff)) && |
| 1431 | (p[n - 2] == ((SSL3_CK_SCSV >> 8) & 0xff)) && | 1430 | (p[1] == (SSL3_CK_SCSV & 0xff))) { |
| 1432 | (p[n - 1] == (SSL3_CK_SCSV & 0xff))) { | ||
| 1433 | /* SCSV fatal if renegotiating */ | 1431 | /* SCSV fatal if renegotiating */ |
| 1434 | if (s->renegotiate) { | 1432 | if (s->renegotiate) { |
| 1435 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, | 1433 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, |
| @@ -1440,12 +1438,12 @@ ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, int num, | |||
| 1440 | goto err; | 1438 | goto err; |
| 1441 | } | 1439 | } |
| 1442 | s->s3->send_connection_binding = 1; | 1440 | s->s3->send_connection_binding = 1; |
| 1443 | p += n; | 1441 | p += SSL3_CIPHER_VALUE_SIZE; |
| 1444 | continue; | 1442 | continue; |
| 1445 | } | 1443 | } |
| 1446 | 1444 | ||
| 1447 | c = ssl3_get_cipher_by_char(p); | 1445 | c = ssl3_get_cipher_by_char(p); |
| 1448 | p += n; | 1446 | p += SSL3_CIPHER_VALUE_SIZE; |
| 1449 | if (c != NULL) { | 1447 | if (c != NULL) { |
| 1450 | if (!sk_SSL_CIPHER_push(sk, c)) { | 1448 | if (!sk_SSL_CIPHER_push(sk, c)) { |
| 1451 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, | 1449 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, |
