Skip to content

Commit 5208ed2

Browse files
Nitesh Lalherbertx
authored andcommitted
crypto: testmgr - add aead cbc des, des3_ede tests
Test vectors were taken from existing test for CBC(DES3_EDE). Associated data has been added to test vectors. HMAC computed with Crypto++ has been used. Following algos have been covered. (a) "authenc(hmac(sha1),cbc(des))" (b) "authenc(hmac(sha1),cbc(des3_ede))" (c) "authenc(hmac(sha224),cbc(des))" (d) "authenc(hmac(sha224),cbc(des3_ede))" (e) "authenc(hmac(sha256),cbc(des))" (f) "authenc(hmac(sha256),cbc(des3_ede))" (g) "authenc(hmac(sha384),cbc(des))" (h) "authenc(hmac(sha384),cbc(des3_ede))" (i) "authenc(hmac(sha512),cbc(des))" (j) "authenc(hmac(sha512),cbc(des3_ede))" Signed-off-by: Vakul Garg <vakul@freescale.com> [NiteshNarayanLal@freescale.com: added hooks for the missing algorithms test and tested the patch] Signed-off-by: Nitesh Lal <NiteshNarayanLal@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 9bac019 commit 5208ed2

3 files changed

Lines changed: 848 additions & 23 deletions

File tree

‎crypto/tcrypt.c‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,36 @@ static int do_test(int m)
15191519
case 157:
15201520
ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))");
15211521
break;
1522-
1522+
case 181:
1523+
ret += tcrypt_test("authenc(hmac(sha1),cbc(des))");
1524+
break;
1525+
case 182:
1526+
ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))");
1527+
break;
1528+
case 183:
1529+
ret += tcrypt_test("authenc(hmac(sha224),cbc(des))");
1530+
break;
1531+
case 184:
1532+
ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))");
1533+
break;
1534+
case 185:
1535+
ret += tcrypt_test("authenc(hmac(sha256),cbc(des))");
1536+
break;
1537+
case 186:
1538+
ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))");
1539+
break;
1540+
case 187:
1541+
ret += tcrypt_test("authenc(hmac(sha384),cbc(des))");
1542+
break;
1543+
case 188:
1544+
ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))");
1545+
break;
1546+
case 189:
1547+
ret += tcrypt_test("authenc(hmac(sha512),cbc(des))");
1548+
break;
1549+
case 190:
1550+
ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))");
1551+
break;
15231552
case 200:
15241553
test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
15251554
speed_template_16_24_32);

‎crypto/testmgr.c‎

Lines changed: 162 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,8 +1834,38 @@ static const struct alg_test_desc alg_test_descs[] = {
18341834
.suite = {
18351835
.aead = {
18361836
.enc = {
1837-
.vecs = hmac_sha1_aes_cbc_enc_tv_template,
1838-
.count = HMAC_SHA1_AES_CBC_ENC_TEST_VECTORS
1837+
.vecs =
1838+
hmac_sha1_aes_cbc_enc_tv_temp,
1839+
.count =
1840+
HMAC_SHA1_AES_CBC_ENC_TEST_VEC
1841+
}
1842+
}
1843+
}
1844+
}, {
1845+
.alg = "authenc(hmac(sha1),cbc(des))",
1846+
.test = alg_test_aead,
1847+
.fips_allowed = 1,
1848+
.suite = {
1849+
.aead = {
1850+
.enc = {
1851+
.vecs =
1852+
hmac_sha1_des_cbc_enc_tv_temp,
1853+
.count =
1854+
HMAC_SHA1_DES_CBC_ENC_TEST_VEC
1855+
}
1856+
}
1857+
}
1858+
}, {
1859+
.alg = "authenc(hmac(sha1),cbc(des3_ede))",
1860+
.test = alg_test_aead,
1861+
.fips_allowed = 1,
1862+
.suite = {
1863+
.aead = {
1864+
.enc = {
1865+
.vecs =
1866+
hmac_sha1_des3_ede_cbc_enc_tv_temp,
1867+
.count =
1868+
HMAC_SHA1_DES3_EDE_CBC_ENC_TEST_VEC
18391869
}
18401870
}
18411871
}
@@ -1846,12 +1876,44 @@ static const struct alg_test_desc alg_test_descs[] = {
18461876
.suite = {
18471877
.aead = {
18481878
.enc = {
1849-
.vecs = hmac_sha1_ecb_cipher_null_enc_tv_template,
1850-
.count = HMAC_SHA1_ECB_CIPHER_NULL_ENC_TEST_VECTORS
1879+
.vecs =
1880+
hmac_sha1_ecb_cipher_null_enc_tv_temp,
1881+
.count =
1882+
HMAC_SHA1_ECB_CIPHER_NULL_ENC_TEST_VEC
18511883
},
18521884
.dec = {
1853-
.vecs = hmac_sha1_ecb_cipher_null_dec_tv_template,
1854-
.count = HMAC_SHA1_ECB_CIPHER_NULL_DEC_TEST_VECTORS
1885+
.vecs =
1886+
hmac_sha1_ecb_cipher_null_dec_tv_temp,
1887+
.count =
1888+
HMAC_SHA1_ECB_CIPHER_NULL_DEC_TEST_VEC
1889+
}
1890+
}
1891+
}
1892+
}, {
1893+
.alg = "authenc(hmac(sha224),cbc(des))",
1894+
.test = alg_test_aead,
1895+
.fips_allowed = 1,
1896+
.suite = {
1897+
.aead = {
1898+
.enc = {
1899+
.vecs =
1900+
hmac_sha224_des_cbc_enc_tv_temp,
1901+
.count =
1902+
HMAC_SHA224_DES_CBC_ENC_TEST_VEC
1903+
}
1904+
}
1905+
}
1906+
}, {
1907+
.alg = "authenc(hmac(sha224),cbc(des3_ede))",
1908+
.test = alg_test_aead,
1909+
.fips_allowed = 1,
1910+
.suite = {
1911+
.aead = {
1912+
.enc = {
1913+
.vecs =
1914+
hmac_sha224_des3_ede_cbc_enc_tv_temp,
1915+
.count =
1916+
HMAC_SHA224_DES3_EDE_CBC_ENC_TEST_VEC
18551917
}
18561918
}
18571919
}
@@ -1862,8 +1924,66 @@ static const struct alg_test_desc alg_test_descs[] = {
18621924
.suite = {
18631925
.aead = {
18641926
.enc = {
1865-
.vecs = hmac_sha256_aes_cbc_enc_tv_template,
1866-
.count = HMAC_SHA256_AES_CBC_ENC_TEST_VECTORS
1927+
.vecs =
1928+
hmac_sha256_aes_cbc_enc_tv_temp,
1929+
.count =
1930+
HMAC_SHA256_AES_CBC_ENC_TEST_VEC
1931+
}
1932+
}
1933+
}
1934+
}, {
1935+
.alg = "authenc(hmac(sha256),cbc(des))",
1936+
.test = alg_test_aead,
1937+
.fips_allowed = 1,
1938+
.suite = {
1939+
.aead = {
1940+
.enc = {
1941+
.vecs =
1942+
hmac_sha256_des_cbc_enc_tv_temp,
1943+
.count =
1944+
HMAC_SHA256_DES_CBC_ENC_TEST_VEC
1945+
}
1946+
}
1947+
}
1948+
}, {
1949+
.alg = "authenc(hmac(sha256),cbc(des3_ede))",
1950+
.test = alg_test_aead,
1951+
.fips_allowed = 1,
1952+
.suite = {
1953+
.aead = {
1954+
.enc = {
1955+
.vecs =
1956+
hmac_sha256_des3_ede_cbc_enc_tv_temp,
1957+
.count =
1958+
HMAC_SHA256_DES3_EDE_CBC_ENC_TEST_VEC
1959+
}
1960+
}
1961+
}
1962+
}, {
1963+
.alg = "authenc(hmac(sha384),cbc(des))",
1964+
.test = alg_test_aead,
1965+
.fips_allowed = 1,
1966+
.suite = {
1967+
.aead = {
1968+
.enc = {
1969+
.vecs =
1970+
hmac_sha384_des_cbc_enc_tv_temp,
1971+
.count =
1972+
HMAC_SHA384_DES_CBC_ENC_TEST_VEC
1973+
}
1974+
}
1975+
}
1976+
}, {
1977+
.alg = "authenc(hmac(sha384),cbc(des3_ede))",
1978+
.test = alg_test_aead,
1979+
.fips_allowed = 1,
1980+
.suite = {
1981+
.aead = {
1982+
.enc = {
1983+
.vecs =
1984+
hmac_sha384_des3_ede_cbc_enc_tv_temp,
1985+
.count =
1986+
HMAC_SHA384_DES3_EDE_CBC_ENC_TEST_VEC
18671987
}
18681988
}
18691989
}
@@ -1874,8 +1994,38 @@ static const struct alg_test_desc alg_test_descs[] = {
18741994
.suite = {
18751995
.aead = {
18761996
.enc = {
1877-
.vecs = hmac_sha512_aes_cbc_enc_tv_template,
1878-
.count = HMAC_SHA512_AES_CBC_ENC_TEST_VECTORS
1997+
.vecs =
1998+
hmac_sha512_aes_cbc_enc_tv_temp,
1999+
.count =
2000+
HMAC_SHA512_AES_CBC_ENC_TEST_VEC
2001+
}
2002+
}
2003+
}
2004+
}, {
2005+
.alg = "authenc(hmac(sha512),cbc(des))",
2006+
.test = alg_test_aead,
2007+
.fips_allowed = 1,
2008+
.suite = {
2009+
.aead = {
2010+
.enc = {
2011+
.vecs =
2012+
hmac_sha512_des_cbc_enc_tv_temp,
2013+
.count =
2014+
HMAC_SHA512_DES_CBC_ENC_TEST_VEC
2015+
}
2016+
}
2017+
}
2018+
}, {
2019+
.alg = "authenc(hmac(sha512),cbc(des3_ede))",
2020+
.test = alg_test_aead,
2021+
.fips_allowed = 1,
2022+
.suite = {
2023+
.aead = {
2024+
.enc = {
2025+
.vecs =
2026+
hmac_sha512_des3_ede_cbc_enc_tv_temp,
2027+
.count =
2028+
HMAC_SHA512_DES3_EDE_CBC_ENC_TEST_VEC
18792029
}
18802030
}
18812031
}
@@ -3276,8 +3426,8 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
32763426
panic("%s: %s alg self test failed in fips mode!\n", driver, alg);
32773427

32783428
if (fips_enabled && !rc)
3279-
printk(KERN_INFO "alg: self-tests for %s (%s) passed\n",
3280-
driver, alg);
3429+
pr_info(KERN_INFO "alg: self-tests for %s (%s) passed\n",
3430+
driver, alg);
32813431

32823432
return rc;
32833433

0 commit comments

Comments
 (0)