[openssl] master update

Dr. Paul Dale pauli at openssl.org
Tue Mar 9 01:12:47 UTC 2021


The branch master has been updated
       via  889ad4ef8181093d5c088d5518c7b353ddb48455 (commit)
       via  5e9a8678c5e1442e618ae0abc7b314880ec3ba4e (commit)
       via  913f9d5e52f0541c2fb9c3b60d3fc785f35eacae (commit)
      from  31e2e6e0b1f0f9ab88b9625f841e268766b598d0 (commit)


- Log -----------------------------------------------------------------
commit 889ad4ef8181093d5c088d5518c7b353ddb48455
Author: Tomas Mraz <tomas at openssl.org>
Date:   Fri Mar 5 18:19:12 2021 +0100

    apps/pkcs12: Allow continuing on absent mac
    
    Just print a warning in that case.
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14445)

commit 5e9a8678c5e1442e618ae0abc7b314880ec3ba4e
Author: Tomas Mraz <tomas at openssl.org>
Date:   Fri Mar 5 18:08:05 2021 +0100

    apps/pkcs12: Detect missing PKCS12KDF support on import
    
    Report error message with hint to use -nomacver if
    MAC verification is not required.
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14445)

commit 913f9d5e52f0541c2fb9c3b60d3fc785f35eacae
Author: Tomas Mraz <tomas at openssl.org>
Date:   Fri Mar 5 17:22:35 2021 +0100

    apps/pkcs12: Properly detect MAC setup failure
    
    The MAC requires PKCS12KDF support which is not present
    in FIPS provider as it is not an approved KDF algorithm.
    Suggest using -nomac if MAC is not required.
    
    Fixes #14057
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/14445)

-----------------------------------------------------------------------

Summary of changes:
 apps/pkcs12.c                  | 25 ++++++++++++++++++++++++-
 doc/man1/openssl-pkcs12.pod.in |  6 ++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/apps/pkcs12.c b/apps/pkcs12.c
index 241122b76a..bd87fd4920 100644
--- a/apps/pkcs12.c
+++ b/apps/pkcs12.c
@@ -19,6 +19,7 @@
 #include <openssl/pem.h>
 #include <openssl/pkcs12.h>
 #include <openssl/provider.h>
+#include <openssl/kdf.h>
 
 #define NOKEYS          0x1
 #define NOCERTS         0x2
@@ -655,7 +656,11 @@ int pkcs12_main(int argc, char **argv)
         }
 
         if (maciter != -1)
-            PKCS12_set_mac(p12, mpass, -1, NULL, 0, maciter, macmd);
+            if (!PKCS12_set_mac(p12, mpass, -1, NULL, 0, maciter, macmd)) {
+                BIO_printf(bio_err, "Error creating PKCS12 MAC; no PKCS12KDF support?\n");
+                BIO_printf(bio_err, "Use -nomac if MAC not required and PKCS12KDF support not available.\n");
+                goto export_end;
+            }
 
         assert(private);
 
@@ -729,6 +734,15 @@ int pkcs12_main(int argc, char **argv)
                    tsalt != NULL ? ASN1_STRING_length(tsalt) : 0L);
     }
     if (macver) {
+        EVP_KDF *pkcs12kdf;
+
+        pkcs12kdf = EVP_KDF_fetch(NULL, "PKCS12KDF", NULL);
+        if (pkcs12kdf == NULL) {
+            BIO_printf(bio_err, "Error verifying PKCS12 MAC; no PKCS12KDF support.\n");
+            BIO_printf(bio_err, "Use -nomacver if MAC verification is not required.\n");
+            goto end;
+        }
+        EVP_KDF_free(pkcs12kdf);
         /* If we enter empty password try no password first */
         if (!mpass[0] && PKCS12_verify_mac(p12, NULL, 0)) {
             /* If mac and crypto pass the same set it to NULL too */
@@ -742,6 +756,14 @@ int pkcs12_main(int argc, char **argv)
              */
             unsigned char *utmp;
             int utmplen;
+            unsigned long err = ERR_peek_error();
+
+            if (ERR_GET_LIB(err) == ERR_LIB_PKCS12
+                && ERR_GET_REASON(err) == PKCS12_R_MAC_ABSENT) {
+                BIO_printf(bio_err, "Warning: MAC is absent!\n");
+                goto dump;
+            }
+
             utmp = OPENSSL_asc2uni(mpass, -1, NULL, &utmplen);
             if (utmp == NULL)
                 goto end;
@@ -759,6 +781,7 @@ int pkcs12_main(int argc, char **argv)
         }
     }
 
+ dump:
     assert(private);
     if (!dump_certs_keys_p12(out, p12, cpass, -1, options, passout, enc)) {
         BIO_printf(bio_err, "Error outputting keys and certificates\n");
diff --git a/doc/man1/openssl-pkcs12.pod.in b/doc/man1/openssl-pkcs12.pod.in
index 65c10d1adb..b367be2b7f 100644
--- a/doc/man1/openssl-pkcs12.pod.in
+++ b/doc/man1/openssl-pkcs12.pod.in
@@ -333,7 +333,7 @@ then both, the private key and the certificates are encrypted using triple DES.
 
 =item B<-macalg> I<digest>
 
-Specify the MAC digest algorithm. If not included them SHA1 will be used.
+Specify the MAC digest algorithm. If not included SHA1 will be used.
 
 =item B<-iter> I<count>
 
@@ -362,7 +362,9 @@ to be needed to use MAC iterations counts but they are now used by default.
 
 =item B<-nomac>
 
-Don't attempt to provide the MAC integrity.
+Do not attempt to provide the MAC integrity. This can be useful with the FIPS
+provider as the PKCS12 MAC requires PKCS12KDF which is not an approved FIPS
+algorithm and cannot be supported by the FIPS provider.
 
 =back
 


More information about the openssl-commits mailing list