diff options
Diffstat (limited to 'src/lib/libssl/t1_enc.c')
| -rw-r--r-- | src/lib/libssl/t1_enc.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c index 448eef274f..638405ec39 100644 --- a/src/lib/libssl/t1_enc.c +++ b/src/lib/libssl/t1_enc.c | |||
| @@ -414,15 +414,20 @@ int tls1_change_cipher_state(SSL *s, int which) | |||
| 414 | s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_STREAM; | 414 | s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_STREAM; |
| 415 | else | 415 | else |
| 416 | s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_STREAM; | 416 | s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_STREAM; |
| 417 | if (s->enc_write_ctx != NULL) | 417 | if (s->enc_write_ctx != NULL && !SSL_IS_DTLS(s)) |
| 418 | reuse_dd = 1; | 418 | reuse_dd = 1; |
| 419 | else if ((s->enc_write_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL) | 419 | else if ((s->enc_write_ctx=EVP_CIPHER_CTX_new()) == NULL) |
| 420 | goto err; | 420 | goto err; |
| 421 | else | ||
| 422 | /* make sure it's intialized in case we exit later with an error */ | ||
| 423 | EVP_CIPHER_CTX_init(s->enc_write_ctx); | ||
| 424 | dd= s->enc_write_ctx; | 421 | dd= s->enc_write_ctx; |
| 425 | mac_ctx = ssl_replace_hash(&s->write_hash,NULL); | 422 | if (SSL_IS_DTLS(s)) |
| 423 | { | ||
| 424 | mac_ctx = EVP_MD_CTX_create(); | ||
| 425 | if (!mac_ctx) | ||
| 426 | goto err; | ||
| 427 | s->write_hash = mac_ctx; | ||
| 428 | } | ||
| 429 | else | ||
| 430 | mac_ctx = ssl_replace_hash(&s->write_hash,NULL); | ||
| 426 | #ifndef OPENSSL_NO_COMP | 431 | #ifndef OPENSSL_NO_COMP |
| 427 | if (s->compress != NULL) | 432 | if (s->compress != NULL) |
| 428 | { | 433 | { |
| @@ -915,18 +920,19 @@ int tls1_final_finish_mac(SSL *s, | |||
| 915 | if (mask & ssl_get_algorithm2(s)) | 920 | if (mask & ssl_get_algorithm2(s)) |
| 916 | { | 921 | { |
| 917 | int hashsize = EVP_MD_size(md); | 922 | int hashsize = EVP_MD_size(md); |
| 918 | if (hashsize < 0 || hashsize > (int)(sizeof buf - (size_t)(q-buf))) | 923 | EVP_MD_CTX *hdgst = s->s3->handshake_dgst[idx]; |
| 924 | if (!hdgst || hashsize < 0 || hashsize > (int)(sizeof buf - (size_t)(q-buf))) | ||
| 919 | { | 925 | { |
| 920 | /* internal error: 'buf' is too small for this cipersuite! */ | 926 | /* internal error: 'buf' is too small for this cipersuite! */ |
| 921 | err = 1; | 927 | err = 1; |
| 922 | } | 928 | } |
| 923 | else | 929 | else |
| 924 | { | 930 | { |
| 925 | EVP_MD_CTX_copy_ex(&ctx,s->s3->handshake_dgst[idx]); | 931 | if (!EVP_MD_CTX_copy_ex(&ctx, hdgst) || |
| 926 | EVP_DigestFinal_ex(&ctx,q,&i); | 932 | !EVP_DigestFinal_ex(&ctx,q,&i) || |
| 927 | if (i != (unsigned int)hashsize) /* can't really happen */ | 933 | (i != (unsigned int)hashsize)) |
| 928 | err = 1; | 934 | err = 1; |
| 929 | q+=i; | 935 | q+=hashsize; |
| 930 | } | 936 | } |
| 931 | } | 937 | } |
| 932 | } | 938 | } |
