Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7882780rwi; Mon, 24 Oct 2022 22:41:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5CkmUspWC29WbFgWVJNwjQvLPmjQ8SqFss7VH9lNtV5R73wfXT5pV/ZfAv3zpPK2zpvh2b X-Received: by 2002:a17:906:cc0f:b0:7a0:b91c:855f with SMTP id ml15-20020a170906cc0f00b007a0b91c855fmr14288226ejb.26.1666676472313; Mon, 24 Oct 2022 22:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666676472; cv=none; d=google.com; s=arc-20160816; b=1D70LYAPeLCD3ymUVh8FimYSgo1DQJ2aYe7DP3mywW9YYOCUX0TgtPTjHqoZFW1Yt3 ZLDEpN7Z9o2tmwcn3/kUvZNAcdxHKDD5epEtz/wer3Pgq8zrnOAF67RzNLXjJ2gWi7AR jyDu0PLu+tYpvA7ZTwZgqsVdXcmNlP1K11UTA9PoBjyQABXxloUJTp/AJLwAwA8T5+3j d4rRxu4guIHftmWr7Q29pccPFL1B7qAjUVYTomuVq4+qrkYG6odpSb9x9ln4+xi/Sycn aEkDYrNZ5c+v2u/TW4mPVSK/iCE4G9pXJtRGgFgtPwglDGq9cuAVIyLcvdLH8g9DiKh7 fQVQ== 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:dkim-signature; bh=uPF5k/LnFK8kuzwzM8MK0GFLS9Xgin/CAMLi2FsF7Z8=; b=enMVgYN+H8STOZ8u2eSM2nvkk2VtuP8198uYXPNqqW9m8gsbeJacmBQ1jbNwhcYUW5 Nxe7LYUsDV6s2X7MzhBTT4ztPUW4S5ZuS21CgYlkLYy79MqJRhAFg4I2EiKn7FlhQlyd 63Kmf8xO+Kn97YxHba7NxR3vDB3jTpg/9o5N6dxouc8Ad7109RXuQ7Yh4bykoey0ThAH kIyl1M5vA1ujpEg/r1x/wWU/pRVfmcN5WL1AMonAJ+lKjmXnhUf3yU8mJvvf0YW5PC9i QyhyGVL3bgDmTG7kxsR7kMqrv2fSC+I8KUJiO0/GMRrkUGhJfvLLZjRbaw/DK176EYSw 5+QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="f6w/bAdK"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a170906520900b007806a130086si1674819ejm.302.2022.10.24.22.40.48; Mon, 24 Oct 2022 22:41:12 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="f6w/bAdK"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229491AbiJYFcc (ORCPT + 99 others); Tue, 25 Oct 2022 01:32:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiJYFcb (ORCPT ); Tue, 25 Oct 2022 01:32:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B1B410F8A3 for ; Mon, 24 Oct 2022 22:32:31 -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 dfw.source.kernel.org (Postfix) with ESMTPS id B877661746 for ; Tue, 25 Oct 2022 05:32:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0957C433D7; Tue, 25 Oct 2022 05:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666675950; bh=eoUq+qDRD06XalwYr/1zr8rSnoH2yIwW4iIoE6ZSenw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f6w/bAdKmyY8rvfGv+EX/Z/MkZIvCnTXwo1IjtBQOWNyqV7RpCFCmfnYuTSTVFHHw tMTr5Jk2XSmzDvgg8F/ZFyYbLKA5Y9SQud4oIGwZUZAyItKFcxs8rx3JPyko/iBB9g f9R9zb/vznKLqy1pAGCVbYtxvcgy0NRRC4ovwjFLv2BUsxpEJE28uBbqwMzkhcfvWZ Mz5A0C+q5ZyUje2oYyfBfjIkGKhpe3lyaHrr4qH7DkywMmumMzKR2tIVJ4MNWXtAWn fgbOtnDIunZyb8hyr/Lz+LOOpml2R83SCX3NVB7lNzvF2o9BbnH7HKcRcEXYugQDyY jfNUd45rBJm1w== Date: Mon, 24 Oct 2022 22:32:28 -0700 From: Eric Biggers To: Ard Biesheuvel Cc: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, keescook@chromium.org, jason@zx2c4.com, nikunj@amd.com Subject: Re: [PATCH v4 3/3] crypto: aesgcm - Provide minimal library implementation Message-ID: References: <20221024063052.109148-1-ardb@kernel.org> <20221024063052.109148-4-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221024063052.109148-4-ardb@kernel.org> X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Mon, Oct 24, 2022 at 08:30:52AM +0200, Ard Biesheuvel wrote: > The former concern is addressed trivially, given that the function call > API uses 32-bit signed types for the input lengths. It is still up to > the caller to avoid IV reuse in general, but this is not something we > can police at the implementation level. This doesn't seem to have been any note left about this in the code itself. Sizes are usually size_t, so if another type is used intentionally, that should be carefully documented. Also, does it really need to be signed? > +int __must_check aesgcm_decrypt(const struct aesgcm_ctx *ctx, u8 *dst, > + const u8 *src, int crypt_len, const u8 *assoc, > + int assoc_len, const u8 iv[GCM_AES_IV_SIZE], > + const u8 *authtag); This returns 0 or -EBADMSG, which is inconsistent with chacha20poly1305_decrypt() which returns a bool. It would be nice if the different algorithms would use consistent conventions. - Eric