summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2015-02-07 04:17:11 +0000
committerjsing <>2015-02-07 04:17:11 +0000
commitbe1d02917370f48d43c5e741fbb7b49e6aaa7484 (patch)
tree0df75ae3b916b1b72c13a0fd2ac4593d824ab8aa
parenta6d663db02ac0a71cccf58cb65c2fd12eb475516 (diff)
downloadopenbsd-be1d02917370f48d43c5e741fbb7b49e6aaa7484.tar.gz
openbsd-be1d02917370f48d43c5e741fbb7b49e6aaa7484.tar.bz2
openbsd-be1d02917370f48d43c5e741fbb7b49e6aaa7484.zip
Provide a SSL_CIPHER_get_by_value() function that allows a cipher to be
retrieved via its cipher suite value. A corresponding SSL_CIPHER_by_value() function returns the cipher suite value for a given SSL_CIPHER. These functions should mean that software does not need to resort to put_cipher_by_char()/get_cipher_by_char() in order to locate a cipher. Begrudgingly also provide a SSL_CIPHER_get_by_id() function that locates a cipher via the internal cipher identifier. Unfortunately these have already been leaked outside the library via SSL_CIPHER_by_id() and the various SSL3_CK_* and TLS1_CK_* defines in the ssl3.h/tls1.h headers. ok beck@ miod@
-rw-r--r--src/lib/libssl/s3_lib.c9
-rw-r--r--src/lib/libssl/src/ssl/s3_lib.c9
-rw-r--r--src/lib/libssl/src/ssl/ssl.h5
-rw-r--r--src/lib/libssl/src/ssl/ssl_ciph.c20
-rw-r--r--src/lib/libssl/src/ssl/ssl_locl.h3
-rw-r--r--src/lib/libssl/ssl.h5
-rw-r--r--src/lib/libssl/ssl_ciph.c20
-rw-r--r--src/lib/libssl/ssl_locl.h3
8 files changed, 66 insertions, 8 deletions
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index c7731b3cf4..a1428907ac 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_lib.c,v 1.92 2015/02/06 08:30:23 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.93 2015/02/07 04:17:11 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 *
@@ -1950,9 +1950,16 @@ ssl3_get_cipher_by_id(unsigned int id)
1950 cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS); 1950 cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
1951 if (cp != NULL && cp->valid == 1) 1951 if (cp != NULL && cp->valid == 1)
1952 return (cp); 1952 return (cp);
1953
1953 return (NULL); 1954 return (NULL);
1954} 1955}
1955 1956
1957const SSL_CIPHER *
1958ssl3_get_cipher_by_value(uint16_t value)
1959{
1960 return ssl3_get_cipher_by_id(SSL3_CK_ID | value);
1961}
1962
1956uint16_t 1963uint16_t
1957ssl3_cipher_get_value(const SSL_CIPHER *c) 1964ssl3_cipher_get_value(const SSL_CIPHER *c)
1958{ 1965{
diff --git a/src/lib/libssl/src/ssl/s3_lib.c b/src/lib/libssl/src/ssl/s3_lib.c
index c7731b3cf4..a1428907ac 100644
--- a/src/lib/libssl/src/ssl/s3_lib.c
+++ b/src/lib/libssl/src/ssl/s3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_lib.c,v 1.92 2015/02/06 08:30:23 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.93 2015/02/07 04:17:11 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 *
@@ -1950,9 +1950,16 @@ ssl3_get_cipher_by_id(unsigned int id)
1950 cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS); 1950 cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
1951 if (cp != NULL && cp->valid == 1) 1951 if (cp != NULL && cp->valid == 1)
1952 return (cp); 1952 return (cp);
1953
1953 return (NULL); 1954 return (NULL);
1954} 1955}
1955 1956
1957const SSL_CIPHER *
1958ssl3_get_cipher_by_value(uint16_t value)
1959{
1960 return ssl3_get_cipher_by_id(SSL3_CK_ID | value);
1961}
1962
1956uint16_t 1963uint16_t
1957ssl3_cipher_get_value(const SSL_CIPHER *c) 1964ssl3_cipher_get_value(const SSL_CIPHER *c)
1958{ 1965{
diff --git a/src/lib/libssl/src/ssl/ssl.h b/src/lib/libssl/src/ssl/ssl.h
index 571786dcf6..75103426f3 100644
--- a/src/lib/libssl/src/ssl/ssl.h
+++ b/src/lib/libssl/src/ssl/ssl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl.h,v 1.80 2015/02/06 08:30:23 jsing Exp $ */ 1/* $OpenBSD: ssl.h,v 1.81 2015/02/07 04:17:11 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 *
@@ -1545,10 +1545,13 @@ int SSL_clear(SSL *s);
1545void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm); 1545void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);
1546 1546
1547const SSL_CIPHER *SSL_get_current_cipher(const SSL *s); 1547const SSL_CIPHER *SSL_get_current_cipher(const SSL *s);
1548const SSL_CIPHER *SSL_CIPHER_get_by_id(unsigned int id);
1549const SSL_CIPHER *SSL_CIPHER_get_by_value(uint16_t value);
1548int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits); 1550int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits);
1549char * SSL_CIPHER_get_version(const SSL_CIPHER *c); 1551char * SSL_CIPHER_get_version(const SSL_CIPHER *c);
1550const char * SSL_CIPHER_get_name(const SSL_CIPHER *c); 1552const char * SSL_CIPHER_get_name(const SSL_CIPHER *c);
1551unsigned long SSL_CIPHER_get_id(const SSL_CIPHER *c); 1553unsigned long SSL_CIPHER_get_id(const SSL_CIPHER *c);
1554uint16_t SSL_CIPHER_get_value(const SSL_CIPHER *c);
1552 1555
1553int SSL_get_fd(const SSL *s); 1556int SSL_get_fd(const SSL *s);
1554int SSL_get_rfd(const SSL *s); 1557int SSL_get_rfd(const SSL *s);
diff --git a/src/lib/libssl/src/ssl/ssl_ciph.c b/src/lib/libssl/src/ssl/ssl_ciph.c
index ce82c2705c..96b4099d19 100644
--- a/src/lib/libssl/src/ssl/ssl_ciph.c
+++ b/src/lib/libssl/src/ssl/ssl_ciph.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_ciph.c,v 1.80 2015/01/26 13:06:39 jsing Exp $ */ 1/* $OpenBSD: ssl_ciph.c,v 1.81 2015/02/07 04:17:11 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 *
@@ -1525,6 +1525,18 @@ ssl_create_cipher_list(const SSL_METHOD *ssl_method,
1525 return (cipherstack); 1525 return (cipherstack);
1526} 1526}
1527 1527
1528const SSL_CIPHER *
1529SSL_CIPHER_get_by_id(unsigned int id)
1530{
1531 return ssl3_get_cipher_by_id(id);
1532}
1533
1534const SSL_CIPHER *
1535SSL_CIPHER_get_by_value(uint16_t value)
1536{
1537 return ssl3_get_cipher_by_value(value);
1538}
1539
1528char * 1540char *
1529SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len) 1541SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len)
1530{ 1542{
@@ -1728,6 +1740,12 @@ SSL_CIPHER_get_id(const SSL_CIPHER *c)
1728 return c->id; 1740 return c->id;
1729} 1741}
1730 1742
1743uint16_t
1744SSL_CIPHER_get_value(const SSL_CIPHER *c)
1745{
1746 return ssl3_cipher_get_value(c);
1747}
1748
1731void * 1749void *
1732SSL_COMP_get_compression_methods(void) 1750SSL_COMP_get_compression_methods(void)
1733{ 1751{
diff --git a/src/lib/libssl/src/ssl/ssl_locl.h b/src/lib/libssl/src/ssl/ssl_locl.h
index 94c0d4a83d..20656682bd 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.85 2015/02/06 08:30:23 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.86 2015/02/07 04:17:11 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 *
@@ -616,6 +616,7 @@ int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen);
616int ssl3_num_ciphers(void); 616int ssl3_num_ciphers(void);
617const SSL_CIPHER *ssl3_get_cipher(unsigned int u); 617const SSL_CIPHER *ssl3_get_cipher(unsigned int u);
618const SSL_CIPHER *ssl3_get_cipher_by_id(unsigned int id); 618const SSL_CIPHER *ssl3_get_cipher_by_id(unsigned int id);
619const SSL_CIPHER *ssl3_get_cipher_by_value(uint16_t value);
619uint16_t ssl3_cipher_get_value(const SSL_CIPHER *c); 620uint16_t ssl3_cipher_get_value(const SSL_CIPHER *c);
620int ssl3_renegotiate(SSL *ssl); 621int ssl3_renegotiate(SSL *ssl);
621 622
diff --git a/src/lib/libssl/ssl.h b/src/lib/libssl/ssl.h
index 571786dcf6..75103426f3 100644
--- a/src/lib/libssl/ssl.h
+++ b/src/lib/libssl/ssl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl.h,v 1.80 2015/02/06 08:30:23 jsing Exp $ */ 1/* $OpenBSD: ssl.h,v 1.81 2015/02/07 04:17:11 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 *
@@ -1545,10 +1545,13 @@ int SSL_clear(SSL *s);
1545void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm); 1545void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);
1546 1546
1547const SSL_CIPHER *SSL_get_current_cipher(const SSL *s); 1547const SSL_CIPHER *SSL_get_current_cipher(const SSL *s);
1548const SSL_CIPHER *SSL_CIPHER_get_by_id(unsigned int id);
1549const SSL_CIPHER *SSL_CIPHER_get_by_value(uint16_t value);
1548int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits); 1550int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits);
1549char * SSL_CIPHER_get_version(const SSL_CIPHER *c); 1551char * SSL_CIPHER_get_version(const SSL_CIPHER *c);
1550const char * SSL_CIPHER_get_name(const SSL_CIPHER *c); 1552const char * SSL_CIPHER_get_name(const SSL_CIPHER *c);
1551unsigned long SSL_CIPHER_get_id(const SSL_CIPHER *c); 1553unsigned long SSL_CIPHER_get_id(const SSL_CIPHER *c);
1554uint16_t SSL_CIPHER_get_value(const SSL_CIPHER *c);
1552 1555
1553int SSL_get_fd(const SSL *s); 1556int SSL_get_fd(const SSL *s);
1554int SSL_get_rfd(const SSL *s); 1557int SSL_get_rfd(const SSL *s);
diff --git a/src/lib/libssl/ssl_ciph.c b/src/lib/libssl/ssl_ciph.c
index ce82c2705c..96b4099d19 100644
--- a/src/lib/libssl/ssl_ciph.c
+++ b/src/lib/libssl/ssl_ciph.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_ciph.c,v 1.80 2015/01/26 13:06:39 jsing Exp $ */ 1/* $OpenBSD: ssl_ciph.c,v 1.81 2015/02/07 04:17:11 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 *
@@ -1525,6 +1525,18 @@ ssl_create_cipher_list(const SSL_METHOD *ssl_method,
1525 return (cipherstack); 1525 return (cipherstack);
1526} 1526}
1527 1527
1528const SSL_CIPHER *
1529SSL_CIPHER_get_by_id(unsigned int id)
1530{
1531 return ssl3_get_cipher_by_id(id);
1532}
1533
1534const SSL_CIPHER *
1535SSL_CIPHER_get_by_value(uint16_t value)
1536{
1537 return ssl3_get_cipher_by_value(value);
1538}
1539
1528char * 1540char *
1529SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len) 1541SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len)
1530{ 1542{
@@ -1728,6 +1740,12 @@ SSL_CIPHER_get_id(const SSL_CIPHER *c)
1728 return c->id; 1740 return c->id;
1729} 1741}
1730 1742
1743uint16_t
1744SSL_CIPHER_get_value(const SSL_CIPHER *c)
1745{
1746 return ssl3_cipher_get_value(c);
1747}
1748
1731void * 1749void *
1732SSL_COMP_get_compression_methods(void) 1750SSL_COMP_get_compression_methods(void)
1733{ 1751{
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 94c0d4a83d..20656682bd 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.85 2015/02/06 08:30:23 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.86 2015/02/07 04:17:11 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 *
@@ -616,6 +616,7 @@ int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen);
616int ssl3_num_ciphers(void); 616int ssl3_num_ciphers(void);
617const SSL_CIPHER *ssl3_get_cipher(unsigned int u); 617const SSL_CIPHER *ssl3_get_cipher(unsigned int u);
618const SSL_CIPHER *ssl3_get_cipher_by_id(unsigned int id); 618const SSL_CIPHER *ssl3_get_cipher_by_id(unsigned int id);
619const SSL_CIPHER *ssl3_get_cipher_by_value(uint16_t value);
619uint16_t ssl3_cipher_get_value(const SSL_CIPHER *c); 620uint16_t ssl3_cipher_get_value(const SSL_CIPHER *c);
620int ssl3_renegotiate(SSL *ssl); 621int ssl3_renegotiate(SSL *ssl);
621 622