Received: by 10.223.164.221 with SMTP id h29csp986550wrb; Mon, 16 Oct 2017 16:13:51 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAKtCiLxwmKJUf1yQ3CP08TbEZBKgxU3MNH1+Aq1RBDFzmw1Du4tWhm/EHkW95Wy6bRbRaf X-Received: by 10.99.49.134 with SMTP id x128mr9646137pgx.35.1508195631363; Mon, 16 Oct 2017 16:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508195631; cv=none; d=google.com; s=arc-20160816; b=Suj3Crp9ITtHXWZD314xwccAXfu+cWmMKXRfTvSXkCvzZ1iE2lJwcRBrK9I4GPXiYG MZJ2boVFp1jSr9CXaWRW/YLMbF+dVrCa6cdyd9wvHV830eoBHyq+B8ezijSeBWsa0SaB hXd84q6ZZZJknffgFRfZj4+PtaJZmgjjwEiRpYfi3AjqdBpqwNiwDtLULslA1/uuwP0M OiABwF4RRfiaN+XxAQep+2lgIklerUzcUtDoiF+tFj/LA+Wl2Yi9zESezmTVeM1T2MvX OO/t/bgGATa/4FmPRCuvyU0Pi9SCSYbphoTUBCJJDS/vL50FMkbMXPChqUGnmoIcM18E 2mcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=zMxZ1tt/mF+l2SJ9Wm1Vfd2Zngw0S5lmH0z90XeKTKs=; b=FLM4Ln/wsml4hbqPGYKt9RMUaZWo23LFn0BlVj42gfpd58PCzP/6wMjZkcQiadgPpX vcpUUKu0DV+4upIpuIpHeheUxso0IwGcmI3lcwNIlTFJYnQmnF6XMgVAK1kjk4Io9skD hZBl10SXwSY6F3hZzdHNRwti7Y39Jbbvfehx8IE861wemaVT7uibXMHwxXWT0P6tmvb/ kFzcLP/1tIzg7nyeSQKDtgdw0RkMD7/iKkDSXLkhNzdLpRCPQdzOb7yQw3Zj3XvoE8xh 1+KFq8DaPC4W23i+w4VP8IZMsYWRZx8b09CgKj284odpTBAPSX5ojKu9HbAo5km30QVH dzuw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h63si4609705pgc.833.2017.10.16.16.13.37; Mon, 16 Oct 2017 16:13:51 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757248AbdJPWzO (ORCPT + 99 others); Mon, 16 Oct 2017 18:55:14 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56914 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756162AbdJPWzM (ORCPT ); Mon, 16 Oct 2017 18:55:12 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9GMsbCh107034 for ; Mon, 16 Oct 2017 18:55:11 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dn063pw4h-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 16 Oct 2017 18:55:11 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Oct 2017 16:55:11 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 16 Oct 2017 16:55:08 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9GMt7a08716752; Mon, 16 Oct 2017 15:55:07 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9CBE5BE038; Mon, 16 Oct 2017 16:55:07 -0600 (MDT) Received: from dublin.ltc.br.ibm.com (unknown [9.80.210.206]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id 8F5BFBE040; Mon, 16 Oct 2017 16:55:04 -0600 (MDT) From: Paulo Flabiano Smorigo To: linux-kernel@vger.kernel.org Cc: Paulo Flabiano Smorigo , "Leonidas S. Barbosa" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH] crypto: vmx - Use skcipher for ctr fallback Date: Mon, 16 Oct 2017 20:54:19 -0200 X-Mailer: git-send-email 2.9.4 X-TM-AS-GCONF: 00 x-cbid: 17101622-0004-0000-0000-00001312B2B1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007901; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000236; SDB=6.00932141; UDB=6.00469379; IPR=6.00712431; BA=6.00005641; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017565; XFM=3.00000015; UTC=2017-10-16 22:55:10 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101622-0005-0000-0000-00008480BE35 Message-Id: <20171016225420.31081-1-pfsmorigo@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-16_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710160319 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Paulo Flabiano Smorigo --- drivers/crypto/vmx/aes_ctr.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/crypto/vmx/aes_ctr.c b/drivers/crypto/vmx/aes_ctr.c index 17d8421..fc60d00 100644 --- a/drivers/crypto/vmx/aes_ctr.c +++ b/drivers/crypto/vmx/aes_ctr.c @@ -27,21 +27,23 @@ #include #include #include +#include + #include "aesp8-ppc.h" struct p8_aes_ctr_ctx { - struct crypto_blkcipher *fallback; + struct crypto_skcipher *fallback; struct aes_key enc_key; }; static int p8_aes_ctr_init(struct crypto_tfm *tfm) { const char *alg = crypto_tfm_alg_name(tfm); - struct crypto_blkcipher *fallback; + struct crypto_skcipher *fallback; struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(tfm); - fallback = - crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK); + fallback = crypto_alloc_skcipher(alg, 0, + CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK); if (IS_ERR(fallback)) { printk(KERN_ERR "Failed to allocate transformation for '%s': %ld\n", @@ -49,11 +51,11 @@ static int p8_aes_ctr_init(struct crypto_tfm *tfm) return PTR_ERR(fallback); } printk(KERN_INFO "Using '%s' as fallback implementation.\n", - crypto_tfm_alg_driver_name((struct crypto_tfm *) fallback)); + crypto_skcipher_driver_name(fallback)); - crypto_blkcipher_set_flags( + crypto_skcipher_set_flags( fallback, - crypto_blkcipher_get_flags((struct crypto_blkcipher *)tfm)); + crypto_skcipher_get_flags((struct crypto_skcipher *)tfm)); ctx->fallback = fallback; return 0; @@ -64,7 +66,7 @@ static void p8_aes_ctr_exit(struct crypto_tfm *tfm) struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(tfm); if (ctx->fallback) { - crypto_free_blkcipher(ctx->fallback); + crypto_free_skcipher(ctx->fallback); ctx->fallback = NULL; } } @@ -83,7 +85,7 @@ static int p8_aes_ctr_setkey(struct crypto_tfm *tfm, const u8 *key, pagefault_enable(); preempt_enable(); - ret += crypto_blkcipher_setkey(ctx->fallback, key, keylen); + ret += crypto_skcipher_setkey(ctx->fallback, key, keylen); return ret; } @@ -117,15 +119,14 @@ static int p8_aes_ctr_crypt(struct blkcipher_desc *desc, struct blkcipher_walk walk; struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm)); - struct blkcipher_desc fallback_desc = { - .tfm = ctx->fallback, - .info = desc->info, - .flags = desc->flags - }; if (in_interrupt()) { - ret = crypto_blkcipher_encrypt(&fallback_desc, dst, src, - nbytes); + SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback); + skcipher_request_set_tfm(req, ctx->fallback); + skcipher_request_set_callback(req, desc->flags, NULL, NULL); + skcipher_request_set_crypt(req, src, dst, nbytes, desc->info); + ret = crypto_skcipher_encrypt(req); + skcipher_request_zero(req); } else { blkcipher_walk_init(&walk, dst, src, nbytes); ret = blkcipher_walk_virt_block(desc, &walk, AES_BLOCK_SIZE); -- 2.9.4 From 1583660348085726576@xxx Fri Nov 10 06:43:19 +0000 2017 X-GM-THRID: 1583660348085726576 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread