Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3702369ybk; Tue, 19 May 2020 10:54:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO0L2/z6akv92mJ7D7L8vTQEyyvl9Q6GS2c2OFduwjITcy/Z8WCkUzRUw5w9VjqiyjsBr4 X-Received: by 2002:a50:cf4c:: with SMTP id d12mr107404edk.121.1589910898167; Tue, 19 May 2020 10:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589910898; cv=none; d=google.com; s=arc-20160816; b=TCxDgjst0gmzj6/TukfiePwBL8zq+iscmsGUkWJrCIdWplc6Wf61E946TIBOUEuAYb 219FTe5KttT8yF/S/Hnef8ijsRPA8IblfWukzhXT9WsEFXwzubr98xFptgkXsRef666y 4azxq5g2RBPSEdeauCmLLjq3ubf8mmPET8mRtTW3BqnxJx0HAHgFLinoEqqGgOsgEqAl aHfSKR1rIuxXx2md3DV7MrvSQIKMXslJ6GNhx7CO8VrnmuIKZt2ibj8QXYwqj1oMRss8 V4AH4/I3SZK7zbr5vxSeyQdzBd0TTM3uDtBpPmEJgKiQmyR3eCddXfpbTp3bMgO/gGWj fnAA== 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=fl8pYH4AeZxksrK0NgdhMuIPX1qljfOgOYbMDe337a8=; b=OFBvhASFCOjQ9mhf0cZR6/GiAUoOogxOOIxtl9VwWEnVPv58psmLsvUdYMt7vEn+XQ QAY3nXx6zr4V4nyKHRUQAmXzGWONfQQRZHN5HSOz/GVhi1djgg/oJjw74GphPY/iuLnY IFZwybHu+N9y/SA3fSpVcHahjWq5JuUHHpGOMQ0C3ZPLISVc8IA1Xruow15RKkpw9Vhw fnt90fqQ6NmuQ27BZwkl1EfCJSGPaVOiQBF6OvAZV39TY/ei5bDfDHHc/7+8rBovah/r gimPsvZ1l8+KvICNcCL2n3XDoXn9D0U2B0LIG9zxgKH9ZAYyDNNpQfjCSIj7mn5vZbMQ fWaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kRNUodjx; 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 w15si60608edi.597.2020.05.19.10.54.33; Tue, 19 May 2020 10:54:58 -0700 (PDT) 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=default header.b=kRNUodjx; 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 S1729164AbgESRyJ (ORCPT + 99 others); Tue, 19 May 2020 13:54:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:40364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbgESRyJ (ORCPT ); Tue, 19 May 2020 13:54:09 -0400 Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) (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 9991F207D3 for ; Tue, 19 May 2020 17:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589910848; bh=BLuKHIqrK9WZLY79C4AHsafY7pqItDoXkx14zosVmsw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=kRNUodjxV/2W4OwEQNv5CUa7vJGWbckT1ChWfuVlHCnG/4dMn/LNs7m9E6Zi6hIAI eAIYEboml0niZfcGEo4KIIjn+ez4NkGV+bX//XN/U6TOCUl3L+MWxBHpdXmZvxyJQ4 8m9vAwUXtCMl0lMJV6xQQ/245sKP23ERjPV7kIGw= Received: by mail-io1-f44.google.com with SMTP id c16so108492iol.3 for ; Tue, 19 May 2020 10:54:08 -0700 (PDT) X-Gm-Message-State: AOAM531pWSWHUJ9PpM9s/a8yPxECZm2c5H+43ZHr/j//hulrYLX/uD1H iQTMVW1c1Z12A6BKPj1fm7cIai83K527hYG/RKk= X-Received: by 2002:a6b:5008:: with SMTP id e8mr71854iob.161.1589910848060; Tue, 19 May 2020 10:54:08 -0700 (PDT) MIME-Version: 1.0 References: <4311723.JCXmkh6OgN@tauon.chronox.de> <8691076.XE7dyB1q2z@tauon.chronox.de> In-Reply-To: From: Ard Biesheuvel Date: Tue, 19 May 2020 19:53:57 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: ARM CE: CTS IV handling To: Stephan Mueller Cc: Eric Biggers , Ard Biesheuvel , Linux Crypto Mailing List 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, 19 May 2020 at 19:50, Ard Biesheuvel wrote: > > On Tue, 19 May 2020 at 19:35, Stephan Mueller wrote: > > > > Am Dienstag, 19. Mai 2020, 18:21:01 CEST schrieb Ard Biesheuvel: > > > > Hi Ard, > > > > > > > > To be honest, this looks like the API is being used incorrectly. Is > > > this a similar issue to the one Herbert spotted recently with the CTR > > > code? > > > > > > When you say 'leaving the TFM untouched' do you mean the skcipher > > > request? The TFM should not retain any per-request state in the first > > > place. > > > > > > The skcipher request struct is not meant to retain any state either - > > > the API simply does not support incremental encryption if the input is > > > not a multiple of the chunksize. > > > > > > Could you give some sample code on how you are using the API in this case? > > > > What I am doing technically is to allocate a new tfm and request at the > > beginning and then reuse the TFM and request. In that sense, I think I violate > > that constraint. > > > > But in order to implement such repetition, I can surely clear / allocate a new > > TFM. But in order to get that right, I need the resulting IV after the cipher > > operation. > > > > This IV that I get after the cipher operation completes is different between C > > and CE. > > > > So is the expected output IV simply the last block of ciphertext that > was generated (as usual), but located before the truncated block in > the output? If so, does the below fix the encrypt case? index cf618d8f6cec..22f190a44689 100644 --- a/arch/arm64/crypto/aes-modes.S +++ b/arch/arm64/crypto/aes-modes.S @@ -275,6 +275,7 @@ AES_FUNC_START(aes_cbc_cts_encrypt) add x4, x0, x4 st1 {v0.16b}, [x4] /* overlapping stores */ st1 {v1.16b}, [x0] + st1 {v1.16b}, [x5] ret AES_FUNC_END(aes_cbc_cts_encrypt)