Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp70363iof; Sun, 5 Jun 2022 21:25:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPlOv18EUaLIjoIGDgg2n+x6CHVZDgi9eHXc0CktZiHRUbo/gO05caBR0PRKPHiCtuMNXn X-Received: by 2002:a17:903:248b:b0:160:f4b0:e663 with SMTP id p11-20020a170903248b00b00160f4b0e663mr22180205plw.49.1654489524530; Sun, 05 Jun 2022 21:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654489524; cv=none; d=google.com; s=arc-20160816; b=DgNPb8raz0wHdOh7FdF9gqAe8ZlK3tt0wfHB5FFpIIG0LMtczSMQb1FLgHFDBMZ0l2 5ndqGLwpnhY+niZIiHuZmlOoHLO2Ux+5jMPWHYf+USrtyuxXoA0H+S7ZkJsEpwFJNs1D BDasX/+3MJLiy1Y+00zcn3kxkqdQ6GjiKAs9hbI2/50vVc+iMjtckTHzb+12GLcekRDW nzm0tCGVZ9OZVpTA1O01ZKgMLlj2RjUPdkBIG3zxyaszRFCOV1bR+vd0afZx0lbypnX+ azrBjHCPklYRE7tYc9pPjAYHDSeN6nXeOVT8LCC4W/2CfBaL5eJXndnehfVF2jLZrDH8 Mh0w== 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=AyxplF5KvrU0DlfHCjo27WHw4DhCDjUgaScau7ixfHn2V7nTxhk9MQV0IXX4VrG4Fv fulGpjY8HE/9UQkxGP54A7oviJYBFYc3tzn4vFVPB/uA3F0jun9teYi9A8sCUbVAzUba 6q9Qy1TAbrJqt+TJui5UqFBgj8ILahrJoIoWcCHO8KM6RLKhirq61eXE8p5scKEKausa uyxfzrvT8P3zcgCsAlULxP9KCsFh+29x2arxYWQn7SY2Kg7hwWqYAvFCMXspHGWIXpve nZA9lJAXHFrofnMICQEdnXnPvDioN/+2i1+vKnV80jwNENhUJZs3PbRT1lrzo9rARViv dRDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uNVmtlsI; 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 z15-20020a056a00240f00b0051b90c123basi20547899pfh.127.2022.06.05.21.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 21:25:24 -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=uNVmtlsI; 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 339B9941A5; Sun, 5 Jun 2022 20:56:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346606AbiFCSA1 (ORCPT + 99 others); Fri, 3 Jun 2022 14:00:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347219AbiFCRwI (ORCPT ); Fri, 3 Jun 2022 13:52:08 -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 4AA63562DA; Fri, 3 Jun 2022 10:50:33 -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 DB9FC60EE9; Fri, 3 Jun 2022 17:50:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E75FDC3411C; Fri, 3 Jun 2022 17:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278632; bh=sQ0GPSl5NoQwPN9POfGGNsMy+Sxch4CTIxQGvcHIVJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uNVmtlsI96A2wYZ40DU+Fu95l8C8eENXStboWnRUCz6hUHomfdAO4CncSQ0WEhN7r nxWsKZCsFx+UikUYP4tKKnMB5krM0yM4VE0+qwsVcliIXcXlfLyUylvSBD2K4E0kLM YvLdPUaNX0Z7fGRycTcG8Iuv/wGEFPUgFyy4ky1s= 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.15 35/66] crypto: ecrdsa - Fix incorrect use of vli_cmp Date: Fri, 3 Jun 2022 19:43:15 +0200 Message-Id: <20220603173821.665178127@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173820.663747061@linuxfoundation.org> References: <20220603173820.663747061@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 */