diff options
author | James Morris <jmorris@intercode.com.au> | 2002-11-01 10:07:19 -0800 |
---|---|---|
committer | David S. Miller <davem@nuts.ninka.net> | 2002-11-01 10:07:19 -0800 |
commit | 4cbbc1847d4a69bea3d3bed8d60ae01d72f12766 (patch) | |
tree | bada1ede99bee0f644e162a638e18554c1a22b3c /crypto | |
parent | 95d6c2106d03ca0656b1feab7acfd3744eb558c0 (diff) | |
download | history-4cbbc1847d4a69bea3d3bed8d60ae01d72f12766.tar.gz |
[CRYPTO]: Add crypto_alg_available interface.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/api.c | 22 | ||||
-rw-r--r-- | crypto/autoload.c | 10 | ||||
-rw-r--r-- | crypto/internal.h | 8 | ||||
-rw-r--r-- | crypto/tcrypt.c | 19 |
4 files changed, 52 insertions, 7 deletions
diff --git a/crypto/api.c b/crypto/api.c index 5a29cb8c93f693..6a0ba2df1bc9a6 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -100,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; @@ -208,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; @@ -297,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 204a3b18ccc8ce..a75326211f1e87 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -40,8 +40,16 @@ 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"); |