From patchwork Thu Jul 18 21:35:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Chikunov X-Patchwork-Id: 11049575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9433F13B1 for ; Thu, 18 Jul 2019 21:35:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 832BF2844C for ; Thu, 18 Jul 2019 21:35:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74887285F9; Thu, 18 Jul 2019 21:35:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0B772844C for ; Thu, 18 Jul 2019 21:35:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728056AbfGRVfP (ORCPT ); Thu, 18 Jul 2019 17:35:15 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:53014 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728020AbfGRVfP (ORCPT ); Thu, 18 Jul 2019 17:35:15 -0400 Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id 04B8E72CA65; Fri, 19 Jul 2019 00:35:13 +0300 (MSK) Received: from beacon.altlinux.org (unknown [185.6.174.98]) by imap.altlinux.org (Postfix) with ESMTPSA id D74EA4A4A29; Fri, 19 Jul 2019 00:35:12 +0300 (MSK) From: Vitaly Chikunov To: Mimi Zohar , Dmitry Kasatkin , linux-integrity@vger.kernel.org Subject: [PATCH 1/3] ima-evm-utils: Remove indirect call to subfunctions in verify_hash Date: Fri, 19 Jul 2019 00:35:08 +0300 Message-Id: <20190718213510.10829-1-vt@altlinux.org> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is more human understandable and also will improve handling of the sources by cscope. Signed-off-by: Vitaly Chikunov --- src/imaevm.h | 3 --- src/libimaevm.c | 10 +++------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/imaevm.h b/src/imaevm.h index 36050f4..0414433 100644 --- a/src/imaevm.h +++ b/src/imaevm.h @@ -188,9 +188,6 @@ struct signature_v2_hdr { uint8_t sig[0]; /* signature payload */ } __packed; - -typedef int (*verify_hash_fn_t)(const char *file, const unsigned char *hash, int size, unsigned char *sig, int siglen, const char *keyfile); - struct libevm_params { int verbose; int x509; diff --git a/src/libimaevm.c b/src/libimaevm.c index afd2105..97b7167 100644 --- a/src/libimaevm.c +++ b/src/libimaevm.c @@ -572,22 +572,18 @@ static int get_hash_algo_from_sig(unsigned char *sig) int verify_hash(const char *file, const unsigned char *hash, int size, unsigned char *sig, int siglen) { - const char *key = NULL; - verify_hash_fn_t verify_hash; - /* Get signature type from sig header */ if (sig[0] == DIGSIG_VERSION_1) { - verify_hash = verify_hash_v1; + const char *key = NULL; /* Read pubkey from RSA key */ if (!params.keyfile) key = "/etc/keys/pubkey_evm.pem"; + return verify_hash_v1(file, hash, size, sig, siglen, key); } else if (sig[0] == DIGSIG_VERSION_2) { - verify_hash = verify_hash_v2; + return verify_hash_v2(file, hash, size, sig, siglen, NULL); } else return -1; - - return verify_hash(file, hash, size, sig, siglen, key); } int ima_verify_signature(const char *file, unsigned char *sig, int siglen,