Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp99216iof; Sun, 5 Jun 2022 22:20:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4qqAUaxNnOSkMW3AEn91jlx7MJiosmSGx6f6Cr0c33MsLE9Ik1+deojnNdbq6Wc/HC1Sx X-Received: by 2002:a17:903:32c1:b0:166:3f58:c1b3 with SMTP id i1-20020a17090332c100b001663f58c1b3mr21326799plr.108.1654492806570; Sun, 05 Jun 2022 22:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654492806; cv=none; d=google.com; s=arc-20160816; b=bfMGpcm8+NXnouAz0iudxQTV+aWkhe0zaMJabh3+4JdnGV0pZqscfjArcTIUVXFMZJ y2iaWJErM8xqsWExYJJ1/AOXKw2dOo/uErNghmn8VQPx/b3pvfNrzB4t2ZTnC2OzGV64 kR3+kbzletMxVmJMIDjwrIGUXQW9InEj0VYOjB4DUMO1X5WfroYVlEOR4rCRzLlhpGW8 /wEMCHnihp5zFpkwjfagL0G2JYTZMKLk8hcy90J2JvvHZpQ8F5U3+EndM2ussISWHsBA Wj3x7VxNDNkRXELpLoUu0ALK84jDbzUvMW2At1qXVSUWOJ7qXYFqP+TKwnyQAOcbtOgB 6azA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EdtQ9RBc+X41pA6X0v3yoLbzILaLeDTdH7Ry4zi1j+c=; b=TnFiEQLKffIpkdof7yT4adBjkKeWRnIlKhOqW0ncbH5nRfiBTEJkbV3rat0BOtmgO/ vtJm+ma/7UwDbMW8Qn4vi7F3jvhNsCyb4UlolYmSlnkLcwR41cEehMCZccDHo5She4eR 8uoBZ44myq3E2euRGAH1cFViLaJ5+zwcylbO47CfN73Ci5NMBqXk1FjmOuD0/aC/Y5BG 5r8ZBDFRXsPXFE78dac+AcsT42rt9bBHRHDmdBC3ZVPGMguxluUCO07sq+fC54bHlldc lktQctz5o/VsdKYErAj6BIreGDCaYPLoozsm9pOd34OflOLhhQN0JKFmAIu7PXv/w2Yi /poA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d8QglLYa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d13-20020a63d70d000000b003f27cfcc9dfsi5400151pgg.828.2022.06.05.22.20.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:20:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d8QglLYa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 861E01C864F; Sun, 5 Jun 2022 21:27:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347700AbiFCSVD (ORCPT + 99 others); Fri, 3 Jun 2022 14:21:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346935AbiFCSFb (ORCPT ); Fri, 3 Jun 2022 14:05:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6D1C5713A; Fri, 3 Jun 2022 10:58:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6D9B461555; Fri, 3 Jun 2022 17:57:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F527C385A9; Fri, 3 Jun 2022 17:57:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654279030; bh=sQ0GPSl5NoQwPN9POfGGNsMy+Sxch4CTIxQGvcHIVJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d8QglLYaP7lLjnWrtvETevHqI7ugDa11zvYxCcTdkFthbziZEFq9OzAwTuNo/QvgE LAKQw4yIVZHGEleaOU4SWPj0va8wfPz1xvv/1RE+z9aGhCO5Ea+QvhHW/t/Hg1dnpp dz9zFPe+twF6d2Pn2wy51RrxUAaPVp2qGG336XQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Chikunov , Herbert Xu Subject: [PATCH 5.18 30/67] crypto: ecrdsa - Fix incorrect use of vli_cmp Date: Fri, 3 Jun 2022 19:43:31 +0200 Message-Id: <20220603173821.590743078@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173820.731531504@linuxfoundation.org> References: <20220603173820.731531504@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vitaly Chikunov commit 7cc7ab73f83ee6d50dc9536bc3355495d8600fad upstream. Correctly compare values that shall be greater-or-equal and not just greater. Fixes: 0d7a78643f69 ("crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm") Cc: Signed-off-by: Vitaly Chikunov Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/ecrdsa.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/crypto/ecrdsa.c +++ b/crypto/ecrdsa.c @@ -113,15 +113,15 @@ static int ecrdsa_verify(struct akcipher /* Step 1: verify that 0 < r < q, 0 < s < q */ if (vli_is_zero(r, ndigits) || - vli_cmp(r, ctx->curve->n, ndigits) == 1 || + vli_cmp(r, ctx->curve->n, ndigits) >= 0 || vli_is_zero(s, ndigits) || - vli_cmp(s, ctx->curve->n, ndigits) == 1) + vli_cmp(s, ctx->curve->n, ndigits) >= 0) return -EKEYREJECTED; /* Step 2: calculate hash (h) of the message (passed as input) */ /* Step 3: calculate e = h \mod q */ vli_from_le64(e, digest, ndigits); - if (vli_cmp(e, ctx->curve->n, ndigits) == 1) + if (vli_cmp(e, ctx->curve->n, ndigits) >= 0) vli_sub(e, e, ctx->curve->n, ndigits); if (vli_is_zero(e, ndigits)) e[0] = 1; @@ -137,7 +137,7 @@ static int ecrdsa_verify(struct akcipher /* Step 6: calculate point C = z_1P + z_2Q, and R = x_c \mod q */ ecc_point_mult_shamir(&cc, z1, &ctx->curve->g, z2, &ctx->pub_key, ctx->curve); - if (vli_cmp(cc.x, ctx->curve->n, ndigits) == 1) + if (vli_cmp(cc.x, ctx->curve->n, ndigits) >= 0) vli_sub(cc.x, cc.x, ctx->curve->n, ndigits); /* Step 7: if R == r signature is valid */