mirror of
https://github.com/openssl/openssl.git
synced 2024-12-05 07:54:47 +08:00
Fix minor compiler issues.
Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3220)
This commit is contained in:
parent
87b81496fe
commit
d1186c30a2
@ -21,7 +21,7 @@
|
||||
* -1: if the record's AEAD-authenticator is invalid or, if sending,
|
||||
* an internal error occurred.
|
||||
*/
|
||||
int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
|
||||
int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int sending)
|
||||
{
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
unsigned char iv[EVP_MAX_IV_LENGTH];
|
||||
@ -38,7 +38,7 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (send) {
|
||||
if (sending) {
|
||||
ctx = s->enc_write_ctx;
|
||||
staticiv = s->write_iv;
|
||||
seq = RECORD_LAYER_get_write_sequence(&s->rlayer);
|
||||
@ -75,7 +75,7 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
|
||||
taglen = EVP_CCM8_TLS_TAG_LEN;
|
||||
else
|
||||
taglen = EVP_CCM_TLS_TAG_LEN;
|
||||
if (send && EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, taglen,
|
||||
if (sending && EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, taglen,
|
||||
NULL) <= 0)
|
||||
return -1;
|
||||
} else if (alg_enc & SSL_AESGCM) {
|
||||
@ -86,7 +86,7 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!send) {
|
||||
if (!sending) {
|
||||
/*
|
||||
* Take off tag. There must be at least one byte of content type as
|
||||
* well as the tag
|
||||
@ -118,8 +118,8 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
|
||||
}
|
||||
|
||||
/* TODO(size_t): lenu/lenf should be a size_t but EVP doesn't support it */
|
||||
if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, iv, send) <= 0
|
||||
|| (!send && EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,
|
||||
if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, iv, sending) <= 0
|
||||
|| (!sending && EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,
|
||||
taglen,
|
||||
rec->data + rec->length) <= 0)
|
||||
|| EVP_CipherUpdate(ctx, rec->data, &lenu, rec->input,
|
||||
@ -128,7 +128,7 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
|
||||
|| (size_t)(lenu + lenf) != rec->length) {
|
||||
return -1;
|
||||
}
|
||||
if (send) {
|
||||
if (sending) {
|
||||
/* Add the tag */
|
||||
if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, taglen,
|
||||
rec->data + rec->length) <= 0)
|
||||
|
@ -780,7 +780,7 @@ int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
* client's due to the network latency). Therefore we add 1000ms to our age
|
||||
* calculation to adjust for rounding errors.
|
||||
*/
|
||||
if (sess->timeout >= agesec
|
||||
if (sess->timeout >= (long)agesec
|
||||
&& agems / (uint32_t)1000 == agesec
|
||||
&& ticket_age <= agems + 1000
|
||||
&& ticket_age + TICKET_AGE_ALLOWANCE >= agems + 1000) {
|
||||
|
@ -172,13 +172,13 @@ int ossl_statem_skip_early_data(SSL *s)
|
||||
* Called when we are in SSL_read*(), SSL_write*(), or SSL_accept()
|
||||
* /SSL_connect()/SSL_do_handshake(). Used to test whether we are in an early
|
||||
* data state and whether we should attempt to move the handshake on if so.
|
||||
* |send| is 1 if we are attempting to send data (SSL_write*()), 0 if we are
|
||||
* |sending| is 1 if we are attempting to send data (SSL_write*()), 0 if we are
|
||||
* attempting to read data (SSL_read*()), or -1 if we are in SSL_do_handshake()
|
||||
* or similar.
|
||||
*/
|
||||
void ossl_statem_check_finish_init(SSL *s, int send)
|
||||
void ossl_statem_check_finish_init(SSL *s, int sending)
|
||||
{
|
||||
if (send == -1) {
|
||||
if (sending == -1) {
|
||||
if (s->statem.hand_state == TLS_ST_PENDING_EARLY_DATA_END
|
||||
|| s->statem.hand_state == TLS_ST_EARLY_DATA) {
|
||||
ossl_statem_set_in_init(s, 1);
|
||||
@ -191,16 +191,16 @@ void ossl_statem_check_finish_init(SSL *s, int send)
|
||||
}
|
||||
}
|
||||
} else if (!s->server) {
|
||||
if ((send && (s->statem.hand_state == TLS_ST_PENDING_EARLY_DATA_END
|
||||
if ((sending && (s->statem.hand_state == TLS_ST_PENDING_EARLY_DATA_END
|
||||
|| s->statem.hand_state == TLS_ST_EARLY_DATA)
|
||||
&& s->early_data_state != SSL_EARLY_DATA_WRITING)
|
||||
|| (!send && s->statem.hand_state == TLS_ST_EARLY_DATA)) {
|
||||
|| (!sending && s->statem.hand_state == TLS_ST_EARLY_DATA)) {
|
||||
ossl_statem_set_in_init(s, 1);
|
||||
/*
|
||||
* SSL_write() has been called directly. We don't allow any more
|
||||
* writing of early data.
|
||||
*/
|
||||
if (send && s->early_data_state == SSL_EARLY_DATA_WRITE_RETRY)
|
||||
if (sending && s->early_data_state == SSL_EARLY_DATA_WRITE_RETRY)
|
||||
s->early_data_state = SSL_EARLY_DATA_FINISHED_WRITING;
|
||||
}
|
||||
} else {
|
||||
|
@ -267,7 +267,7 @@ int tls13_setup_key_block(SSL *s)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int derive_secret_key_and_iv(SSL *s, int send, const EVP_MD *md,
|
||||
static int derive_secret_key_and_iv(SSL *s, int sending, const EVP_MD *md,
|
||||
const EVP_CIPHER *ciph,
|
||||
const unsigned char *insecret,
|
||||
const unsigned char *hash,
|
||||
@ -312,7 +312,7 @@ static int derive_secret_key_and_iv(SSL *s, int send, const EVP_MD *md,
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (EVP_CipherInit_ex(ciph_ctx, ciph, NULL, NULL, NULL, send) <= 0
|
||||
if (EVP_CipherInit_ex(ciph_ctx, ciph, NULL, NULL, NULL, sending) <= 0
|
||||
|| !EVP_CIPHER_CTX_ctrl(ciph_ctx, EVP_CTRL_AEAD_SET_IVLEN, ivlen, NULL)
|
||||
|| (taglen != 0 && !EVP_CIPHER_CTX_ctrl(ciph_ctx, EVP_CTRL_AEAD_SET_TAG,
|
||||
taglen, NULL))
|
||||
@ -323,7 +323,7 @@ static int derive_secret_key_and_iv(SSL *s, int send, const EVP_MD *md,
|
||||
|
||||
#ifdef OPENSSL_SSL_TRACE_CRYPTO
|
||||
if (s->msg_callback) {
|
||||
int wh = send ? TLS1_RT_CRYPTO_WRITE : 0;
|
||||
int wh = sending ? TLS1_RT_CRYPTO_WRITE : 0;
|
||||
|
||||
if (ciph->key_len)
|
||||
s->msg_callback(2, s->version, wh | TLS1_RT_CRYPTO_KEY,
|
||||
@ -557,7 +557,7 @@ int tls13_change_cipher_state(SSL *s, int which)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int tls13_update_key(SSL *s, int send)
|
||||
int tls13_update_key(SSL *s, int sending)
|
||||
{
|
||||
static const unsigned char application_traffic[] =
|
||||
"application traffic secret";
|
||||
@ -568,12 +568,12 @@ int tls13_update_key(SSL *s, int send)
|
||||
EVP_CIPHER_CTX *ciph_ctx;
|
||||
int ret = 0;
|
||||
|
||||
if (s->server == send)
|
||||
if (s->server == sending)
|
||||
insecret = s->server_app_traffic_secret;
|
||||
else
|
||||
insecret = s->client_app_traffic_secret;
|
||||
|
||||
if (send) {
|
||||
if (sending) {
|
||||
iv = s->write_iv;
|
||||
ciph_ctx = s->enc_write_ctx;
|
||||
RECORD_LAYER_reset_write_sequence(&s->rlayer);
|
||||
@ -583,7 +583,7 @@ int tls13_update_key(SSL *s, int send)
|
||||
RECORD_LAYER_reset_read_sequence(&s->rlayer);
|
||||
}
|
||||
|
||||
if (!derive_secret_key_and_iv(s, send, ssl_handshake_md(s),
|
||||
if (!derive_secret_key_and_iv(s, sending, ssl_handshake_md(s),
|
||||
s->s3->tmp.new_sym_enc, insecret, NULL,
|
||||
application_traffic,
|
||||
sizeof(application_traffic) - 1, secret, iv,
|
||||
|
@ -548,8 +548,8 @@ static int test_bad_dtls(void)
|
||||
|
||||
if (!TEST_true(send_record(rbio, SSL3_RT_APPLICATION_DATA, tests[i].seq,
|
||||
&tests[i].seq, sizeof(uint64_t)))) {
|
||||
TEST_error("Failed to send data seq #0x%lx (%d)\n",
|
||||
tests[i].seq, i);
|
||||
TEST_error("Failed to send data seq #0x%x%08x (%d)\n",
|
||||
(unsigned int)(tests[i].seq >> 32), (unsigned int)tests[i].seq, i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -558,8 +558,8 @@ static int test_bad_dtls(void)
|
||||
|
||||
ret = SSL_read(con, recv_buf, 2 * sizeof(uint64_t));
|
||||
if (!TEST_int_eq(ret, (int)sizeof(uint64_t))) {
|
||||
TEST_error("SSL_read failed or wrong size on seq#0x%lx (%d)\n",
|
||||
tests[i].seq, i);
|
||||
TEST_error("SSL_read failed or wrong size on seq#0x%x%08x (%d)\n",
|
||||
(unsigned int)(tests[i].seq >> 32), (unsigned int)tests[i].seq, i);
|
||||
goto end;
|
||||
}
|
||||
if (!TEST_true(recv_buf[0] == tests[i].seq))
|
||||
|
Loading…
Reference in New Issue
Block a user