Skip to content

Commit cce9e06

Browse files
committed
[CRYPTO] api: Split out low-level API
The crypto API is made up of the part facing users such as IPsec and the low-level part which is used by cryptographic entities such as algorithms. This patch splits out the latter so that the two APIs are more clearly delineated. As a bonus the low-level API can now be modularised if all algorithms are built as modules. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 9409f38 commit cce9e06

8 files changed

Lines changed: 204 additions & 134 deletions

File tree

‎crypto/Kconfig‎

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,54 @@ config CRYPTO
99
help
1010
This option provides the core Cryptographic API.
1111

12+
if CRYPTO
13+
14+
config CRYPTO_ALGAPI
15+
tristate
16+
help
17+
This option provides the API for cryptographic algorithms.
18+
1219
config CRYPTO_HMAC
1320
bool "HMAC support"
14-
depends on CRYPTO
1521
help
1622
HMAC: Keyed-Hashing for Message Authentication (RFC2104).
1723
This is required for IPSec.
1824

1925
config CRYPTO_NULL
2026
tristate "Null algorithms"
21-
depends on CRYPTO
27+
select CRYPTO_ALGAPI
2228
help
2329
These are 'Null' algorithms, used by IPsec, which do nothing.
2430

2531
config CRYPTO_MD4
2632
tristate "MD4 digest algorithm"
27-
depends on CRYPTO
33+
select CRYPTO_ALGAPI
2834
help
2935
MD4 message digest algorithm (RFC1320).
3036

3137
config CRYPTO_MD5
3238
tristate "MD5 digest algorithm"
33-
depends on CRYPTO
39+
select CRYPTO_ALGAPI
3440
help
3541
MD5 message digest algorithm (RFC1321).
3642

3743
config CRYPTO_SHA1
3844
tristate "SHA1 digest algorithm"
39-
depends on CRYPTO
45+
select CRYPTO_ALGAPI
4046
help
4147
SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2).
4248

4349
config CRYPTO_SHA1_S390
4450
tristate "SHA1 digest algorithm (s390)"
45-
depends on CRYPTO && S390
51+
depends on S390
52+
select CRYPTO_ALGAPI
4653
help
4754
This is the s390 hardware accelerated implementation of the
4855
SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2).
4956

5057
config CRYPTO_SHA256
5158
tristate "SHA256 digest algorithm"
52-
depends on CRYPTO
59+
select CRYPTO_ALGAPI
5360
help
5461
SHA256 secure hash standard (DFIPS 180-2).
5562

@@ -58,7 +65,8 @@ config CRYPTO_SHA256
5865

5966
config CRYPTO_SHA256_S390
6067
tristate "SHA256 digest algorithm (s390)"
61-
depends on CRYPTO && S390
68+
depends on S390
69+
select CRYPTO_ALGAPI
6270
help
6371
This is the s390 hardware accelerated implementation of the
6472
SHA256 secure hash standard (DFIPS 180-2).
@@ -68,7 +76,7 @@ config CRYPTO_SHA256_S390
6876

6977
config CRYPTO_SHA512
7078
tristate "SHA384 and SHA512 digest algorithms"
71-
depends on CRYPTO
79+
select CRYPTO_ALGAPI
7280
help
7381
SHA512 secure hash standard (DFIPS 180-2).
7482

@@ -80,7 +88,7 @@ config CRYPTO_SHA512
8088

8189
config CRYPTO_WP512
8290
tristate "Whirlpool digest algorithms"
83-
depends on CRYPTO
91+
select CRYPTO_ALGAPI
8492
help
8593
Whirlpool hash algorithm 512, 384 and 256-bit hashes
8694

@@ -92,7 +100,7 @@ config CRYPTO_WP512
92100

93101
config CRYPTO_TGR192
94102
tristate "Tiger digest algorithms"
95-
depends on CRYPTO
103+
select CRYPTO_ALGAPI
96104
help
97105
Tiger hash algorithm 192, 160 and 128-bit hashes
98106

@@ -105,19 +113,20 @@ config CRYPTO_TGR192
105113

106114
config CRYPTO_DES
107115
tristate "DES and Triple DES EDE cipher algorithms"
108-
depends on CRYPTO
116+
select CRYPTO_ALGAPI
109117
help
110118
DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).
111119

112120
config CRYPTO_DES_S390
113121
tristate "DES and Triple DES cipher algorithms (s390)"
114-
depends on CRYPTO && S390
122+
depends on S390
123+
select CRYPTO_ALGAPI
115124
help
116125
DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).
117126

118127
config CRYPTO_BLOWFISH
119128
tristate "Blowfish cipher algorithm"
120-
depends on CRYPTO
129+
select CRYPTO_ALGAPI
121130
help
122131
Blowfish cipher algorithm, by Bruce Schneier.
123132

@@ -130,7 +139,7 @@ config CRYPTO_BLOWFISH
130139

131140
config CRYPTO_TWOFISH
132141
tristate "Twofish cipher algorithm"
133-
depends on CRYPTO
142+
select CRYPTO_ALGAPI
134143
select CRYPTO_TWOFISH_COMMON
135144
help
136145
Twofish cipher algorithm.
@@ -145,14 +154,14 @@ config CRYPTO_TWOFISH
145154

146155
config CRYPTO_TWOFISH_COMMON
147156
tristate
148-
depends on CRYPTO
149157
help
150158
Common parts of the Twofish cipher algorithm shared by the
151159
generic c and the assembler implementations.
152160

153161
config CRYPTO_TWOFISH_586
154162
tristate "Twofish cipher algorithms (i586)"
155-
depends on CRYPTO && ((X86 || UML_X86) && !64BIT)
163+
depends on (X86 || UML_X86) && !64BIT
164+
select CRYPTO_ALGAPI
156165
select CRYPTO_TWOFISH_COMMON
157166
help
158167
Twofish cipher algorithm.
@@ -167,7 +176,8 @@ config CRYPTO_TWOFISH_586
167176

168177
config CRYPTO_TWOFISH_X86_64
169178
tristate "Twofish cipher algorithm (x86_64)"
170-
depends on CRYPTO && ((X86 || UML_X86) && 64BIT)
179+
depends on (X86 || UML_X86) && 64BIT
180+
select CRYPTO_ALGAPI
171181
select CRYPTO_TWOFISH_COMMON
172182
help
173183
Twofish cipher algorithm (x86_64).
@@ -182,7 +192,7 @@ config CRYPTO_TWOFISH_X86_64
182192

183193
config CRYPTO_SERPENT
184194
tristate "Serpent cipher algorithm"
185-
depends on CRYPTO
195+
select CRYPTO_ALGAPI
186196
help
187197
Serpent cipher algorithm, by Anderson, Biham & Knudsen.
188198

@@ -195,7 +205,7 @@ config CRYPTO_SERPENT
195205

196206
config CRYPTO_AES
197207
tristate "AES cipher algorithms"
198-
depends on CRYPTO
208+
select CRYPTO_ALGAPI
199209
help
200210
AES cipher algorithms (FIPS-197). AES uses the Rijndael
201211
algorithm.
@@ -215,7 +225,8 @@ config CRYPTO_AES
215225

216226
config CRYPTO_AES_586
217227
tristate "AES cipher algorithms (i586)"
218-
depends on CRYPTO && ((X86 || UML_X86) && !64BIT)
228+
depends on (X86 || UML_X86) && !64BIT
229+
select CRYPTO_ALGAPI
219230
help
220231
AES cipher algorithms (FIPS-197). AES uses the Rijndael
221232
algorithm.
@@ -235,7 +246,8 @@ config CRYPTO_AES_586
235246

236247
config CRYPTO_AES_X86_64
237248
tristate "AES cipher algorithms (x86_64)"
238-
depends on CRYPTO && ((X86 || UML_X86) && 64BIT)
249+
depends on (X86 || UML_X86) && 64BIT
250+
select CRYPTO_ALGAPI
239251
help
240252
AES cipher algorithms (FIPS-197). AES uses the Rijndael
241253
algorithm.
@@ -255,7 +267,8 @@ config CRYPTO_AES_X86_64
255267

256268
config CRYPTO_AES_S390
257269
tristate "AES cipher algorithms (s390)"
258-
depends on CRYPTO && S390
270+
depends on S390
271+
select CRYPTO_ALGAPI
259272
help
260273
This is the s390 hardware accelerated implementation of the
261274
AES cipher algorithms (FIPS-197). AES uses the Rijndael
@@ -275,21 +288,21 @@ config CRYPTO_AES_S390
275288

276289
config CRYPTO_CAST5
277290
tristate "CAST5 (CAST-128) cipher algorithm"
278-
depends on CRYPTO
291+
select CRYPTO_ALGAPI
279292
help
280293
The CAST5 encryption algorithm (synonymous with CAST-128) is
281294
described in RFC2144.
282295

283296
config CRYPTO_CAST6
284297
tristate "CAST6 (CAST-256) cipher algorithm"
285-
depends on CRYPTO
298+
select CRYPTO_ALGAPI
286299
help
287300
The CAST6 encryption algorithm (synonymous with CAST-256) is
288301
described in RFC2612.
289302

290303
config CRYPTO_TEA
291304
tristate "TEA, XTEA and XETA cipher algorithms"
292-
depends on CRYPTO
305+
select CRYPTO_ALGAPI
293306
help
294307
TEA cipher algorithm.
295308

@@ -306,7 +319,7 @@ config CRYPTO_TEA
306319

307320
config CRYPTO_ARC4
308321
tristate "ARC4 cipher algorithm"
309-
depends on CRYPTO
322+
select CRYPTO_ALGAPI
310323
help
311324
ARC4 cipher algorithm.
312325

@@ -317,7 +330,7 @@ config CRYPTO_ARC4
317330

318331
config CRYPTO_KHAZAD
319332
tristate "Khazad cipher algorithm"
320-
depends on CRYPTO
333+
select CRYPTO_ALGAPI
321334
help
322335
Khazad cipher algorithm.
323336

@@ -330,7 +343,7 @@ config CRYPTO_KHAZAD
330343

331344
config CRYPTO_ANUBIS
332345
tristate "Anubis cipher algorithm"
333-
depends on CRYPTO
346+
select CRYPTO_ALGAPI
334347
help
335348
Anubis cipher algorithm.
336349

@@ -345,7 +358,7 @@ config CRYPTO_ANUBIS
345358

346359
config CRYPTO_DEFLATE
347360
tristate "Deflate compression algorithm"
348-
depends on CRYPTO
361+
select CRYPTO_ALGAPI
349362
select ZLIB_INFLATE
350363
select ZLIB_DEFLATE
351364
help
@@ -356,7 +369,7 @@ config CRYPTO_DEFLATE
356369

357370
config CRYPTO_MICHAEL_MIC
358371
tristate "Michael MIC keyed digest algorithm"
359-
depends on CRYPTO
372+
select CRYPTO_ALGAPI
360373
help
361374
Michael MIC is used for message integrity protection in TKIP
362375
(IEEE 802.11i). This algorithm is required for TKIP, but it
@@ -365,7 +378,7 @@ config CRYPTO_MICHAEL_MIC
365378

366379
config CRYPTO_CRC32C
367380
tristate "CRC32c CRC algorithm"
368-
depends on CRYPTO
381+
select CRYPTO_ALGAPI
369382
select LIBCRC32C
370383
help
371384
Castagnoli, et al Cyclic Redundancy-Check Algorithm. Used
@@ -375,10 +388,13 @@ config CRYPTO_CRC32C
375388

376389
config CRYPTO_TEST
377390
tristate "Testing module"
378-
depends on CRYPTO && m
391+
depends on m
392+
select CRYPTO_ALGAPI
379393
help
380394
Quick & dirty crypto test module.
381395

382396
source "drivers/crypto/Kconfig"
383-
endmenu
384397

398+
endif # if CRYPTO
399+
400+
endmenu

‎crypto/Makefile‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
# Cryptographic API
33
#
44

5-
proc-crypto-$(CONFIG_PROC_FS) = proc.o
5+
obj-$(CONFIG_CRYPTO) += api.o scatterwalk.o cipher.o digest.o compress.o
66

7-
obj-$(CONFIG_CRYPTO) += api.o scatterwalk.o cipher.o digest.o compress.o \
8-
$(proc-crypto-y)
7+
crypto_algapi-$(CONFIG_PROC_FS) += proc.o
8+
crypto_algapi-objs := algapi.o $(crypto_algapi-y)
9+
obj-$(CONFIG_CRYPTO_ALGAPI) += crypto_algapi.o
910

1011
obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
1112
obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o

0 commit comments

Comments
 (0)