crypto: cipher - move API definition to internal header file
Subsystems (7)
PATCH 1/1 crypto: cipher - move API definition to internal header file
The single block cipher API is not intended for general use, and so it should not be exposed to users outside of the crypto subsystem via the public header files. So create a new internal header file and move the definitions there.
--- Documentation/crypto/api-skcipher.rst | 9 - arch/arm/crypto/aes-neonbs-glue.c | 1 + arch/s390/crypto/aes_s390.c | 1 + crypto/adiantum.c | 1 + crypto/ansi_cprng.c | 1 + crypto/cbc.c | 1 + crypto/ccm.c | 1 + crypto/cfb.c | 1 + crypto/cipher.c | 1 + crypto/cmac.c | 1 + crypto/ctr.c | 1 + crypto/drbg.c | 1 + crypto/ecb.c | 1 + crypto/essiv.c | 1 + crypto/keywrap.c | 1 + crypto/ofb.c | 1 + crypto/pcbc.c | 1 + crypto/skcipher.c | 1 + crypto/vmac.c | 1 + crypto/xcbc.c | 1 + crypto/xts.c | 1 + drivers/crypto/geode-aes.c | 1 + .../crypto/inside-secure/safexcel_cipher.c | 1 + drivers/crypto/inside-secure/safexcel_hash.c | 1 + include/crypto/algapi.h | 29 --- include/crypto/internal/cipher.h | 206 ++++++++++++++++++ include/linux/crypto.h | 163 -------------- 27 files changed, 229 insertions(+), 201 deletions(-) create mode 100644 include/crypto/internal/cipher.h
Documentation/crypto/api-skcipher.rst +0 -9
@@ -24,12 +24,3 @@ Symmetric Key Cipher Request Handle .. kernel-doc:: include/crypto/skcipher.h :functions: crypto_skcipher_reqsize skcipher_request_set_tfm skcipher_request_alloc skcipher_request_free skcipher_request_set_callback skcipher_request_set_crypt - -Single Block Cipher API ------------------------ - -.. kernel-doc:: include/linux/crypto.h - :doc: Single Block Cipher API - -.. kernel-doc:: include/linux/crypto.h - :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 +1 -0
@@ -10,6 +10,7 @@#include <crypto/aes.h> #include <crypto/cbc.h> #include <crypto/ctr.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/simd.h> #include <crypto/internal/skcipher.h> #include <crypto/scatterwalk.h>
arch/s390/crypto/aes_s390.c +1 -0
@@ -21,6 +21,7 @@#include <crypto/algapi.h> #include <crypto/ghash.h> #include <crypto/internal/aead.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include <crypto/scatterwalk.h> #include <linux/err.h>
crypto/adiantum.c +1 -0
@@ -32,6 +32,7 @@#include <crypto/b128ops.h> #include <crypto/chacha.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/hash.h> #include <crypto/internal/poly1305.h> #include <crypto/internal/skcipher.h>
crypto/ansi_cprng.c +1 -0
@@ -7,6 +7,7 @@* (C) Neil Horman <[email protected]> */ +#include <crypto/internal/cipher.h> #include <crypto/internal/rng.h> #include <linux/err.h> #include <linux/init.h>
crypto/cbc.c +1 -0
@@ -7,6 +7,7 @@#include <crypto/algapi.h> #include <crypto/cbc.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include <linux/err.h> #include <linux/init.h>
crypto/ccm.c +1 -0
@@ -6,6 +6,7 @@*/ #include <crypto/internal/aead.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/hash.h> #include <crypto/internal/skcipher.h> #include <crypto/scatterwalk.h>
crypto/cfb.c +1 -0
@@ -20,6 +20,7 @@*/ #include <crypto/algapi.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include <linux/err.h> #include <linux/init.h>
crypto/cipher.c +1 -0
@@ -9,6 +9,7 @@*/ #include <crypto/algapi.h> +#include <crypto/internal/cipher.h> #include <linux/kernel.h> #include <linux/crypto.h> #include <linux/errno.h>
crypto/cmac.c +1 -0
@@ -11,6 +11,7 @@* Author: Kazunori Miyazawa <[email protected]> */ +#include <crypto/internal/cipher.h> #include <crypto/internal/hash.h> #include <linux/err.h> #include <linux/kernel.h>
crypto/ctr.c +1 -0
@@ -7,6 +7,7 @@#include <crypto/algapi.h> #include <crypto/ctr.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include <linux/err.h> #include <linux/init.h>
crypto/drbg.c +1 -0
@@ -98,6 +98,7 @@*/ #include <crypto/drbg.h> +#include <crypto/internal/cipher.h> #include <linux/kernel.h> /***************************************************************
crypto/ecb.c +1 -0
@@ -6,6 +6,7 @@*/ #include <crypto/algapi.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include <linux/err.h> #include <linux/init.h>
crypto/essiv.c +1 -0
@@ -31,6 +31,7 @@#include <crypto/authenc.h> #include <crypto/internal/aead.h> #include <crypto/internal/hash.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include <crypto/scatterwalk.h> #include <linux/module.h>
crypto/keywrap.c +1 -0
@@ -85,6 +85,7 @@#include <linux/crypto.h> #include <linux/scatterlist.h> #include <crypto/scatterwalk.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> struct crypto_kw_block {
crypto/ofb.c +1 -0
@@ -8,6 +8,7 @@*/ #include <crypto/algapi.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include <linux/err.h> #include <linux/init.h>
crypto/pcbc.c +1 -0
@@ -10,6 +10,7 @@*/ #include <crypto/algapi.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include <linux/err.h> #include <linux/init.h>
crypto/skcipher.c +1 -0
@@ -10,6 +10,7 @@*/ #include <crypto/internal/aead.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include <crypto/scatterwalk.h> #include <linux/bug.h>
crypto/vmac.c +1 -0
@@ -36,6 +36,7 @@#include <linux/scatterlist.h> #include <asm/byteorder.h> #include <crypto/scatterwalk.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/hash.h> /*
crypto/xcbc.c +1 -0
@@ -6,6 +6,7 @@* Kazunori Miyazawa <[email protected]> */ +#include <crypto/internal/cipher.h> #include <crypto/internal/hash.h> #include <linux/err.h> #include <linux/kernel.h>
crypto/xts.c +1 -0
@@ -7,6 +7,7 @@* Based on ecb.c * Copyright (c) 2006 Herbert Xu <[email protected]> */ +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include <crypto/scatterwalk.h> #include <linux/err.h>
drivers/crypto/geode-aes.c +1 -0
@@ -10,6 +10,7 @@#include <linux/spinlock.h> #include <crypto/algapi.h> #include <crypto/aes.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include <linux/io.h>
drivers/crypto/inside-secure/safexcel_cipher.c +1 -0
@@ -24,6 +24,7 @@#include <crypto/xts.h> #include <crypto/skcipher.h> #include <crypto/internal/aead.h> +#include <crypto/internal/cipher.h> #include <crypto/internal/skcipher.h> #include "safexcel.h"
drivers/crypto/inside-secure/safexcel_hash.c +1 -0
@@ -12,6 +12,7 @@#include <crypto/sha3.h> #include <crypto/skcipher.h> #include <crypto/sm3.h> +#include <crypto/internal/cipher.h> #include <linux/device.h> #include <linux/dma-mapping.h> #include <linux/dmapool.h>
include/crypto/algapi.h +0 -29
@@ -191,41 +191,12 @@ struct crypto_cipher_spawn {struct crypto_spawn base; }; -static inline int crypto_grab_cipher (struct crypto_cipher_spawn *spawn, -struct crypto_instance *inst, -const char *name,u32 type,u32 mask) -{ - type &= ~CRYPTO_ALG_TYPE_MASK ; - type |=CRYPTO_ALG_TYPE_CIPHER ; - mask |=CRYPTO_ALG_TYPE_MASK ; -return crypto_grab_spawn (&spawn->base, inst, name, type, mask); -} - -static inline void crypto_drop_cipher (struct crypto_cipher_spawn *spawn) -{ -crypto_drop_spawn (&spawn->base); -} -static inline struct crypto_alg *crypto_spawn_cipher_alg (struct crypto_cipher_spawn *spawn) {return spawn->base.alg; } -static inline struct crypto_cipher *crypto_spawn_cipher ( -struct crypto_cipher_spawn *spawn) -{ -u32 type =CRYPTO_ALG_TYPE_CIPHER ; -u32 mask =CRYPTO_ALG_TYPE_MASK ; - -return __crypto_cipher_cast (crypto_spawn_tfm (&spawn->base, type, mask)); -} - -static inline struct cipher_alg *crypto_cipher_alg (struct crypto_cipher *tfm) -{ -return &crypto_cipher_tfm (tfm)->__crt_alg->cra_cipher; -} -static inline struct crypto_async_request *crypto_get_backlog (struct crypto_queue *queue) {
include/crypto/internal/cipher.h new file +206 -0
206 lines not on this page · raw message
include/linux/crypto.h +0 -163
175 lines not on this page · raw message
Signature · 1 line
2.20.1
kbuild test robot
build botI love your patch! Yet something to improve:
Hi Ard,
I love your patch! Yet something to improve:
[auto build test ERROR on cryptodev/master]
[cannot apply to crypto/master v5.5-rc5 next-20200109]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Ard-Biesheuvel/crypto-cipher-move-API-definition-to-internal-header-file/20200110-193618 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master config: powerpc-defconfig (attached as .config) compiler: powerpc64-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=powerpc
If you fix the issue, kindly add following tag
All error/warnings (new ones prefixed by >>):
drivers/crypto/vmx/aes.c: In function 'p8_aes_init':
>> drivers/crypto/vmx/aes.c:33:13: error: implicit declaration of function 'crypto_alloc_cipher'; did you mean 'crypto_alloc_comp'? [-Werror=implicit-function-declaration]
fallback = crypto_alloc_cipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
^~~~~~~~~~~~~~~~~~~
crypto_alloc_comp
>> drivers/crypto/vmx/aes.c:33:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
fallback = crypto_alloc_cipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
^
>> drivers/crypto/vmx/aes.c:41:2: error: implicit declaration of function 'crypto_cipher_set_flags'; did you mean 'crypto_tfm_set_flags'? [-Werror=implicit-function-declaration]
crypto_cipher_set_flags(fallback,
^~~~~~~~~~~~~~~~~~~~~~~
crypto_tfm_set_flags
>> drivers/crypto/vmx/aes.c:42:5: error: implicit declaration of function 'crypto_cipher_get_flags'; did you mean 'crypto_tfm_get_flags'? [-Werror=implicit-function-declaration]
crypto_cipher_get_flags((struct
^~~~~~~~~~~~~~~~~~~~~~~
crypto_tfm_get_flags
drivers/crypto/vmx/aes.c: In function 'p8_aes_exit':
>> drivers/crypto/vmx/aes.c:55:3: error: implicit declaration of function 'crypto_free_cipher'; did you mean 'crypto_free_comp'? [-Werror=implicit-function-declaration]
crypto_free_cipher(ctx->fallback);
^~~~~~~~~~~~~~~~~~
crypto_free_comp
drivers/crypto/vmx/aes.c: In function 'p8_aes_setkey':
>> drivers/crypto/vmx/aes.c:75:9: error: implicit declaration of function 'crypto_cipher_setkey'; did you mean 'crypto_aes_set_key'? [-Werror=implicit-function-declaration]
ret |= crypto_cipher_setkey(ctx->fallback, key, keylen);
^~~~~~~~~~~~~~~~~~~~
crypto_aes_set_key
drivers/crypto/vmx/aes.c: In function 'p8_aes_encrypt':
>> drivers/crypto/vmx/aes.c:85:3: error: implicit declaration of function 'crypto_cipher_encrypt_one'; did you mean 'crypto_stats_skcipher_encrypt'? [-Werror=implicit-function-declaration]
crypto_cipher_encrypt_one(ctx->fallback, dst, src);
^~~~~~~~~~~~~~~~~~~~~~~~~
crypto_stats_skcipher_encrypt
drivers/crypto/vmx/aes.c: In function 'p8_aes_decrypt':
>> drivers/crypto/vmx/aes.c:102:3: error: implicit declaration of function 'crypto_cipher_decrypt_one'; did you mean 'crypto_comp_decompress'? [-Werror=implicit-function-declaration]
crypto_cipher_decrypt_one(ctx->fallback, dst, src);
^~~~~~~~~~~~~~~~~~~~~~~~~
crypto_comp_decompresscc1: some warnings being treated as errors
vim +33 drivers/crypto/vmx/aes.c
8676590a159320 Marcelo H. Cerri 2015-02-06 26
8676590a159320 Marcelo H. Cerri 2015-02-06 27 static int p8_aes_init(struct crypto_tfm *tfm)
8676590a159320 Marcelo H. Cerri 2015-02-06 28 {
78557e77b25a98 Tudor-Dan Ambarus 2017-06-16 29 const char *alg = crypto_tfm_alg_name(tfm);
8676590a159320 Marcelo H. Cerri 2015-02-06 30 struct crypto_cipher *fallback;
8676590a159320 Marcelo H. Cerri 2015-02-06 31 struct p8_aes_ctx *ctx = crypto_tfm_ctx(tfm);
8676590a159320 Marcelo H. Cerri 2015-02-06 32
8676590a159320 Marcelo H. Cerri 2015-02-06 @33 fallback = crypto_alloc_cipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
8676590a159320 Marcelo H. Cerri 2015-02-06 34 if (IS_ERR(fallback)) {
4beb106045976b Herbert Xu 2015-06-15 35 printk(KERN_ERR
4beb106045976b Herbert Xu 2015-06-15 36 "Failed to allocate transformation for '%s': %ld\n",
8676590a159320 Marcelo H. Cerri 2015-02-06 37 alg, PTR_ERR(fallback));
8676590a159320 Marcelo H. Cerri 2015-02-06 38 return PTR_ERR(fallback);
8676590a159320 Marcelo H. Cerri 2015-02-06 39 }
8676590a159320 Marcelo H. Cerri 2015-02-06 40
8676590a159320 Marcelo H. Cerri 2015-02-06 @41 crypto_cipher_set_flags(fallback,
4beb106045976b Herbert Xu 2015-06-15 @42 crypto_cipher_get_flags((struct
4beb106045976b Herbert Xu 2015-06-15 43 crypto_cipher *)
4beb106045976b Herbert Xu 2015-06-15 44 tfm));
8676590a159320 Marcelo H. Cerri 2015-02-06 45 ctx->fallback = fallback;
8676590a159320 Marcelo H. Cerri 2015-02-06 46
8676590a159320 Marcelo H. Cerri 2015-02-06 47 return 0;
8676590a159320 Marcelo H. Cerri 2015-02-06 48 }
8676590a159320 Marcelo H. Cerri 2015-02-06 49
8676590a159320 Marcelo H. Cerri 2015-02-06 50 static void p8_aes_exit(struct crypto_tfm *tfm)
8676590a159320 Marcelo H. Cerri 2015-02-06 51 {
8676590a159320 Marcelo H. Cerri 2015-02-06 52 struct p8_aes_ctx *ctx = crypto_tfm_ctx(tfm);
8676590a159320 Marcelo H. Cerri 2015-02-06 53
8676590a159320 Marcelo H. Cerri 2015-02-06 54 if (ctx->fallback) {
8676590a159320 Marcelo H. Cerri 2015-02-06 @55 crypto_free_cipher(ctx->fallback);
8676590a159320 Marcelo H. Cerri 2015-02-06 56 ctx->fallback = NULL;
8676590a159320 Marcelo H. Cerri 2015-02-06 57 }
8676590a159320 Marcelo H. Cerri 2015-02-06 58 }
8676590a159320 Marcelo H. Cerri 2015-02-06 59
8676590a159320 Marcelo H. Cerri 2015-02-06 60 static int p8_aes_setkey(struct crypto_tfm *tfm, const u8 *key,
8676590a159320 Marcelo H. Cerri 2015-02-06 61 unsigned int keylen)
8676590a159320 Marcelo H. Cerri 2015-02-06 62 {
8676590a159320 Marcelo H. Cerri 2015-02-06 63 int ret;
8676590a159320 Marcelo H. Cerri 2015-02-06 64 struct p8_aes_ctx *ctx = crypto_tfm_ctx(tfm);
8676590a159320 Marcelo H. Cerri 2015-02-06 65
5f76eea88dcbe7 David Hildenbrand 2015-05-11 66 preempt_disable();
8676590a159320 Marcelo H. Cerri 2015-02-06 67 pagefault_disable();
2d6f0600b2cd75 Leonidas Da Silva Barbosa 2015-07-13 68 enable_kernel_vsx();
8676590a159320 Marcelo H. Cerri 2015-02-06 69 ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key);
694e0db6600c12 Eric Biggers 2019-04-09 70 ret |= aes_p8_set_decrypt_key(key, keylen * 8, &ctx->dec_key);
dc4fbba11e4661 Anton Blanchard 2015-10-29 71 disable_kernel_vsx();
8676590a159320 Marcelo H. Cerri 2015-02-06 72 pagefault_enable();
5f76eea88dcbe7 David Hildenbrand 2015-05-11 73 preempt_enable();
8676590a159320 Marcelo H. Cerri 2015-02-06 74
694e0db6600c12 Eric Biggers 2019-04-09 @75 ret |= crypto_cipher_setkey(ctx->fallback, key, keylen);
694e0db6600c12 Eric Biggers 2019-04-09 76
694e0db6600c12 Eric Biggers 2019-04-09 77 return ret ? -EINVAL : 0;
8676590a159320 Marcelo H. Cerri 2015-02-06 78 }
8676590a159320 Marcelo H. Cerri 2015-02-06 79
8676590a159320 Marcelo H. Cerri 2015-02-06 80 static void p8_aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
8676590a159320 Marcelo H. Cerri 2015-02-06 81 {
8676590a159320 Marcelo H. Cerri 2015-02-06 82 struct p8_aes_ctx *ctx = crypto_tfm_ctx(tfm);
8676590a159320 Marcelo H. Cerri 2015-02-06 83
626ddb2fbe7931 Eric Biggers 2019-04-12 84 if (!crypto_simd_usable()) {
8676590a159320 Marcelo H. Cerri 2015-02-06 @85 crypto_cipher_encrypt_one(ctx->fallback, dst, src);
8676590a159320 Marcelo H. Cerri 2015-02-06 86 } else {
5f76eea88dcbe7 David Hildenbrand 2015-05-11 87 preempt_disable();
8676590a159320 Marcelo H. Cerri 2015-02-06 88 pagefault_disable();
2d6f0600b2cd75 Leonidas Da Silva Barbosa 2015-07-13 89 enable_kernel_vsx();
8676590a159320 Marcelo H. Cerri 2015-02-06 90 aes_p8_encrypt(src, dst, &ctx->enc_key);
dc4fbba11e4661 Anton Blanchard 2015-10-29 91 disable_kernel_vsx();
8676590a159320 Marcelo H. Cerri 2015-02-06 92 pagefault_enable();
5f76eea88dcbe7 David Hildenbrand 2015-05-11 93 preempt_enable();
8676590a159320 Marcelo H. Cerri 2015-02-06 94 }
8676590a159320 Marcelo H. Cerri 2015-02-06 95 }
8676590a159320 Marcelo H. Cerri 2015-02-06 96
8676590a159320 Marcelo H. Cerri 2015-02-06 97 static void p8_aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
8676590a159320 Marcelo H. Cerri 2015-02-06 98 {
8676590a159320 Marcelo H. Cerri 2015-02-06 99 struct p8_aes_ctx *ctx = crypto_tfm_ctx(tfm);
8676590a159320 Marcelo H. Cerri 2015-02-06 100
626ddb2fbe7931 Eric Biggers 2019-04-12 101 if (!crypto_simd_usable()) {
8676590a159320 Marcelo H. Cerri 2015-02-06 @102 crypto_cipher_decrypt_one(ctx->fallback, dst, src);
8676590a159320 Marcelo H. Cerri 2015-02-06 103 } else {
5f76eea88dcbe7 David Hildenbrand 2015-05-11 104 preempt_disable();
8676590a159320 Marcelo H. Cerri 2015-02-06 105 pagefault_disable();
2d6f0600b2cd75 Leonidas Da Silva Barbosa 2015-07-13 106 enable_kernel_vsx();
8676590a159320 Marcelo H. Cerri 2015-02-06 107 aes_p8_decrypt(src, dst, &ctx->dec_key);
dc4fbba11e4661 Anton Blanchard 2015-10-29 108 disable_kernel_vsx();
8676590a159320 Marcelo H. Cerri 2015-02-06 109 pagefault_enable();
5f76eea88dcbe7 David Hildenbrand 2015-05-11 110 preempt_enable();
8676590a159320 Marcelo H. Cerri 2015-02-06 111 }
8676590a159320 Marcelo H. Cerri 2015-02-06 112 }
8676590a159320 Marcelo H. Cerri 2015-02-06 113 :::::: The code at line 33 was first introduced by commit
:::::: 8676590a159320a9de2a1818df14a3bac3f065a1 crypto: vmx - Adding AES routines for VMX module
:::::: TO: Marcelo H. Cerri <[email protected]> :::::: CC: Herbert Xu <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation