]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Reject inappropriate private key encryption ciphers.
authorDr. Stephen Henson <steve@openssl.org>
Sat, 23 Apr 2016 12:33:05 +0000 (13:33 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Wed, 27 Apr 2016 23:06:07 +0000 (00:06 +0100)
The traditional private key encryption algorithm doesn't function
properly if the IV length of the cipher is zero. These ciphers
(e.g. ECB mode) are not suitable for private key encryption
anyway.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit d78df5dfd650e6de159a19a033513481064644f5)

crypto/pem/pem_lib.c

index a29821aab2ebd501c676814b6e6b2701518384f5..fe881d664171dcccb7e028c998b2290505546c06 100644 (file)
@@ -348,7 +348,7 @@ int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp,
 
     if (enc != NULL) {
         objstr = OBJ_nid2sn(EVP_CIPHER_nid(enc));
-        if (objstr == NULL) {
+        if (objstr == NULL || EVP_CIPHER_iv_length(enc) == 0) {
             PEMerr(PEM_F_PEM_ASN1_WRITE_BIO, PEM_R_UNSUPPORTED_CIPHER);
             goto err;
         }