Skip to content

Commit

Permalink
Rename new_cipher to cipher.
Browse files Browse the repository at this point in the history
This is in the SSL_HANDSHAKE struct and is what we're currently
negotiating, so there is really nothing more "new" about the cipher
than there is the key block or other parts of the handshake data.

ok inoguchi@ tb@
  • Loading branch information
4a6f656c committed Mar 24, 2021
1 parent 48b0de1 commit 661440b
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions lib/libssl/s3_lib.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: s3_lib.c,v 1.205 2021/03/21 18:36:34 jsing Exp $ */
/* $OpenBSD: s3_lib.c,v 1.206 2021/03/24 18:43:59 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
Expand Down Expand Up @@ -2548,7 +2548,7 @@ ssl3_get_req_cert_types(SSL *s, CBB *cbb)
{
unsigned long alg_k;

alg_k = S3I(s)->hs.new_cipher->algorithm_mkey;
alg_k = S3I(s)->hs.cipher->algorithm_mkey;

#ifndef OPENSSL_NO_GOST
if ((alg_k & SSL_kGOST) != 0) {
Expand Down
4 changes: 2 additions & 2 deletions lib/libssl/ssl_both.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ssl_both.c,v 1.24 2021/02/20 14:14:16 tb Exp $ */
/* $OpenBSD: ssl_both.c,v 1.25 2021/03/24 18:44:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
Expand Down Expand Up @@ -224,7 +224,7 @@ ssl3_take_mac(SSL *s)
* If no new cipher setup return immediately: other functions will
* set the appropriate error.
*/
if (S3I(s)->hs.new_cipher == NULL)
if (S3I(s)->hs.cipher == NULL)
return;

if (S3I(s)->hs.state & SSL_ST_CONNECT) {
Expand Down
6 changes: 3 additions & 3 deletions lib/libssl/ssl_ciph.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ssl_ciph.c,v 1.120 2021/02/07 15:26:32 jsing Exp $ */
/* $OpenBSD: ssl_ciph.c,v 1.121 2021/03/24 18:44:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
Expand Down Expand Up @@ -563,10 +563,10 @@ ssl_get_handshake_evp_md(SSL *s, const EVP_MD **md)

*md = NULL;

if (S3I(s)->hs.new_cipher == NULL)
if (S3I(s)->hs.cipher == NULL)
return 0;

handshake_mac = S3I(s)->hs.new_cipher->algorithm2 &
handshake_mac = S3I(s)->hs.cipher->algorithm2 &
SSL_HANDSHAKE_MAC_MASK;

/* For TLSv1.2 we upgrade the default MD5+SHA1 MAC to SHA256. */
Expand Down
28 changes: 14 additions & 14 deletions lib/libssl/ssl_clnt.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ssl_clnt.c,v 1.87 2021/03/24 18:40:03 jsing Exp $ */
/* $OpenBSD: ssl_clnt.c,v 1.88 2021/03/24 18:44:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
Expand Down Expand Up @@ -343,7 +343,7 @@ ssl3_connect(SSL *s)
break;
}
/* Check if it is anon DH/ECDH. */
if (!(S3I(s)->hs.new_cipher->algorithm_auth &
if (!(S3I(s)->hs.cipher->algorithm_auth &
SSL_aNULL)) {
ret = ssl3_get_server_certificate(s);
if (ret <= 0)
Expand Down Expand Up @@ -477,7 +477,7 @@ ssl3_connect(SSL *s)
S3I(s)->hs.state = SSL3_ST_CW_FINISHED_A;
s->internal->init_num = 0;

s->session->cipher = S3I(s)->hs.new_cipher;
s->session->cipher = S3I(s)->hs.cipher;
if (!tls1_setup_key_block(s)) {
ret = -1;
goto end;
Expand Down Expand Up @@ -1054,7 +1054,7 @@ ssl3_get_server_hello(SSL *s)
SSLerror(s, SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED);
goto fatal_err;
}
S3I(s)->hs.new_cipher = cipher;
S3I(s)->hs.cipher = cipher;

if (!tls1_transcript_hash_init(s))
goto err;
Expand All @@ -1063,7 +1063,7 @@ ssl3_get_server_hello(SSL *s)
* Don't digest cached records if no sigalgs: we may need them for
* client authentication.
*/
alg_k = S3I(s)->hs.new_cipher->algorithm_mkey;
alg_k = S3I(s)->hs.cipher->algorithm_mkey;
if (!(SSL_USE_SIGALGS(s) || (alg_k & SSL_kGOST)))
tls1_transcript_free(s);

Expand Down Expand Up @@ -1276,7 +1276,7 @@ ssl3_get_server_kex_dhe(SSL *s, EVP_PKEY **pkey, CBS *cbs)
long alg_a;
int al;

alg_a = S3I(s)->hs.new_cipher->algorithm_auth;
alg_a = S3I(s)->hs.cipher->algorithm_auth;
sc = SSI(s)->sess_cert;

if ((dh = DH_new()) == NULL) {
Expand Down Expand Up @@ -1404,7 +1404,7 @@ ssl3_get_server_kex_ecdhe(SSL *s, EVP_PKEY **pkey, CBS *cbs)
int nid;
int al;

alg_a = S3I(s)->hs.new_cipher->algorithm_auth;
alg_a = S3I(s)->hs.cipher->algorithm_auth;
sc = SSI(s)->sess_cert;

/* Only named curves are supported. */
Expand Down Expand Up @@ -1483,8 +1483,8 @@ ssl3_get_server_key_exchange(SSL *s)

EVP_MD_CTX_init(&md_ctx);

alg_k = S3I(s)->hs.new_cipher->algorithm_mkey;
alg_a = S3I(s)->hs.new_cipher->algorithm_auth;
alg_k = S3I(s)->hs.cipher->algorithm_mkey;
alg_a = S3I(s)->hs.cipher->algorithm_auth;

/*
* Use same message size as in ssl3_get_certificate_request()
Expand Down Expand Up @@ -1682,7 +1682,7 @@ ssl3_get_certificate_request(SSL *s)
}

/* TLS does not like anon-DH with client cert */
if (S3I(s)->hs.new_cipher->algorithm_auth & SSL_aNULL) {
if (S3I(s)->hs.cipher->algorithm_auth & SSL_aNULL) {
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE);
SSLerror(s, SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER);
goto err;
Expand Down Expand Up @@ -2251,7 +2251,7 @@ ssl3_send_client_kex_gost(SSL *s, SESS_CERT *sess_cert, CBB *cbb)
}

/* XXX check handshake hash instead. */
if (S3I(s)->hs.new_cipher->algorithm2 & SSL_HANDSHAKE_MAC_GOST94)
if (S3I(s)->hs.cipher->algorithm2 & SSL_HANDSHAKE_MAC_GOST94)
nid = NID_id_GostR3411_94;
else
nid = NID_id_tc26_gost3411_2012_256;
Expand Down Expand Up @@ -2314,7 +2314,7 @@ ssl3_send_client_key_exchange(SSL *s)
memset(&cbb, 0, sizeof(cbb));

if (S3I(s)->hs.state == SSL3_ST_CW_KEY_EXCH_A) {
alg_k = S3I(s)->hs.new_cipher->algorithm_mkey;
alg_k = S3I(s)->hs.cipher->algorithm_mkey;

if ((sess_cert = SSI(s)->sess_cert) == NULL) {
ssl3_send_alert(s, SSL3_AL_FATAL,
Expand Down Expand Up @@ -2726,8 +2726,8 @@ ssl3_check_cert_and_algorithm(SSL *s)
SESS_CERT *sc;
DH *dh;

alg_k = S3I(s)->hs.new_cipher->algorithm_mkey;
alg_a = S3I(s)->hs.new_cipher->algorithm_auth;
alg_k = S3I(s)->hs.cipher->algorithm_mkey;
alg_a = S3I(s)->hs.cipher->algorithm_auth;

/* We don't have a certificate. */
if (alg_a & SSL_aNULL)
Expand Down
16 changes: 8 additions & 8 deletions lib/libssl/ssl_lib.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ssl_lib.c,v 1.251 2021/03/02 15:43:12 tb Exp $ */
/* $OpenBSD: ssl_lib.c,v 1.252 2021/03/24 18:44:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
Expand Down Expand Up @@ -2111,8 +2111,8 @@ ssl_using_ecc_cipher(SSL *s)
{
unsigned long alg_a, alg_k;

alg_a = S3I(s)->hs.new_cipher->algorithm_auth;
alg_k = S3I(s)->hs.new_cipher->algorithm_mkey;
alg_a = S3I(s)->hs.cipher->algorithm_auth;
alg_k = S3I(s)->hs.cipher->algorithm_mkey;

return SSI(s)->tlsext_ecpointformatlist != NULL &&
SSI(s)->tlsext_ecpointformatlist_length > 0 &&
Expand All @@ -2122,7 +2122,7 @@ ssl_using_ecc_cipher(SSL *s)
int
ssl_check_srvr_ecc_cert_and_alg(X509 *x, SSL *s)
{
const SSL_CIPHER *cs = S3I(s)->hs.new_cipher;
const SSL_CIPHER *cs = S3I(s)->hs.cipher;
unsigned long alg_a;

alg_a = cs->algorithm_auth;
Expand Down Expand Up @@ -2150,9 +2150,9 @@ ssl_get_server_send_pkey(const SSL *s)
int i;

c = s->cert;
ssl_set_cert_masks(c, S3I(s)->hs.new_cipher);
ssl_set_cert_masks(c, S3I(s)->hs.cipher);

alg_a = S3I(s)->hs.new_cipher->algorithm_auth;
alg_a = S3I(s)->hs.cipher->algorithm_auth;

if (alg_a & SSL_aECDSA) {
i = SSL_PKEY_ECC;
Expand Down Expand Up @@ -2211,9 +2211,9 @@ ssl_get_auto_dh(SSL *s)

if (s->cert->dh_tmp_auto == 2) {
keylen = 1024;
} else if (S3I(s)->hs.new_cipher->algorithm_auth & SSL_aNULL) {
} else if (S3I(s)->hs.cipher->algorithm_auth & SSL_aNULL) {
keylen = 1024;
if (S3I(s)->hs.new_cipher->strength_bits == 256)
if (S3I(s)->hs.cipher->strength_bits == 256)
keylen = 3072;
} else {
if ((cpk = ssl_get_server_send_pkey(s)) == NULL)
Expand Down
4 changes: 2 additions & 2 deletions lib/libssl/ssl_locl.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ssl_locl.h,v 1.329 2021/03/24 18:40:03 jsing Exp $ */
/* $OpenBSD: ssl_locl.h,v 1.330 2021/03/24 18:44:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
Expand Down Expand Up @@ -483,7 +483,7 @@ typedef struct ssl_handshake_st {
int state;

/* Cipher being negotiated in this handshake. */
const SSL_CIPHER *new_cipher;
const SSL_CIPHER *cipher;

/* Extensions seen in this handshake. */
uint32_t extensions_seen;
Expand Down
6 changes: 3 additions & 3 deletions lib/libssl/ssl_pkt.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ssl_pkt.c,v 1.38 2021/03/24 18:40:03 jsing Exp $ */
/* $OpenBSD: ssl_pkt.c,v 1.39 2021/03/24 18:44:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
Expand Down Expand Up @@ -1038,7 +1038,7 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
}

/* Check we have a cipher to change to */
if (S3I(s)->hs.new_cipher == NULL) {
if (S3I(s)->hs.cipher == NULL) {
al = SSL_AD_UNEXPECTED_MESSAGE;
SSLerror(s, SSL_R_CCS_RECEIVED_EARLY);
goto fatal_err;
Expand Down Expand Up @@ -1170,7 +1170,7 @@ ssl3_do_change_cipher_spec(SSL *s)
return (0);
}

s->session->cipher = S3I(s)->hs.new_cipher;
s->session->cipher = S3I(s)->hs.cipher;
if (!tls1_setup_key_block(s))
return (0);
}
Expand Down
34 changes: 17 additions & 17 deletions lib/libssl/ssl_srvr.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ssl_srvr.c,v 1.98 2021/03/24 18:40:03 jsing Exp $ */
/* $OpenBSD: ssl_srvr.c,v 1.99 2021/03/24 18:44:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
Expand Down Expand Up @@ -394,7 +394,7 @@ ssl3_accept(SSL *s)
case SSL3_ST_SW_CERT_A:
case SSL3_ST_SW_CERT_B:
/* Check if it is anon DH or anon ECDH. */
if (!(S3I(s)->hs.new_cipher->algorithm_auth &
if (!(S3I(s)->hs.cipher->algorithm_auth &
SSL_aNULL)) {
if (SSL_is_dtls(s))
dtls1_start_timer(s);
Expand All @@ -414,7 +414,7 @@ ssl3_accept(SSL *s)

case SSL3_ST_SW_KEY_EXCH_A:
case SSL3_ST_SW_KEY_EXCH_B:
alg_k = S3I(s)->hs.new_cipher->algorithm_mkey;
alg_k = S3I(s)->hs.cipher->algorithm_mkey;

/*
* Only send if using a DH key exchange.
Expand Down Expand Up @@ -459,7 +459,7 @@ ssl3_accept(SSL *s)
if (!(s->verify_mode & SSL_VERIFY_PEER) ||
((s->session->peer != NULL) &&
(s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) ||
((S3I(s)->hs.new_cipher->algorithm_auth &
((S3I(s)->hs.cipher->algorithm_auth &
SSL_aNULL) && !(s->verify_mode &
SSL_VERIFY_FAIL_IF_NO_PEER_CERT))) {
/* No cert request. */
Expand Down Expand Up @@ -542,7 +542,7 @@ ssl3_accept(SSL *s)
s->internal->init_num = 0;
}

alg_k = S3I(s)->hs.new_cipher->algorithm_mkey;
alg_k = S3I(s)->hs.cipher->algorithm_mkey;
if (ret == 2) {
/*
* For the ECDH ciphersuites when
Expand Down Expand Up @@ -641,7 +641,7 @@ ssl3_accept(SSL *s)

case SSL3_ST_SW_CHANGE_A:
case SSL3_ST_SW_CHANGE_B:
s->session->cipher = S3I(s)->hs.new_cipher;
s->session->cipher = S3I(s)->hs.cipher;
if (!tls1_setup_key_block(s)) {
ret = -1;
goto end;
Expand Down Expand Up @@ -1122,15 +1122,15 @@ ssl3_get_client_hello(SSL *s)
SSLerror(s, SSL_R_NO_SHARED_CIPHER);
goto fatal_err;
}
S3I(s)->hs.new_cipher = c;
S3I(s)->hs.cipher = c;
} else {
S3I(s)->hs.new_cipher = s->session->cipher;
S3I(s)->hs.cipher = s->session->cipher;
}

if (!tls1_transcript_hash_init(s))
goto err;

alg_k = S3I(s)->hs.new_cipher->algorithm_mkey;
alg_k = S3I(s)->hs.cipher->algorithm_mkey;
if (!(SSL_USE_SIGALGS(s) || (alg_k & SSL_kGOST)) ||
!(s->verify_mode & SSL_VERIFY_PEER))
tls1_transcript_free(s);
Expand All @@ -1144,7 +1144,7 @@ ssl3_get_client_hello(SSL *s)
* ssl version is set - sslv3
* s->session - The ssl session has been setup.
* s->internal->hit - session reuse flag
* s->hs.new_cipher - the new cipher to use.
* s->hs.cipher - the new cipher to use.
*/

/* Handles TLS extensions that we couldn't check earlier */
Expand Down Expand Up @@ -1265,7 +1265,7 @@ ssl3_send_server_hello(SSL *s)

/* Cipher suite. */
if (!CBB_add_u16(&server_hello,
ssl3_cipher_get_value(S3I(s)->hs.new_cipher)))
ssl3_cipher_get_value(S3I(s)->hs.cipher)))
goto err;

/* Compression method (null). */
Expand Down Expand Up @@ -1336,7 +1336,7 @@ ssl3_send_server_kex_dhe(SSL *s, CBB *cbb)

if (dhp == NULL && s->cert->dh_tmp_cb != NULL)
dhp = s->cert->dh_tmp_cb(s, 0,
SSL_C_PKEYLENGTH(S3I(s)->hs.new_cipher));
SSL_C_PKEYLENGTH(S3I(s)->hs.cipher));

if (dhp == NULL) {
al = SSL_AD_HANDSHAKE_FAILURE;
Expand Down Expand Up @@ -1544,7 +1544,7 @@ ssl3_send_server_key_exchange(SSL *s)
if (!CBB_init(&cbb_params, 0))
goto err;

type = S3I(s)->hs.new_cipher->algorithm_mkey;
type = S3I(s)->hs.cipher->algorithm_mkey;
if (type & SSL_kDHE) {
if (ssl3_send_server_kex_dhe(s, &cbb_params) != 1)
goto err;
Expand All @@ -1564,8 +1564,8 @@ ssl3_send_server_key_exchange(SSL *s)
goto err;

/* Add signature unless anonymous. */
if (!(S3I(s)->hs.new_cipher->algorithm_auth & SSL_aNULL)) {
if ((pkey = ssl_get_sign_pkey(s, S3I(s)->hs.new_cipher,
if (!(S3I(s)->hs.cipher->algorithm_auth & SSL_aNULL)) {
if ((pkey = ssl_get_sign_pkey(s, S3I(s)->hs.cipher,
&md, &sigalg)) == NULL) {
al = SSL_AD_DECODE_ERROR;
goto fatal_err;
Expand Down Expand Up @@ -2002,7 +2002,7 @@ ssl3_get_client_kex_gost(SSL *s, CBS *cbs)
int ret = 0;

/* Get our certificate private key*/
alg_a = S3I(s)->hs.new_cipher->algorithm_auth;
alg_a = S3I(s)->hs.cipher->algorithm_auth;
if (alg_a & SSL_aGOST01)
pk = s->cert->pkeys[SSL_PKEY_GOST01].privatekey;

Expand Down Expand Up @@ -2081,7 +2081,7 @@ ssl3_get_client_key_exchange(SSL *s)

CBS_init(&cbs, s->internal->init_msg, n);

alg_k = S3I(s)->hs.new_cipher->algorithm_mkey;
alg_k = S3I(s)->hs.cipher->algorithm_mkey;

if (alg_k & SSL_kRSA) {
if (ssl3_get_client_kex_rsa(s, &cbs) != 1)
Expand Down
4 changes: 2 additions & 2 deletions lib/libssl/t1_enc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: t1_enc.c,v 1.134 2021/03/24 18:40:03 jsing Exp $ */
/* $OpenBSD: t1_enc.c,v 1.135 2021/03/24 18:44:00 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
Expand Down Expand Up @@ -343,7 +343,7 @@ tls1_change_cipher_state(SSL *s, int which)

if (aead != NULL) {
key_len = EVP_AEAD_key_length(aead);
iv_len = SSL_CIPHER_AEAD_FIXED_NONCE_LEN(S3I(s)->hs.new_cipher);
iv_len = SSL_CIPHER_AEAD_FIXED_NONCE_LEN(S3I(s)->hs.cipher);
} else {
key_len = EVP_CIPHER_key_length(cipher);
iv_len = EVP_CIPHER_iv_length(cipher);
Expand Down
Loading

0 comments on commit 661440b

Please sign in to comment.