Received: by 10.223.176.46 with SMTP id f43csp2569939wra; Sun, 21 Jan 2018 23:08:07 -0800 (PST) X-Google-Smtp-Source: AH8x2268g2b9ZmSiekWbQFUrjXz13MCpd5vTm5cHBLiwSJWU7tOX96cDzPlUowYQCODimgOgaXhM X-Received: by 10.101.69.141 with SMTP id o13mr6612803pgq.204.1516604886908; Sun, 21 Jan 2018 23:08:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516604886; cv=none; d=google.com; s=arc-20160816; b=jyx6TMupHWxv4TAAPpXsqR++/Dpg6k2sW9/7dlbahHRiG4ueNQ/OPDYx7agFhRz8W5 rQW4+ppG503Gt5raOeM5jxhDJl4Dm215ERT+bh/QMfb1y7MYjIGkiuvWKB1MJw1wgnA5 tzld+HieI6g1H1R7ohBQxKCVyxfJcdZeW1doEhtWObMg3bqgqY/gz5vueIPR9bl+rF9x VE1h6tBbTu6GmjTBKe4HQkltNy5pv7QVyA+IA8k/RnJXSZl4XYXqNB7GOjhqMvKL7dWT ysf4ye9ZRig3HXhJMpabTl8hZsX0IDUCWayFAcInEr0hv1BdG5mIV+M24oadrFmLVzbB 5teQ== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=2ORGU1WxkAQQWKaqC+MYGazKHLurZqfq04XpTX3YkOI=; b=m5sKvCNESvN0akasfaR1GCecH7vOvOlNCTDihrk+Hslv8ucIM2LA/ymZiRyLDFBuwu 6QpTQSmMTDjKMwrH3lQVuD/A65A5y6OzQ0p8M1b13vXXYnFQtW2laOjh8afQRnsrs8sC gAWQoFduIfJa6Ms9+deo/eTI3Qejo0Cmqj2/NHc6+ifYXdhXKHvnBF9HhkyyQ5hXe8KE ZFVewFGM6ZVie5/IxD60BFgdG1DtnCiWHcRaviS/lBoSyNw2EXaV6ED8sUnxjT9IC9JH E205nU3YAppljce6SpvHofLmuwUpi3ChNN32DjBylMPcm83e1Ri900m8XpOtOMrd0fyi nL6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@benyossef-com.20150623.gappssmtp.com header.s=20150623 header.b=fo7Id3dm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13si13032644pgq.776.2018.01.21.23.07.52; Sun, 21 Jan 2018 23:08:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@benyossef-com.20150623.gappssmtp.com header.s=20150623 header.b=fo7Id3dm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751101AbeAVHH2 (ORCPT + 99 others); Mon, 22 Jan 2018 02:07:28 -0500 Received: from mail-ot0-f195.google.com ([74.125.82.195]:45514 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751005AbeAVHH0 (ORCPT ); Mon, 22 Jan 2018 02:07:26 -0500 Received: by mail-ot0-f195.google.com with SMTP id r4so6608670oti.12 for ; Sun, 21 Jan 2018 23:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=benyossef-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=2ORGU1WxkAQQWKaqC+MYGazKHLurZqfq04XpTX3YkOI=; b=fo7Id3dmUFwEZp3Ly/hf//bqxfX9mzrI6P66jOfjP9Zuyy/uwcq4M0DFOKNyiusJL8 iD/WrZ2KgKuzH7+bB6gv885gASf6bD7FlzzIjd/aj91dTio0crfYW16cSeCSco8H4zBM WVA56qZfKtqU/M6uB46uwXmotbO0ESNzH58mNXIuphJj797EeTMpLUxTSsF9b/6jwLfJ Y0C/E582/E3DnIG4YiomHjnttaQS1ulC0MrR90KDv6Yoo75ZR3cI4TREEA/kOIvNtdVK UHfx3jT1/FdVB7alcQKmW/HHPn7t8u0/vE6+EvGB8mnXHDJhrQDYYVKKZjb7/xO7YIkI Lzaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=2ORGU1WxkAQQWKaqC+MYGazKHLurZqfq04XpTX3YkOI=; b=rh6dQ7WecATf+2J9MWYD/WygVNeqwM8ikn0elXyxH0BeFJqJA450r9Fz8CcfNLja0G h53ess1JLsBh2WerLmDUnaQk4nHC+yxFSHDyDteJV3LZ1FShrMXoctwPe4pn7wUB2L9O 6DjT17dir6HuP7WwucZxSruh7VXFypz/AyBxTnxL6m4dIIKIF4GnN9hDBHrkfllTU3F0 rZ/lTsRHKgeVOgZ83Vd7ljjYBolSr0N+PYkRhzYkjBtsUzrOj0QT/696VGcewwlT+Xah 9njhbx30iccjocaBATn7VeIbct9zTL0CU1zdXnzA72MRsHZXHqs1XfSLnOEtRRJLK5dy AN/A== X-Gm-Message-State: AKwxyteCawcwzdV5h1XeK60xXC8vQKHs4jiMcj1PYxRtheESIbIfdutd aGUMSHf7lHhxewUGjjfX54lmYfMuKwisPIKlf4JCfQ== X-Received: by 10.157.83.4 with SMTP id g4mr4446606oth.264.1516604844945; Sun, 21 Jan 2018 23:07:24 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.38.230 with HTTP; Sun, 21 Jan 2018 23:07:24 -0800 (PST) X-Originating-IP: [217.140.96.140] In-Reply-To: <20180111100137.GA15690@Red> References: <1515662239-1714-1-git-send-email-gilad@benyossef.com> <1515662239-1714-4-git-send-email-gilad@benyossef.com> <20180111100137.GA15690@Red> From: Gilad Ben-Yossef Date: Mon, 22 Jan 2018 09:07:24 +0200 Message-ID: Subject: Re: [PATCH 3/7] crypto: ccree: add ablkcipher support To: Corentin Labbe Cc: Herbert Xu , "David S. Miller" , Greg Kroah-Hartman , Ofir Drang , Linux kernel mailing list , Linux Crypto Mailing List , devel@driverdev.osuosl.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Corentin, On Thu, Jan 11, 2018 at 12:01 PM, Corentin Labbe wrote: > On Thu, Jan 11, 2018 at 09:17:10AM +0000, Gilad Ben-Yossef wrote: >> Add CryptoCell ablkcipher support >> > > Hello > > I have some minor comments: > > ablkcipher is deprecated, so you need to use skcipher instead. Fixed in v2. > >> Signed-off-by: Gilad Ben-Yossef >> --- >> drivers/crypto/ccree/Makefile | 2 +- >> drivers/crypto/ccree/cc_buffer_mgr.c | 125 ++++ >> drivers/crypto/ccree/cc_buffer_mgr.h | 10 + >> drivers/crypto/ccree/cc_cipher.c | 1167 ++++++++++++++++++++++++++++++++++ >> drivers/crypto/ccree/cc_cipher.h | 74 +++ >> drivers/crypto/ccree/cc_driver.c | 11 + >> drivers/crypto/ccree/cc_driver.h | 2 + >> 7 files changed, 1390 insertions(+), 1 deletion(-) >> create mode 100644 drivers/crypto/ccree/cc_cipher.c >> create mode 100644 drivers/crypto/ccree/cc_cipher.h >> > [...] >> + >> +struct tdes_keys { >> + u8 key1[DES_KEY_SIZE]; >> + u8 key2[DES_KEY_SIZE]; >> + u8 key3[DES_KEY_SIZE]; >> +}; >> + >> +static const u8 zero_buff[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, >> + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, >> + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, >> + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; >> + > > This constant is used nowhere. Fixed in v2. > >> +/* The function verifies that tdes keys are not weak.*/ >> +static int cc_verify_3des_keys(const u8 *key, unsigned int keylen) >> +{ >> + struct tdes_keys *tdes_key = (struct tdes_keys *)key; >> + >> + /* verify key1 != key2 and key3 != key2*/ >> + if ((memcmp((u8 *)tdes_key->key1, (u8 *)tdes_key->key2, >> + sizeof(tdes_key->key1)) == 0) || >> + (memcmp((u8 *)tdes_key->key3, (u8 *)tdes_key->key2, >> + sizeof(tdes_key->key3)) == 0)) { >> + return -ENOEXEC; >> + } >> + >> + return 0; >> +} > > All driver testing 3des key also use des_ekey() Well, the weak key test which is part of des_ekey() are not needed AFAIK for 3des as per RFC2451 and the HW does 3des key expansion so that function is not useful here. > > [...] >> +static void cc_cipher_complete(struct device *dev, void *cc_req, int err) >> +{ >> + struct ablkcipher_request *areq = (struct ablkcipher_request *)cc_req; >> + struct scatterlist *dst = areq->dst; >> + struct scatterlist *src = areq->src; >> + struct blkcipher_req_ctx *req_ctx = ablkcipher_request_ctx(areq); >> + struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq); >> + unsigned int ivsize = crypto_ablkcipher_ivsize(tfm); >> + struct ablkcipher_request *req = (struct ablkcipher_request *)areq; >> + >> + cc_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst); >> + kfree(req_ctx->iv); > > kzfree for all stuff with IV/key Fixed in v2. > > [...] >> + >> +#ifdef CRYPTO_TFM_REQ_HW_KEY >> + >> +static inline bool cc_is_hw_key(struct crypto_tfm *tfm) >> +{ >> + return (crypto_tfm_get_flags(tfm) & CRYPTO_TFM_REQ_HW_KEY); >> +} >> + >> +#else >> + >> +struct arm_hw_key_info { >> + int hw_key1; >> + int hw_key2; >> +}; >> + >> +static inline bool cc_is_hw_key(struct crypto_tfm *tfm) >> +{ >> + return false; >> +} >> + >> +#endif /* CRYPTO_TFM_REQ_HW_KEY */ > > I see nowhere any use/documentation of CRYPTO_TFM_REQ_HW_KEY, so a cleaning could be done You are right. It's a badly implemented stub function. I'll drop the ifdef as it is useless right now. Many thanks for the review! Gilad -- Gilad Ben-Yossef Chief Coffee Drinker "If you take a class in large-scale robotics, can you end up in a situation where the homework eats your dog?" -- Jean-Baptiste Queru