Skip to content

Commit

Permalink
crypto/af_alg0[13]: update tests for additional possible errno case
Browse files Browse the repository at this point in the history
kernel behaviour wrt checking invalid algorithms has changed [1] [2]
in v6.12-rc1. Updating the tests to address the additional errno case.
Related discussion on the mailing list [3].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e7a4142b35ce489fc8908d75596c51549711ade0
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=795f85fca229a88543a0a706039f901106bf11c1
[3] https://lore.kernel.org/lkml/[email protected]/

Link: https://lore.kernel.org/ltp/[email protected]/
Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: Avinesh Kumar <[email protected]>
  • Loading branch information
Avinesh authored and pevik committed Nov 4, 2024
1 parent c2457dd commit 2345298
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/tst_af_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ bool tst_have_alg(const char *algtype, const char *algname)
case 0:
return true;
case ENOENT:
case EINVAL:
tst_res(TCONF, "kernel doesn't have %s algorithm '%s'",
algtype, algname);
return false;
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/crypto/af_alg01.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ static void test_with_hash_alg(const char *hash_algname)
{
char hmac_algname[64];
char key[4096] = { 0 };
int ret;

if (!tst_have_alg("hash", hash_algname))
return;
Expand All @@ -30,7 +31,9 @@ static void test_with_hash_alg(const char *hash_algname)
return;

sprintf(hmac_algname, "hmac(hmac(%s))", hash_algname);
if (tst_try_alg("hash", hmac_algname) != ENOENT) {

ret = tst_try_alg("hash", hmac_algname);
if (ret != ENOENT && ret != EINVAL) {
int algfd;

tst_res(TFAIL, "instantiated nested hmac algorithm ('%s')!",
Expand Down
5 changes: 4 additions & 1 deletion testcases/kernel/crypto/af_alg03.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@

static void run(void)
{
int ret;

tst_require_alg("aead", "rfc7539(chacha20,poly1305)");
tst_require_alg("hash", "sha256");

if (tst_try_alg("aead", "rfc7539(chacha20,sha256)") != ENOENT) {
ret = tst_try_alg("aead", "rfc7539(chacha20,sha256)");
if (ret != ENOENT && ret != EINVAL) {
tst_res(TFAIL,
"instantiated rfc7539 template with wrong digest size");
} else {
Expand Down

0 comments on commit 2345298

Please sign in to comment.