aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/testmgr.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 308d9cffdc46..67dce77d49d5 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1010,6 +1010,55 @@ static int alg_test_hash(const struct alg_test_desc *desc, const char *driver,
1010 return err; 1010 return err;
1011} 1011}
1012 1012
1013static int alg_test_crc32c(const struct alg_test_desc *desc,
1014 const char *driver, u32 type, u32 mask)
1015{
1016 struct crypto_shash *tfm;
1017 u32 val;
1018 int err;
1019
1020 err = alg_test_hash(desc, driver, type, mask);
1021 if (err)
1022 goto out;
1023
1024 tfm = crypto_alloc_shash(driver, type, mask);
1025 if (IS_ERR(tfm)) {
1026 printk(KERN_ERR "alg: crc32c: Failed to load transform for %s: "
1027 "%ld\n", driver, PTR_ERR(tfm));
1028 err = PTR_ERR(tfm);
1029 goto out;
1030 }
1031
1032 do {
1033 struct {
1034 struct shash_desc shash;
1035 char ctx[crypto_shash_descsize(tfm)];
1036 } sdesc;
1037
1038 sdesc.shash.tfm = tfm;
1039 sdesc.shash.flags = 0;
1040
1041 *(u32 *)sdesc.ctx = le32_to_cpu(420553207);
1042 err = crypto_shash_final(&sdesc.shash, (u8 *)&val);
1043 if (err) {
1044 printk(KERN_ERR "alg: crc32c: Operation failed for "
1045 "%s: %d\n", driver, err);
1046 break;
1047 }
1048
1049 if (val != ~420553207) {
1050 printk(KERN_ERR "alg: crc32c: Test failed for %s: "
1051 "%d\n", driver, val);
1052 err = -EINVAL;
1053 }
1054 } while (0);
1055
1056 crypto_free_shash(tfm);
1057
1058out:
1059 return err;
1060}
1061
1013/* Please keep this list sorted by algorithm name. */ 1062/* Please keep this list sorted by algorithm name. */
1014static const struct alg_test_desc alg_test_descs[] = { 1063static const struct alg_test_desc alg_test_descs[] = {
1015 { 1064 {
@@ -1134,7 +1183,7 @@ static const struct alg_test_desc alg_test_descs[] = {
1134 } 1183 }
1135 }, { 1184 }, {
1136 .alg = "crc32c", 1185 .alg = "crc32c",
1137 .test = alg_test_hash, 1186 .test = alg_test_crc32c,
1138 .suite = { 1187 .suite = {
1139 .hash = { 1188 .hash = {
1140 .vecs = crc32c_tv_template, 1189 .vecs = crc32c_tv_template,