Skip to content

Commit ca66a75

Browse files
committed
Use imaevm_create_sigv3 for fsverity signature creation
Convert the code that built the fsverity signature with V3 signing scheme to use the new imaevm_create_sigv3 function. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
1 parent ed7c9b5 commit ca66a75

1 file changed

Lines changed: 9 additions & 15 deletions

File tree

src/evmctl.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,6 @@ static int cmd_sign_ima(struct command *cmd)
828828
*/
829829
static int cmd_sign_hash(struct command *cmd)
830830
{
831-
unsigned char sigv3_hash[MAX_DIGEST_SIZE];
832831
unsigned char sig[MAX_SIGNATURE_SIZE];
833832
unsigned char hash[MAX_DIGEST_SIZE];
834833
size_t algolen = 0;
@@ -840,7 +839,6 @@ static int cmd_sign_hash(struct command *cmd)
840839
const char *key;
841840
char algo[7]; /* Current maximum fsverity hash algo name length */
842841
ssize_t len;
843-
int ret;
844842

845843
key = imaevm_params.keyfile ? : "/etc/keys/privkey_evm.pem";
846844

@@ -888,19 +886,15 @@ static int cmd_sign_hash(struct command *cmd)
888886
assert(hashlen / 2 <= sizeof(hash));
889887
hex2bin(hash, hashp, hashlen / 2);
890888

891-
ret = calc_hash_sigv3(IMA_VERITY_DIGSIG, algo, hash,
892-
sigv3_hash);
893-
if (ret < 0 || ret == 1) {
894-
log_info("Failure to calculate fs-verity hash\n");
895-
continue;
896-
}
897-
898-
siglen = imaevm_signhash(algo, sigv3_hash, hashlen / 2,
899-
key, g_keypass, sig + 1, sigflags,
900-
&access_info, imaevm_keyid);
901-
902-
sig[0] = IMA_VERITY_DIGSIG;
903-
sig[1] = DIGSIG_VERSION_3; /* sigv3 */
889+
psig = sig;
890+
siglen = imaevm_create_sigv3(algo, hash,
891+
hashlen / 2, key, g_keypass,
892+
&psig, sizeof(sig), sigflags,
893+
IMA_VERITY_DIGSIG,
894+
&access_info, imaevm_keyid);
895+
if (siglen <= 1)
896+
return siglen;
897+
assert(siglen <= (int)sizeof(sig));
904898
} else {
905899
/* Parse the shaXsum output */
906900
token = strpbrk(line, " \t");

0 commit comments

Comments
 (0)