Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E53CAC433F5 for ; Wed, 9 Mar 2022 13:57:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ED9138398B; Wed, 9 Mar 2022 14:57:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="e7YQTrSo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4ACC483991; Wed, 9 Mar 2022 10:28:42 +0100 (CET) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 760ED8399C for ; Wed, 9 Mar 2022 10:28:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=giojahermann@gmail.com Received: by mail-wm1-x32f.google.com with SMTP id q7-20020a7bce87000000b00382255f4ca9so2969147wmj.2 for ; Wed, 09 Mar 2022 01:28:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VSiRxH+Kwf9WZQB5IYyUxlGxXh4CMw4IUFJaRcBMajQ=; b=e7YQTrSov7KyIs/+b1TvuRdug6Ul+RFcN6oDrDUhymsnLJhQRl6oC2cTPtwuWQCaZi LuMrqPS1gcmoblZhxPgv2TY7RM2nmlEhrwea3GufN1KB6nGGYhjPyDzo/zH7WuplPVC4 1RFPP3LsvMhyHGI35+jksEl6rbofmjn6cAK4nySLEylJ4obLVjw5q4vGXh4b8H6q/nBE SApLk/5wed7DELLRMeo3muJxJzWoNSetk1pgMYGOQ/yeogIUjKeoStR04Y5ECDtgkJqJ Cy6Pf0IkSCxvUFnei6GMFNqN5tai6hngKZ+XuRN/xukiEcV7jILI4QvlyYOh9NotzEW0 qI1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VSiRxH+Kwf9WZQB5IYyUxlGxXh4CMw4IUFJaRcBMajQ=; b=RrdiOgXUeX7vdTwOOB+NK3MmHopzQBjxg3yt38tpd3yuXUETXZjzDESL6TeJCjfKNl uh91roN1g97WCoc5wqmiTPJE+mIiVq1aqaaedrUINEKyjegnqt+EvbJuSh+NRMRRW5Mv 3HROxyAFnkA8V+M4bLg2RKXMb4dbkngTUpmiBPbpCKagYQciWOO2QwrT6vCCNny+ZHC7 +p3jI2JpaVV1cbdKHQEmkPN8tGVcT687uU97EzzQg8C14951f51mvt5F0Vd8WlmZZvxB HgSafXdjjLh3lP6+Is7EuQP4NwlcGdRxVRwbGuL5BIFI0Anj7Q6jtSX5TWtHhZRebxG3 2yKw== X-Gm-Message-State: AOAM533xfd8MBzDNctnRpaUUZtYZ38LTF5zSDKgzZVe1ACrpwMCCYVW3 F1Vb8BrcgXExgY5tSCGXybU= X-Google-Smtp-Source: ABdhPJxYelU9aHA/qtx54Wo1oZJ74AWxN5Dz0rUuRkfztzW2j8ebkNlzLH9Z7fuuirdJk5x5nxSKPw== X-Received: by 2002:a05:600c:3544:b0:389:bcb8:cc6e with SMTP id i4-20020a05600c354400b00389bcb8cc6emr2584693wmq.194.1646818115876; Wed, 09 Mar 2022 01:28:35 -0800 (PST) Received: from localhost.localdomain ([185.228.230.0]) by smtp.gmail.com with ESMTPSA id v13-20020adfe28d000000b0020375f27a5asm1221771wri.4.2022.03.09.01.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 01:28:35 -0800 (PST) From: SESA644425 X-Google-Original-From: SESA644425 To: sjg@chromium.org Cc: gioja.hermann@non.se.com, mr.nuke.me@gmail.com, jamin_lin@aspeedtech.com, xypron.glpk@gmx.de, philippe.reynes@softathome.com, thomas.perrot@bootlin.com, u-boot@lists.denx.de, giojahermann@gmail.com Subject: [PATCH 1/3] lib: rsa: Fix const-correctness of rsassa_pss functions Date: Wed, 9 Mar 2022 01:27:15 -0800 Message-Id: <20220309092717.4203-2-gioja.hermann@non.se.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220309092717.4203-1-gioja.hermann@non.se.com> References: <20220309092717.4203-1-gioja.hermann@non.se.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Wed, 09 Mar 2022 14:57:21 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Prior to introduction of modifications in rsassa_pss functions related to padding verification, doing a pass to update const-correctness in targeted functions to comply with coding-rules and avoid const-cast Signed-off-by: SESA644425 --- Despite checkpath.pl recommendation, it is not possible to use u8 instead of uint8_t. Proceeding with u8 breaks build with error: unknown type name u8 include/image.h | 2 +- include/u-boot/rsa.h | 4 ++-- lib/rsa/rsa-verify.c | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/image.h b/include/image.h index 97e5f2eb24..bea93118f8 100644 --- a/include/image.h +++ b/include/image.h @@ -1291,7 +1291,7 @@ ll_entry_declare(struct crypto_algo, __name, cryptos) struct padding_algo { const char *name; int (*verify)(struct image_sign_info *info, - uint8_t *pad, int pad_len, + const uint8_t *pad, int pad_len, const uint8_t *hash, int hash_len); }; diff --git a/include/u-boot/rsa.h b/include/u-boot/rsa.h index b9634e38d9..085363eb1e 100644 --- a/include/u-boot/rsa.h +++ b/include/u-boot/rsa.h @@ -101,11 +101,11 @@ int rsa_verify_with_pkey(struct image_sign_info *info, const void *hash, uint8_t *sig, uint sig_len); int padding_pkcs_15_verify(struct image_sign_info *info, - uint8_t *msg, int msg_len, + const uint8_t *msg, int msg_len, const uint8_t *hash, int hash_len); int padding_pss_verify(struct image_sign_info *info, - uint8_t *msg, int msg_len, + const uint8_t *msg, int msg_len, const uint8_t *hash, int hash_len); #define RSA_DEFAULT_PADDING_NAME "pkcs-1.5" diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 112664059c..c2c7248f90 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -73,7 +73,7 @@ static int rsa_verify_padding(const uint8_t *msg, const int pad_len, } int padding_pkcs_15_verify(struct image_sign_info *info, - uint8_t *msg, int msg_len, + const uint8_t *msg, int msg_len, const uint8_t *hash, int hash_len) { struct checksum_algo *checksum = info->checksum; @@ -125,7 +125,7 @@ static void u32_i2osp(uint32_t val, uint8_t *buf) * Return: 0 if the octet string was correctly generated, others on error */ static int mask_generation_function1(struct checksum_algo *checksum, - uint8_t *seed, int seed_len, + const uint8_t *seed, int seed_len, uint8_t *output, int output_len) { struct image_region region[2]; @@ -176,9 +176,9 @@ out: } static int compute_hash_prime(struct checksum_algo *checksum, - uint8_t *pad, int pad_len, - uint8_t *hash, int hash_len, - uint8_t *salt, int salt_len, + const uint8_t *pad, int pad_len, + const uint8_t *hash, int hash_len, + const uint8_t *salt, int salt_len, uint8_t *hprime) { struct image_region region[3]; @@ -215,7 +215,7 @@ out: * @hash_len: Length of the hash */ int padding_pss_verify(struct image_sign_info *info, - uint8_t *msg, int msg_len, + const uint8_t *msg, int msg_len, const uint8_t *hash, int hash_len) { uint8_t *masked_db = NULL; @@ -287,7 +287,7 @@ int padding_pss_verify(struct image_sign_info *info, /* step 12 & 13 */ compute_hash_prime(checksum, pad_zero, 8, - (uint8_t *)hash, hash_len, + hash, hash_len, salt, salt_len, hprime); /* step 14 */ -- 2.25.1