* -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];
return -1;
}
- if (send) {
+ if (sending) {
ctx = s->enc_write_ctx;
staticiv = s->write_iv;
seq = RECORD_LAYER_get_write_sequence(&s->rlayer);
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) {
return -1;
}
- if (!send) {
+ if (!sending) {
/*
* Take off tag. There must be at least one byte of content type as
* well as the tag
}
/* 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,
|| (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)
* 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) {
* 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);
}
}
} 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 {
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,
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))
#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,
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";
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);
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,
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;
}
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))