Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1920564rwb; Fri, 11 Nov 2022 02:20:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf64Dl50mS2BVkPoh9YRSnMf0Xr2mXnEgan1OOU1n1sEwr9b07oYAP8YlirIV4PPIjDZv8iW X-Received: by 2002:a17:906:68d8:b0:78d:e786:e322 with SMTP id y24-20020a17090668d800b0078de786e322mr1286698ejr.308.1668162029448; Fri, 11 Nov 2022 02:20:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668162029; cv=none; d=google.com; s=arc-20160816; b=kZ3kuluVUDl90iTgmsTxlmP1iOa7Wy4106v+AW/Q0Xhbd+fzI3dYng4nlfiYCbkoAt NRjVomaRhC4DaN3mLMim8EFCk75RyFLtgpLkLWaIHsy22mIjNY8VIcwA9nLw4xvH6YB5 9cXKA9gsWvjEOAMeoLQzrO0eALuJ/Lxv/5FKk3anJkyu1RPAhFYFXYRT3seF+yrip2dm /jZmOtiTWRzB+jMMVppypRtbhH3VOjD3IYII34MQO/iv0+HFN85kDF+Bf+W1lhRCf4o0 nnbNMRkLp/gkyQFul/g05q3xlZmVrYhsxnCNj4KudA1bItAm5yvQGFmq1thLss2ZVI0Y O2ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=DLNcluQO3vkeBAAMre86KgX3L/5HdiZ4y8BFFp3HOms=; b=JdJ9ZOtvmY/ASexCi3zfXWzJH/tIRyzFsyqL4iNwpbkSMH8AVIvIzpp3jMEcbnA4L6 w/w/YhJQKOH7Ck6UEN9OfM5MoylJZBfkjNsLZQ2HNSZhVcMQxNQeoyazkHY0iPcac197 j1/uyHu2VxBWb4q51D9HXgNIohOfoYiAdfZGo5Yc8M6hFUhSP5JGibUdgr/O6hy5SivR MGsgtjWpeOPsIMBG6Kvv/b8CsW9AbGfkmrdF2aAerrhntTWXG5GaxlWGxg7VNKdpym0T CD0bFhYf7alcAaelAl83pXN1v9njBzlOUTxd5q2vY8cQbCKwFpzqx9tnv+g+7g0yHILL HWKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs19-20020a1709073e9300b007ae72eabbcbsi1827802ejc.824.2022.11.11.02.20.04; Fri, 11 Nov 2022 02:20:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233732AbiKKKSU (ORCPT + 99 others); Fri, 11 Nov 2022 05:18:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233769AbiKKKRg (ORCPT ); Fri, 11 Nov 2022 05:17:36 -0500 Received: from formenos.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 539447E9A1 for ; Fri, 11 Nov 2022 02:17:35 -0800 (PST) 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 1otR6J-00Cyuq-QV; Fri, 11 Nov 2022 18:17:32 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 11 Nov 2022 18:17:31 +0800 Date: Fri, 11 Nov 2022 18:17:31 +0800 From: Herbert Xu To: Ard Biesheuvel Cc: linux-crypto@vger.kernel.org, keescook@chromium.org, Eric Biggers , Robert Elliott , "Jason A . Donenfeld" , Nikunj A Dadhania Subject: Re: [PATCH v5 0/3] crypto: Add AES-GCM implementation to lib/crypto Message-ID: References: <20221103192259.2229-1-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221103192259.2229-1-ardb@kernel.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham 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-crypto@vger.kernel.org On Thu, Nov 03, 2022 at 08:22:56PM +0100, Ard Biesheuvel wrote: > Provide a generic library implementation of AES-GCM which can be used > really early during boot, e.g., to communicate with the security > coprocessor on SEV-SNP virtual machines to bring up secondary cores. > This is needed because the crypto API is not available yet this early. > > We cannot rely on special instructions for AES or polynomial > multiplication, which are arch specific and rely on in-kernel SIMD > infrastructure. Instead, add a generic C implementation that combines > the existing C implementations of AES and multiplication in GF(2^128). > > To reduce the risk of forgery attacks, replace data dependent table > lookups and conditional branches in the used gf128mul routine with > constant-time equivalents. The AES library has already been robustified > to some extent to prevent known-plaintext timing attacks on the key, but > we call it with interrupts disabled to make it a bit more robust. (Note > that in SEV-SNP context, the VMM is untrusted, and is able to inject > interrupts arbitrarily, and potentially maliciously.) > > Changes since v4: > - Rename CONFIG_CRYPTO_GF128MUL to CONFIG_CRYPTO_LIB_GF128MUL > - Use bool return value for decrypt routine to align with other AEAD > library code > - Return -ENODEV on selftest failure to align with other algos > - Use pr_err() not WARN() on selftest failure for the same reason > - Mention in a code comment that the counter cannot roll over or result > in a carry due to the width of the type representing the size of the > input > > Changes since v3: > - rename GCM-AES to AES-GCM > > Changes since v2: > - move gf128mul to lib/crypto > - add patch #2 to make gf128mul_lle constant time > - fix kerneldoc headers and drop them from the .h file > > Changes since v1: > - rename gcm to gcmaes to reflect that GCM is also used in > combination with other symmetric ciphers (Jason) > - add Nikunj's Tested-by > > Cc: Eric Biggers > Cc: Robert Elliott > Cc: Jason A. Donenfeld > Cc: Nikunj A Dadhania > > Ard Biesheuvel (3): > crypto: move gf128mul library into lib/crypto > crypto: gf128mul - make gf128mul_lle time invariant > crypto: aesgcm - Provide minimal library implementation > > arch/arm/crypto/Kconfig | 2 +- > arch/arm64/crypto/Kconfig | 2 +- > crypto/Kconfig | 9 +- > crypto/Makefile | 1 - > drivers/crypto/chelsio/Kconfig | 2 +- > include/crypto/gcm.h | 22 + > lib/crypto/Kconfig | 9 + > lib/crypto/Makefile | 5 + > lib/crypto/aesgcm.c | 727 ++++++++++++++++++++ > {crypto => lib/crypto}/gf128mul.c | 58 +- > 10 files changed, 808 insertions(+), 29 deletions(-) > create mode 100644 lib/crypto/aesgcm.c > rename {crypto => lib/crypto}/gf128mul.c (87%) > > -- > 2.35.1 All applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt