Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2176399imm; Tue, 2 Oct 2018 22:56:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV62XPVOSIU0GWjWJ/bKDgqWd94u3kGk6LZUBY9MBWwKvuqj6QKdmQAePCatQk0mHlKM25C8u X-Received: by 2002:a62:6643:: with SMTP id a64-v6mr19514947pfc.202.1538546183516; Tue, 02 Oct 2018 22:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538546183; cv=none; d=google.com; s=arc-20160816; b=IKuPm2AaGp+DvMKxDMT+XnU4bo5IHStoFLjYOUdiQe9fDmlqQkVi0FUvJdwLVNRHfz Ws/2vAuJbb4WThuquAGaczpL2wmn8ZASR45FDKnvPyJjQrt1Il5LcCpzRqnXOvnB85mw bYUOf0mbf7t9wQr/ghvc/CnP7gWNpcBza5GWJLNr29wDtJRZ6dVjRUENDtkc/37VP8SA A9re4olqvx8Uk4jYZRTzzkym7V1MGcrkG4ksn04wGJowKJ9oB0k1fo3nmOPYjltK5Dyp DxyLNdA33pbhm8Q5JKDLnvn7OiJ6vRpLh34ylVWdB2Xf0FFMrHeaW15MhlWqIzsCykal 7RDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vec/VqqfhPc9joR/JVXwHZlVPSPxEwwCzs04re796r8=; b=dIgW+0/+Jz3GIYBEKkK1j8qeoMTyW9snclfr5q2Si3ExgirX5CAZC6UO4sK4NI9Hwy +YAmo7J0BHpcyrbSNTIst7mNN2Trw8WnkPgsBtYm94gJSzTY1CjGVzJ2OkXS09H64E80 0RiJd5+qtsZYIEFJnOKTpIP+gWRnO4VmnxcZas2RMsF2yoOoK6jkt6FtWvCZWVfk3o6t BLnzudLPFc0/c/PViaMUMKiec1frzqoiGMKomXAHa1UdSnk22KSx7QvmXot82mkj4hmT aCA4W1dAFVsLRTj8/N8Z+g8EnQ4a1TSgo3EbTzALR5hxplKoNZBWgdy1EQR0EOGvZ4Iz YEsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r66F6whZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t19-v6si460553pfm.152.2018.10.02.22.56.08; Tue, 02 Oct 2018 22:56:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r66F6whZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726781AbeJCMmy (ORCPT + 99 others); Wed, 3 Oct 2018 08:42:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:55052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726552AbeJCMmy (ORCPT ); Wed, 3 Oct 2018 08:42:54 -0400 Received: from sol.localdomain (c-67-185-97-198.hsd1.wa.comcast.net [67.185.97.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C929020835; Wed, 3 Oct 2018 05:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1538546162; bh=CJ6awt8fMuMaOMIo6OcnF1Mm9DyzE4LLAQwoYkjVnpg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=r66F6whZFILkej8NY0bRcPf8ab/ZNqfAJFLZVgEEeoDvmo3zBr4kd1P2rQQD3sMJd H9y2ghRJxKYmJN5BQeOSL9c1C20tQlwOkKTvz43nHg911Z4/1Nm/Bu3Q/B8Soov3c5 dMwXRR/jBuGUS1MVt2EN1O5vLSESQe4MIqOrUiWA= Date: Tue, 2 Oct 2018 22:56:00 -0700 From: Eric Biggers To: "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-crypto@vger.kernel.org, davem@davemloft.net, gregkh@linuxfoundation.org, Samuel Neves , Andy Lutomirski , Jean-Philippe Aumasson Subject: Re: [PATCH net-next v6 21/23] crypto: port ChaCha20 to Zinc Message-ID: <20181003055559.GA745@sol.localdomain> References: <20180925145622.29959-1-Jason@zx2c4.com> <20180925145622.29959-22-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180925145622.29959-22-Jason@zx2c4.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 25, 2018 at 04:56:20PM +0200, Jason A. Donenfeld wrote: > diff --git a/crypto/chacha20_zinc.c b/crypto/chacha20_zinc.c > new file mode 100644 > index 000000000000..f7d70b3efc31 > --- /dev/null > +++ b/crypto/chacha20_zinc.c > @@ -0,0 +1,90 @@ > +/* SPDX-License-Identifier: GPL-2.0 > + * > + * Copyright (C) 2018 Jason A. Donenfeld . All Rights Reserved. > + */ > + > +#include > +#include > +#include > +#include > +#include > + > +static int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key, > + unsigned int keysize) > +{ > + struct chacha20_ctx *ctx = crypto_skcipher_ctx(tfm); > + > + if (keysize != CHACHA20_KEY_SIZE) > + return -EINVAL; > + chacha20_init(ctx, key, 0); > + return 0; > +} > + > +static int crypto_chacha20_crypt(struct skcipher_request *req) > +{ > + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); > + struct chacha20_ctx *ctx = crypto_skcipher_ctx(tfm); > + struct skcipher_walk walk; > + simd_context_t simd_context; > + int err, i; > + > + err = skcipher_walk_virt(&walk, req, true); > + if (unlikely(err)) > + return err; > + > + for (i = 0; i < ARRAY_SIZE(ctx->counter); ++i) > + ctx->counter[i] = get_unaligned_le32(walk.iv + i * sizeof(u32)); > + Multiple threads may use the same tfm concurrently, so the tfm context must not be used to store per-request information such as the IV. - Eric