Update pre9
This commit is contained in:
+9
-2
@@ -383,7 +383,8 @@ static int cmd_Options(SSL_CONF_CTX *cctx, const char *value)
|
||||
SSL_FLAG_TBL("NoRenegotiation", SSL_OP_NO_RENEGOTIATION),
|
||||
SSL_FLAG_TBL("AllowNoDHEKEX", SSL_OP_ALLOW_NO_DHE_KEX),
|
||||
SSL_FLAG_TBL("PrioritizeChaCha", SSL_OP_PRIORITIZE_CHACHA),
|
||||
SSL_FLAG_TBL("MiddleboxCompat", SSL_OP_ENABLE_MIDDLEBOX_COMPAT)
|
||||
SSL_FLAG_TBL("MiddleboxCompat", SSL_OP_ENABLE_MIDDLEBOX_COMPAT),
|
||||
SSL_FLAG_TBL_INV("AntiReplay", SSL_OP_NO_ANTI_REPLAY)
|
||||
};
|
||||
if (value == NULL)
|
||||
return -3;
|
||||
@@ -626,6 +627,8 @@ static const ssl_conf_cmd_tbl ssl_conf_cmds[] = {
|
||||
SSL_CONF_CMD_SWITCH("prioritize_chacha", SSL_CONF_FLAG_SERVER),
|
||||
SSL_CONF_CMD_SWITCH("strict", 0),
|
||||
SSL_CONF_CMD_SWITCH("no_middlebox", 0),
|
||||
SSL_CONF_CMD_SWITCH("anti_replay", SSL_CONF_FLAG_SERVER),
|
||||
SSL_CONF_CMD_SWITCH("no_anti_replay", SSL_CONF_FLAG_SERVER),
|
||||
SSL_CONF_CMD_STRING(SignatureAlgorithms, "sigalgs", 0),
|
||||
SSL_CONF_CMD_STRING(ClientSignatureAlgorithms, "client_sigalgs", 0),
|
||||
SSL_CONF_CMD_STRING(Curves, "curves", 0),
|
||||
@@ -671,7 +674,7 @@ static const ssl_conf_cmd_tbl ssl_conf_cmds[] = {
|
||||
SSL_CONF_TYPE_FILE),
|
||||
#endif
|
||||
SSL_CONF_CMD_STRING(RecordPadding, "record_padding", 0),
|
||||
SSL_CONF_CMD_STRING(NumTickets, "num_tickets", SSL_CONF_FLAG_SERVER)
|
||||
SSL_CONF_CMD_STRING(NumTickets, "num_tickets", SSL_CONF_FLAG_SERVER),
|
||||
};
|
||||
|
||||
/* Supported switches: must match order of switches in ssl_conf_cmds */
|
||||
@@ -704,6 +707,10 @@ static const ssl_switch_tbl ssl_cmd_switches[] = {
|
||||
{SSL_CERT_FLAG_TLS_STRICT, SSL_TFLAG_CERT}, /* strict */
|
||||
/* no_middlebox */
|
||||
{SSL_OP_ENABLE_MIDDLEBOX_COMPAT, SSL_TFLAG_INV},
|
||||
/* anti_replay */
|
||||
{SSL_OP_NO_ANTI_REPLAY, SSL_TFLAG_INV},
|
||||
/* no_anti_replay */
|
||||
{SSL_OP_NO_ANTI_REPLAY, 0},
|
||||
};
|
||||
|
||||
static int ssl_conf_cmd_skip_prefix(SSL_CONF_CTX *cctx, const char **pcmd)
|
||||
|
||||
+21
-1
@@ -805,6 +805,9 @@ SSL *SSL_new(SSL_CTX *ctx)
|
||||
|
||||
s->key_update = SSL_KEY_UPDATE_NONE;
|
||||
|
||||
s->allow_early_data_cb = ctx->allow_early_data_cb;
|
||||
s->allow_early_data_cb_data = ctx->allow_early_data_cb_data;
|
||||
|
||||
if (!s->method->ssl_new(s))
|
||||
goto err;
|
||||
|
||||
@@ -3447,7 +3450,8 @@ void ssl_update_cache(SSL *s, int mode)
|
||||
if ((i & SSL_SESS_CACHE_NO_INTERNAL_STORE) == 0
|
||||
&& (!SSL_IS_TLS13(s)
|
||||
|| !s->server
|
||||
|| s->max_early_data > 0
|
||||
|| (s->max_early_data > 0
|
||||
&& (s->options & SSL_OP_NO_ANTI_REPLAY) == 0)
|
||||
|| s->session_ctx->remove_session_cb != NULL
|
||||
|| (s->options & SSL_OP_NO_TICKET) != 0))
|
||||
SSL_CTX_add_session(s->session_ctx, s->session);
|
||||
@@ -5550,3 +5554,19 @@ int SSL_CTX_set_session_ticket_cb(SSL_CTX *ctx,
|
||||
ctx->ticket_cb_data = arg;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void SSL_CTX_set_allow_early_data_cb(SSL_CTX *ctx,
|
||||
SSL_allow_early_data_cb_fn cb,
|
||||
void *arg)
|
||||
{
|
||||
ctx->allow_early_data_cb = cb;
|
||||
ctx->allow_early_data_cb_data = arg;
|
||||
}
|
||||
|
||||
void SSL_set_allow_early_data_cb(SSL *s,
|
||||
SSL_allow_early_data_cb_fn cb,
|
||||
void *arg)
|
||||
{
|
||||
s->allow_early_data_cb = cb;
|
||||
s->allow_early_data_cb_data = arg;
|
||||
}
|
||||
@@ -1084,6 +1084,10 @@ struct ssl_ctx_st {
|
||||
|
||||
/* The number of TLS1.3 tickets to automatically send */
|
||||
size_t num_tickets;
|
||||
|
||||
/* Callback to determine if early_data is acceptable or not */
|
||||
SSL_allow_early_data_cb_fn allow_early_data_cb;
|
||||
void *allow_early_data_cb_data;
|
||||
};
|
||||
|
||||
struct ssl_st {
|
||||
@@ -1242,6 +1246,7 @@ struct ssl_st {
|
||||
# endif
|
||||
SSL_psk_find_session_cb_func psk_find_session_cb;
|
||||
SSL_psk_use_session_cb_func psk_use_session_cb;
|
||||
|
||||
SSL_CTX *ctx;
|
||||
/* Verified chain of peer */
|
||||
STACK_OF(X509) *verified_chain;
|
||||
@@ -1461,6 +1466,10 @@ struct ssl_st {
|
||||
size_t sent_tickets;
|
||||
/* The next nonce value to use when we send a ticket on this connection */
|
||||
uint64_t next_ticket_nonce;
|
||||
|
||||
/* Callback to determine if early_data is acceptable or not */
|
||||
SSL_allow_early_data_cb_fn allow_early_data_cb;
|
||||
void *allow_early_data_cb_data;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
+2
-1
@@ -33,10 +33,11 @@ int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x)
|
||||
{
|
||||
size_t i;
|
||||
const char *s;
|
||||
int istls13 = (x->ssl_version == TLS1_3_VERSION);
|
||||
int istls13;
|
||||
|
||||
if (x == NULL)
|
||||
goto err;
|
||||
istls13 = (x->ssl_version == TLS1_3_VERSION);
|
||||
if (BIO_puts(bp, "SSL-Session:\n") <= 0)
|
||||
goto err;
|
||||
s = ssl_protocol_to_string(x->ssl_version);
|
||||
|
||||
@@ -1622,7 +1622,10 @@ static int final_early_data(SSL *s, unsigned int context, int sent)
|
||||
|| s->session->ext.tick_identity != 0
|
||||
|| s->early_data_state != SSL_EARLY_DATA_ACCEPTING
|
||||
|| !s->ext.early_data_ok
|
||||
|| s->hello_retry_request != SSL_HRR_NONE) {
|
||||
|| s->hello_retry_request != SSL_HRR_NONE
|
||||
|| (s->ctx->allow_early_data_cb != NULL
|
||||
&& !s->ctx->allow_early_data_cb(s,
|
||||
s->ctx->allow_early_data_cb_data))) {
|
||||
s->ext.early_data = SSL_EARLY_DATA_REJECTED;
|
||||
} else {
|
||||
s->ext.early_data = SSL_EARLY_DATA_ACCEPTED;
|
||||
|
||||
@@ -1165,7 +1165,8 @@ int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
* is no point in using full stateless tickets.
|
||||
*/
|
||||
if ((s->options & SSL_OP_NO_TICKET) != 0
|
||||
|| s->max_early_data > 0)
|
||||
|| (s->max_early_data > 0
|
||||
&& (s->options & SSL_OP_NO_ANTI_REPLAY) == 0))
|
||||
ret = tls_get_stateful_ticket(s, &identity, &sess);
|
||||
else
|
||||
ret = tls_decrypt_ticket(s, PACKET_data(&identity),
|
||||
@@ -1189,6 +1190,7 @@ int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
|
||||
/* Check for replay */
|
||||
if (s->max_early_data > 0
|
||||
&& (s->options & SSL_OP_NO_ANTI_REPLAY) == 0
|
||||
&& !SSL_CTX_remove_session(s->session_ctx, sess)) {
|
||||
SSL_SESSION_free(sess);
|
||||
sess = NULL;
|
||||
|
||||
@@ -2591,6 +2591,7 @@ MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt)
|
||||
*/
|
||||
if (SSL_IS_TLS13(s) || s->session->session_id_length > 0) {
|
||||
SSL_SESSION *new_sess;
|
||||
|
||||
/*
|
||||
* We reused an existing session, so we need to replace it with a new
|
||||
* one
|
||||
@@ -2602,6 +2603,16 @@ MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if ((s->session_ctx->session_cache_mode & SSL_SESS_CACHE_CLIENT) != 0
|
||||
&& !SSL_IS_TLS13(s)) {
|
||||
/*
|
||||
* In TLSv1.2 and below the arrival of a new tickets signals that
|
||||
* any old ticket we were using is now out of date, so we remove the
|
||||
* old session from the cache. We carry on if this fails
|
||||
*/
|
||||
SSL_CTX_remove_session(s->session_ctx, s->session);
|
||||
}
|
||||
|
||||
SSL_SESSION_free(s->session);
|
||||
s->session = new_sess;
|
||||
}
|
||||
@@ -2671,6 +2682,7 @@ MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt)
|
||||
goto err;
|
||||
}
|
||||
s->session->session_id_length = sess_len;
|
||||
s->session->not_resumable = 0;
|
||||
|
||||
/* This is a standalone message in TLSv1.3, so there is no more to read */
|
||||
if (SSL_IS_TLS13(s)) {
|
||||
|
||||
+14
-5
@@ -1068,12 +1068,21 @@ WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs, int stop)
|
||||
dtls1_start_timer(s);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* In TLSv1.3 we update the cache as part of processing the
|
||||
* NewSessionTicket
|
||||
*/
|
||||
if (!SSL_IS_TLS13(s))
|
||||
if (SSL_IS_TLS13(s)) {
|
||||
/*
|
||||
* We encourage applications to only use TLSv1.3 tickets once,
|
||||
* so we remove this one from the cache.
|
||||
*/
|
||||
if ((s->session_ctx->session_cache_mode
|
||||
& SSL_SESS_CACHE_CLIENT) != 0)
|
||||
SSL_CTX_remove_session(s->session_ctx, s->session);
|
||||
} else {
|
||||
/*
|
||||
* In TLSv1.3 we update the cache as part of processing the
|
||||
* NewSessionTicket
|
||||
*/
|
||||
ssl_update_cache(s, SSL_SESS_CACHE_CLIENT);
|
||||
}
|
||||
if (s->hit)
|
||||
CRYPTO_atomic_add(&s->session_ctx->stats.sess_hit, 1, &discard,
|
||||
s->session_ctx->lock);
|
||||
|
||||
@@ -3130,14 +3130,13 @@ static int tls_process_cke_dhe(SSL *s, PACKET *pkt)
|
||||
SSL_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
||||
cdh = EVP_PKEY_get0_DH(ckey);
|
||||
pub_key = BN_bin2bn(data, i, NULL);
|
||||
|
||||
if (pub_key == NULL || !DH_set0_key(cdh, pub_key, NULL)) {
|
||||
if (pub_key == NULL || cdh == NULL || !DH_set0_key(cdh, pub_key, NULL)) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CKE_DHE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
if (pub_key != NULL)
|
||||
BN_free(pub_key);
|
||||
BN_free(pub_key);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -4088,8 +4087,10 @@ int tls_construct_new_session_ticket(SSL *s, WPACKET *pkt)
|
||||
* SSL_OP_NO_TICKET is set - we are caching tickets anyway so there
|
||||
* is no point in using full stateless tickets.
|
||||
*/
|
||||
if (((s->options & SSL_OP_NO_TICKET) != 0 || s->max_early_data > 0)
|
||||
&& SSL_IS_TLS13(s)) {
|
||||
if (SSL_IS_TLS13(s)
|
||||
&& ((s->options & SSL_OP_NO_TICKET) != 0
|
||||
|| (s->max_early_data > 0
|
||||
&& (s->options & SSL_OP_NO_ANTI_REPLAY) == 0))) {
|
||||
if (!construct_stateful_ticket(s, pkt, age_add_u.age_add, tick_nonce)) {
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
|
||||
+6
-3
@@ -2309,13 +2309,16 @@ DH *ssl_get_auto_dh(SSL *s)
|
||||
if (dhp == NULL)
|
||||
return NULL;
|
||||
g = BN_new();
|
||||
if (g != NULL)
|
||||
BN_set_word(g, 2);
|
||||
if (g == NULL || !BN_set_word(g, 2)) {
|
||||
DH_free(dhp);
|
||||
BN_free(g);
|
||||
return NULL;
|
||||
}
|
||||
if (dh_secbits >= 192)
|
||||
p = BN_get_rfc3526_prime_8192(NULL);
|
||||
else
|
||||
p = BN_get_rfc3526_prime_3072(NULL);
|
||||
if (p == NULL || g == NULL || !DH_set0_pqg(dhp, p, NULL, g)) {
|
||||
if (p == NULL || !DH_set0_pqg(dhp, p, NULL, g)) {
|
||||
DH_free(dhp);
|
||||
BN_free(p);
|
||||
BN_free(g);
|
||||
|
||||
Reference in New Issue
Block a user