diff options
author | Matt Caswell <matt@openssl.org> | 2017-06-21 12:17:30 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2017-06-21 14:45:36 +0100 |
commit | 72257204bd2a88773461150765dfd0e0a428ee86 (patch) | |
tree | 0f62189accc00c2b1e58de678a7e56c1a8748325 /ssl | |
parent | adfc37868e2dc406b80ab3111163eb475ef06975 (diff) | |
download | openssl-72257204bd2a88773461150765dfd0e0a428ee86.tar.gz |
PSK related tweaks based on review feedback
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3670)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/ssl_ciph.c | 3 | ||||
-rw-r--r-- | ssl/ssl_lib.c | 1 | ||||
-rw-r--r-- | ssl/statem/extensions_clnt.c | 39 |
3 files changed, 23 insertions, 20 deletions
diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c index 0afdfdaba1..64bb264b52 100644 --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c @@ -1933,9 +1933,8 @@ int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c) const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c) { - int idx = c->algorithm2; + int idx = c->algorithm2 & SSL_HANDSHAKE_MAC_MASK; - idx &= SSL_HANDSHAKE_MAC_MASK; if (idx < 0 || idx >= SSL_MD_NUM_IDX) return NULL; return ssl_digest_methods[idx]; diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index f9c7b4451b..d8dd45eb5b 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -3733,7 +3733,6 @@ int SSL_SESSION_set1_master_key(SSL_SESSION *sess, const unsigned char *in, memcpy(sess->master_key, in, len); sess->master_key_length = len; - return 1; } diff --git a/ssl/statem/extensions_clnt.c b/ssl/statem/extensions_clnt.c index d4af0329f3..846ee30091 100644 --- a/ssl/statem/extensions_clnt.c +++ b/ssl/statem/extensions_clnt.c @@ -825,31 +825,35 @@ EXT_RETURN tls_construct_ctos_psk(SSL *s, WPACKET *pkt, unsigned int context, } if (s->session->ext.ticklen != 0) { + /* Get the digest associated with the ciphersuite in the session */ if (s->session->cipher == NULL) { SSLerr(SSL_F_TLS_CONSTRUCT_CTOS_PSK, ERR_R_INTERNAL_ERROR); goto err; } - mdres = ssl_md(s->session->cipher->algorithm2); if (mdres == NULL) { - /* Don't recognize this cipher so we can't use the session. Ignore it */ + /* + * Don't recognize this cipher so we can't use the session. + * Ignore it + */ goto dopsksess; } if (s->hello_retry_request && mdres != handmd) { /* - * Selected ciphersuite hash does not match the hash for the session so - * we can't use it. + * Selected ciphersuite hash does not match the hash for the session + * so we can't use it. */ goto dopsksess; } /* * Technically the C standard just says time() returns a time_t and says - * nothing about the encoding of that type. In practice most implementations - * follow POSIX which holds it as an integral type in seconds since epoch. - * We've already made the assumption that we can do this in multiple places - * in the code, so portability shouldn't be an issue. + * nothing about the encoding of that type. In practice most + * implementations follow POSIX which holds it as an integral type in + * seconds since epoch. We've already made the assumption that we can do + * this in multiple places in the code, so portability shouldn't be an + * issue. */ now = (uint32_t)time(NULL); agesec = now - (uint32_t)s->session->time; @@ -867,15 +871,15 @@ EXT_RETURN tls_construct_ctos_psk(SSL *s, WPACKET *pkt, unsigned int context, if (agesec != 0 && agems / (uint32_t)1000 != agesec) { /* - * Overflow. Shouldn't happen unless this is a *really* old session. If - * so we just ignore it. + * Overflow. Shouldn't happen unless this is a *really* old session. + * If so we just ignore it. */ goto dopsksess; } /* - * Obfuscate the age. Overflow here is fine, this addition is supposed to - * be mod 2^32. + * Obfuscate the age. Overflow here is fine, this addition is supposed + * to be mod 2^32. */ agems += s->session->ext.tick_age_add; @@ -956,15 +960,16 @@ EXT_RETURN tls_construct_ctos_psk(SSL *s, WPACKET *pkt, unsigned int context, msgstart = WPACKET_get_curr(pkt) - msglen; - if (dores && tls_psk_do_binder(s, mdres, msgstart, binderoffset, NULL, - resbinder, s->session, 1, 0) != 1) { + if (dores + && tls_psk_do_binder(s, mdres, msgstart, binderoffset, NULL, + resbinder, s->session, 1, 0) != 1) { SSLerr(SSL_F_TLS_CONSTRUCT_CTOS_PSK, ERR_R_INTERNAL_ERROR); goto err; } - if (psksess != NULL && tls_psk_do_binder(s, mdpsk, msgstart, - binderoffset, NULL, pskbinder, - psksess, 1, 1) != 1) { + if (psksess != NULL + && tls_psk_do_binder(s, mdpsk, msgstart, binderoffset, NULL, + pskbinder, psksess, 1, 1) != 1) { SSLerr(SSL_F_TLS_CONSTRUCT_CTOS_PSK, ERR_R_INTERNAL_ERROR); goto err; } |