Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
}
}
}, {
.alg = "rmd160",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = rmd160_tv_template,
.count = RMD160_TEST_VECTORS
}
}
}, {
.alg = "rmd256",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = rmd256_tv_template,
.count = RMD256_TEST_VECTORS
}
}
}, {
.alg = "rmd320",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = rmd320_tv_template,
.count = RMD320_TEST_VECTORS
}
}
}, {
.alg = "salsa20",
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
.suite = {
.cipher = {
.enc = {
.vecs = salsa20_stream_enc_tv_template,
.count = SALSA20_STREAM_ENC_TEST_VECTORS
}
}
}
}, {
.alg = "sha1",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = sha1_tv_template,
.count = SHA1_TEST_VECTORS
}
}
}, {
.alg = "sha224",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = sha224_tv_template,
.count = SHA224_TEST_VECTORS
}
}
}, {
.alg = "sha256",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = sha256_tv_template,
.count = SHA256_TEST_VECTORS
}
}
}, {
.alg = "sha384",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = sha384_tv_template,
.count = SHA384_TEST_VECTORS
}
}
}, {
.alg = "sha512",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = sha512_tv_template,
.count = SHA512_TEST_VECTORS
}
}
}, {
.alg = "tgr128",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = tgr128_tv_template,
.count = TGR128_TEST_VECTORS
}
}
}, {
.alg = "tgr160",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = tgr160_tv_template,
.count = TGR160_TEST_VECTORS
}
}
}, {
.alg = "tgr192",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = tgr192_tv_template,
.count = TGR192_TEST_VECTORS
}
}
}, {
.alg = "wp256",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = wp256_tv_template,
.count = WP256_TEST_VECTORS
}
}
}, {
.alg = "wp384",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = wp384_tv_template,
.count = WP384_TEST_VECTORS
}
}
}, {
.alg = "wp512",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = wp512_tv_template,
.count = WP512_TEST_VECTORS
}
}
}, {
.alg = "xcbc(aes)",
.test = alg_test_hash,
.suite = {
.hash = {
.vecs = aes_xcbc128_tv_template,
.count = XCBC_AES_TEST_VECTORS
}
}
}, {
.alg = "xts(aes)",
.suite = {
.cipher = {
.enc = {
.vecs = aes_xts_enc_tv_template,
.count = AES_XTS_ENC_TEST_VECTORS
},
.dec = {
.vecs = aes_xts_dec_tv_template,
.count = AES_XTS_DEC_TEST_VECTORS
}
}
}
}, {
.alg = "zlib",
.test = alg_test_pcomp,
.suite = {
.pcomp = {
.comp = {
.vecs = zlib_comp_tv_template,
.count = ZLIB_COMP_TEST_VECTORS
},
.decomp = {
.vecs = zlib_decomp_tv_template,
.count = ZLIB_DECOMP_TEST_VECTORS
}
}
}
static int alg_find_test(const char *alg)
{
int start = 0;
int end = ARRAY_SIZE(alg_test_descs);
while (start < end) {
int i = (start + end) / 2;
int diff = strcmp(alg_test_descs[i].alg, alg);
if (diff > 0) {
end = i;
continue;
}
if (diff < 0) {
start = i + 1;
continue;
}
return i;
}
return -1;
}
int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
{
int i;
int rc;
if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) {
char nalg[CRYPTO_MAX_ALG_NAME];
if (snprintf(nalg, sizeof(nalg), "ecb(%s)", alg) >=
sizeof(nalg))
return -ENAMETOOLONG;
i = alg_find_test(nalg);
if (i < 0)
goto notest;
rc = alg_test_cipher(alg_test_descs + i, driver, type, mask);
goto test_done;
i = alg_find_test(alg);
if (i < 0)
goto notest;
rc = alg_test_descs[i].test(alg_test_descs + i, driver,
test_done:
if (fips_enabled && rc)
panic("%s: %s alg self test failed in fips mode!\n", driver, alg);
if (fips_enabled && !rc)
printk(KERN_INFO "alg: self-tests for %s (%s) passed\n",
driver, alg);
return rc;
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
printk(KERN_INFO "alg: No test for %s (%s)\n", alg, driver);
return 0;
}
EXPORT_SYMBOL_GPL(alg_test);
int __init testmgr_init(void)
{
int i;
for (i = 0; i < XBUFSIZE; i++) {
xbuf[i] = (void *)__get_free_page(GFP_KERNEL);
if (!xbuf[i])
goto err_free_xbuf;
}
for (i = 0; i < XBUFSIZE; i++) {
axbuf[i] = (void *)__get_free_page(GFP_KERNEL);
if (!axbuf[i])
goto err_free_axbuf;
}
return 0;
err_free_axbuf:
for (i = 0; i < XBUFSIZE && axbuf[i]; i++)
free_page((unsigned long)axbuf[i]);
err_free_xbuf:
for (i = 0; i < XBUFSIZE && xbuf[i]; i++)
free_page((unsigned long)xbuf[i]);
return -ENOMEM;
}
void testmgr_exit(void)
{
int i;
for (i = 0; i < XBUFSIZE; i++)
free_page((unsigned long)axbuf[i]);
for (i = 0; i < XBUFSIZE; i++)
free_page((unsigned long)xbuf[i]);
}