ssl/s3_pkt.c: detect RAND_bytes error in multi-block.
authorAndy Polyakov <appro@openssl.org>
Fri, 14 Feb 2014 16:43:31 +0000 (17:43 +0100)
committerAndy Polyakov <appro@openssl.org>
Fri, 14 Feb 2014 16:45:33 +0000 (17:45 +0100)
(cherry picked from commit 701134320a94908d8c0ac513741cab41e215a7b5)

crypto/evp/e_aes_cbc_hmac_sha1.c
crypto/evp/e_aes_cbc_hmac_sha256.c
ssl/s3_pkt.c

index 0b6f292f62015f537be23830155884ee8b51c856..6ece66f27a16d651a9b1f1a86b79dbb494cc7abb 100644 (file)
@@ -212,7 +212,8 @@ static size_t tls1_1_multi_block_encrypt(EVP_AES_HMAC_SHA1 *key,
        u64             seqnum;
 #endif
 
-       RAND_bytes((IVs=blocks[0].c),16*x4);    /* ask for IVs in bulk */
+       if (RAND_bytes((IVs=blocks[0].c),16*x4)<=0)     /* ask for IVs in bulk */
+               return 0;
 
        ctx = (SHA1_MB_CTX *)(storage+32-((size_t)storage%32)); /* align */
 
index c2c48f045c3131c2ba5d18d71fdafc22571a8f10..df031cc1c039c7ed3b8151478e07c73f0f0cad8b 100644 (file)
@@ -208,7 +208,8 @@ static size_t tls1_1_multi_block_encrypt(EVP_AES_HMAC_SHA256 *key,
        u64             seqnum;
 #endif
 
-       RAND_bytes((IVs=blocks[0].c),16*x4);    /* ask for IVs in bulk */
+       if (RAND_bytes((IVs=blocks[0].c),16*x4)<=0)     /* ask for IVs in bulk */
+               return 0;
 
        ctx = (SHA256_MB_CTX *)(storage+32-((size_t)storage%32));       /* align */
 
index ddb474bb93738e1fb815484047aecc93133ea625..a41c54f11bcad6c12bee63a2b968c18fc71ad95c 100644 (file)
@@ -725,9 +725,10 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
                        mb_param.inp = &buf[tot];
                        mb_param.len = nw;
 
-                       EVP_CIPHER_CTX_ctrl(s->enc_write_ctx,
-                               EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT,
-                               sizeof(mb_param),&mb_param);
+                       if (EVP_CIPHER_CTX_ctrl(s->enc_write_ctx,
+                                       EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT,
+                                       sizeof(mb_param),&mb_param)<=0)
+                               return -1;
 
                        s->s3->write_sequence[7] += mb_param.interleave;
                        if (s->s3->write_sequence[7] < mb_param.interleave)