crypto: move sm3 and sm4 into crypto directory
Subsystems (3)
Jason A. Donenfeld
maintainerPATCH 1/1 crypto: move sm3 and sm4 into crypto directory
The lib/crypto libraries live in lib because they are used by various drivers of the kernel. In contrast, the various helper functions in crypto are there because they're used exclusively by the crypto API. The SM3 and SM4 helper functions were erroniously moved into lib/crypto/ instead of crypto/, even though there are no in-kernel users outside of the crypto API of those functions. This commit moves them into crypto/.
---
arch/arm64/crypto/Kconfig | 4 ++--
crypto/Kconfig | 18 ++++++++++++------
crypto/Makefile | 6 ++++--
{lib/crypto => crypto}/sm3.c | 0
{lib/crypto => crypto}/sm4.c | 0
lib/crypto/Kconfig | 6 ------
lib/crypto/Makefile | 6 ------
7 files changed, 18 insertions(+), 22 deletions(-)
rename {lib/crypto => crypto}/sm3.c (100%)
rename {lib/crypto => crypto}/sm4.c (100%)arch/arm64/crypto/Kconfig +2 -2
@@ -45,13 +45,13 @@ config CRYPTO_SM3_ARM64_CE tristate "SM3 digest algorithm (ARMv8.2 Crypto Extensions)" depends on KERNEL_MODE_NEON select CRYPTO_HASH - select CRYPTO_LIB_SM3 + select CRYPTO_SM3 config CRYPTO_SM4_ARM64_CE tristate "SM4 symmetric cipher (ARMv8.2 Crypto Extensions)" depends on KERNEL_MODE_NEON select CRYPTO_ALGAPI - select CRYPTO_LIB_SM4 + select CRYPTO_SM4 config CRYPTO_GHASH_ARM64_CE tristate "GHASH/AES-GCM using ARMv8 Crypto Extensions"
crypto/Kconfig +12 -6
@@ -274,7 +274,7 @@ config CRYPTO_ECRDSA config CRYPTO_SM2 tristate "SM2 algorithm" - select CRYPTO_LIB_SM3 + select CRYPTO_SM3 select CRYPTO_AKCIPHER select CRYPTO_MANAGER select MPILIB
@@ -1005,9 +1005,12 @@ config CRYPTO_SHA3 http://keccak.noekeon.org/ config CRYPTO_SM3 + tristate + +config CRYPTO_SM3_GENERIC tristate "SM3 digest algorithm" select CRYPTO_HASH - select CRYPTO_LIB_SM3 + select CRYPTO_SM3 help SM3 secure hash function as defined by OSCCA GM/T 0004-2012 SM3). It is part of the Chinese Commercial Cryptography suite.
@@ -1020,7 +1023,7 @@ config CRYPTO_SM3_AVX_X86_64 tristate "SM3 digest algorithm (x86_64/AVX)" depends on X86 && 64BIT select CRYPTO_HASH - select CRYPTO_LIB_SM3 + select CRYPTO_SM3 help SM3 secure hash function as defined by OSCCA GM/T 0004-2012 SM3). It is part of the Chinese Commercial Cryptography suite. This is
@@ -1567,9 +1570,12 @@ config CRYPTO_SERPENT_AVX2_X86_64 <https://www.cl.cam.ac.uk/~rja14/serpent.html> config CRYPTO_SM4 + tristate + +config CRYPTO_SM4_GENERIC tristate "SM4 cipher algorithm" select CRYPTO_ALGAPI - select CRYPTO_LIB_SM4 + select CRYPTO_SM4 help SM4 cipher algorithms (OSCCA GB/T 32907-2016).
@@ -1598,7 +1604,7 @@ config CRYPTO_SM4_AESNI_AVX_X86_64 select CRYPTO_SKCIPHER select CRYPTO_SIMD select CRYPTO_ALGAPI - select CRYPTO_LIB_SM4 + select CRYPTO_SM4 help SM4 cipher algorithms (OSCCA GB/T 32907-2016) (x86_64/AES-NI/AVX).
@@ -1619,7 +1625,7 @@ config CRYPTO_SM4_AESNI_AVX2_X86_64 select CRYPTO_SKCIPHER select CRYPTO_SIMD select CRYPTO_ALGAPI - select CRYPTO_LIB_SM4 + select CRYPTO_SM4 select CRYPTO_SM4_AESNI_AVX_X86_64 help SM4 cipher algorithms (OSCCA GB/T 32907-2016) (x86_64/AES-NI/AVX2).
crypto/Makefile +4 -2
@@ -78,7 +78,8 @@ obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o obj-$(CONFIG_CRYPTO_SHA256) += sha256_generic.o obj-$(CONFIG_CRYPTO_SHA512) += sha512_generic.o obj-$(CONFIG_CRYPTO_SHA3) += sha3_generic.o -obj-$(CONFIG_CRYPTO_SM3) += sm3_generic.o +obj-$(CONFIG_CRYPTO_SM3) += sm3.o +obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o obj-$(CONFIG_CRYPTO_WP512) += wp512.o CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
@@ -134,7 +135,8 @@ obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149 obj-$(CONFIG_CRYPTO_AES) += aes_generic.o CFLAGS_aes_generic.o := $(call cc-option,-fno-code-hoisting) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83356 -obj-$(CONFIG_CRYPTO_SM4) += sm4_generic.o +obj-$(CONFIG_CRYPTO_SM4) += sm4.o +obj-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o obj-$(CONFIG_CRYPTO_AES_TI) += aes_ti.o obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
crypto/sm3.c renamed from lib/crypto/sm3.c +0 -0
crypto/sm4.c renamed from lib/crypto/sm4.c +0 -0
lib/crypto/Kconfig +0 -6
@@ -123,10 +123,4 @@ config CRYPTO_LIB_CHACHA20POLY1305 config CRYPTO_LIB_SHA256 tristate -config CRYPTO_LIB_SM3 - tristate - -config CRYPTO_LIB_SM4 - tristate - endmenu
lib/crypto/Makefile +0 -6
@@ -37,12 +37,6 @@ libpoly1305-y += poly1305.o obj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o libsha256-y := sha256.o -obj-$(CONFIG_CRYPTO_LIB_SM3) += libsm3.o -libsm3-y := sm3.o - -obj-$(CONFIG_CRYPTO_LIB_SM4) += libsm4.o -libsm4-y := sm4.o - ifneq ($(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS),y) libblake2s-y += blake2s-selftest.o libchacha20poly1305-y += chacha20poly1305-selftest.o
Signature · 1 line
2.35.1
Eric Biggers
maintainerQuoted 60 lines · Jason A. Donenfeld
The lib/crypto libraries live in lib because they are used by various drivers of the kernel. In contrast, the various helper functions in crypto are there because they're used exclusively by the crypto API. The SM3 and SM4 helper functions were erroniously moved into
lib/crypto/instead ofcrypto/, even though there are no in-kernel users outside of the crypto API of those functions. This commit moves them intocrypto/.Cc Herbert Xu <[email protected]>Cc Tianjia Zhang <[email protected]>Cc Eric Biggers <[email protected]>Signed-off-by Jason A. Donenfeld <[email protected]>--- arch/arm64/crypto/Kconfig | 4 ++-- crypto/Kconfig | 18 ++++++++++++------ crypto/Makefile | 6 ++++-- {lib/crypto => crypto}/sm3.c | 0 {lib/crypto => crypto}/sm4.c | 0 lib/crypto/Kconfig | 6 ------ lib/crypto/Makefile | 6 ------ 7 files changed, 18 insertions(+), 22 deletions(-) rename {lib/crypto => crypto}/sm3.c (100%) rename {lib/crypto => crypto}/sm4.c (100%)arch/arm64/crypto/Kconfig +2
-2@@ -45,13 +45,13 @@ config CRYPTO_SM3_ARM64_CE tristate "SM3 digest algorithm (ARMv8.2 Crypto Extensions)" depends on KERNEL_MODE_NEON select CRYPTO_HASH - select CRYPTO_LIB_SM3 + select CRYPTO_SM3 config CRYPTO_SM4_ARM64_CE tristate "SM4 symmetric cipher (ARMv8.2 Crypto Extensions)" depends on KERNEL_MODE_NEON select CRYPTO_ALGAPI - select CRYPTO_LIB_SM4 + select CRYPTO_SM4 config CRYPTO_GHASH_ARM64_CE tristate "GHASH/AES-GCM using ARMv8 Crypto Extensions"crypto/Kconfig +1
-1@@ -274,7 +274,7 @@ config CRYPTO_ECRDSA config CRYPTO_SM2 tristate "SM2 algorithm" - select CRYPTO_LIB_SM3 + select CRYPTO_SM3 select CRYPTO_AKCIPHER select CRYPTO_MANAGER select MPILIB@@ -1005,9 +1005,12 @@ config CRYPTO_SHA3 http://keccak.noekeon.org/ config CRYPTO_SM3
crypto/Kconfig config CRYPTO_SHA3 · line 1016
Quoted 10 lines
crypto/Kconfig +4
-1+ tristate + +config CRYPTO_SM3_GENERIC tristate "SM3 digest algorithm" select CRYPTO_HASH - select CRYPTO_LIB_SM3 + select CRYPTO_SM3 help SM3 secure hash function as defined by OSCCA GM/T 0004-2012 SM3). It is part of the Chinese Commercial Cryptography suite.
This patch generally looks good, but perhaps CRYPTO_SM3 and CRYPTO_SM3_GENERIC should be merged? Having separate options provides the ability to enable the architecture implementation without the generic implementation, so arguably it's the right thing to do; however, that's not what the other algorithms in crypto/ do. For example, if you enable CONFIG_CRYPTO_SHA3, you get the generic SHA-3 algorithms as well as the SHA-3 library functions. I.e., there's no CONFIG_CRYPTO_SHA3_GENERIC.
IMO, being consistent is more important than providing the ability to omit the generic implementation.
- Eric
Jason A. Donenfeld
maintainerHi Eric,
I guess I could do that, but I think that might partially weaken the argument for moving this out of lib/. Can we do that in a subsequent patch, so that this one stays hermetic to its purpose?
Jason
Herbert Xu
maintainerQuoted 11 lines · Jason A. Donenfeld
The lib/crypto libraries live in lib because they are used by various drivers of the kernel. In contrast, the various helper functions in crypto are there because they're used exclusively by the crypto API. The SM3 and SM4 helper functions were erroniously moved into
lib/crypto/instead ofcrypto/, even though there are no in-kernel users outside of the crypto API of those functions. This commit moves them intocrypto/.Cc Herbert Xu <[email protected]>Cc Tianjia Zhang <[email protected]>Cc Eric Biggers <[email protected]>Signed-off-by Jason A. Donenfeld <[email protected]>
Quoted 11 lines
---
arch/arm64/crypto/Kconfig | 4 ++--
crypto/Kconfig | 18 ++++++++++++------
crypto/Makefile | 6 ++++--
{lib/crypto => crypto}/sm3.c | 0
{lib/crypto => crypto}/sm4.c | 0
lib/crypto/Kconfig | 6 ------
lib/crypto/Makefile | 6 ------
7 files changed, 18 insertions(+), 22 deletions(-)
rename {lib/crypto => crypto}/sm3.c (100%)
rename {lib/crypto => crypto}/sm4.c (100%)Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt