Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp83854yba; Wed, 15 May 2019 19:31:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKiDj0hiM/JiTupWBSmNs3JLX6uYRTRpmw1qSZzHK6hZGxq2zzHqruQpeZgRDIFz2kgkON X-Received: by 2002:a62:2b82:: with SMTP id r124mr42399125pfr.235.1557973876436; Wed, 15 May 2019 19:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557973876; cv=none; d=google.com; s=arc-20160816; b=SzH8dQfDZYYrMFxhvqOPV5eFSSWEZqlex8d9wKDPi13oSb9zB/tjmVGSbJGA+y1qOo PaN7KJKZKOeDUxp4a+BCnIvYO0JNceqzKYZoWVXDrFqh9f5eNUQCUZ7mqNJVGM28bnI6 yS5T/Nq6fUMT/x4ALZ5si9WRKea+/KFhN9s/zXOUHKUsrjCPUfiGuNmtNsZGgB89kknU isLaLB9jsV2kV/Q/GXxUv4cLdUBBAGX9U6/yE+jHHl3/KWJNevtrlnDdHmWL2w2WoLFj 3wriuXfecX8gJLE4/UzjZOhNZk/U9oeg8tRhCOmg4/2G4ZATWhBIOgRzVQI46jafLlvX tj0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K+F7fvHB1yl0skc4kMIQvFkx78M7ISrmmpzskR8H09Q=; b=R4wkLkWPver8gL6ZC+UeeRYOo/ZbUxPDiEOs1bsIwGcqTc2AqV1rP2h8TviDmif/8z FojDKP8ShmDrwPiSVT4jY47uitlIb9qAOpZX4S82rVUuXkjjsxNfMY1moZNwdW/8lEUc eySl9zkPJ1yjVbW34wTXCbLQ1gQDLvQHA6zKHbnF+9jBrjgA3Ywur3uaLBL3F4vBdBEJ 1IRNOyHuD120O7Smhd3xItJPV70tAsjywH2qDVXStHFIeygszKcK5tovMJQyFCP8rqaq Jkj0BM1R5k51JTCreeuttXR/BE+lc1IVUOUj3lfGXYhwkBmLHoJ7D7V07GffC6XT+ewT DQIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mxuvneyk; 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 b11si3397832pge.440.2019.05.15.19.30.57; Wed, 15 May 2019 19:31:16 -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=Mxuvneyk; 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 S1725977AbfEPCay (ORCPT + 99 others); Wed, 15 May 2019 22:30:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:45876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbfEPCay (ORCPT ); Wed, 15 May 2019 22:30:54 -0400 Received: from sol.localdomain (c-24-5-143-220.hsd1.ca.comcast.net [24.5.143.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ACA6720843; Thu, 16 May 2019 02:30:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557973853; bh=wM9TNClsZacWcRgk7xTDNK0BYza1+wzkgKUWbX29yrM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MxuvneykuaKmPMU593+C93QcL9NYo0U3hIQ3jPbZUw9YVhW3okQwsdkSF23jGw6Vs E47HWjp4V2AI4tkf9BtC9jDKrM3vOeIuB5S4G1NQveQFaD7L9HQKfCIvLEr7cqAVpo Sa9VmLheapfklWiIY0Pu9I17VSa/syzd6uR1jgC8= Date: Wed, 15 May 2019 19:30:52 -0700 From: Eric Biggers To: Christophe Leroy Cc: Horia Geanta , Herbert Xu , "David S. Miller" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" Subject: Re: [PATCH] crypto: talitos - fix skcipher failure due to wrong output IV Message-ID: <20190516023050.GA23200@sol.localdomain> References: <29db3f20-f931-efc6-02a8-fe160ab8b484@c-s.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <29db3f20-f931-efc6-02a8-fe160ab8b484@c-s.fr> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, May 15, 2019 at 08:49:48PM +0200, Christophe Leroy wrote: > > > Le 15/05/2019 à 16:05, Horia Geanta a écrit : > > On 5/15/2019 3:29 PM, Christophe Leroy wrote: > > > Selftests report the following: > > > > > > [ 2.984845] alg: skcipher: cbc-aes-talitos encryption test failed (wrong output IV) on test vector 0, cfg="in-place" > > > [ 2.995377] 00000000: 3d af ba 42 9d 9e b4 30 b4 22 da 80 2c 9f ac 41 > > > [ 3.032673] alg: skcipher: cbc-des-talitos encryption test failed (wrong output IV) on test vector 0, cfg="in-place" > > > [ 3.043185] 00000000: fe dc ba 98 76 54 32 10 > > > [ 3.063238] alg: skcipher: cbc-3des-talitos encryption test failed (wrong output IV) on test vector 0, cfg="in-place" > > > [ 3.073818] 00000000: 7d 33 88 93 0f 93 b2 42 > > > > > > This above dumps show that the actual output IV is indeed the input IV. > > > This is due to the IV not being copied back into the request. > > > > > > This patch fixes that. > > > > > > Signed-off-by: Christophe Leroy > > Reviewed-by: Horia Geantă > > It's missing a Fixes: tag and a Cc: to stable. > > I'll resend tomorrow. > > > > > While here, could you please check ecb mode (which by definition does not have > > an IV) is behaving correctly? > > Looking in driver_algs[] list of crypto algorithms supported by talitos, > > ecb(aes,des,3des) are declared with ivsize != 0. > > According to /proc/crypto, test are passed for ecb. > Did you try enabling CONFIG_CRYPTO_MANAGER_EXTRA_TESTS? There is now a check that the driver's ivsize matches the generic implementation's: if (ivsize != crypto_skcipher_ivsize(generic_tfm)) { pr_err("alg: skcipher: ivsize for %s (%u) doesn't match generic impl (%u)\n", driver, ivsize, crypto_skcipher_ivsize(generic_tfm)); err = -EINVAL; goto out; } For ECB that means the ivsize must be 0. AFAICS the talitos driver even accesses the IV for ECB, which is wrong; and the only reason this isn't crashing the self-tests already is that they are confused by the declared ivsize being nonzero so they don't pass NULL as they should. - Eric