Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8359377rwi; Tue, 25 Oct 2022 05:54:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM69Iq94FW1IWpAiafG1HTqDjeRmjxhDsGAmVmxkAIONaEHpsT+hmbRaqs/dD1ywfSGX0qgF X-Received: by 2002:a17:907:6288:b0:78d:ab30:c374 with SMTP id nd8-20020a170907628800b0078dab30c374mr32950628ejc.266.1666702492323; Tue, 25 Oct 2022 05:54:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666702492; cv=none; d=google.com; s=arc-20160816; b=D7J0TOkyseG4j8ppPtZ7/TzA2M+zfqutDY8fgrCnMB1s8dfHvq7w0VlI8t2s5R57gA k1d+iGmGknwPoUG+U0bywnwVWG6pgSBTkRKPsWobHXr8AeGE64YS0DmjQ3zaM+8HjnJT vyYWDbEKu4BjcEGm6XxVd6KU8xOfm8RfjHLFZjpAacUfU5Qzjkjycrw1JC+xUIQIkYiZ 1XIgWXAAq7N9oFCM3dT80zKhg33+pdc/pM3iv+jg79saA3eckfjwlTuqm5suKnWSoQj7 hVmq6v4BEjwKZfo8BuYAbCIBFxghuOomANnRSJI+TlybFzhJXnDN2sCYN1ldVMmmyWJj V7BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=AOrlJ+rodCtWsfa8eqYig82HAfhB2SWx2ifugD9c7r4=; b=TR+J3J3dPxgUXcYP5iyefUzgMn2f0YNDoRY6NTsDqDXYAB/6G6v7Qzfjlcz7ZM1dOn 6yUt4Mg6JeUevn5wBJQ7Vf68LpC4/amVtvIg2zR7zX3ZIToPbL3UUnUNSzg50sNabHes Ng3nkyOgfcUE8C7bzydEB3s8o0oo6qNYG1en5HtT+Xr2mKwKYrD4y7ugsQdw0YpzXTKD H3agvs9k3bdJoh1x8hhjz+FnZvTM0DvjUR/w31HgXl7BlpmlwtTRpjIFV3ZW3lvsEM/T SRylOEYitt/y49rcO3JxfJmOuAFPITCKqMsyfQJQnwyDOWjSBRj6d2PYGOltZ0+d+nlr Lj9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t+KHtLRj; 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 hb12-20020a170907160c00b0078b0865d468si2839533ejc.549.2022.10.25.05.54.21; Tue, 25 Oct 2022 05:54:52 -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=t+KHtLRj; 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 S232568AbiJYMw7 (ORCPT + 99 others); Tue, 25 Oct 2022 08:52:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232571AbiJYMwB (ORCPT ); Tue, 25 Oct 2022 08:52:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D11A315FF8 for ; Tue, 25 Oct 2022 05:49:12 -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 3C9656190E for ; Tue, 25 Oct 2022 12:49:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A084BC43470 for ; Tue, 25 Oct 2022 12:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666702151; bh=pn5WWsG1lQ2xaUHJwXQ9SZKo6QxRqX9z+SXjmgXixcs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=t+KHtLRjdLlWfhrr9Q2yQouRsOg4ETNK1ksIA2JbBoUNuiT2Km9RUs/E5hv0O91n/ A+mBABPZMhdpevR6lHaAPRhcSTrGufwzoruLLXPN1M4C/5gPMyV6+X8ok2wNXjG6z3 VBY7DB5Qakw3OXitNLIBIhpIoNgjbpdmfQQ1K36ZAEK5IrgUEK3IsPoKv4w1y0E9Ge 0gx+I/LpD87b2IvGDEOhULWJDHFe1ODxoTtEH0VUWfipAux0CxSkZvcXxFp9bDzxv/ 0oa+HTRhK+otTlIBCplhozfQ7dHsDYxLol+6gy8fGOtNt83qvXnqtcN8h/eL724gdu L9K3UQ3nkerlw== Received: by mail-lf1-f52.google.com with SMTP id bp15so21681227lfb.13 for ; Tue, 25 Oct 2022 05:49:11 -0700 (PDT) X-Gm-Message-State: ACrzQf14TAqf6sdM2cRL9tES5+ZbLmxbf/fYE7jGcH9lk0IGeJunOyJ8 Ka8q6+24KrcIoJNzgXNs/Jj+dRAAeRCbUrS4rg8= X-Received: by 2002:ac2:4c47:0:b0:4a2:c07b:4b62 with SMTP id o7-20020ac24c47000000b004a2c07b4b62mr12946385lfk.426.1666702149638; Tue, 25 Oct 2022 05:49:09 -0700 (PDT) MIME-Version: 1.0 References: <20221024063052.109148-1-ardb@kernel.org> <20221024063052.109148-4-ardb@kernel.org> In-Reply-To: From: Ard Biesheuvel Date: Tue, 25 Oct 2022 14:48:57 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 3/3] crypto: aesgcm - Provide minimal library implementation To: Eric Biggers Cc: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, keescook@chromium.org, jason@zx2c4.com, nikunj@amd.com Content-Type: text/plain; charset="UTF-8" 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 Tue, 25 Oct 2022 at 07:32, Eric Biggers wrote: > > 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? > I'll add a comment in the code where the counter increment occurs. Using int is easier because I can use signed comparison with 0 to decide whether we are done. We don't need the range so unless someone feels using unsigned int is essential here, I am going to leave it as is. > > +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. > I'll change that.