Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3944950ybl; Tue, 20 Aug 2019 04:49:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5r6jy7twMFo5aL+c84fnJbMdY8Idgb2ZiGKeiky0HbuKhiBp2h3L1CRK+KLRlhiaIyLdS X-Received: by 2002:a63:460c:: with SMTP id t12mr24074251pga.69.1566301787596; Tue, 20 Aug 2019 04:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566301787; cv=none; d=google.com; s=arc-20160816; b=OT/38cb1zBeWYwKnAnN0Ukuhz77t96fl7W6DFt62fX7YxJ+xHNyCKVLXizTMDFcvbc Tc78igp5iOrOCUz+wSz84AsOpeTErIq1NKs+NweVBBkIbRe1VQhRI27Hi00rTEDM2yin GQiMVHoGbhwsWO2/p775KmbGxg2iKSE7nh3m4wgeUnOL5svS8aNktJyfVHaryNc2j0D5 VEaOMCr3pDK3R8BSxDxQm5VILgflbML/QRp4PwoLeIkYNaPqgvFeH3zselNAu9NGFLwR a5p3mAvNX+2Su+Uc9dD8kLsb+S4ONZxMn7zCtUzik6+3mcciHzUXxZWRCV8OsZ07ak57 TPHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=K3/TC0aGjFtADML4Ma9a0bc6JqRKM4VYLmDtRBZrLeg=; b=h4a09zIBpqlXyUnEEcKVXbkrr9FNg52D26VvyqPk+klhehPRyfnBqf2kPF63bcE3zZ TMjCgXcS0/IGHTvZ+utG2d+S6rgZCG11ka5gP8RZqPlAm1jTqmEXF9C4gxhUd34hEeT3 kNco+ACVPOmeEwtc1AWPC6EUCFwjIkcLGGhYKWdozMWi2/VFhqTUHWjt9MPwT3YbSgQp rfyrcPr5a6gPYNgmZGDrDOTYaNTlsSpCTCsSiRL2ScBcGkQssN6i/to5HyocMvF0wp8i Wcw7Jpu5hPCp7gZkiosCKAieRKJtKRvVG08eDxp+hLU0/MG1lXsMTPFwfLMxNB6nqzGL pEKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Gpj26vqT; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id l15si10906870pjq.104.2019.08.20.04.49.33; Tue, 20 Aug 2019 04:49:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=Gpj26vqT; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 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 S1729827AbfHTLtF (ORCPT + 99 others); Tue, 20 Aug 2019 07:49:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:48506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729421AbfHTLtF (ORCPT ); Tue, 20 Aug 2019 07:49:05 -0400 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9112A22DCC; Tue, 20 Aug 2019 11:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566301743; bh=0KpTsWcb0dkbJwJinibwYWvwKro8mAVjXeRX97ogQbM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Gpj26vqTLPqEOtmRR10zSDqrgy7WXts9oCk3/mtPnsWYCAzHKA/Bl2RCclCpQQ2uS zja0eu6CRV/O2iIAUJZyXapDkC1IBqcopJPrkUH8MBrxNTPOYqLWKAyiCC24V4X8ae 8WKQmSOK1HvliQtn+Ms4X89Mtd0kpaXuzyzaATrQ= Received: by mail-lf1-f52.google.com with SMTP id j17so3880584lfp.3; Tue, 20 Aug 2019 04:49:03 -0700 (PDT) X-Gm-Message-State: APjAAAUhiaFFWz+6xr6ijYaR5s4U9txghMf4oqU52rQvxpo0FFdiL+8N K5BSrcZEQXC6Zu7Ly3R0UfKuDx8+T/ueUb9jEs0= X-Received: by 2002:ac2:44ac:: with SMTP id c12mr7436815lfm.33.1566301741719; Tue, 20 Aug 2019 04:49:01 -0700 (PDT) MIME-Version: 1.0 References: <20190819142226.1703-1-ard.biesheuvel@linaro.org> <20190819142226.1703-3-ard.biesheuvel@linaro.org> <1f932022-0335-1d00-b651-83c82d77fa7a@partner.samsung.com> In-Reply-To: <1f932022-0335-1d00-b651-83c82d77fa7a@partner.samsung.com> From: Krzysztof Kozlowski Date: Tue, 20 Aug 2019 13:48:50 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] crypto: s5p - use correct block size of 1 for ctr(aes) To: Kamil Konieczny Cc: Ard Biesheuvel , linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, Vladimir Zapolskiy , "linux-samsung-soc@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, 20 Aug 2019 at 13:39, Kamil Konieczny wrote: > > > > On 20.08.2019 12:24, Krzysztof Kozlowski wrote: > > On Mon, 19 Aug 2019 at 16:24, Ard Biesheuvel wrote: > >> > >> Align the s5p ctr(aes) implementation with other implementations > >> of the same mode, by setting the block size to 1. > >> > >> Signed-off-by: Ard Biesheuvel > >> --- > >> drivers/crypto/s5p-sss.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c > >> index ef90c58edb1f..010f1bb20dad 100644 > >> --- a/drivers/crypto/s5p-sss.c > >> +++ b/drivers/crypto/s5p-sss.c > >> @@ -2173,7 +2173,7 @@ static struct crypto_alg algs[] = { > >> .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | > >> CRYPTO_ALG_ASYNC | > >> CRYPTO_ALG_KERN_DRIVER_ONLY, > >> - .cra_blocksize = AES_BLOCK_SIZE, > >> + .cra_blocksize = 1, > > > > This makes sense but I wonder how does it work later with > > s5p_aes_crypt() and its check for request length alignment > > (AES_BLOCK_SIZE). With block size of 1 byte, I understand that > > req->nbytes can be for example 4 bytes which is not AES block > > aligned... If my reasoning is correct, then the CTR mode in s5p-sss is > > not fully working. > > As I remember this case there are allocated buffers with len aligned up > AES_BLOCK_SIZE, source data copy to one buf, hw encrypts full block, > then nbytes are copy back. Buffer alignment is different thing and it is defined in cra_alignmask. I am talking about req->nbytes which should be aligned according to s5p_aes_crypt(). But if blocksize is 1 byte, then what possible values for req->nbytes? Best regards, Krzysztof