[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c8a92826-280c-c79b-c831-485e1da9d0f4@linux.alibaba.com>
Date: Sun, 13 Jun 2021 18:14:45 +0800
From: Tianjia Zhang <tianjia.zhang@...ux.alibaba.com>
To: Eric Biggers <ebiggers@...nel.org>
Cc: Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>,
Gilad Ben-Yossef <gilad@...yossef.com>,
Ard Biesheuvel <ard.biesheuvel@...aro.org>,
"Markku-Juhani O . Saarinen" <mjos@....fi>,
Jussi Kivilinna <jussi.kivilinna@....fi>, x86@...nel.org,
linux-crypto@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] crypto: sm4 - create SM4 library based on sm4 generic
code
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
Powered by blists - more mailing lists