Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5551718rwi; Tue, 18 Oct 2022 00:13:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+EOCp6r64KHuD7hG1JYOr4zC87AOKSVEoSiuTnkchU3rifQJzyWLxYlLRxZdu0nqp/RYi X-Received: by 2002:a17:906:9b83:b0:730:b3ae:343 with SMTP id dd3-20020a1709069b8300b00730b3ae0343mr1270054ejc.670.1666077229821; Tue, 18 Oct 2022 00:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666077229; cv=none; d=google.com; s=arc-20160816; b=Qb2xvqaIvHT29/dLT9brLYqj85rmXaFLP47v8SNMfcaX3lhLBkW3KedGiadPpHrNVP S1piFIqCRgDPl+Wz8XXVWBX/FA/2hjVG/aK/lxoQed9i3L4Yu3kHllQvAp+m5tsWKBud t2zOVwFGyb86VcM66tca8sP9cUhqr3ZeVoSop9oRfDkV9Mwwe4MjWWqL4SdHDXjirxXs URt8ELfw6TZNiokKCj1fYM1dr27+qUX2usmjGhof2Q99qLak3vOgIntvjxIRAhf0AFxB JKRlizha1m3h3igczDEx12sjeTzdKUfZo52znzDEmwoGkReKHzaS0mI6ZqdD9G8PuyMV XhXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rHSyVlQyQiHtYMUPA93G/tFaq5SvsTuWnEA+5nIcnuQ=; b=0rY6vxYWNUaNbi2T+HO4ijbQnA1UmVQ70R3QgSa6fySP5ZD2oUdvPrRrSQCqMM5UY9 dvfYQ/zgumQVfxJgMyysJ0DFs/WGGlD9egoXSk8WQLIl/TxyqLTMCprsOTjonK1bIrh1 qeMkUmng8wEYHqNge1z3sTEFAt8/7MqNQ/IEf8gFSllH/ajqTEI2vVfCbLLwfXfK16Qd x1bHxvcGaM9oAmJ6cuBWfxW+ybolOiW741trygODUiW76sFbcV1+6xdsFjb7JtNfkzcH wVZjjjMGJkILwV8Yjti4GEOQ+AWM4X3DLWaVbi0IdV3ZzjkNahCGxGn2O/BaLOKyFrIv QTxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr1-20020a1709073f8100b0078d71a6bd56si13181848ejc.757.2022.10.18.00.13.25; Tue, 18 Oct 2022 00:13:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230206AbiJRHLk (ORCPT + 99 others); Tue, 18 Oct 2022 03:11:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbiJRHLF (ORCPT ); Tue, 18 Oct 2022 03:11:05 -0400 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1766BA98F2; Tue, 18 Oct 2022 00:10:32 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0VSTWskf_1666077026; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0VSTWskf_1666077026) by smtp.aliyun-inc.com; Tue, 18 Oct 2022 15:10:27 +0800 From: Tianjia Zhang To: Herbert Xu , "David S. Miller" , Jussi Kivilinna , Ard Biesheuvel , Mark Brown , Catalin Marinas , Will Deacon , Maxime Coquelin , Alexandre Torgue , Eric Biggers , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Cc: Tianjia Zhang Subject: [PATCH v2 08/15] crypto: arm64/sm4 - export reusable CE acceleration functions Date: Tue, 18 Oct 2022 15:09:59 +0800 Message-Id: <20221018071006.5717-9-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20221018071006.5717-1-tianjia.zhang@linux.alibaba.com> References: <20221018071006.5717-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org In the accelerated implementation of the SM4 algorithm using the Crypto Extension instructions, there are some functions that can be reused in the upcoming accelerated implementation of the GCM/CCM mode, and the CBC/CFB encryption is reused in the optimized implementation of SVESM4. Signed-off-by: Tianjia Zhang --- arch/arm64/crypto/sm4-ce-glue.c | 5 +++++ arch/arm64/crypto/sm4-ce.h | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 arch/arm64/crypto/sm4-ce.h diff --git a/arch/arm64/crypto/sm4-ce-glue.c b/arch/arm64/crypto/sm4-ce-glue.c index ff2d8442d473..63abcadc684b 100644 --- a/arch/arm64/crypto/sm4-ce-glue.c +++ b/arch/arm64/crypto/sm4-ce-glue.c @@ -36,6 +36,11 @@ asmlinkage void sm4_ce_cfb_dec(const u32 *rkey, u8 *dst, const u8 *src, asmlinkage void sm4_ce_ctr_enc(const u32 *rkey, u8 *dst, const u8 *src, u8 *iv, unsigned int nblks); +EXPORT_SYMBOL(sm4_ce_expand_key); +EXPORT_SYMBOL(sm4_ce_crypt_block); +EXPORT_SYMBOL(sm4_ce_cbc_enc); +EXPORT_SYMBOL(sm4_ce_cfb_enc); + static int sm4_setkey(struct crypto_skcipher *tfm, const u8 *key, unsigned int key_len) { diff --git a/arch/arm64/crypto/sm4-ce.h b/arch/arm64/crypto/sm4-ce.h new file mode 100644 index 000000000000..109c21b37590 --- /dev/null +++ b/arch/arm64/crypto/sm4-ce.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * SM4 common functions for Crypto Extensions + * Copyright (C) 2022 Tianjia Zhang + */ + +void sm4_ce_expand_key(const u8 *key, u32 *rkey_enc, u32 *rkey_dec, + const u32 *fk, const u32 *ck); + +void sm4_ce_crypt_block(const u32 *rkey, u8 *dst, const u8 *src); + +void sm4_ce_cbc_enc(const u32 *rkey_enc, u8 *dst, const u8 *src, + u8 *iv, unsigned int nblocks); + +void sm4_ce_cfb_enc(const u32 *rkey_enc, u8 *dst, const u8 *src, + u8 *iv, unsigned int nblocks); -- 2.24.3 (Apple Git-128)