Skip to content

Commit 0eb76ba

Browse files
ardbiesheuvelherbertx
authored andcommitted
crypto: remove cipher routines from public crypto API
The cipher routines in the crypto API are mostly intended for templates implementing skcipher modes generically in software, and shouldn't be used outside of the crypto subsystem. So move the prototypes and all related definitions to a new header file under include/crypto/internal. Also, let's use the new module namespace feature to move the symbol exports into a new namespace CRYPTO_INTERNAL. Signed-off-by: Ard Biesheuvel <[email protected]> Acked-by: Eric Biggers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent a3b01ff commit 0eb76ba

File tree

33 files changed

+273
-207
lines changed

33 files changed

+273
-207
lines changed

Documentation/crypto/api-skcipher.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ Symmetric Key Cipher Request Handle
2828
Single Block Cipher API
2929
-----------------------
3030

31-
.. kernel-doc:: include/linux/crypto.h
31+
.. kernel-doc:: include/crypto/internal/cipher.h
3232
:doc: Single Block Cipher API
3333

34-
.. kernel-doc:: include/linux/crypto.h
34+
.. kernel-doc:: include/crypto/internal/cipher.h
3535
:functions: crypto_alloc_cipher crypto_free_cipher crypto_has_cipher crypto_cipher_blocksize crypto_cipher_setkey crypto_cipher_encrypt_one crypto_cipher_decrypt_one

arch/arm/crypto/aes-neonbs-glue.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <asm/simd.h>
1010
#include <crypto/aes.h>
1111
#include <crypto/ctr.h>
12+
#include <crypto/internal/cipher.h>
1213
#include <crypto/internal/simd.h>
1314
#include <crypto/internal/skcipher.h>
1415
#include <crypto/scatterwalk.h>
@@ -23,6 +24,8 @@ MODULE_ALIAS_CRYPTO("cbc(aes)-all");
2324
MODULE_ALIAS_CRYPTO("ctr(aes)");
2425
MODULE_ALIAS_CRYPTO("xts(aes)");
2526

27+
MODULE_IMPORT_NS(CRYPTO_INTERNAL);
28+
2629
asmlinkage void aesbs_convert_key(u8 out[], u32 const rk[], int rounds);
2730

2831
asmlinkage void aesbs_ecb_encrypt(u8 out[], u8 const in[], u8 const rk[],

arch/s390/crypto/aes_s390.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <crypto/algapi.h>
2222
#include <crypto/ghash.h>
2323
#include <crypto/internal/aead.h>
24+
#include <crypto/internal/cipher.h>
2425
#include <crypto/internal/skcipher.h>
2526
#include <crypto/scatterwalk.h>
2627
#include <linux/err.h>
@@ -1055,3 +1056,4 @@ MODULE_ALIAS_CRYPTO("aes-all");
10551056

10561057
MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm");
10571058
MODULE_LICENSE("GPL");
1059+
MODULE_IMPORT_NS(CRYPTO_INTERNAL);

crypto/adiantum.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include <crypto/b128ops.h>
3434
#include <crypto/chacha.h>
35+
#include <crypto/internal/cipher.h>
3536
#include <crypto/internal/hash.h>
3637
#include <crypto/internal/poly1305.h>
3738
#include <crypto/internal/skcipher.h>
@@ -616,3 +617,4 @@ MODULE_DESCRIPTION("Adiantum length-preserving encryption mode");
616617
MODULE_LICENSE("GPL v2");
617618
MODULE_AUTHOR("Eric Biggers <[email protected]>");
618619
MODULE_ALIAS_CRYPTO("adiantum");
620+
MODULE_IMPORT_NS(CRYPTO_INTERNAL);

crypto/ansi_cprng.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* (C) Neil Horman <[email protected]>
88
*/
99

10+
#include <crypto/internal/cipher.h>
1011
#include <crypto/internal/rng.h>
1112
#include <linux/err.h>
1213
#include <linux/init.h>
@@ -470,3 +471,4 @@ subsys_initcall(prng_mod_init);
470471
module_exit(prng_mod_fini);
471472
MODULE_ALIAS_CRYPTO("stdrng");
472473
MODULE_ALIAS_CRYPTO("ansi_cprng");
474+
MODULE_IMPORT_NS(CRYPTO_INTERNAL);

crypto/cbc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <crypto/algapi.h>
9+
#include <crypto/internal/cipher.h>
910
#include <crypto/internal/skcipher.h>
1011
#include <linux/err.h>
1112
#include <linux/init.h>

crypto/ccm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <crypto/internal/aead.h>
9+
#include <crypto/internal/cipher.h>
910
#include <crypto/internal/hash.h>
1011
#include <crypto/internal/skcipher.h>
1112
#include <crypto/scatterwalk.h>
@@ -954,3 +955,4 @@ MODULE_ALIAS_CRYPTO("ccm_base");
954955
MODULE_ALIAS_CRYPTO("rfc4309");
955956
MODULE_ALIAS_CRYPTO("ccm");
956957
MODULE_ALIAS_CRYPTO("cbcmac");
958+
MODULE_IMPORT_NS(CRYPTO_INTERNAL);

crypto/cfb.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*/
2121

2222
#include <crypto/algapi.h>
23+
#include <crypto/internal/cipher.h>
2324
#include <crypto/internal/skcipher.h>
2425
#include <linux/err.h>
2526
#include <linux/init.h>
@@ -250,3 +251,4 @@ module_exit(crypto_cfb_module_exit);
250251
MODULE_LICENSE("GPL");
251252
MODULE_DESCRIPTION("CFB block cipher mode of operation");
252253
MODULE_ALIAS_CRYPTO("cfb");
254+
MODULE_IMPORT_NS(CRYPTO_INTERNAL);

crypto/cipher.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <crypto/algapi.h>
12+
#include <crypto/internal/cipher.h>
1213
#include <linux/kernel.h>
1314
#include <linux/crypto.h>
1415
#include <linux/errno.h>
@@ -53,7 +54,7 @@ int crypto_cipher_setkey(struct crypto_cipher *tfm,
5354

5455
return cia->cia_setkey(crypto_cipher_tfm(tfm), key, keylen);
5556
}
56-
EXPORT_SYMBOL_GPL(crypto_cipher_setkey);
57+
EXPORT_SYMBOL_NS_GPL(crypto_cipher_setkey, CRYPTO_INTERNAL);
5758

5859
static inline void cipher_crypt_one(struct crypto_cipher *tfm,
5960
u8 *dst, const u8 *src, bool enc)
@@ -81,11 +82,11 @@ void crypto_cipher_encrypt_one(struct crypto_cipher *tfm,
8182
{
8283
cipher_crypt_one(tfm, dst, src, true);
8384
}
84-
EXPORT_SYMBOL_GPL(crypto_cipher_encrypt_one);
85+
EXPORT_SYMBOL_NS_GPL(crypto_cipher_encrypt_one, CRYPTO_INTERNAL);
8586

8687
void crypto_cipher_decrypt_one(struct crypto_cipher *tfm,
8788
u8 *dst, const u8 *src)
8889
{
8990
cipher_crypt_one(tfm, dst, src, false);
9091
}
91-
EXPORT_SYMBOL_GPL(crypto_cipher_decrypt_one);
92+
EXPORT_SYMBOL_NS_GPL(crypto_cipher_decrypt_one, CRYPTO_INTERNAL);

crypto/cmac.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Author: Kazunori Miyazawa <[email protected]>
1212
*/
1313

14+
#include <crypto/internal/cipher.h>
1415
#include <crypto/internal/hash.h>
1516
#include <linux/err.h>
1617
#include <linux/kernel.h>
@@ -313,3 +314,4 @@ module_exit(crypto_cmac_module_exit);
313314
MODULE_LICENSE("GPL");
314315
MODULE_DESCRIPTION("CMAC keyed hash algorithm");
315316
MODULE_ALIAS_CRYPTO("cmac");
317+
MODULE_IMPORT_NS(CRYPTO_INTERNAL);

0 commit comments

Comments
 (0)