Commit 65c92cbb authored by Robert Elliott's avatar Robert Elliott Committed by Herbert Xu

crypto: tcrypt - fix return value for multiple subtests

When a test mode invokes multiple tests (e.g., mode 0 invokes modes
1 through 199, and mode 3 tests three block cipher modes with des),
don't keep accumulating the return values with ret += tcrypt_test(),
which results in a bogus value if more than one report a nonzero
value (e.g., two reporting -2 (-ENOENT) end up reporting -4 (-EINTR)).
Instead, keep track of the minimum return value reported by any
subtest.

Fixes: 4e033a6b ("crypto: tcrypt - Do not exit on success in fips mode")
Signed-off-by: default avatarRobert Elliott <elliott@hpe.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 46beeade
...@@ -1471,387 +1471,387 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) ...@@ -1471,387 +1471,387 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
} }
for (i = 1; i < 200; i++) for (i = 1; i < 200; i++)
ret += do_test(NULL, 0, 0, i, num_mb); ret = min(ret, do_test(NULL, 0, 0, i, num_mb));
break; break;
case 1: case 1:
ret += tcrypt_test("md5"); ret = min(ret, tcrypt_test("md5"));
break; break;
case 2: case 2:
ret += tcrypt_test("sha1"); ret = min(ret, tcrypt_test("sha1"));
break; break;
case 3: case 3:
ret += tcrypt_test("ecb(des)"); ret = min(ret, tcrypt_test("ecb(des)"));
ret += tcrypt_test("cbc(des)"); ret = min(ret, tcrypt_test("cbc(des)"));
ret += tcrypt_test("ctr(des)"); ret = min(ret, tcrypt_test("ctr(des)"));
break; break;
case 4: case 4:
ret += tcrypt_test("ecb(des3_ede)"); ret = min(ret, tcrypt_test("ecb(des3_ede)"));
ret += tcrypt_test("cbc(des3_ede)"); ret = min(ret, tcrypt_test("cbc(des3_ede)"));
ret += tcrypt_test("ctr(des3_ede)"); ret = min(ret, tcrypt_test("ctr(des3_ede)"));
break; break;
case 5: case 5:
ret += tcrypt_test("md4"); ret = min(ret, tcrypt_test("md4"));
break; break;
case 6: case 6:
ret += tcrypt_test("sha256"); ret = min(ret, tcrypt_test("sha256"));
break; break;
case 7: case 7:
ret += tcrypt_test("ecb(blowfish)"); ret = min(ret, tcrypt_test("ecb(blowfish)"));
ret += tcrypt_test("cbc(blowfish)"); ret = min(ret, tcrypt_test("cbc(blowfish)"));
ret += tcrypt_test("ctr(blowfish)"); ret = min(ret, tcrypt_test("ctr(blowfish)"));
break; break;
case 8: case 8:
ret += tcrypt_test("ecb(twofish)"); ret = min(ret, tcrypt_test("ecb(twofish)"));
ret += tcrypt_test("cbc(twofish)"); ret = min(ret, tcrypt_test("cbc(twofish)"));
ret += tcrypt_test("ctr(twofish)"); ret = min(ret, tcrypt_test("ctr(twofish)"));
ret += tcrypt_test("lrw(twofish)"); ret = min(ret, tcrypt_test("lrw(twofish)"));
ret += tcrypt_test("xts(twofish)"); ret = min(ret, tcrypt_test("xts(twofish)"));
break; break;
case 9: case 9:
ret += tcrypt_test("ecb(serpent)"); ret = min(ret, tcrypt_test("ecb(serpent)"));
ret += tcrypt_test("cbc(serpent)"); ret = min(ret, tcrypt_test("cbc(serpent)"));
ret += tcrypt_test("ctr(serpent)"); ret = min(ret, tcrypt_test("ctr(serpent)"));
ret += tcrypt_test("lrw(serpent)"); ret = min(ret, tcrypt_test("lrw(serpent)"));
ret += tcrypt_test("xts(serpent)"); ret = min(ret, tcrypt_test("xts(serpent)"));
break; break;
case 10: case 10:
ret += tcrypt_test("ecb(aes)"); ret = min(ret, tcrypt_test("ecb(aes)"));
ret += tcrypt_test("cbc(aes)"); ret = min(ret, tcrypt_test("cbc(aes)"));
ret += tcrypt_test("lrw(aes)"); ret = min(ret, tcrypt_test("lrw(aes)"));
ret += tcrypt_test("xts(aes)"); ret = min(ret, tcrypt_test("xts(aes)"));
ret += tcrypt_test("ctr(aes)"); ret = min(ret, tcrypt_test("ctr(aes)"));
ret += tcrypt_test("rfc3686(ctr(aes))"); ret = min(ret, tcrypt_test("rfc3686(ctr(aes))"));
ret += tcrypt_test("ofb(aes)"); ret = min(ret, tcrypt_test("ofb(aes)"));
ret += tcrypt_test("cfb(aes)"); ret = min(ret, tcrypt_test("cfb(aes)"));
ret += tcrypt_test("xctr(aes)"); ret = min(ret, tcrypt_test("xctr(aes)"));
break; break;
case 11: case 11:
ret += tcrypt_test("sha384"); ret = min(ret, tcrypt_test("sha384"));
break; break;
case 12: case 12:
ret += tcrypt_test("sha512"); ret = min(ret, tcrypt_test("sha512"));
break; break;
case 13: case 13:
ret += tcrypt_test("deflate"); ret = min(ret, tcrypt_test("deflate"));
break; break;
case 14: case 14:
ret += tcrypt_test("ecb(cast5)"); ret = min(ret, tcrypt_test("ecb(cast5)"));
ret += tcrypt_test("cbc(cast5)"); ret = min(ret, tcrypt_test("cbc(cast5)"));
ret += tcrypt_test("ctr(cast5)"); ret = min(ret, tcrypt_test("ctr(cast5)"));
break; break;
case 15: case 15:
ret += tcrypt_test("ecb(cast6)"); ret = min(ret, tcrypt_test("ecb(cast6)"));
ret += tcrypt_test("cbc(cast6)"); ret = min(ret, tcrypt_test("cbc(cast6)"));
ret += tcrypt_test("ctr(cast6)"); ret = min(ret, tcrypt_test("ctr(cast6)"));
ret += tcrypt_test("lrw(cast6)"); ret = min(ret, tcrypt_test("lrw(cast6)"));
ret += tcrypt_test("xts(cast6)"); ret = min(ret, tcrypt_test("xts(cast6)"));
break; break;
case 16: case 16:
ret += tcrypt_test("ecb(arc4)"); ret = min(ret, tcrypt_test("ecb(arc4)"));
break; break;
case 17: case 17:
ret += tcrypt_test("michael_mic"); ret = min(ret, tcrypt_test("michael_mic"));
break; break;
case 18: case 18:
ret += tcrypt_test("crc32c"); ret = min(ret, tcrypt_test("crc32c"));
break; break;
case 19: case 19:
ret += tcrypt_test("ecb(tea)"); ret = min(ret, tcrypt_test("ecb(tea)"));
break; break;
case 20: case 20:
ret += tcrypt_test("ecb(xtea)"); ret = min(ret, tcrypt_test("ecb(xtea)"));
break; break;
case 21: case 21:
ret += tcrypt_test("ecb(khazad)"); ret = min(ret, tcrypt_test("ecb(khazad)"));
break; break;
case 22: case 22:
ret += tcrypt_test("wp512"); ret = min(ret, tcrypt_test("wp512"));
break; break;
case 23: case 23:
ret += tcrypt_test("wp384"); ret = min(ret, tcrypt_test("wp384"));
break; break;
case 24: case 24:
ret += tcrypt_test("wp256"); ret = min(ret, tcrypt_test("wp256"));
break; break;
case 26: case 26:
ret += tcrypt_test("ecb(anubis)"); ret = min(ret, tcrypt_test("ecb(anubis)"));
ret += tcrypt_test("cbc(anubis)"); ret = min(ret, tcrypt_test("cbc(anubis)"));
break; break;
case 30: case 30:
ret += tcrypt_test("ecb(xeta)"); ret = min(ret, tcrypt_test("ecb(xeta)"));
break; break;
case 31: case 31:
ret += tcrypt_test("pcbc(fcrypt)"); ret = min(ret, tcrypt_test("pcbc(fcrypt)"));
break; break;
case 32: case 32:
ret += tcrypt_test("ecb(camellia)"); ret = min(ret, tcrypt_test("ecb(camellia)"));
ret += tcrypt_test("cbc(camellia)"); ret = min(ret, tcrypt_test("cbc(camellia)"));
ret += tcrypt_test("ctr(camellia)"); ret = min(ret, tcrypt_test("ctr(camellia)"));
ret += tcrypt_test("lrw(camellia)"); ret = min(ret, tcrypt_test("lrw(camellia)"));
ret += tcrypt_test("xts(camellia)"); ret = min(ret, tcrypt_test("xts(camellia)"));
break; break;
case 33: case 33:
ret += tcrypt_test("sha224"); ret = min(ret, tcrypt_test("sha224"));
break; break;
case 35: case 35:
ret += tcrypt_test("gcm(aes)"); ret = min(ret, tcrypt_test("gcm(aes)"));
break; break;
case 36: case 36:
ret += tcrypt_test("lzo"); ret = min(ret, tcrypt_test("lzo"));
break; break;
case 37: case 37:
ret += tcrypt_test("ccm(aes)"); ret = min(ret, tcrypt_test("ccm(aes)"));
break; break;
case 38: case 38:
ret += tcrypt_test("cts(cbc(aes))"); ret = min(ret, tcrypt_test("cts(cbc(aes))"));
break; break;
case 39: case 39:
ret += tcrypt_test("xxhash64"); ret = min(ret, tcrypt_test("xxhash64"));
break; break;
case 40: case 40:
ret += tcrypt_test("rmd160"); ret = min(ret, tcrypt_test("rmd160"));
break; break;
case 42: case 42:
ret += tcrypt_test("blake2b-512"); ret = min(ret, tcrypt_test("blake2b-512"));
break; break;
case 43: case 43:
ret += tcrypt_test("ecb(seed)"); ret = min(ret, tcrypt_test("ecb(seed)"));
break; break;
case 45: case 45:
ret += tcrypt_test("rfc4309(ccm(aes))"); ret = min(ret, tcrypt_test("rfc4309(ccm(aes))"));
break; break;
case 46: case 46:
ret += tcrypt_test("ghash"); ret = min(ret, tcrypt_test("ghash"));
break; break;
case 47: case 47:
ret += tcrypt_test("crct10dif"); ret = min(ret, tcrypt_test("crct10dif"));
break; break;
case 48: case 48:
ret += tcrypt_test("sha3-224"); ret = min(ret, tcrypt_test("sha3-224"));
break; break;
case 49: case 49:
ret += tcrypt_test("sha3-256"); ret = min(ret, tcrypt_test("sha3-256"));
break; break;
case 50: case 50:
ret += tcrypt_test("sha3-384"); ret = min(ret, tcrypt_test("sha3-384"));
break; break;
case 51: case 51:
ret += tcrypt_test("sha3-512"); ret = min(ret, tcrypt_test("sha3-512"));
break; break;
case 52: case 52:
ret += tcrypt_test("sm3"); ret = min(ret, tcrypt_test("sm3"));
break; break;
case 53: case 53:
ret += tcrypt_test("streebog256"); ret = min(ret, tcrypt_test("streebog256"));
break; break;
case 54: case 54:
ret += tcrypt_test("streebog512"); ret = min(ret, tcrypt_test("streebog512"));
break; break;
case 55: case 55:
ret += tcrypt_test("gcm(sm4)"); ret = min(ret, tcrypt_test("gcm(sm4)"));
break; break;
case 56: case 56:
ret += tcrypt_test("ccm(sm4)"); ret = min(ret, tcrypt_test("ccm(sm4)"));
break; break;
case 57: case 57:
ret += tcrypt_test("polyval"); ret = min(ret, tcrypt_test("polyval"));
break; break;
case 58: case 58:
ret += tcrypt_test("gcm(aria)"); ret = min(ret, tcrypt_test("gcm(aria)"));
break; break;
case 100: case 100:
ret += tcrypt_test("hmac(md5)"); ret = min(ret, tcrypt_test("hmac(md5)"));
break; break;
case 101: case 101:
ret += tcrypt_test("hmac(sha1)"); ret = min(ret, tcrypt_test("hmac(sha1)"));
break; break;
case 102: case 102:
ret += tcrypt_test("hmac(sha256)"); ret = min(ret, tcrypt_test("hmac(sha256)"));
break; break;
case 103: case 103:
ret += tcrypt_test("hmac(sha384)"); ret = min(ret, tcrypt_test("hmac(sha384)"));
break; break;
case 104: case 104:
ret += tcrypt_test("hmac(sha512)"); ret = min(ret, tcrypt_test("hmac(sha512)"));
break; break;
case 105: case 105:
ret += tcrypt_test("hmac(sha224)"); ret = min(ret, tcrypt_test("hmac(sha224)"));
break; break;
case 106: case 106:
ret += tcrypt_test("xcbc(aes)"); ret = min(ret, tcrypt_test("xcbc(aes)"));
break; break;
case 108: case 108:
ret += tcrypt_test("hmac(rmd160)"); ret = min(ret, tcrypt_test("hmac(rmd160)"));
break; break;
case 109: case 109:
ret += tcrypt_test("vmac64(aes)"); ret = min(ret, tcrypt_test("vmac64(aes)"));
break; break;
case 111: case 111:
ret += tcrypt_test("hmac(sha3-224)"); ret = min(ret, tcrypt_test("hmac(sha3-224)"));
break; break;
case 112: case 112:
ret += tcrypt_test("hmac(sha3-256)"); ret = min(ret, tcrypt_test("hmac(sha3-256)"));
break; break;
case 113: case 113:
ret += tcrypt_test("hmac(sha3-384)"); ret = min(ret, tcrypt_test("hmac(sha3-384)"));
break; break;
case 114: case 114:
ret += tcrypt_test("hmac(sha3-512)"); ret = min(ret, tcrypt_test("hmac(sha3-512)"));
break; break;
case 115: case 115:
ret += tcrypt_test("hmac(streebog256)"); ret = min(ret, tcrypt_test("hmac(streebog256)"));
break; break;
case 116: case 116:
ret += tcrypt_test("hmac(streebog512)"); ret = min(ret, tcrypt_test("hmac(streebog512)"));
break; break;
case 150: case 150:
ret += tcrypt_test("ansi_cprng"); ret = min(ret, tcrypt_test("ansi_cprng"));
break; break;
case 151: case 151:
ret += tcrypt_test("rfc4106(gcm(aes))"); ret = min(ret, tcrypt_test("rfc4106(gcm(aes))"));
break; break;
case 152: case 152:
ret += tcrypt_test("rfc4543(gcm(aes))"); ret = min(ret, tcrypt_test("rfc4543(gcm(aes))"));
break; break;
case 153: case 153:
ret += tcrypt_test("cmac(aes)"); ret = min(ret, tcrypt_test("cmac(aes)"));
break; break;
case 154: case 154:
ret += tcrypt_test("cmac(des3_ede)"); ret = min(ret, tcrypt_test("cmac(des3_ede)"));
break; break;
case 155: case 155:
ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))"); ret = min(ret, tcrypt_test("authenc(hmac(sha1),cbc(aes))"));
break; break;
case 156: case 156:
ret += tcrypt_test("authenc(hmac(md5),ecb(cipher_null))"); ret = min(ret, tcrypt_test("authenc(hmac(md5),ecb(cipher_null))"));
break; break;
case 157: case 157:
ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))"); ret = min(ret, tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))"));
break; break;
case 158: case 158:
ret += tcrypt_test("cbcmac(sm4)"); ret = min(ret, tcrypt_test("cbcmac(sm4)"));
break; break;
case 159: case 159:
ret += tcrypt_test("cmac(sm4)"); ret = min(ret, tcrypt_test("cmac(sm4)"));
break; break;
case 181: case 181:
ret += tcrypt_test("authenc(hmac(sha1),cbc(des))"); ret = min(ret, tcrypt_test("authenc(hmac(sha1),cbc(des))"));
break; break;
case 182: case 182:
ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))"); ret = min(ret, tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))"));
break; break;
case 183: case 183:
ret += tcrypt_test("authenc(hmac(sha224),cbc(des))"); ret = min(ret, tcrypt_test("authenc(hmac(sha224),cbc(des))"));
break; break;
case 184: case 184:
ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))"); ret = min(ret, tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))"));
break; break;
case 185: case 185:
ret += tcrypt_test("authenc(hmac(sha256),cbc(des))"); ret = min(ret, tcrypt_test("authenc(hmac(sha256),cbc(des))"));
break; break;
case 186: case 186:
ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))"); ret = min(ret, tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))"));
break; break;
case 187: case 187:
ret += tcrypt_test("authenc(hmac(sha384),cbc(des))"); ret = min(ret, tcrypt_test("authenc(hmac(sha384),cbc(des))"));
break; break;
case 188: case 188:
ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))"); ret = min(ret, tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))"));
break; break;
case 189: case 189:
ret += tcrypt_test("authenc(hmac(sha512),cbc(des))"); ret = min(ret, tcrypt_test("authenc(hmac(sha512),cbc(des))"));
break; break;
case 190: case 190:
ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))"); ret = min(ret, tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))"));
break; break;
case 191: case 191:
ret += tcrypt_test("ecb(sm4)"); ret = min(ret, tcrypt_test("ecb(sm4)"));
ret += tcrypt_test("cbc(sm4)"); ret = min(ret, tcrypt_test("cbc(sm4)"));
ret += tcrypt_test("cfb(sm4)"); ret = min(ret, tcrypt_test("cfb(sm4)"));
ret += tcrypt_test("ctr(sm4)"); ret = min(ret, tcrypt_test("ctr(sm4)"));
break; break;
case 192: case 192:
ret += tcrypt_test("ecb(aria)"); ret = min(ret, tcrypt_test("ecb(aria)"));
ret += tcrypt_test("cbc(aria)"); ret = min(ret, tcrypt_test("cbc(aria)"));
ret += tcrypt_test("cfb(aria)"); ret = min(ret, tcrypt_test("cfb(aria)"));
ret += tcrypt_test("ctr(aria)"); ret = min(ret, tcrypt_test("ctr(aria)"));
break; break;
case 200: case 200:
test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment