summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2014-06-07 15:57:27 +0000
committerjsing <>2014-06-07 15:57:27 +0000
commit0c97e2ddf22154228374ee463e4020bfc0c116de (patch)
treeed62fbbde220219d8b236eb0b3ac3b84fc3381b9 /src
parentbe87c66b077143932acac714aba190ca4a70bc75 (diff)
downloadopenbsd-0c97e2ddf22154228374ee463e4020bfc0c116de.tar.gz
openbsd-0c97e2ddf22154228374ee463e4020bfc0c116de.tar.bz2
openbsd-0c97e2ddf22154228374ee463e4020bfc0c116de.zip
Rename variables to make it clear that these are only used in the export
code. Additionally, these need to be cleaned in the export case. Based on Adam Langley's chromium patches.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/src/ssl/t1_enc.c33
-rw-r--r--src/lib/libssl/t1_enc.c33
2 files changed, 36 insertions, 30 deletions
diff --git a/src/lib/libssl/src/ssl/t1_enc.c b/src/lib/libssl/src/ssl/t1_enc.c
index 87e241edca..c20682a129 100644
--- a/src/lib/libssl/src/ssl/t1_enc.c
+++ b/src/lib/libssl/src/ssl/t1_enc.c
@@ -300,11 +300,11 @@ tls1_generate_key_block(SSL *s, unsigned char *km, unsigned char *tmp, int num)
300int 300int
301tls1_change_cipher_state(SSL *s, int which) 301tls1_change_cipher_state(SSL *s, int which)
302{ 302{
303 static const unsigned char empty[]=""; 303 static const unsigned char empty[] = "";
304 unsigned char tmp1[EVP_MAX_KEY_LENGTH]; 304 unsigned char export_tmp1[EVP_MAX_KEY_LENGTH];
305 unsigned char tmp2[EVP_MAX_KEY_LENGTH]; 305 unsigned char export_tmp2[EVP_MAX_KEY_LENGTH];
306 unsigned char iv1[EVP_MAX_IV_LENGTH*2]; 306 unsigned char export_iv1[EVP_MAX_IV_LENGTH * 2];
307 unsigned char iv2[EVP_MAX_IV_LENGTH*2]; 307 unsigned char export_iv2[EVP_MAX_IV_LENGTH * 2];
308 308
309 const unsigned char *client_write_mac_secret, *server_write_mac_secret; 309 const unsigned char *client_write_mac_secret, *server_write_mac_secret;
310 const unsigned char *client_write_key, *server_write_key; 310 const unsigned char *client_write_key, *server_write_key;
@@ -503,26 +503,26 @@ tls1_change_cipher_state(SSL *s, int which)
503 exp_label, exp_label_len, 503 exp_label, exp_label_len,
504 s->s3->client_random, SSL3_RANDOM_SIZE, 504 s->s3->client_random, SSL3_RANDOM_SIZE,
505 s->s3->server_random, SSL3_RANDOM_SIZE, 505 s->s3->server_random, SSL3_RANDOM_SIZE,
506 NULL, 0, NULL, 0, key, key_len, tmp1, tmp2, 506 NULL, 0, NULL, 0, key, key_len, export_tmp1, export_tmp2,
507 EVP_CIPHER_key_length(cipher))) 507 EVP_CIPHER_key_length(cipher)))
508 goto err2; 508 goto err2;
509 key = tmp1; 509 key = export_tmp1;
510 510
511 if (iv_len > 0) { 511 if (iv_len > 0) {
512 if (!tls1_PRF(ssl_get_algorithm2(s), 512 if (!tls1_PRF(ssl_get_algorithm2(s),
513 TLS_MD_IV_BLOCK_CONST, TLS_MD_IV_BLOCK_CONST_SIZE, 513 TLS_MD_IV_BLOCK_CONST, TLS_MD_IV_BLOCK_CONST_SIZE,
514 s->s3->client_random, SSL3_RANDOM_SIZE, 514 s->s3->client_random, SSL3_RANDOM_SIZE,
515 s->s3->server_random, SSL3_RANDOM_SIZE, 515 s->s3->server_random, SSL3_RANDOM_SIZE,
516 NULL, 0, NULL, 0, empty, 0, iv1, iv2, iv_len * 2)) 516 NULL, 0, NULL, 0, empty, 0,
517 export_iv1, export_iv2, iv_len * 2))
517 goto err2; 518 goto err2;
518 if (use_client_keys) 519 if (use_client_keys)
519 iv = iv1; 520 iv = export_iv1;
520 else 521 else
521 iv = &(iv1[iv_len]); 522 iv = &(export_iv1[iv_len]);
522 } 523 }
523 } 524 }
524 525
525
526 if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE) { 526 if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE) {
527 EVP_CipherInit_ex(cipher_ctx, cipher, NULL, key, NULL, 527 EVP_CipherInit_ex(cipher_ctx, cipher, NULL, key, NULL,
528 (which & SSL3_CC_WRITE)); 528 (which & SSL3_CC_WRITE));
@@ -538,10 +538,13 @@ tls1_change_cipher_state(SSL *s, int which)
538 EVP_CIPHER_CTX_ctrl(cipher_ctx, EVP_CTRL_AEAD_SET_MAC_KEY, 538 EVP_CIPHER_CTX_ctrl(cipher_ctx, EVP_CTRL_AEAD_SET_MAC_KEY,
539 mac_secret_size, (unsigned char *)mac_secret); 539 mac_secret_size, (unsigned char *)mac_secret);
540 540
541 OPENSSL_cleanse(tmp1, sizeof(tmp1)); 541 if (is_export) {
542 OPENSSL_cleanse(tmp2, sizeof(tmp2)); 542 OPENSSL_cleanse(export_tmp1, sizeof(export_tmp1));
543 OPENSSL_cleanse(iv1, sizeof(iv1)); 543 OPENSSL_cleanse(export_tmp2, sizeof(export_tmp2));
544 OPENSSL_cleanse(iv2, sizeof(iv2)); 544 OPENSSL_cleanse(export_iv1, sizeof(export_iv1));
545 OPENSSL_cleanse(export_iv2, sizeof(export_iv2));
546 }
547
545 return (1); 548 return (1);
546 549
547err: 550err:
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c
index 87e241edca..c20682a129 100644
--- a/src/lib/libssl/t1_enc.c
+++ b/src/lib/libssl/t1_enc.c
@@ -300,11 +300,11 @@ tls1_generate_key_block(SSL *s, unsigned char *km, unsigned char *tmp, int num)
300int 300int
301tls1_change_cipher_state(SSL *s, int which) 301tls1_change_cipher_state(SSL *s, int which)
302{ 302{
303 static const unsigned char empty[]=""; 303 static const unsigned char empty[] = "";
304 unsigned char tmp1[EVP_MAX_KEY_LENGTH]; 304 unsigned char export_tmp1[EVP_MAX_KEY_LENGTH];
305 unsigned char tmp2[EVP_MAX_KEY_LENGTH]; 305 unsigned char export_tmp2[EVP_MAX_KEY_LENGTH];
306 unsigned char iv1[EVP_MAX_IV_LENGTH*2]; 306 unsigned char export_iv1[EVP_MAX_IV_LENGTH * 2];
307 unsigned char iv2[EVP_MAX_IV_LENGTH*2]; 307 unsigned char export_iv2[EVP_MAX_IV_LENGTH * 2];
308 308
309 const unsigned char *client_write_mac_secret, *server_write_mac_secret; 309 const unsigned char *client_write_mac_secret, *server_write_mac_secret;
310 const unsigned char *client_write_key, *server_write_key; 310 const unsigned char *client_write_key, *server_write_key;
@@ -503,26 +503,26 @@ tls1_change_cipher_state(SSL *s, int which)
503 exp_label, exp_label_len, 503 exp_label, exp_label_len,
504 s->s3->client_random, SSL3_RANDOM_SIZE, 504 s->s3->client_random, SSL3_RANDOM_SIZE,
505 s->s3->server_random, SSL3_RANDOM_SIZE, 505 s->s3->server_random, SSL3_RANDOM_SIZE,
506 NULL, 0, NULL, 0, key, key_len, tmp1, tmp2, 506 NULL, 0, NULL, 0, key, key_len, export_tmp1, export_tmp2,
507 EVP_CIPHER_key_length(cipher))) 507 EVP_CIPHER_key_length(cipher)))
508 goto err2; 508 goto err2;
509 key = tmp1; 509 key = export_tmp1;
510 510
511 if (iv_len > 0) { 511 if (iv_len > 0) {
512 if (!tls1_PRF(ssl_get_algorithm2(s), 512 if (!tls1_PRF(ssl_get_algorithm2(s),
513 TLS_MD_IV_BLOCK_CONST, TLS_MD_IV_BLOCK_CONST_SIZE, 513 TLS_MD_IV_BLOCK_CONST, TLS_MD_IV_BLOCK_CONST_SIZE,
514 s->s3->client_random, SSL3_RANDOM_SIZE, 514 s->s3->client_random, SSL3_RANDOM_SIZE,
515 s->s3->server_random, SSL3_RANDOM_SIZE, 515 s->s3->server_random, SSL3_RANDOM_SIZE,
516 NULL, 0, NULL, 0, empty, 0, iv1, iv2, iv_len * 2)) 516 NULL, 0, NULL, 0, empty, 0,
517 export_iv1, export_iv2, iv_len * 2))
517 goto err2; 518 goto err2;
518 if (use_client_keys) 519 if (use_client_keys)
519 iv = iv1; 520 iv = export_iv1;
520 else 521 else
521 iv = &(iv1[iv_len]); 522 iv = &(export_iv1[iv_len]);
522 } 523 }
523 } 524 }
524 525
525
526 if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE) { 526 if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE) {
527 EVP_CipherInit_ex(cipher_ctx, cipher, NULL, key, NULL, 527 EVP_CipherInit_ex(cipher_ctx, cipher, NULL, key, NULL,
528 (which & SSL3_CC_WRITE)); 528 (which & SSL3_CC_WRITE));
@@ -538,10 +538,13 @@ tls1_change_cipher_state(SSL *s, int which)
538 EVP_CIPHER_CTX_ctrl(cipher_ctx, EVP_CTRL_AEAD_SET_MAC_KEY, 538 EVP_CIPHER_CTX_ctrl(cipher_ctx, EVP_CTRL_AEAD_SET_MAC_KEY,
539 mac_secret_size, (unsigned char *)mac_secret); 539 mac_secret_size, (unsigned char *)mac_secret);
540 540
541 OPENSSL_cleanse(tmp1, sizeof(tmp1)); 541 if (is_export) {
542 OPENSSL_cleanse(tmp2, sizeof(tmp2)); 542 OPENSSL_cleanse(export_tmp1, sizeof(export_tmp1));
543 OPENSSL_cleanse(iv1, sizeof(iv1)); 543 OPENSSL_cleanse(export_tmp2, sizeof(export_tmp2));
544 OPENSSL_cleanse(iv2, sizeof(iv2)); 544 OPENSSL_cleanse(export_iv1, sizeof(export_iv1));
545 OPENSSL_cleanse(export_iv2, sizeof(export_iv2));
546 }
547
545 return (1); 548 return (1);
546 549
547err: 550err: