]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg/OpensslLib: Switch to upstream fix for OpenSSL RT#3674
authorQin Long <qin.long@intel.com>
Sat, 5 Mar 2016 15:40:40 +0000 (23:40 +0800)
committerQin Long <qin.long@intel.com>
Sat, 5 Mar 2016 15:40:40 +0000 (23:40 +0800)
A more complete fix for the no-cms configuration has been added to
OpenSSL 1.1 as commit e968561d5. Drop our own version and use a
backport of what was committed upstream.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Qin Long <qin.long@intel.com>
Tested-by: Qin Long <qin.long@intel.com>
CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2f.patch

index 8d5f4a810778a590974ddbab7781603cc5c0a4c7..04ee8af1df3ec71a575f638d0d3ac915db795e88 100644 (file)
@@ -590,28 +590,128 @@ index 01e275f..7633139 100644
  int DES_read_password(DES_cblock *key, const char *prompt, int verify)\r
  {\r
      int ok;\r
+diff --git a/crypto/dh/Makefile b/crypto/dh/Makefile\r
+index 46fa5ac..cc366ec 100644\r
+--- a/crypto/dh/Makefile\r
++++ b/crypto/dh/Makefile\r
+@@ -134,7 +134,7 @@ dh_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h\r
+ dh_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h\r
+ dh_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h\r
+ dh_gen.o: ../cryptlib.h dh_gen.c\r
+-dh_kdf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h\r
++dh_kdf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h\r
+ dh_kdf.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h\r
+ dh_kdf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h\r
+ dh_kdf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h\r
+diff --git a/crypto/dh/dh.h b/crypto/dh/dh.h\r
+index 5498a9d..4a5c665 100644\r
+--- a/crypto/dh/dh.h\r
++++ b/crypto/dh/dh.h\r
+@@ -240,11 +240,13 @@ DH *DH_get_1024_160(void);\r
+ DH *DH_get_2048_224(void);\r
+ DH *DH_get_2048_256(void);\r
\r
++# ifndef OPENSSL_NO_CMS\r
+ /* RFC2631 KDF */\r
+ int DH_KDF_X9_42(unsigned char *out, size_t outlen,\r
+                  const unsigned char *Z, size_t Zlen,\r
+                  ASN1_OBJECT *key_oid,\r
+                  const unsigned char *ukm, size_t ukmlen, const EVP_MD *md);\r
++# endif\r
\r
+ # define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \\r
+         EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\r
+@@ -337,7 +339,9 @@ int DH_KDF_X9_42(unsigned char *out, size_t outlen,\r
\r
+ /* KDF types */\r
+ # define EVP_PKEY_DH_KDF_NONE                            1\r
++# ifndef OPENSSL_NO_CMS\r
+ # define EVP_PKEY_DH_KDF_X9_42                           2\r
++# endif\r
\r
+ /* BEGIN ERROR CODES */\r
+ /*\r
+diff --git a/crypto/dh/dh_kdf.c b/crypto/dh/dh_kdf.c\r
+index a882cb2..4eddb9a 100644\r
+--- a/crypto/dh/dh_kdf.c\r
++++ b/crypto/dh/dh_kdf.c\r
+@@ -51,13 +51,18 @@\r
+  * ====================================================================\r
+  */\r
\r
++#include <e_os.h>\r
++\r
++#ifndef OPENSSL_NO_CMS\r
+ #include <string.h>\r
+ #include <openssl/dh.h>\r
+ #include <openssl/evp.h>\r
+ #include <openssl/asn1.h>\r
+ #include <openssl/cms.h>\r
\r
++\r
+ /* Key derivation from X9.42/RFC2631 */\r
++/* Uses CMS functions, hence the #ifdef wrapper. */\r
\r
+ #define DH_KDF_MAX      (1L << 30)\r
\r
+@@ -185,3 +190,4 @@ int DH_KDF_X9_42(unsigned char *out, size_t outlen,\r
+     EVP_MD_CTX_cleanup(&mctx);\r
+     return rv;\r
+ }\r
++#endif\r
 diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c\r
-index b58e3fa..e5f345a 100644\r
+index b58e3fa..c6288f6 100644\r
 --- a/crypto/dh/dh_pmeth.c\r
 +++ b/crypto/dh/dh_pmeth.c\r
-@@ -449,6 +449,9 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,\r
-         *keylen = ret;\r
-         return 1;\r
-     } else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) {\r
+@@ -207,7 +207,11 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)\r
+     case EVP_PKEY_CTRL_DH_KDF_TYPE:\r
+         if (p1 == -2)\r
+             return dctx->kdf_type;\r
 +#ifdef OPENSSL_NO_CMS\r
-+        return 0;\r
++        if (p1 != EVP_PKEY_DH_KDF_NONE)\r
 +#else\r
+         if (p1 != EVP_PKEY_DH_KDF_NONE && p1 != EVP_PKEY_DH_KDF_X9_42)\r
++#endif\r
+             return -2;\r
+         dctx->kdf_type = p1;\r
+         return 1;\r
+@@ -448,7 +452,10 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,\r
+             return ret;\r
+         *keylen = ret;\r
+         return 1;\r
+-    } else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) {\r
++    }\r
++#ifndef OPENSSL_NO_CMS\r
++    else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) {\r
++\r
          unsigned char *Z = NULL;\r
          size_t Zlen = 0;\r
          if (!dctx->kdf_outlen || !dctx->kdf_oid)\r
-@@ -478,6 +481,7 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,\r
-             OPENSSL_free(Z);\r
+@@ -479,7 +486,8 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,\r
          }\r
          return ret;\r
-+#endif\r
      }\r
-     return 1;\r
+-    return 1;\r
++#endif\r
++    return 0;\r
  }\r
\r
+ const EVP_PKEY_METHOD dh_pkey_meth = {\r
+diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c\r
+index 83e208c..4869098 100644\r
+--- a/crypto/ec/ec_ameth.c\r
++++ b/crypto/ec/ec_ameth.c\r
+@@ -67,8 +67,10 @@\r
+ #include <openssl/asn1t.h>\r
+ #include "asn1_locl.h"\r
\r
++#ifndef OPENSSL_NO_CMS\r
+ static int ecdh_cms_decrypt(CMS_RecipientInfo *ri);\r
+ static int ecdh_cms_encrypt(CMS_RecipientInfo *ri);\r
++#endif\r
\r
+ static int eckey_param2type(int *pptype, void **ppval, EC_KEY *ec_key)\r
+ {\r
 diff --git a/crypto/engine/eng_int.h b/crypto/engine/eng_int.h\r
 index 46f163b..b4a72a0 100644\r
 --- a/crypto/engine/eng_int.h\r
@@ -962,7 +1062,7 @@ index 266111e..f60fac6 100644
  {\r
      return 0;\r
 diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c\r
-index 4e06218..f591f0f 100644\r
+index 4e06218..ddead3d 100644\r
 --- a/crypto/rsa/rsa_ameth.c\r
 +++ b/crypto/rsa/rsa_ameth.c\r
 @@ -68,10 +68,12 @@\r
@@ -1010,25 +1110,15 @@ index 4e06218..f591f0f 100644
  \r
  static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,\r
                           X509_ALGOR *alg1, X509_ALGOR *alg2,\r
-@@ -785,6 +791,7 @@ static RSA_OAEP_PARAMS *rsa_oaep_decode(const X509_ALGOR *alg,\r
-     return pss;\r
+@@ -762,6 +768,7 @@ static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,\r
+     return 2;\r
  }\r
  \r
 +#ifndef OPENSSL_NO_CMS\r
- static int rsa_cms_decrypt(CMS_RecipientInfo *ri)\r
+ static RSA_OAEP_PARAMS *rsa_oaep_decode(const X509_ALGOR *alg,\r
+                                         X509_ALGOR **pmaskHash)\r
  {\r
-     EVP_PKEY_CTX *pkctx;\r
-@@ -857,7 +864,9 @@ static int rsa_cms_decrypt(CMS_RecipientInfo *ri)\r
-         X509_ALGOR_free(maskHash);\r
-     return rv;\r
- }\r
-+#endif\r
\r
-+#ifndef OPENSSL_NO_CMS\r
- static int rsa_cms_encrypt(CMS_RecipientInfo *ri)\r
- {\r
-     const EVP_MD *md, *mgf1md;\r
-@@ -920,6 +929,7 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri)\r
+@@ -920,6 +927,7 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri)\r
          ASN1_STRING_free(os);\r
      return rv;\r
  }\r
@@ -1859,6 +1949,37 @@ index 514fcb3..2a54cc9 100644
                  else if (RAND_bytes(rec->input, ivlen) <= 0)\r
                      return -1;\r
              }\r
+diff --git a/test/cms-test.pl b/test/cms-test.pl\r
+index baa3b59..1ee3f02 100644\r
+--- a/test/cms-test.pl\r
++++ b/test/cms-test.pl\r
+@@ -100,6 +100,13 @@ my $no_ec2m;\r
+ my $no_ecdh;\r
+ my $ossl8 = `$ossl_path version -v` =~ /0\.9\.8/;\r
\r
++system ("$ossl_path no-cms > $null_path");\r
++if ($? == 0)\r
++        {\r
++        print "CMS disabled\n";\r
++        exit 0;\r
++        }\r
++\r
+ system ("$ossl_path no-ec > $null_path");\r
+ if ($? == 0)\r
+       {\r
+diff --git a/util/libeay.num b/util/libeay.num\r
+index 7f7487d..13b2e3a 100755\r
+--- a/util/libeay.num\r
++++ b/util/libeay.num\r
+@@ -4368,7 +4368,7 @@ DH_compute_key_padded                   4732     EXIST::FUNCTION:DH\r
+ ECDSA_METHOD_set_sign                   4733  EXIST::FUNCTION:ECDSA\r
+ CMS_RecipientEncryptedKey_cert_cmp      4734  EXIST:!VMS:FUNCTION:CMS\r
+ CMS_RecipEncryptedKey_cert_cmp          4734  EXIST:VMS:FUNCTION:CMS\r
+-DH_KDF_X9_42                            4735  EXIST::FUNCTION:DH\r
++DH_KDF_X9_42                            4735  EXIST::FUNCTION:CMS,DH\r
+ RSA_OAEP_PARAMS_free                    4736  EXIST::FUNCTION:RSA\r
+ EVP_des_ede3_wrap                       4737  EXIST::FUNCTION:DES\r
+ RSA_OAEP_PARAMS_it                      4738  EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA\r
 diff --git a/util/mkerr.pl b/util/mkerr.pl\r
 index 09ebebe..cd57ade 100644\r
 --- a/util/mkerr.pl\r