[ima-evm-utils PATCH 04/12] Update a library function definition to include a "hash_algo" parameter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of relying on a global "hash_algo" variable, which is not
concurrency-safe, update the verify_hash2() function definition to
include a "hash_algo" parameter as a place holder.

Export the verify_hash2() definition.

Define verify_hash2().  To avoid library incompatablity, make the existing
function verify_hash() a function wrapper for verify_hash2().

Signed-off-by: Mimi Zohar <zohar@xxxxxxxxxxxxx>
---
 src/imaevm.h    | 1 +
 src/libimaevm.c | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/imaevm.h b/src/imaevm.h
index 146123ba5c42..1ed2c81d510d 100644
--- a/src/imaevm.h
+++ b/src/imaevm.h
@@ -248,6 +248,7 @@ uint32_t imaevm_read_keyid(const char *certfile);
 
 int sign_hash(const char *algo, const unsigned char *hash, int size, const char *keyfile, const char *keypass, unsigned char *sig);
 int verify_hash(const char *file, const unsigned char *hash, int size, unsigned char *sig, int siglen);
+int verify_hash2(void *public_keys, const char *file, const char *hash_algo, const unsigned char *hash, int size, unsigned char *sig, int siglen);
 int ima_verify_signature(const char *file, unsigned char *sig, int siglen, unsigned char *digest, int digestlen);
 int ima_verify_signature2(void *public_keys, const char *file, unsigned char *sig, int siglen, unsigned char *digest, int digestlen);
 void free_public_keys(void *public_keys);
diff --git a/src/libimaevm.c b/src/libimaevm.c
index bf8c99770ddc..e64d167a2a8a 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -732,7 +732,7 @@ int imaevm_hash_algo_from_sig(unsigned char *sig)
 		return -1;
 }
 
-int verify_hash2(void *public_keys, const char *file,
+int verify_hash2(void *public_keys, const char *file, const char *hash_algo,
 		 const unsigned char *hash, int size,
 		 unsigned char *sig, int siglen)
 {
@@ -770,7 +770,7 @@ int verify_hash2(void *public_keys, const char *file,
 int verify_hash(const char *file, const unsigned char *hash, int size,
 		unsigned char *sig, int siglen)
 {
-	return verify_hash2(g_public_keys, file, hash, size, sig, siglen);
+	return verify_hash2(g_public_keys, file, NULL, hash, size, sig, siglen);
 }
 
 int ima_verify_signature2(void *public_keys, const char *file,
@@ -803,7 +803,7 @@ int ima_verify_signature2(void *public_keys, const char *file,
 	 * measurement list, not by calculating the local file digest.
 	 */
 	if (digest && digestlen > 0)
-		return verify_hash2(public_keys, file, digest, digestlen,
+		return verify_hash2(public_keys, file, NULL, digest, digestlen,
 				   sig, siglen);
 
 	hashlen = ima_calc_hash(file, hash);
@@ -811,7 +811,8 @@ int ima_verify_signature2(void *public_keys, const char *file,
 		return hashlen;
 	assert(hashlen <= sizeof(hash));
 
-	return verify_hash2(public_keys, file, hash, hashlen, sig, siglen);
+	return verify_hash2(public_keys, file, NULL, hash, hashlen,
+			    sig, siglen);
 }
 
 /*
-- 
2.39.3





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux