diff options
Diffstat (limited to 'crypto/tcrypt.c')
-rw-r--r-- | crypto/tcrypt.c | 160 |
1 files changed, 51 insertions, 109 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 093764e..2222617 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -33,12 +33,9 @@ #include <linux/jiffies.h> #include <linux/timex.h> #include <linux/interrupt.h> -#ifdef CRYPTO_SPEED_TESTS #include "tcrypt.h" -#endif #include "internal.h" -#ifdef CRYPTO_SPEED_TESTS /* * Need slab memory for testing (size in number of pages). */ @@ -54,15 +51,12 @@ * Used by test_cipher_speed() */ static unsigned int sec; -#endif static char *alg = NULL; static u32 type; static u32 mask; static int mode; -#ifdef CRYPTO_SPEED_TESTS static char *tvmem[TVMEMSIZE]; -#endif static char *check[] = { "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", @@ -72,7 +66,7 @@ static char *check[] = { "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320", "lzo", "cts", "zlib", NULL }; -#ifdef CRYPTO_SPEED_TESTS + static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, struct scatterlist *sg, int blen, int sec) { @@ -724,7 +718,6 @@ static void test_ahash_speed(const char *algo, unsigned int sec, out: crypto_free_ahash(tfm); } -#endif static void test_available(void) { @@ -759,17 +752,15 @@ static int do_test(int m) for (i = 1; i < 200; i++) ret += do_test(i); break; -#ifdef CONFIG_CRYPTO_MD5 + case 1: ret += tcrypt_test("md5"); break; -#endif -#ifdef CONFIG_CRYPTO_SHA1 + case 2: ret += tcrypt_test("sha1"); break; -#endif -#ifdef CONFIG_CRYPTO_DES + case 3: ret += tcrypt_test("ecb(des)"); ret += tcrypt_test("cbc(des)"); @@ -779,47 +770,38 @@ static int do_test(int m) ret += tcrypt_test("ecb(des3_ede)"); ret += tcrypt_test("cbc(des3_ede)"); break; -#endif -#ifdef CONFIG_CRYPTO_MD4 + case 5: ret += tcrypt_test("md4"); break; -#endif + case 6: ret += tcrypt_test("sha256"); break; -#ifdef CONFIG_CRYPTO_BLOWFISH + case 7: ret += tcrypt_test("ecb(blowfish)"); ret += tcrypt_test("cbc(blowfish)"); break; -#endif -#ifdef CONFIG_CRYPTO_TWOFISH + case 8: ret += tcrypt_test("ecb(twofish)"); ret += tcrypt_test("cbc(twofish)"); break; -#endif -#ifdef CONFIG_CRYPTO_SERPENT + case 9: ret += tcrypt_test("ecb(serpent)"); break; -#endif + case 10: ret += tcrypt_test("ecb(aes)"); ret += tcrypt_test("cbc(aes)"); -#ifdef CONFIG_CRYPTO_LRW ret += tcrypt_test("lrw(aes)"); -#endif -#ifdef CONFIG_CRYPTO_XTS ret += tcrypt_test("xts(aes)"); -#endif -#ifdef CONFIG_CRYPTO_CTR ret += tcrypt_test("ctr(aes)"); ret += tcrypt_test("rfc3686(ctr(aes))"); break; -#endif -#ifdef CONFIG_CRYPTO_SHA512 + case 11: ret += tcrypt_test("sha384"); break; @@ -827,34 +809,31 @@ static int do_test(int m) case 12: ret += tcrypt_test("sha512"); break; -#endif -#ifdef CONFIG_CRYPTO_DEFLATE + case 13: ret += tcrypt_test("deflate"); break; -#endif -#ifdef CONFIG_CRYPTO_CAST5 + case 14: ret += tcrypt_test("ecb(cast5)"); break; -#endif -#ifdef CONFIG_CRYPTO_CAST6 + case 15: ret += tcrypt_test("ecb(cast6)"); break; -#endif + case 16: ret += tcrypt_test("ecb(arc4)"); break; -#ifdef CONFIG_CRYPTO_MICHAEL_MIC + case 17: ret += tcrypt_test("michael_mic"); break; -#endif + case 18: ret += tcrypt_test("crc32c"); break; -#ifdef CONFIG_CRYPTO_TEA + case 19: ret += tcrypt_test("ecb(tea)"); break; @@ -862,13 +841,11 @@ static int do_test(int m) case 20: ret += tcrypt_test("ecb(xtea)"); break; -#endif -#ifdef CONFIG_CRYPTO_KHAZAD + case 21: ret += tcrypt_test("ecb(khazad)"); break; -#endif -#ifdef CONFIG_CRYPTO_WP512 + case 22: ret += tcrypt_test("wp512"); break; @@ -880,19 +857,16 @@ static int do_test(int m) case 24: ret += tcrypt_test("wp256"); break; -#endif -#ifdef CONFIG_CRYPTO_SERPENT + case 25: ret += tcrypt_test("ecb(tnepres)"); break; -#endif -#ifdef CONFIG_CRYPTO_ANUBIS + case 26: ret += tcrypt_test("ecb(anubis)"); ret += tcrypt_test("cbc(anubis)"); break; -#endif -#ifdef CONFIG_CRYPTO_TGR192 + case 27: ret += tcrypt_test("tgr192"); break; @@ -905,100 +879,83 @@ static int do_test(int m) case 29: ret += tcrypt_test("tgr128"); break; -#endif -#ifdef CONFIG_CRYPTO_TEA + case 30: ret += tcrypt_test("ecb(xeta)"); break; -#endif -#ifdef CONFIG_CRYPTO_FCRYPT + case 31: ret += tcrypt_test("pcbc(fcrypt)"); break; -#endif -#ifdef CONFIG_CRYPTO_CAMELLIA + case 32: ret += tcrypt_test("ecb(camellia)"); ret += tcrypt_test("cbc(camellia)"); break; -#endif case 33: ret += tcrypt_test("sha224"); break; -#ifdef CONFIG_CRYPTO_SALSA20 + case 34: ret += tcrypt_test("salsa20"); break; -#endif -#ifdef CONFIG_CRYPTO_GCM + case 35: ret += tcrypt_test("gcm(aes)"); break; -#endif -#ifdef CONFIG_CRYPTO_LZO + case 36: ret += tcrypt_test("lzo"); break; -#endif -#ifdef CONFIG_CRYPTO_CCM + case 37: ret += tcrypt_test("ccm(aes)"); break; -#endif -#ifdef CONFIG_CRYPTO_CTS + case 38: ret += tcrypt_test("cts(cbc(aes))"); break; -#endif -#ifdef CONFIG_CRYPTO_RMD128 + case 39: ret += tcrypt_test("rmd128"); break; -#endif -#ifdef CONFIG_CRYPTO_RMD160 + case 40: ret += tcrypt_test("rmd160"); break; -#endif -#ifdef CONFIG_CRYPTO_RMD256 + case 41: ret += tcrypt_test("rmd256"); break; -#endif -#ifdef CONFIG_CRYPTO_RMD320 + case 42: ret += tcrypt_test("rmd320"); break; -#endif -#ifdef CONFIG_CRYPTO_SEED + case 43: ret += tcrypt_test("ecb(seed)"); break; -#endif -#ifdef CONFIG_CRYPTO_ZLIB + case 44: ret += tcrypt_test("zlib"); break; -#endif -#ifdef CONFIG_CRYPTO_CCM + case 45: ret += tcrypt_test("rfc4309(ccm(aes))"); break; -#endif -#ifdef CONFIG_CRYPTO_MD5 + case 100: ret += tcrypt_test("hmac(md5)"); break; -#endif -#ifdef CONFIG_CRYPTO_SHA1 + case 101: ret += tcrypt_test("hmac(sha1)"); break; -#endif + case 102: ret += tcrypt_test("hmac(sha256)"); break; -#ifdef CONFIG_CRYPTO_SHA512 + case 103: ret += tcrypt_test("hmac(sha384)"); break; @@ -1006,16 +963,15 @@ static int do_test(int m) case 104: ret += tcrypt_test("hmac(sha512)"); break; -#endif + case 105: ret += tcrypt_test("hmac(sha224)"); break; -#ifdef CONFIG_CRYPTO_XCBC + case 106: ret += tcrypt_test("xcbc(aes)"); break; -#endif -#ifdef CONFIG_CRYPTO_RMD + case 107: ret += tcrypt_test("hmac(rmd128)"); break; @@ -1023,23 +979,19 @@ static int do_test(int m) case 108: ret += tcrypt_test("hmac(rmd160)"); break; -#endif -#ifdef CONFIG_CRYPTO_VMAC + case 109: ret += tcrypt_test("vmac(aes)"); break; -#endif + case 150: ret += tcrypt_test("ansi_cprng"); break; -#ifdef CONFIG_CRYPTO_GCM case 151: ret += tcrypt_test("rfc4106(gcm(aes))"); break; -#endif -#ifdef CRYPTO_SPEED_TESTS case 200: test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, speed_template_16_24_32); @@ -1278,7 +1230,7 @@ static int do_test(int m) case 499: break; -#endif + case 1000: test_available(); break; @@ -1296,7 +1248,6 @@ static int do_alg_test(const char *alg, u32 type, u32 mask) static int __init tcrypt_mod_init(void) { int err = -ENOMEM; -#ifdef CRYPTO_SPEED_TESTS int i; for (i = 0; i < TVMEMSIZE; i++) { @@ -1304,9 +1255,6 @@ static int __init tcrypt_mod_init(void) if (!tvmem[i]) goto err_free_tv; } -#endif - - testmgr_crypto_proc_init(); if (alg) err = do_alg_test(alg, type, mask); @@ -1316,12 +1264,8 @@ static int __init tcrypt_mod_init(void) if (err) { printk(KERN_ERR "tcrypt: one or more tests failed!\n"); goto err_free_tv; -#ifndef CONFIG_CRYPTO_FIPS } -#else - } else - do_integrity_check(); -#endif + /* We intentionaly return -EAGAIN to prevent keeping the module, * unless we're running in fips mode. It does all its work from * init() and doesn't offer any runtime functionality, but in @@ -1333,10 +1277,9 @@ static int __init tcrypt_mod_init(void) err = -EAGAIN; err_free_tv: -#ifdef CRYPTO_SPEED_TESTS for (i = 0; i < TVMEMSIZE && tvmem[i]; i++) free_page((unsigned long)tvmem[i]); -#endif + return err; } @@ -1353,11 +1296,10 @@ module_param(alg, charp, 0); module_param(type, uint, 0); module_param(mask, uint, 0); module_param(mode, int, 0); -#ifdef SUPPORT_SPEED_TEST module_param(sec, uint, 0); MODULE_PARM_DESC(sec, "Length in seconds of speed tests " "(defaults to zero which uses CPU cycles instead)"); -#endif + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Quick & dirty crypto testing module"); MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); |