Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp136569rdb; Wed, 14 Feb 2024 15:42:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUTb9n6fSRx1XJaTz3if569Zql+nePQSv54mEtIOSB1R2I9/a8ghgA0okXtRfRbRctKRJJaD8TgymJh89bgSqUeWErQUtUfMs1rU35+Tw== X-Google-Smtp-Source: AGHT+IG1M7yT9IpIdK6eGUTS8IEt90t1oqciAJdBWRzInyaveAWzqRZb9u7fyczH73+l8q7fO3yJ X-Received: by 2002:a50:fb8d:0:b0:562:1819:bbc4 with SMTP id e13-20020a50fb8d000000b005621819bbc4mr92115edq.6.1707954162195; Wed, 14 Feb 2024 15:42:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707954162; cv=pass; d=google.com; s=arc-20160816; b=uKT35YluLDApUb8N9KfLmUOALxBhRMk6pEHmnxf9e/FqV1fhjBMlYPla8KG5fX2ABf wVHa0h5AxfzwTd+Cn7vu9L025ka0y1pO8jA6OATA1tYU53Vb8HGE3n1j7rucxhzCvjac QwuCXx+MLzvjcSQoe3azBcpi0q9q9Y+Udw7jpcsAp761/l2Tf1zWN9p72TG49+TVgxXG i8lsEesY/TXNKcdrITc6hI+gUtuYKsJ0MGmlN1rSuj2aj3cbK6h2tXKxnOtYDhTqf+S4 PCP6kxWM67KYCUQ/IaTj1hluXdedU30LeKtHGsEe0By9RSLxuYVxzFQtPkfOP/OBuh+e GvFw== 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:dkim-signature; bh=pY6B3Qyx0cDWVPXWSXApwoEVAuwGHKOrKxhHD7mrxjc=; fh=OUpgHz8gu+EFyREjScBnwgXxe9p5hHef04jJGlkpTWE=; b=ARY8YZktpMQZ3riVQ7nDkZ8UXsdYpFIWDdURHv8XXJWO4cwaFP7DsZstnW7nyYqOyg kqGtzlSWYAk9WimSV8xI5hRwLQNIZgwUZ3Ih0KrOS0xMdbApOoiX4S9Uw1jqlcpXsdjt /MFrbOe/BMa6sg6zWTvtpQoQtuhqKB9kVA8YWLhvIkUKwtMtvDWHBbXkj/Bzf7GXeOAR j7xWeGpLPTVDKOOLyIUYUPPsqLLLEaR9mmVmekQ93t3YL8G2rnLiGuOkpempbA00QJMM DaKfo2P2oNe2vqnmcN4LqqG3Vq/6heCxzojWQP354pILeEjPHmsX0Z2+hcfCtPxqm9cv M3iA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WtbdFJe8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-2066-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2066-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ee11-20020a056402290b00b005606ba1169csi23658edb.314.2024.02.14.15.42.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 15:42:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2066-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WtbdFJe8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-2066-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2066-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 96D9F1F27A80 for ; Wed, 14 Feb 2024 23:41:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C5741420B0; Wed, 14 Feb 2024 23:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WtbdFJe8" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1CB991864C for ; Wed, 14 Feb 2024 23:41:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707954114; cv=none; b=nDTvwKR0LoKix9h3Z6ivjHaiPtkOqCTDaOBKVo2HhXPMXi+2lmrsc+hju4xwC3kF2d3MXOnuXi2DT71DoKHDJ5l6S8x4Ph4/BL57tKrl2xj/yLq8UFUU1aSG+nkhjx3T1p81/1yD74z7+nsQLgcOgka3uLmTCqBndZOshAmX/jQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707954114; c=relaxed/simple; bh=CEb7IBHx+fjusQQcE8apVrNp83EBkkAjWwir31Bc96Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CsFpJ4QxPih9nNJOGaaAfRNhpA6+0fRoo0GFqOP3mJWmPYX9ygT+iIb97bQ+UFheKfHnWaRBX1mSc3XuzwomV5OY9BUNo3AxkNQFVzTtsGcUBKD67o5y9M7qnPaHLoB0TA3Z7ZdvHiIyWi5Dwg7W6WGbwSVdpWdHPhZROOD8WRo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WtbdFJe8; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72B11C433C7; Wed, 14 Feb 2024 23:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707954113; bh=CEb7IBHx+fjusQQcE8apVrNp83EBkkAjWwir31Bc96Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WtbdFJe8M9eTIYkkR8eeyYnwPV44QBQjaIvcpB0Oy99auSOYUfCqYA/REFb02mdYO /JHAyoB8P/ejLDK2Clea2vUd3QdzkiGQAyKhpk6cq0pd8XwehKeoagr18f+qq60uxp GklWnAPeVxQju9EdkvBFFR30N6CriRYyTI+NhtbIl0LhQdN04+xksd1rKu5+T8rLj1 4ID3bNmfrPGdkyifwe+1tCZh4rC8pd7QiH7WvkdBF126BTMAs2co1jl4AUU78qZNIo gpoatCfFlYUuWAcxRaV3XS3lMG+u4csbyBAM5i+7bJsaYOPfIspRlAvIL2ro3DzJiJ xu/o5b3UFciTg== Date: Wed, 14 Feb 2024 15:41:51 -0800 From: Eric Biggers To: Herbert Xu Cc: Linux Crypto Mailing List Subject: Re: [PATCH 09/15] crypto: chacha-generic - Convert from skcipher to lskcipher Message-ID: <20240214234151.GE1638@sol.localdomain> References: <1585df67b3f356eba2c23ac9f36c7181432d191e.1707815065.git.herbert@gondor.apana.org.au> 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: <1585df67b3f356eba2c23ac9f36c7181432d191e.1707815065.git.herbert@gondor.apana.org.au> On Wed, Dec 06, 2023 at 01:49:32PM +0800, Herbert Xu wrote: > +static int chacha_stream_xor(const struct chacha_ctx *ctx, const u8 *src, > + u8 *dst, unsigned nbytes, u8 *siv, u32 flags) In cryptography, siv normally stands for Synthetic Initialization Vector. I *think* that here you're having it stand for "state and IV", or something like that. Is there a better name for it? Maybe it should just be state? > -static int crypto_xchacha_crypt(struct skcipher_request *req) > +static int crypto_xchacha_crypt(struct crypto_lskcipher *tfm, const u8 *src, > + u8 *dst, unsigned nbytes, u8 *siv, u32 flags) > { > - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); > - struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm); > + struct chacha_ctx *ctx = crypto_lskcipher_ctx(tfm); > struct chacha_ctx subctx; > - u32 state[16]; > - u8 real_iv[16]; > + u8 *real_iv; > + u32 *state; > > - /* Compute the subkey given the original key and first 128 nonce bits */ > - chacha_init_generic(state, ctx->key, req->iv); > - hchacha_block_generic(state, subctx.key, ctx->nrounds); > + real_iv = siv + XCHACHA_IV_SIZE; > + state = (u32 *)(real_iv + CHACHA_IV_SIZE); So the "siv" contains xchacha_iv || real_iv || state? That's 112 bytes, which is more than the 80 that's allocated for it. Isn't the state the only thing that actually needs to be carried forward? - Eric