From: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Gilad Ben-Yossef <gilad@benyossef.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
"Markku-Juhani O . Saarinen" <mjos@iki.fi>,
Jussi Kivilinna <jussi.kivilinna@iki.fi>,
x86@kernel.org, linux-crypto@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] crypto: sm4 - create SM4 library based on sm4 generic code
Date: Sun, 13 Jun 2021 18:14:45 +0800 [thread overview]
Message-ID: <c8a92826-280c-c79b-c831-485e1da9d0f4@linux.alibaba.com> (raw)
In-Reply-To: <YMKeCIfSWZCVX+BT@gmail.com>
Hi Eric,
On 6/11/21 7:19 AM, Eric Biggers wrote:
> On Thu, Jun 10, 2021 at 09:44:57PM +0800, Tianjia Zhang wrote:
>> Take the existing small footprint and mostly time invariant C code
>
> It is using an S-box without any prefetching. That doesn't look very
> "time invariant" to me.
>
Thanks for your suggestion, will do in the next version patch.
>> diff --git a/lib/crypto/sm4.c b/lib/crypto/sm4.c
>> new file mode 100644
>> index 000000000000..cbdd14a254d0
> [..]
>> +/**
>> + * crypto_sm4_expand_key - Expands the SM4 key as described in GB/T 32907-2016
>> + * @ctx: The location where the computed key will be stored.
>> + * @in_key: The supplied key.
>> + * @key_len: The length of the supplied key.
>> + *
>> + * Returns 0 on success. The function fails only if an invalid key size (or
>> + * pointer) is supplied.
>> + */
>> +int crypto_sm4_expand_key(struct crypto_sm4_ctx *ctx, const u8 *in_key,
>> + unsigned int key_len)
> [...]
>> +/**
>> + * crypto_sm4_do_crypt - Encrypt or decrypt a single SM4 block
>> + * @rk: The rkey_enc for encrypt or rkey_dec for decrypt
>> + * @out: Buffer to store output data
>> + * @in: Buffer containing the input data
>> + */
>> +void crypto_sm4_do_crypt(const u32 *rk, u8 *out, const u8 *in)
>
> Calling these "sm4_expandkey()" and "sm4_crypt_block()" would be more consistent
> with the other lib/crypto/ functions such as the AES ones. The other
> lib/crypto/ functions don't have a "crypto_" prefix, as that is used for
> functions related to the traditional crypto API rather than the library API.
Ditto. thanks for pointing it out.
>
> - Eric
>
Best regards,
Tianjia
next prev parent reply other threads:[~2021-06-13 10:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-10 13:44 [PATCH 0/3] Introduce x86 assembler accelerated implementation for SM4 algorithm Tianjia Zhang
2021-06-10 13:44 ` [PATCH 1/3] crypto: sm4 - create SM4 library based on sm4 generic code Tianjia Zhang
2021-06-10 23:19 ` Eric Biggers
2021-06-13 10:14 ` Tianjia Zhang [this message]
2022-03-01 10:34 ` Jason A. Donenfeld
2022-03-01 11:50 ` Tianjia Zhang
2022-03-01 13:22 ` Jason A. Donenfeld
2022-03-01 14:17 ` Jason A. Donenfeld
2022-03-02 0:24 ` Herbert Xu
2022-03-02 0:26 ` Jason A. Donenfeld
2022-03-02 22:23 ` Eric Biggers
2022-03-11 23:03 ` Jason A. Donenfeld
2022-03-14 2:32 ` Tianjia Zhang
2022-03-14 2:40 ` Jason A. Donenfeld
2022-03-14 2:45 ` Herbert Xu
2022-03-14 2:46 ` Jason A. Donenfeld
2021-06-10 13:44 ` [PATCH 2/3] crypto: arm64/sm4-ce - Make dependent on sm4 library instead of sm4-generic Tianjia Zhang
2021-06-10 13:44 ` [PATCH 3/3] crypto: x86/sm4 - add AES-NI/AVX/x86_64 assembler implementation Tianjia Zhang
2021-06-10 23:27 ` Eric Biggers
2021-06-13 10:14 ` Tianjia Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c8a92826-280c-c79b-c831-485e1da9d0f4@linux.alibaba.com \
--to=tianjia.zhang@linux.alibaba.com \
--cc=ard.biesheuvel@linaro.org \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=davem@davemloft.net \
--cc=ebiggers@kernel.org \
--cc=gilad@benyossef.com \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=jussi.kivilinna@iki.fi \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mjos@iki.fi \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox