Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp411968rdb; Thu, 25 Jan 2024 21:58:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZ4bDBggf12erCK6d6X7plCSC5/250mrqeLJ24GRWWG0vdOYYjajYTx3sxIxwSxqlujF94 X-Received: by 2002:a17:906:d793:b0:a34:a178:5acf with SMTP id pj19-20020a170906d79300b00a34a1785acfmr228114ejb.16.1706248732820; Thu, 25 Jan 2024 21:58:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706248732; cv=pass; d=google.com; s=arc-20160816; b=hcoJ8Uj7pOCt8fOzQa/cCxhk1zRUR+faQSf2ZRS2Ba1uzpMrlqA94mpLjlzZaJNXzj 8Yl76RFxSLeVcKHGeuWrjsfy8WfYxHSN9NZfqZfOh+R8gf9ZBm2komHcjySIeSfsGJq4 dsGJZSsqc+XP0ayLcIoZrcoE4oLeGlKvIT+nWXI47DeskZx3bLqjXqUN73iiC9rm8tfs MpE6nG3j2VCLXrnTzBkf4ku6FoIWPWM09tPxayF58fW56b0QZFe/u10+ETYt4a2i2YP5 PU8i7ibHTvxHrgpumSgRCR2dt+YBRmNeJ6dCwlObNLL3aGfw0DHW4Qn821WMFwj9kD0h GFlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=nRYF6N0AmvWZVOsh41CMQFZb9eKU/DOzP0HbM2SyhVU=; fh=/D49KBa3fyr96NYOa/LXBGD571yxC/n3ewN/DUvgBUc=; b=GdaeYSBVaZGeAZYZAfSnzRW95bdYI/c2QGpI6uVfZEhHqGQF0d3TUCcNbSWaa3Gmtl H6z3lXWx9Mh1TCWAbliwVJW6BtdX8CIHG3EzeH4S0sHHSfh9k7KvLBM5FBa14fdSFuvl YzpsV395klLHx5gsQyxISQ2HPzU8FJCLPNX7hD6gYRCli3Ordyf0UeCanzpBEmFWSwfd zLq+17kniQAzC8Pv94h5fqzf+izWwZ9wFYQeu35ln6fB/eCzvfrn35BQuNpjXRoWA2vS WVnNTRNxPMtkmFdZTPcxkj3bgO9CS0Ltwhy21PAeAJG8CPgenPxTPyCFueUnVwj4I3Ff A6Xw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gondor.apana.org.au); spf=pass (google.com: domain of linux-crypto+bounces-1640-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1640-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gh20-20020a170906e09400b00a316c066274si229661ejb.312.2024.01.25.21.58.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 21:58:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-1640-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gondor.apana.org.au); spf=pass (google.com: domain of linux-crypto+bounces-1640-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1640-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8A60D1F255D2 for ; Fri, 26 Jan 2024 05:58:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92780BE7D; Fri, 26 Jan 2024 05:58:48 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0518CBE4E for ; Fri, 26 Jan 2024 05:58:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=144.6.53.87 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706248728; cv=none; b=Jb0Nv/rXzS+7RJRJ5q8nUk8Ds8P++PsczCDMyIF4uYdWrWZiG+vd2lvGkgn/LIDARl0V+t0l4N3yE2na7FN2iKcMPdgsT9zzTJeHeDk8n11G71vtHLRBJpLyWn/WI9NWhOZRW1Doji1j7NXb+ty0zF2u3dvpzU3+Rvg9OyHH/b8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706248728; c=relaxed/simple; bh=9L+GGz90Pc91pu0axVQOTlb+2Gj2Rd8uRYAPgahsf/0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Obk+AZK8aOJEOqGssQhoNjAaDyWs/zhX1NDD9+qqatjD4eQSKm3S7Ro+4faz5RXmM9WvH5WXNwmSqyM9qSgzGIJfJoNX0zGNDmzgaQMj5Rsem1nfJaBWg1hZoL6FrwcGcovFtfPT6nVi+cn6nZB3GNVTkTX6trlL7fZAs4/4g3M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gondor.apana.org.au; spf=pass smtp.mailfrom=gondor.apana.org.au; arc=none smtp.client-ip=144.6.53.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gondor.apana.org.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gondor.apana.org.au Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1rTFEd-006Ct5-R0; Fri, 26 Jan 2024 13:58:40 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 26 Jan 2024 13:58:52 +0800 Date: Fri, 26 Jan 2024 13:58:52 +0800 From: Herbert Xu To: Joachim Vandersmissen Cc: linux-crypto@vger.kernel.org Subject: Re: [PATCH] crypto: rsa - restrict plaintext/ciphertext values more in FIPS mode Message-ID: References: <20240121194901.344206-1-git@jvdsn.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240121194901.344206-1-git@jvdsn.com> On Sun, Jan 21, 2024 at 01:49:00PM -0600, Joachim Vandersmissen wrote: > > static int _rsa_enc(const struct rsa_mpi_key *key, MPI c, MPI m) > { > + /* For FIPS, SP 800-56Br2, Section 7.1.1 requires 1 < m < n - 1 */ > + if (fips_enabled && rsa_check_payload_fips(m, key->n)) > + return -EINVAL; > + > /* (1) Validate 0 <= m < n */ > if (mpi_cmp_ui(m, 0) < 0 || mpi_cmp(m, key->n) >= 0) > return -EINVAL; I think this check makes sense in general, so why not simply replace the second check above with the new check? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt