All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
To: zohar@linux.ibm.com, vt@altlinux.org, linux-integrity@vger.kernel.org
Cc: tianjia.zhang@linux.alibaba.com
Subject: [PATCH ima-evm-utils 2/3] ima-evm-utils: beautify the code to make it more readable
Date: Wed,  8 Jul 2020 14:07:37 +0800	[thread overview]
Message-ID: <20200708060738.43558-2-tianjia.zhang@linux.alibaba.com> (raw)
In-Reply-To: <20200708060738.43558-1-tianjia.zhang@linux.alibaba.com>

Use enum type instead of hard-coded numbers to improve code readability.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 src/libimaevm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libimaevm.c b/src/libimaevm.c
index a9419ee..8f2ebcf 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -579,7 +579,7 @@ static int get_hash_algo_from_sig(unsigned char *sig)
 {
 	uint8_t hashalgo;
 
-	if (sig[0] == 1) {
+	if (sig[0] == DIGSIG_VERSION_1) {
 		hashalgo = ((struct signature_hdr *)sig)->hash;
 
 		if (hashalgo >= DIGEST_ALGO_MAX)
@@ -593,7 +593,7 @@ static int get_hash_algo_from_sig(unsigned char *sig)
 		default:
 			return -1;
 		}
-	} else if (sig[0] == 2) {
+	} else if (sig[0] == DIGSIG_VERSION_2) {
 		hashalgo = ((struct signature_v2_hdr *)sig)->hash_algo;
 		if (hashalgo >= PKEY_HASH__LAST)
 			return -1;
@@ -625,7 +625,7 @@ int ima_verify_signature(const char *file, unsigned char *sig, int siglen,
 	unsigned char hash[MAX_DIGEST_SIZE];
 	int hashlen, sig_hash_algo;
 
-	if (sig[0] != 0x03) {
+	if (sig[0] != EVM_IMA_XATTR_DIGSIG) {
 		log_err("xattr ima has no signature\n");
 		return -1;
 	}
-- 
2.17.1


  reply	other threads:[~2020-07-08  6:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08  6:07 [PATCH ima-evm-utils 1/3] ima-evm-utils: Fix mismatched type checking Tianjia Zhang
2020-07-08  6:07 ` Tianjia Zhang [this message]
2020-07-08  6:07 ` [PATCH ima-evm-utils 3/3] ima-evm-utils: ima_sign supports sm3 algorithm Tianjia Zhang
  -- strict thread matches above, loose matches on Subject: below --
2020-07-07  3:35 [PATCH ima-evm-utils 1/3] ima-evm-utils: Fix mismatched type checking Tianjia Zhang
2020-07-07  3:35 ` [PATCH ima-evm-utils 2/3] ima-evm-utils: beautify the code to make it more readable Tianjia Zhang
2020-07-08 16:28   ` Mimi Zohar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200708060738.43558-2-tianjia.zhang@linux.alibaba.com \
    --to=tianjia.zhang@linux.alibaba.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=vt@altlinux.org \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.