linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [USER] [PATCH 1/2] Remove hardcoding of SHA1 in EVM signatures
@ 2018-04-17 22:56 Matthew Garrett
  2018-04-17 22:56 ` [USER] [PATCH 2/2] Add security.apparmor to the set of extended attributes used by EVM Matthew Garrett
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Matthew Garrett @ 2018-04-17 22:56 UTC (permalink / raw)
  To: linux-integrity; +Cc: zohar, Matthew Garrett

EVM signatures are always being generated with SHA1 even if the -a
argument has been provided to evmctl. Fix this so the provided hash
algorithm is used instead.

Signed-off-by: Matthew Garrett <mjg59@google.com>
---
 src/evmctl.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/evmctl.c b/src/evmctl.c
index 2ffee78..43d261f 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -313,6 +313,7 @@ err:
 
 static int calc_evm_hash(const char *file, unsigned char *hash)
 {
+        const EVP_MD *md;
 	struct stat st;
 	int err;
 	uint32_t generation = 0;
@@ -374,7 +375,13 @@ static int calc_evm_hash(const char *file, unsigned char *hash)
 		return -1;
 	}
 
-	err = EVP_DigestInit(pctx, EVP_sha1());
+	md = EVP_get_digestbyname(params.hash_algo);
+	if (!md) {
+		log_err("EVP_get_digestbyname() failed\n");
+		return 1;
+	}
+
+	err = EVP_DigestInit(pctx, md);
 	if (!err) {
 		log_err("EVP_DigestInit() failed\n");
 		return 1;
@@ -498,7 +505,7 @@ static int sign_evm(const char *file, const char *key)
 	if (len <= 1)
 		return len;
 
-	len = sign_hash("sha1", hash, len, key, NULL, sig + 1);
+	len = sign_hash(params.hash_algo, hash, len, key, NULL, sig + 1);
 	if (len <= 1)
 		return len;
 
@@ -967,6 +974,7 @@ static int cmd_setxattr_ima(struct command *cmd)
 
 static int calc_evm_hmac(const char *file, const char *keyfile, unsigned char *hash)
 {
+        const EVP_MD *md;
 	struct stat st;
 	int err = -1;
 	uint32_t generation = 0;
@@ -1033,7 +1041,13 @@ static int calc_evm_hmac(const char *file, const char *keyfile, unsigned char *h
 		goto out;
 	}
 
-	err = !HMAC_Init_ex(pctx, evmkey, sizeof(evmkey), EVP_sha1(), NULL);
+	md = EVP_get_digestbyname(params.hash_algo);
+	if (!md) {
+		log_err("EVP_get_digestbyname() failed\n");
+		goto out;
+	}
+
+	err = !HMAC_Init_ex(pctx, evmkey, sizeof(evmkey), md, NULL);
 	if (err) {
 		log_err("HMAC_Init() failed\n");
 		goto out;
-- 
2.17.0.484.g0c8726318c-goog

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-07-01 20:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-17 22:56 [USER] [PATCH 1/2] Remove hardcoding of SHA1 in EVM signatures Matthew Garrett
2018-04-17 22:56 ` [USER] [PATCH 2/2] Add security.apparmor to the set of extended attributes used by EVM Matthew Garrett
2018-06-12 23:42   ` Mimi Zohar
2018-06-14 19:43     ` Matthew Garrett
2018-06-14 20:41       ` Mimi Zohar
2018-07-01 20:28         ` Mimi Zohar
2018-04-18 12:13 ` [USER] [PATCH 1/2] Remove hardcoding of SHA1 in EVM signatures Mimi Zohar
2018-06-13 13:41 ` Mimi Zohar
2018-06-14 19:42   ` Matthew Garrett
2018-06-22 20:24 ` Mimi Zohar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).