diff options
author | David S. Miller <davem@nuts.ninka.net> | 2002-11-03 09:30:55 -0800 |
---|---|---|
committer | David S. Miller <davem@nuts.ninka.net> | 2002-11-03 09:30:55 -0800 |
commit | cc3c38af26c76028d56228b1c64e34f33e844a66 (patch) | |
tree | d46175189db08851f3391e4f703d84498345b245 /crypto | |
parent | 3ec0428eb484a539cfe9e826592da5194f3d0b9e (diff) | |
parent | 03d08a27ba03a5c2ac70f215ad165e7444f27877 (diff) | |
download | history-cc3c38af26c76028d56228b1c64e34f33e844a66.tar.gz |
Merge nuts.ninka.net:/home/davem/src/BK/network-2.5
into nuts.ninka.net:/home/davem/src/BK/net-2.5
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/api.c | 25 | ||||
-rw-r--r-- | crypto/autoload.c | 10 | ||||
-rw-r--r-- | crypto/internal.h | 10 | ||||
-rw-r--r-- | crypto/tcrypt.c | 19 |
4 files changed, 55 insertions, 9 deletions
diff --git a/crypto/api.c b/crypto/api.c index 51cd1a8113dcb5..6a0ba2df1bc9a6 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -67,9 +67,10 @@ static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags) return crypto_init_compress_flags(tfm, flags); default: - BUG(); + break; } + BUG(); return -EINVAL; } @@ -99,13 +100,7 @@ struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags) struct crypto_tfm *tfm = NULL; struct crypto_alg *alg; - alg = crypto_alg_lookup(name); -#ifdef CONFIG_KMOD - if (alg == NULL) { - crypto_alg_autoload(name); - alg = crypto_alg_lookup(name); - } -#endif + alg = crypto_alg_mod_lookup(name); if (alg == NULL) goto out; @@ -207,6 +202,19 @@ out: return ret; } +int crypto_alg_available(const char *name, u32 flags) +{ + int ret = 0; + struct crypto_alg *alg = crypto_alg_mod_lookup(name); + + if (alg) { + crypto_alg_put(alg); + ret = 1; + } + + return ret; +} + static void *c_start(struct seq_file *m, loff_t *pos) { struct list_head *v; @@ -296,3 +304,4 @@ EXPORT_SYMBOL_GPL(crypto_register_alg); EXPORT_SYMBOL_GPL(crypto_unregister_alg); EXPORT_SYMBOL_GPL(crypto_alloc_tfm); EXPORT_SYMBOL_GPL(crypto_free_tfm); +EXPORT_SYMBOL_GPL(crypto_alg_available); diff --git a/crypto/autoload.c b/crypto/autoload.c index ee001b6b05e2eb..21d3b22a8398f8 100644 --- a/crypto/autoload.c +++ b/crypto/autoload.c @@ -25,3 +25,13 @@ void crypto_alg_autoload(const char *name) { request_module(name); } + +struct crypto_alg *crypto_alg_mod_lookup(const char *name) +{ + struct crypto_alg *alg = crypto_alg_lookup(name); + if (alg == NULL) { + crypto_alg_autoload(name); + alg = crypto_alg_lookup(name); + } + return alg; +} diff --git a/crypto/internal.h b/crypto/internal.h index c1904830595049..a75326211f1e87 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -35,13 +35,21 @@ static inline void crypto_yield(struct crypto_tfm *tfm) cond_resched(); } -static inline int crypto_cipher_flags(u32 flags) +static inline u32 crypto_cipher_flags(u32 flags) { return flags & (CRYPTO_TFM_MODE_MASK|CRYPTO_TFM_REQ_WEAK_KEY); } +struct crypto_alg *crypto_alg_lookup(const char *name); + #ifdef CONFIG_KMOD void crypto_alg_autoload(const char *name); +struct crypto_alg *crypto_alg_mod_lookup(const char *name); +#else +static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name) +{ + return crypto_alg_lookup(name); +} #endif int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags); diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index adebcd9f4c4621..fd284ee8836cdf 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -46,6 +46,8 @@ static int mode = 0; static char *xbuf; static char *tvmem; +static char *check[] = { "des", "md5", "des3_ede", "rot13", "sha1", NULL }; + static void hexdump(unsigned char *buf, unsigned int len) { @@ -1300,6 +1302,19 @@ test_des3_ede(void) } static void +test_available(void) +{ + char **name = check; + + while (*name) { + printk("alg %s ", *name); + printk((crypto_alg_available(*name, 0)) ? + "found\n" : "not found\n"); + name++; + } +} + +static void do_test(void) { switch (mode) { @@ -1332,6 +1347,10 @@ do_test(void) test_md4(); break; + case 100: + test_available(); + break; + default: /* useful for debugging */ printk("not testing anything\n"); |