Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1593220pxb; Thu, 4 Feb 2021 17:57:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvTMAorUCUd+cCrQ0uQsHXiNlqEJlpldbEEtNKsqK8gonVq7Xjqj28RjqqQ0PMNPgPjQVR X-Received: by 2002:a05:6402:125a:: with SMTP id l26mr1411939edw.188.1612490244591; Thu, 04 Feb 2021 17:57:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612490244; cv=none; d=google.com; s=arc-20160816; b=V/IqyhPOSoTe1nJqd0U9KL3jQ6zCG9Baf9hKvyojTxfWWICLol7J82jvfYyv1I+LGP JFpBINYweZwP3bgVTeBQEampXvNe/wxZ+5P3aCFgzR90z++TQZAPvOxy1SrYW9hnYC1W 5qFA9rMcRl7NUkCFa+tJRUJdSRP76hzgbhVoimKlBgv8kjsNjkiU2pEB5xIdhE1zI6WZ AiCQhIWcLd0L8J07bJ0BISt0aHgWpJw6vkkuUPdeowaYEgniivagZxuC9lRbSNvLSRW1 3h4RXnHWc3/j092GfngSe4afSrAGZlz/2Lc9XB+skQaiyTrrh3mgV13ApW5ZG1b+rpBV BEmA== 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=8gBa/tbP9c2+Vcbeb7UpCTfaPUbAe1tfjMAguMzjWHE=; b=1EC9vLe62GcXKh9uf4Xl4E09AO/+35sSb04tK4Fx7P+g7154hpw/lIpAcxUS+RyJdZ wyP+22ZI8O5ttICKV7pYpc18n1tQdH3aOY9fJKsqIMN0UHpxqizbL3kCyWpLNMlWcNka Bttji8kjxTXQybFqReKVLmwVA9G+y3MA67t3LBSkHPBRTD8/2xJcvK0FP61OMrOzQU2m EecIEtyDPCy/uJiM1/XRd47Vtd0g1z8Vrb/Sk1cPL5/Sx62uhBiRl4NXPW/kt1IZAECu ImvA/0KsAvcbuE5pydaMu5rw9YhHD9TolqY6QIQ0GCtTH+1PhGJlVtfB4Yomv4nP+LRk YA+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uWgZGLa6; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si4332260edr.61.2021.02.04.17.57.01; Thu, 04 Feb 2021 17:57:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uWgZGLa6; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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 S231925AbhBEA05 (ORCPT + 99 others); Thu, 4 Feb 2021 19:26:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:56670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231922AbhBEA04 (ORCPT ); Thu, 4 Feb 2021 19:26:56 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 90E5A64D9D; Fri, 5 Feb 2021 00:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612484775; bh=leZEpI4tCbCaIcMRqiMOvFUKRIKm1hwWHpDcUc3Hyew=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uWgZGLa6VR1Mty6aqa7qwwo12eQtntAaYwA2MJoYK2F6O/ahDB2GevWUOWuZSjuyR iaLKcWs06tkiewx7woo0aUrRg4ZfSgZbbsH/JM+v3kRw1URyZvEARhA6PauvR0789x d7A87g1JA4aDGsCCZSGsP22zFSRIDRB7kXqkRBVTsI6R5jR6n8i+dWGVNoWEKGNifo NgsI0jR5oIsIWE0/8qN6J9IgTfCNQDQLd+24I+qu7GzC9ptxJ1g3Dc7B6BvbvQmpVL M3M9xU0knt5ykidCH+BLwbOpLclspcuQA5UB54a+nKeT9g+6zouS04XJGgx60xBlBO mq6VQfFjMHOWg== Date: Thu, 4 Feb 2021 16:26:13 -0800 From: Eric Biggers To: Thara Gopinath Cc: herbert@gondor.apana.org.au, davem@davemloft.net, bjorn.andersson@linaro.org, ardb@kernel.org, sivaprak@codeaurora.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 05/11] crypto: qce: skcipher: Return error for zero length messages Message-ID: References: <20210204214359.1993065-1-thara.gopinath@linaro.org> <20210204214359.1993065-6-thara.gopinath@linaro.org> <00d759f3-8ea3-1f85-b623-225c372c0a04@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00d759f3-8ea3-1f85-b623-225c372c0a04@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Feb 04, 2021 at 07:09:53PM -0500, Thara Gopinath wrote: > > > @@ -260,6 +261,10 @@ static int qce_skcipher_crypt(struct skcipher_request *req, int encrypt) > > > rctx->flags |= encrypt ? QCE_ENCRYPT : QCE_DECRYPT; > > > keylen = IS_XTS(rctx->flags) ? ctx->enc_keylen >> 1 : ctx->enc_keylen; > > > + /* CE does not handle 0 length messages */ > > > + if (!req->cryptlen) > > > + return -EOPNOTSUPP; > > > + > > > > For the algorithms in question, the correct behavior is to return 0. > > What do you mean? The driver should return a 0 ? Yes, there is nothing to do for empty inputs, so just return 0 (success). > > Aren't the tests catching that difference? > > I was anyways planning on sending an email to the list with these queries. > But since you asked, these are my observations with fuzz testing which I > have been doing quite a bit now (I am also working on adding a few qualcomm > AEAD algorithms support in mainline). > > - if the generic algorithm supports 0 length messages and the transformation > I am testing does not, the test framework throws an error and stops. > - key support mismatch between the generic algorithm vs my algorithm /engine > also does the same thing.For eg, Qualcomm CE engine does not support any > three keys being same for triple des algorithms. Where as a two key 3des is > a valid scenario for generic algorithm(k1=k3). Another example is hardware > engine not supporting AES192. > > How are these scenarios usually handled ? Why not allow the test framework > to proceed with the testing if the algorithm does not support a particular > scenario ? Omitting support for certain inputs isn't allowed. Anyone in the kernel who wants to use a particular algorithm could get this driver for it, and if they happen to use inputs which the driver decided not to support, things will break. The way that drivers handle this is to use a fallback cipher for inputs they don't support. - Eric