Add checks to the return value of EVP_Cipher to prevent silent encryption failure.
authorMatt Caswell <matt@openssl.org>
Tue, 18 Nov 2014 12:56:26 +0000 (12:56 +0000)
committerMatt Caswell <matt@openssl.org>
Thu, 27 Nov 2014 21:44:03 +0000 (21:44 +0000)
PR#1767

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit fe78f08d1541211566a5656395186bfbdc61b6f8)

ssl/d1_pkt.c
ssl/s3_enc.c
ssl/s3_pkt.c

index 657c12f975a2fbb46848c73cea5b70ebaa5e988a..dc5b6f40c493c4ddd78f1b044a55669c42e8b63d 100644 (file)
@@ -1635,7 +1635,7 @@ int do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len,
        if (eivlen)
                wr->length += eivlen;
 
-       s->method->ssl3_enc->enc(s,1);
+       if(s->method->ssl3_enc->enc(s,1) < 1) goto err;
 
        /* record length after mac and block padding */
 /*     if (type == SSL3_RT_APPLICATION_DATA ||
index 73f3e1730c53081ac36a7bd5a8e1c5d7fbc7c407..b55d0da6e8c1478039b3d1450f933e46a33a0d32 100644 (file)
@@ -556,7 +556,8 @@ int ssl3_enc(SSL *s, int send)
                        /* otherwise, rec->length >= bs */
                        }
                
-               EVP_Cipher(ds,rec->data,rec->input,l);
+               if(EVP_Cipher(ds,rec->data,rec->input,l) < 1)
+                       return -1;
 
                if (EVP_MD_CTX_md(s->read_hash) != NULL)
                        mac_size = EVP_MD_CTX_size(s->read_hash);
index 3103b54619c283038021196ea3386ce1948fba29..0804d556a199a519af8255bdfaa549204c80a704 100644 (file)
@@ -1040,8 +1040,7 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
                wr->length += eivlen;
                }
 
-       /* ssl3_enc can only have an error on read */
-       s->method->ssl3_enc->enc(s,1);
+       if(s->method->ssl3_enc->enc(s,1)<1) goto err;
 
        /* record length after mac and block padding */
        s2n(wr->length,plen);