summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2014-08-11 01:06:22 +0000
committerjsing <>2014-08-11 01:06:22 +0000
commitb4d8ae6f39ff2ded10621922d24e574845e23ece (patch)
treec4b22f9d4535ad9c0a7097891de25f1e7d9dde3b
parenta7c77634045ea4fc410870715aea4a916d36adb1 (diff)
downloadopenbsd-b4d8ae6f39ff2ded10621922d24e574845e23ece.tar.gz
openbsd-b4d8ae6f39ff2ded10621922d24e574845e23ece.tar.bz2
openbsd-b4d8ae6f39ff2ded10621922d24e574845e23ece.zip
Provide a ssl3_get_cipher_by_id() function that allows ciphers to be looked
up by their ID. For one, this avoids an ugly mess in ssl_sess.c, where the cipher value is manually written into a buffer, just so the cipher can be located using ssl3_get_cipher_by_char(). ok bcook@ miod@
-rw-r--r--src/lib/libssl/s3_lib.c15
-rw-r--r--src/lib/libssl/src/ssl/s3_lib.c15
-rw-r--r--src/lib/libssl/src/ssl/ssl_locl.h3
-rw-r--r--src/lib/libssl/src/ssl/ssl_sess.c15
-rw-r--r--src/lib/libssl/ssl_locl.h3
-rw-r--r--src/lib/libssl/ssl_sess.c15
6 files changed, 36 insertions, 30 deletions
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index acb35a8f25..1d84effeea 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.75 2014/08/10 15:06:15 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.76 2014/08/11 01:06:22 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 *
@@ -1873,6 +1873,19 @@ ssl3_get_cipher(unsigned int u)
1873 return (NULL); 1873 return (NULL);
1874} 1874}
1875 1875
1876const SSL_CIPHER *
1877ssl3_get_cipher_by_id(unsigned int id)
1878{
1879 const SSL_CIPHER *cp;
1880 SSL_CIPHER c;
1881
1882 c.id = id;
1883 cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
1884 if (cp != NULL && cp->valid == 1)
1885 return (cp);
1886 return (NULL);
1887}
1888
1876int 1889int
1877ssl3_pending(const SSL *s) 1890ssl3_pending(const SSL *s)
1878{ 1891{
diff --git a/src/lib/libssl/src/ssl/s3_lib.c b/src/lib/libssl/src/ssl/s3_lib.c
index acb35a8f25..1d84effeea 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.75 2014/08/10 15:06:15 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.76 2014/08/11 01:06:22 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 *
@@ -1873,6 +1873,19 @@ ssl3_get_cipher(unsigned int u)
1873 return (NULL); 1873 return (NULL);
1874} 1874}
1875 1875
1876const SSL_CIPHER *
1877ssl3_get_cipher_by_id(unsigned int id)
1878{
1879 const SSL_CIPHER *cp;
1880 SSL_CIPHER c;
1881
1882 c.id = id;
1883 cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
1884 if (cp != NULL && cp->valid == 1)
1885 return (cp);
1886 return (NULL);
1887}
1888
1876int 1889int
1877ssl3_pending(const SSL *s) 1890ssl3_pending(const SSL *s)
1878{ 1891{
diff --git a/src/lib/libssl/src/ssl/ssl_locl.h b/src/lib/libssl/src/ssl/ssl_locl.h
index 7961c4c06e..87b27a1d99 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.64 2014/08/10 14:42:56 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.65 2014/08/11 01:06:22 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 *
@@ -614,6 +614,7 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok);
614int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen); 614int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen);
615int ssl3_num_ciphers(void); 615int ssl3_num_ciphers(void);
616const SSL_CIPHER *ssl3_get_cipher(unsigned int u); 616const SSL_CIPHER *ssl3_get_cipher(unsigned int u);
617const SSL_CIPHER *ssl3_get_cipher_by_id(unsigned int id);
617int ssl3_renegotiate(SSL *ssl); 618int ssl3_renegotiate(SSL *ssl);
618 619
619int ssl3_renegotiate_check(SSL *ssl); 620int ssl3_renegotiate_check(SSL *ssl);
diff --git a/src/lib/libssl/src/ssl/ssl_sess.c b/src/lib/libssl/src/ssl/ssl_sess.c
index d4fa5a618f..8e285ea9b1 100644
--- a/src/lib/libssl/src/ssl/ssl_sess.c
+++ b/src/lib/libssl/src/ssl/ssl_sess.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_sess.c,v 1.39 2014/08/10 14:42:56 jsing Exp $ */ 1/* $OpenBSD: ssl_sess.c,v 1.40 2014/08/11 01:06:22 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 *
@@ -558,18 +558,7 @@ ssl_get_prev_session(SSL *s, unsigned char *session_id, int len,
558 } 558 }
559 559
560 if (ret->cipher == NULL) { 560 if (ret->cipher == NULL) {
561 unsigned char buf[5], *p; 561 ret->cipher = ssl3_get_cipher_by_id(ret->cipher_id);
562 unsigned long l;
563
564 p = buf;
565 l = ret->cipher_id;
566 l2n(l, p);
567
568 if ((ret->ssl_version >> 8) >= SSL3_VERSION_MAJOR)
569 ret->cipher = ssl3_get_cipher_by_char(&buf[2]);
570 else
571 ret->cipher = ssl3_get_cipher_by_char(&buf[1]);
572
573 if (ret->cipher == NULL) 562 if (ret->cipher == NULL)
574 goto err; 563 goto err;
575 } 564 }
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 7961c4c06e..87b27a1d99 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.64 2014/08/10 14:42:56 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.65 2014/08/11 01:06:22 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 *
@@ -614,6 +614,7 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok);
614int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen); 614int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen);
615int ssl3_num_ciphers(void); 615int ssl3_num_ciphers(void);
616const SSL_CIPHER *ssl3_get_cipher(unsigned int u); 616const SSL_CIPHER *ssl3_get_cipher(unsigned int u);
617const SSL_CIPHER *ssl3_get_cipher_by_id(unsigned int id);
617int ssl3_renegotiate(SSL *ssl); 618int ssl3_renegotiate(SSL *ssl);
618 619
619int ssl3_renegotiate_check(SSL *ssl); 620int ssl3_renegotiate_check(SSL *ssl);
diff --git a/src/lib/libssl/ssl_sess.c b/src/lib/libssl/ssl_sess.c
index d4fa5a618f..8e285ea9b1 100644
--- a/src/lib/libssl/ssl_sess.c
+++ b/src/lib/libssl/ssl_sess.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_sess.c,v 1.39 2014/08/10 14:42:56 jsing Exp $ */ 1/* $OpenBSD: ssl_sess.c,v 1.40 2014/08/11 01:06:22 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 *
@@ -558,18 +558,7 @@ ssl_get_prev_session(SSL *s, unsigned char *session_id, int len,
558 } 558 }
559 559
560 if (ret->cipher == NULL) { 560 if (ret->cipher == NULL) {
561 unsigned char buf[5], *p; 561 ret->cipher = ssl3_get_cipher_by_id(ret->cipher_id);
562 unsigned long l;
563
564 p = buf;
565 l = ret->cipher_id;
566 l2n(l, p);
567
568 if ((ret->ssl_version >> 8) >= SSL3_VERSION_MAJOR)
569 ret->cipher = ssl3_get_cipher_by_char(&buf[2]);
570 else
571 ret->cipher = ssl3_get_cipher_by_char(&buf[1]);
572
573 if (ret->cipher == NULL) 562 if (ret->cipher == NULL)
574 goto err; 563 goto err;
575 } 564 }