Commit 39761214eefc6b070f29402aa1165f24d789b3f7

Authored by Tim Chen
Committed by Herbert Xu
1 parent 0b95a7f857

crypto: crct10dif - Simple correctness and speed test for CRCT10DIF hash

These are simple tests to do sanity check of CRC T10 DIF hash.  The
correctness of the transform can be checked with the command
	modprobe tcrypt mode=47
The speed of the transform can be evaluated with the command
	modprobe tcrypt mode=320

Set the cpu frequency to constant and turn turbo off when running the
speed test so the frequency governor will not tweak the frequency and
affects the measurements.

Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Showing 3 changed files with 51 additions and 0 deletions Side-by-side Diff

... ... @@ -1174,6 +1174,10 @@
1174 1174 ret += tcrypt_test("ghash");
1175 1175 break;
1176 1176  
  1177 + case 47:
  1178 + ret += tcrypt_test("crct10dif");
  1179 + break;
  1180 +
1177 1181 case 100:
1178 1182 ret += tcrypt_test("hmac(md5)");
1179 1183 break;
... ... @@ -1496,6 +1500,10 @@
1496 1500  
1497 1501 case 319:
1498 1502 test_hash_speed("crc32c", sec, generic_hash_speed_template);
  1503 + if (mode > 300 && mode < 400) break;
  1504 +
  1505 + case 320:
  1506 + test_hash_speed("crct10dif", sec, generic_hash_speed_template);
1499 1507 if (mode > 300 && mode < 400) break;
1500 1508  
1501 1509 case 399:
... ... @@ -1974,6 +1974,16 @@
1974 1974 }
1975 1975 }
1976 1976 }, {
  1977 + .alg = "crct10dif",
  1978 + .test = alg_test_hash,
  1979 + .fips_allowed = 1,
  1980 + .suite = {
  1981 + .hash = {
  1982 + .vecs = crct10dif_tv_template,
  1983 + .count = CRCT10DIF_TEST_VECTORS
  1984 + }
  1985 + }
  1986 + }, {
1977 1987 .alg = "cryptd(__driver-cbc-aes-aesni)",
1978 1988 .test = alg_test_null,
1979 1989 .fips_allowed = 1,
... ... @@ -450,6 +450,39 @@
450 450 }
451 451 };
452 452  
  453 +#define CRCT10DIF_TEST_VECTORS 3
  454 +static struct hash_testvec crct10dif_tv_template[] = {
  455 + {
  456 + .plaintext = "abc",
  457 + .psize = 3,
  458 +#ifdef __LITTLE_ENDIAN
  459 + .digest = "\x3b\x44",
  460 +#else
  461 + .digest = "\x44\x3b",
  462 +#endif
  463 + }, {
  464 + .plaintext = "1234567890123456789012345678901234567890"
  465 + "123456789012345678901234567890123456789",
  466 + .psize = 79,
  467 +#ifdef __LITTLE_ENDIAN
  468 + .digest = "\x70\x4b",
  469 +#else
  470 + .digest = "\x4b\x70",
  471 +#endif
  472 + }, {
  473 + .plaintext =
  474 + "abcddddddddddddddddddddddddddddddddddddddddddddddddddddd",
  475 + .psize = 56,
  476 +#ifdef __LITTLE_ENDIAN
  477 + .digest = "\xe3\x9c",
  478 +#else
  479 + .digest = "\x9c\xe3",
  480 +#endif
  481 + .np = 2,
  482 + .tap = { 28, 28 }
  483 + }
  484 +};
  485 +
453 486 /*
454 487 * SHA1 test vectors from from FIPS PUB 180-1
455 488 * Long vector from CAVS 5.0