Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp112358iof; Sun, 5 Jun 2022 22:45:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtrhdFGCLw9oviF6N/MMznsmV4MVPSAIkaKwhVSr+CqLAWnJ2Xu1E7ApII5WgR/vUMY4GL X-Received: by 2002:a63:ea06:0:b0:3fd:a385:a856 with SMTP id c6-20020a63ea06000000b003fda385a856mr4952924pgi.393.1654494333945; Sun, 05 Jun 2022 22:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654494333; cv=none; d=google.com; s=arc-20160816; b=HWBwPWozRC6xIyOdHjFrad6thmCGS/hb+/9Tx35j3DawkV6n3TnVxZc69I25FZWNQq L0livhnXgPSdTaRTJyONUZ4Uji/wIyBAhfP2bMv5LLClqVJudffftLxVppZcSecd2c0v g0402cZKeNuxro1XQre0dKcuANaq1LFvE9k2+yW9YryLQJG9+/DtGarA3CIDOHh9kguu fKD2JEZ6h5NHfUbYG6yIKfpygTrq0+VUU+VlGBRcQtaCaBoG+qNhMatmXw0WIFyAy9Cf Hk9Qn59hNPY7gXzgt9AzQzQFWrtAj6rUSUaBHOJmZJCr4pWoqwdCY6vJuhiWLMpx9hm9 zujQ== 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=L9s5GHXXydbtRVH3DVccKubHKg7rN4tyD7/+bX+QS+U=; b=AyBE+AMTHvBaqW1ZDRe9raz0UnLI5emRkacFkAlSRcwtm1oVlWTI4BfCzEvOwuJ5IH G90F8JKEt2jhpZpmzu5DIW4de3LbBLkXS1XYgYEchLpBm2y5hBrBhth7n2D/YWWBUmRl 7HPCpH0ToopZg9fr7SU2jQYz0FECNzpIeeOYAN/HZeSQphEoLkrkEFVg3bwFYknL6x/v 82/lMLAbYugX9cWD4UMQo4+4JCmU4M8vIKe77p1NX9QAVxpinryrQmQ58xfFRp3Pu0Y7 hWvAekCDU50Eoa65VV1EVU4z8jiBHAuJLOp3nA7evP1Q6eGwEsOKUc4X5TS80XS+xq7V J/Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=esNiSIDp; 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 g13-20020a056a000b8d00b0050e128eef5csi21734611pfj.154.2022.06.05.22.45.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:45:33 -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=esNiSIDp; 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 750E4239085; Sun, 5 Jun 2022 21:36:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345386AbiFCRty (ORCPT + 99 others); Fri, 3 Jun 2022 13:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345357AbiFCRsL (ORCPT ); Fri, 3 Jun 2022 13:48:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9EA253E05; Fri, 3 Jun 2022 10:45:00 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6BBE4B82430; Fri, 3 Jun 2022 17:44:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB7F6C385A9; Fri, 3 Jun 2022 17:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278298; bh=JRlXN+QbL40CRn9Cwv7aCRqGZNOb6OjwTpt42fLYcMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=esNiSIDpMjzKWdJUlsPeQsQCEH6REuZV7ZcAr5qg59BqYgYfApa7YVYwvQi+EVUle ZEnKSwXdfq7nXoRSK1G4UraUutuI5TpryJLoCcOFbVQREjvKD3veP+PuBK0TnON09w 6/Rrw8rhFAtqiOuQ6V7ELsJEGNK75ikkELg2rmKQ= 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.4 21/34] crypto: ecrdsa - Fix incorrect use of vli_cmp Date: Fri, 3 Jun 2022 19:43:17 +0200 Message-Id: <20220603173816.609143086@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173815.990072516@linuxfoundation.org> References: <20220603173815.990072516@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 @@ -112,15 +112,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; @@ -136,7 +136,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 */