summaryrefslogtreecommitdiff
path: root/src/lib/libssl/s3_lib.c
diff options
context:
space:
mode:
authorjsing <>2015-02-06 08:30:23 +0000
committerjsing <>2015-02-06 08:30:23 +0000
commit04f5c3dd2b47368b601e30fea9b329d7e90e5233 (patch)
tree3d9e90980fb8319df5be140e688f4782d92d6aa1 /src/lib/libssl/s3_lib.c
parentd9fc2c3367b4d3680c1f1fa9d18253a4ba0f42cc (diff)
downloadopenbsd-04f5c3dd2b47368b601e30fea9b329d7e90e5233.tar.gz
openbsd-04f5c3dd2b47368b601e30fea9b329d7e90e5233.tar.bz2
openbsd-04f5c3dd2b47368b601e30fea9b329d7e90e5233.zip
Bring back the horrible API that is get_cipher_by_char/put_cipher_by_char.
This API was intended to be an internal only, however like many things in OpenSSL, it is exposed externally and parts of the software ecosystem are now using it since there is no real alternative within the public API. ok doug@, tedu@ and reluctantly miod@
Diffstat (limited to 'src/lib/libssl/s3_lib.c')
-rw-r--r--src/lib/libssl/s3_lib.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index 98eff97131..c7731b3cf4 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.91 2014/12/16 05:47:28 miod Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.92 2015/02/06 08:30:23 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 *
@@ -2519,7 +2519,42 @@ ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void))
2519 return (1); 2519 return (1);
2520} 2520}
2521 2521
2522SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt, 2522/*
2523 * This function needs to check if the ciphers required are actually available.
2524 */
2525const SSL_CIPHER *
2526ssl3_get_cipher_by_char(const unsigned char *p)
2527{
2528 const SSL_CIPHER *cp;
2529 unsigned long id;
2530 SSL_CIPHER c;
2531
2532 id = 0x03000000L | ((unsigned long)p[0] << 8L) | (unsigned long)p[1];
2533 c.id = id;
2534 cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
2535 if (cp == NULL || cp->valid == 0)
2536 return NULL;
2537 else
2538 return cp;
2539}
2540
2541int
2542ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
2543{
2544 long l;
2545
2546 if (p != NULL) {
2547 l = c->id;
2548 if ((l & 0xff000000) != 0x03000000)
2549 return (0);
2550 p[0] = ((unsigned char)(l >> 8L)) & 0xFF;
2551 p[1] = ((unsigned char)(l)) & 0xFF;
2552 }
2553 return (2);
2554}
2555
2556SSL_CIPHER *
2557ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
2523 STACK_OF(SSL_CIPHER) *srvr) 2558 STACK_OF(SSL_CIPHER) *srvr)
2524{ 2559{
2525 unsigned long alg_k, alg_a, mask_k, mask_a; 2560 unsigned long alg_k, alg_a, mask_k, mask_a;