summaryrefslogtreecommitdiffstats
path: root/ssl/s3_lib.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-07-06 09:55:31 +0100
committerMatt Caswell <matt@openssl.org>2016-07-18 22:55:07 +0100
commit0907d7105cbf8d72b267f4453f96dd636fa59621 (patch)
tree4e0bededa6aed005cb48b1477de3208c58647f7a /ssl/s3_lib.c
parentbb5592dd7b4c00581731091a84f4652687fe43a6 (diff)
Split out PSK preamble and RSA from process CKE code
The tls_process_client_key_exchange() function is far too long. This splits out the PSK preamble processing, and the RSA processing into separate functions. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'ssl/s3_lib.c')
-rw-r--r--ssl/s3_lib.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index bd831bc48d..8218c2fa74 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -3919,9 +3919,9 @@ int ssl_fill_hello_random(SSL *s, int server, unsigned char *result, int len)
int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen,
int free_pms)
{
-#ifndef OPENSSL_NO_PSK
unsigned long alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
if (alg_k & SSL_PSK) {
+#ifndef OPENSSL_NO_PSK
unsigned char *pskpms, *t;
size_t psklen = s->s3->tmp.psklen;
size_t pskpmslen;
@@ -3955,15 +3955,19 @@ int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen,
s->session->master_key,
pskpms, pskpmslen);
OPENSSL_clear_free(pskpms, pskpmslen);
- } else
+#else
+ /* Should never happen */
+ s->session->master_key_length = 0;
+ goto err;
#endif
+ } else {
s->session->master_key_length =
s->method->ssl3_enc->generate_master_secret(s,
s->session->master_key,
pms, pmslen);
-#ifndef OPENSSL_NO_PSK
- err:
-#endif
+ }
+
+ err:
if (pms) {
if (free_pms)
OPENSSL_clear_free(pms, pmslen);