Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: null - Remove default null blkcipher

The default null blkcipher is no longer used and can now be removed.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+17 -46
+6 -43
crypto/crypto_null.c
··· 26 26 #include <linux/string.h> 27 27 28 28 static DEFINE_MUTEX(crypto_default_null_skcipher_lock); 29 - static struct crypto_blkcipher *crypto_default_null_skcipher; 29 + static struct crypto_skcipher *crypto_default_null_skcipher; 30 30 static int crypto_default_null_skcipher_refcnt; 31 - static struct crypto_skcipher *crypto_default_null_skcipher2; 32 - static int crypto_default_null_skcipher2_refcnt; 33 31 34 32 static int null_compress(struct crypto_tfm *tfm, const u8 *src, 35 33 unsigned int slen, u8 *dst, unsigned int *dlen) ··· 153 155 MODULE_ALIAS_CRYPTO("digest_null"); 154 156 MODULE_ALIAS_CRYPTO("cipher_null"); 155 157 156 - struct crypto_blkcipher *crypto_get_default_null_skcipher(void) 158 + struct crypto_skcipher *crypto_get_default_null_skcipher(void) 157 159 { 158 - struct crypto_blkcipher *tfm; 160 + struct crypto_skcipher *tfm; 159 161 160 162 mutex_lock(&crypto_default_null_skcipher_lock); 161 163 tfm = crypto_default_null_skcipher; 162 164 163 165 if (!tfm) { 164 - tfm = crypto_alloc_blkcipher("ecb(cipher_null)", 0, 0); 166 + tfm = crypto_alloc_skcipher("ecb(cipher_null)", 167 + 0, CRYPTO_ALG_ASYNC); 165 168 if (IS_ERR(tfm)) 166 169 goto unlock; 167 170 ··· 182 183 { 183 184 mutex_lock(&crypto_default_null_skcipher_lock); 184 185 if (!--crypto_default_null_skcipher_refcnt) { 185 - crypto_free_blkcipher(crypto_default_null_skcipher); 186 + crypto_free_skcipher(crypto_default_null_skcipher); 186 187 crypto_default_null_skcipher = NULL; 187 188 } 188 189 mutex_unlock(&crypto_default_null_skcipher_lock); 189 190 } 190 191 EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher); 191 - 192 - struct crypto_skcipher *crypto_get_default_null_skcipher2(void) 193 - { 194 - struct crypto_skcipher *tfm; 195 - 196 - mutex_lock(&crypto_default_null_skcipher_lock); 197 - tfm = crypto_default_null_skcipher2; 198 - 199 - if (!tfm) { 200 - tfm = crypto_alloc_skcipher("ecb(cipher_null)", 201 - 0, CRYPTO_ALG_ASYNC); 202 - if (IS_ERR(tfm)) 203 - goto unlock; 204 - 205 - crypto_default_null_skcipher2 = tfm; 206 - } 207 - 208 - crypto_default_null_skcipher2_refcnt++; 209 - 210 - unlock: 211 - mutex_unlock(&crypto_default_null_skcipher_lock); 212 - 213 - return tfm; 214 - } 215 - EXPORT_SYMBOL_GPL(crypto_get_default_null_skcipher2); 216 - 217 - void crypto_put_default_null_skcipher2(void) 218 - { 219 - mutex_lock(&crypto_default_null_skcipher_lock); 220 - if (!--crypto_default_null_skcipher2_refcnt) { 221 - crypto_free_skcipher(crypto_default_null_skcipher2); 222 - crypto_default_null_skcipher2 = NULL; 223 - } 224 - mutex_unlock(&crypto_default_null_skcipher_lock); 225 - } 226 - EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher2); 227 192 228 193 static int __init crypto_null_mod_init(void) 229 194 {
+11 -3
include/crypto/null.h
··· 8 8 #define NULL_DIGEST_SIZE 0 9 9 #define NULL_IV_SIZE 0 10 10 11 - struct crypto_blkcipher *crypto_get_default_null_skcipher(void); 11 + struct crypto_skcipher *crypto_get_default_null_skcipher(void); 12 12 void crypto_put_default_null_skcipher(void); 13 - struct crypto_skcipher *crypto_get_default_null_skcipher2(void); 14 - void crypto_put_default_null_skcipher2(void); 13 + 14 + static inline struct crypto_skcipher *crypto_get_default_null_skcipher2(void) 15 + { 16 + return crypto_get_default_null_skcipher(); 17 + } 18 + 19 + static inline void crypto_put_default_null_skcipher2(void) 20 + { 21 + crypto_put_default_null_skcipher(); 22 + } 15 23 16 24 #endif