Blame SOURCES/0001-esys_crypto_ossl-remove-non-needed-_ex-OSSL-funcs.patch

897056
From 446aef29b5e5d376a3724dbf95c851ac82baeb7f Mon Sep 17 00:00:00 2001
897056
From: William Roberts <william.c.roberts@intel.com>
897056
Date: Thu, 19 Nov 2020 11:09:56 -0600
897056
Subject: [PATCH 01/23] esys_crypto_ossl: remove non-needed _ex OSSL funcs
897056
897056
Some of the OSSL _ex suffixed routines remained even after the ENGINE
897056
pointer was removed. The _ex functions with NULL engine don't do
897056
anything different then the non _ex suffixed ones. One _ex routine
897056
remains, RSA_generate_key_ex, becuase the _ex version is deprecated.
897056
897056
Signed-off-by: William Roberts <william.c.roberts@intel.com>
897056
---
897056
 src/tss2-esys/esys_crypto_ossl.c | 23 +++++++++++------------
897056
 1 file changed, 11 insertions(+), 12 deletions(-)
897056
897056
diff --git a/src/tss2-esys/esys_crypto_ossl.c b/src/tss2-esys/esys_crypto_ossl.c
897056
index 392f97ae..6856e92d 100644
897056
--- a/src/tss2-esys/esys_crypto_ossl.c
897056
+++ b/src/tss2-esys/esys_crypto_ossl.c
897056
@@ -136,10 +136,9 @@ iesys_cryptossl_hash_start(IESYS_CRYPTO_CONTEXT_BLOB ** context,
897056
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Error EVP_MD_CTX_create", cleanup);
897056
     }
897056
 
897056
-    if (1 != EVP_DigestInit_ex(mycontext->hash.ossl_context,
897056
-                               mycontext->hash.ossl_hash_alg,
897056
-                               NULL)) {
897056
-        goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Errror EVP_DigestInit_ex", cleanup);
897056
+    if (1 != EVP_DigestInit(mycontext->hash.ossl_context,
897056
+                               mycontext->hash.ossl_hash_alg)) {
897056
+        goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Errror EVP_DigestInit", cleanup);
897056
     }
897056
 
897056
     *context = (IESYS_CRYPTO_CONTEXT_BLOB *) mycontext;
897056
@@ -241,13 +240,13 @@ iesys_cryptossl_hash_finish(IESYS_CRYPTO_CONTEXT_BLOB ** context,
897056
         return_error(TSS2_ESYS_RC_BAD_SIZE, "Buffer too small");
897056
     }
897056
 
897056
-    if (1 != EVP_DigestFinal_ex(mycontext->hash.ossl_context, buffer, &digest_size)) {
897056
+    if (1 != EVP_DigestFinal(mycontext->hash.ossl_context, buffer, &digest_size)) {
897056
         return_error(TSS2_ESYS_RC_GENERAL_FAILURE, "Ossl error.");
897056
     }
897056
 
897056
     if (digest_size != mycontext->hash.hash_len) {
897056
         return_error(TSS2_ESYS_RC_GENERAL_FAILURE,
897056
-                     "Invalid size computed by EVP_DigestFinal_ex");
897056
+                     "Invalid size computed by EVP_DigestFinal");
897056
     }
897056
 
897056
     LOGBLOB_TRACE(buffer, mycontext->hash.hash_len, "read hash result");
897056
@@ -1056,11 +1055,11 @@ iesys_cryptossl_sym_aes_encrypt(uint8_t * key,
897056
                    "Initialize cipher context", cleanup);
897056
     }
897056
 
897056
-    if (1 != EVP_EncryptInit_ex(ctx, cipher_alg, NULL, key, iv)) {
897056
+    if (1 != EVP_EncryptInit(ctx, cipher_alg,key, iv)) {
897056
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE,
897056
                    "Initialize cipher operation", cleanup);
897056
     }
897056
-    if (1 != EVP_EncryptInit_ex(ctx, NULL, NULL, key, iv)) {
897056
+    if (1 != EVP_EncryptInit(ctx, NULL, key, iv)) {
897056
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Set key and iv", cleanup);
897056
     }
897056
 
897056
@@ -1069,7 +1068,7 @@ iesys_cryptossl_sym_aes_encrypt(uint8_t * key,
897056
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Encrypt update", cleanup);
897056
     }
897056
 
897056
-    if (1 != EVP_EncryptFinal_ex(ctx, buffer, &cipher_len)) {
897056
+    if (1 != EVP_EncryptFinal(ctx, buffer, &cipher_len)) {
897056
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Encrypt final", cleanup);
897056
     }
897056
     LOGBLOB_TRACE(buffer, buffer_size, "IESYS AES output");
897056
@@ -1144,12 +1143,12 @@ iesys_cryptossl_sym_aes_decrypt(uint8_t * key,
897056
 
897056
     LOGBLOB_TRACE(buffer, buffer_size, "IESYS AES input");
897056
 
897056
-    if (1 != EVP_DecryptInit_ex(ctx, cipher_alg, NULL, key, iv)) {
897056
+    if (1 != EVP_DecryptInit(ctx, cipher_alg, key, iv)) {
897056
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE,
897056
                    "Initialize cipher operation", cleanup);
897056
     }
897056
 
897056
-    if (1 != EVP_DecryptInit_ex(ctx, NULL, NULL, key, iv)) {
897056
+    if (1 != EVP_DecryptInit(ctx, NULL, key, iv)) {
897056
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Set key and iv", cleanup);
897056
     }
897056
 
897056
@@ -1158,7 +1157,7 @@ iesys_cryptossl_sym_aes_decrypt(uint8_t * key,
897056
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Encrypt update", cleanup);
897056
     }
897056
 
897056
-    if (1 != EVP_DecryptFinal_ex(ctx, buffer, &cipher_len)) {
897056
+    if (1 != EVP_DecryptFinal(ctx, buffer, &cipher_len)) {
897056
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Encrypt final", cleanup);
897056
     }
897056
     LOGBLOB_TRACE(buffer, buffer_size, "IESYS AES output");
897056
-- 
897056
2.34.3
897056