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:39:47 +0000 (21:39 +0000)
PR#1767

Reviewed-by: Richard Levitte <levitte@openssl.org>
ssl/d1_pkt.c
ssl/s3_enc.c
ssl/s3_pkt.c

index ed246a007807c9c59e96664e28f9154254150377..2952bccc5eb58ab8dfd3796581851cb73ae62c95 100644 (file)
@@ -1632,7 +1632,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 6b7132380da50a72e96104a93af39e4838bc22dc..63774bcc8746d078e2b6c25b7cfe21b4a2bb33a7 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 ea45b8650f2e9423d2f598f7ff775dede105251b..8fedf5a80d7c64e4815dd1706f9cf7c039abaedb 100644 (file)
@@ -1118,8 +1118,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;
 
        if (SSL_USE_ETM(s) && mac_size != 0)
                {