Skip to content

Commit d2825fa

Browse files
zx2c4herbertx
authored andcommitted
crypto: sm3,sm4 - move 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/. Cc: Herbert Xu <[email protected]> Cc: Tianjia Zhang <[email protected]> Cc: Eric Biggers <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 3123109 commit d2825fa

File tree

7 files changed

+18
-22
lines changed

7 files changed

+18
-22
lines changed

arch/arm64/crypto/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ config CRYPTO_SM3_ARM64_CE
4545
tristate "SM3 digest algorithm (ARMv8.2 Crypto Extensions)"
4646
depends on KERNEL_MODE_NEON
4747
select CRYPTO_HASH
48-
select CRYPTO_LIB_SM3
48+
select CRYPTO_SM3
4949

5050
config CRYPTO_SM4_ARM64_CE
5151
tristate "SM4 symmetric cipher (ARMv8.2 Crypto Extensions)"
5252
depends on KERNEL_MODE_NEON
5353
select CRYPTO_ALGAPI
54-
select CRYPTO_LIB_SM4
54+
select CRYPTO_SM4
5555

5656
config CRYPTO_GHASH_ARM64_CE
5757
tristate "GHASH/AES-GCM using ARMv8 Crypto Extensions"

crypto/Kconfig

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ config CRYPTO_ECRDSA
274274

275275
config CRYPTO_SM2
276276
tristate "SM2 algorithm"
277-
select CRYPTO_LIB_SM3
277+
select CRYPTO_SM3
278278
select CRYPTO_AKCIPHER
279279
select CRYPTO_MANAGER
280280
select MPILIB
@@ -1010,9 +1010,12 @@ config CRYPTO_SHA3
10101010
http://keccak.noekeon.org/
10111011

10121012
config CRYPTO_SM3
1013+
tristate
1014+
1015+
config CRYPTO_SM3_GENERIC
10131016
tristate "SM3 digest algorithm"
10141017
select CRYPTO_HASH
1015-
select CRYPTO_LIB_SM3
1018+
select CRYPTO_SM3
10161019
help
10171020
SM3 secure hash function as defined by OSCCA GM/T 0004-2012 SM3).
10181021
It is part of the Chinese Commercial Cryptography suite.
@@ -1025,7 +1028,7 @@ config CRYPTO_SM3_AVX_X86_64
10251028
tristate "SM3 digest algorithm (x86_64/AVX)"
10261029
depends on X86 && 64BIT
10271030
select CRYPTO_HASH
1028-
select CRYPTO_LIB_SM3
1031+
select CRYPTO_SM3
10291032
help
10301033
SM3 secure hash function as defined by OSCCA GM/T 0004-2012 SM3).
10311034
It is part of the Chinese Commercial Cryptography suite. This is
@@ -1572,9 +1575,12 @@ config CRYPTO_SERPENT_AVX2_X86_64
15721575
<https://www.cl.cam.ac.uk/~rja14/serpent.html>
15731576

15741577
config CRYPTO_SM4
1578+
tristate
1579+
1580+
config CRYPTO_SM4_GENERIC
15751581
tristate "SM4 cipher algorithm"
15761582
select CRYPTO_ALGAPI
1577-
select CRYPTO_LIB_SM4
1583+
select CRYPTO_SM4
15781584
help
15791585
SM4 cipher algorithms (OSCCA GB/T 32907-2016).
15801586

@@ -1603,7 +1609,7 @@ config CRYPTO_SM4_AESNI_AVX_X86_64
16031609
select CRYPTO_SKCIPHER
16041610
select CRYPTO_SIMD
16051611
select CRYPTO_ALGAPI
1606-
select CRYPTO_LIB_SM4
1612+
select CRYPTO_SM4
16071613
help
16081614
SM4 cipher algorithms (OSCCA GB/T 32907-2016) (x86_64/AES-NI/AVX).
16091615

@@ -1624,7 +1630,7 @@ config CRYPTO_SM4_AESNI_AVX2_X86_64
16241630
select CRYPTO_SKCIPHER
16251631
select CRYPTO_SIMD
16261632
select CRYPTO_ALGAPI
1627-
select CRYPTO_LIB_SM4
1633+
select CRYPTO_SM4
16281634
select CRYPTO_SM4_AESNI_AVX_X86_64
16291635
help
16301636
SM4 cipher algorithms (OSCCA GB/T 32907-2016) (x86_64/AES-NI/AVX2).

crypto/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o
7878
obj-$(CONFIG_CRYPTO_SHA256) += sha256_generic.o
7979
obj-$(CONFIG_CRYPTO_SHA512) += sha512_generic.o
8080
obj-$(CONFIG_CRYPTO_SHA3) += sha3_generic.o
81-
obj-$(CONFIG_CRYPTO_SM3) += sm3_generic.o
81+
obj-$(CONFIG_CRYPTO_SM3) += sm3.o
82+
obj-$(CONFIG_CRYPTO_SM3_GENERIC) += sm3_generic.o
8283
obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
8384
obj-$(CONFIG_CRYPTO_WP512) += wp512.o
8485
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
134135
CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
135136
obj-$(CONFIG_CRYPTO_AES) += aes_generic.o
136137
CFLAGS_aes_generic.o := $(call cc-option,-fno-code-hoisting) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83356
137-
obj-$(CONFIG_CRYPTO_SM4) += sm4_generic.o
138+
obj-$(CONFIG_CRYPTO_SM4) += sm4.o
139+
obj-$(CONFIG_CRYPTO_SM4_GENERIC) += sm4_generic.o
138140
obj-$(CONFIG_CRYPTO_AES_TI) += aes_ti.o
139141
obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
140142
obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
File renamed without changes.
File renamed without changes.

lib/crypto/Kconfig

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,4 @@ config CRYPTO_LIB_CHACHA20POLY1305
123123
config CRYPTO_LIB_SHA256
124124
tristate
125125

126-
config CRYPTO_LIB_SM3
127-
tristate
128-
129-
config CRYPTO_LIB_SM4
130-
tristate
131-
132126
endmenu

lib/crypto/Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ libpoly1305-y += poly1305.o
3737
obj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o
3838
libsha256-y := sha256.o
3939

40-
obj-$(CONFIG_CRYPTO_LIB_SM3) += libsm3.o
41-
libsm3-y := sm3.o
42-
43-
obj-$(CONFIG_CRYPTO_LIB_SM4) += libsm4.o
44-
libsm4-y := sm4.o
45-
4640
ifneq ($(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS),y)
4741
libblake2s-y += blake2s-selftest.o
4842
libchacha20poly1305-y += chacha20poly1305-selftest.o

0 commit comments

Comments
 (0)