From 93074b2509141fa9730532b94eb499e4a9bc1523 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lutz=20J=C3=A4nicke?= Date: Tue, 3 Jul 2001 10:32:30 +0000 Subject: [PATCH] When only the key is given to "enc", the IV is undefined (found by Andy Brown ). --- CHANGES | 4 ++++ apps/enc.c | 8 ++++++++ doc/apps/enc.pod | 10 ++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 47582d5b4a..824156315c 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,10 @@ Changes between 0.9.6a and 0.9.6b [XX xxx XXXX] + *) When only the key is given to "enc", the IV is undefined. Print out + an error message in this case. + [Lutz Jaenicke] + *) Handle special case when X509_NAME is empty in X509 printing routines. [Steve Henson] diff --git a/apps/enc.c b/apps/enc.c index 2101b4cc64..ef0e872ffe 100644 --- a/apps/enc.c +++ b/apps/enc.c @@ -515,6 +515,14 @@ bad: BIO_printf(bio_err,"invalid hex iv value\n"); goto end; } + if ((hiv == NULL) && (str == NULL)) + { + /* No IV was explicitly set and no IV was generated + * during EVP_BytesToKey. Hence the IV is undefined, + * making correct decryption impossible. */ + BIO_printf(bio_err, "iv undefined\n"); + goto end; + } if ((hkey != NULL) && !set_hex(hkey,key,24)) { BIO_printf(bio_err,"invalid hex key value\n"); diff --git a/doc/apps/enc.pod b/doc/apps/enc.pod index e436ccc37e..a68ddca139 100644 --- a/doc/apps/enc.pod +++ b/doc/apps/enc.pod @@ -96,12 +96,18 @@ of hex digits. =item B<-K key> the actual key to use: this must be represented as a string comprised only -of hex digits. +of hex digits. If only the key is specified, the IV must additionally specified +using the B<-iv> option. When both a key and a password are specified, the +key given with the B<-K> option will be used and the IV generated from the +password will be taken. It probably does not make much sense to specify +both key and password. =item B<-iv IV> the actual IV to use: this must be represented as a string comprised only -of hex digits. +of hex digits. When only the key is specified using the B<-K> option, the +IV must explicitly be defined. When a password is being specified using +one of the other options, the IV is generated from this password. =item B<-p> -- 2.25.1