[LTP] [PATCH v2 4/6] crypto/af_alg03: new regression test for rfc7539 hash alg validation
Eric Biggers
ebiggers@kernel.org
Mon Mar 18 18:13:25 CET 2019
From: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
runtest/crypto | 1 +
testcases/kernel/crypto/.gitignore | 1 +
testcases/kernel/crypto/af_alg03.c | 31 ++++++++++++++++++++++++++++++
3 files changed, 33 insertions(+)
create mode 100644 testcases/kernel/crypto/af_alg03.c
diff --git a/runtest/crypto b/runtest/crypto
index 758586c19..03a49df3a 100644
--- a/runtest/crypto
+++ b/runtest/crypto
@@ -1,4 +1,5 @@
af_alg01 af_alg01
af_alg02 af_alg02
+af_alg03 af_alg03
pcrypt_aead01 pcrypt_aead01
crypto_user01 crypto_user01
diff --git a/testcases/kernel/crypto/.gitignore b/testcases/kernel/crypto/.gitignore
index dc79f3275..3e7936fc9 100644
--- a/testcases/kernel/crypto/.gitignore
+++ b/testcases/kernel/crypto/.gitignore
@@ -1,4 +1,5 @@
af_alg01
af_alg02
+af_alg03
pcrypt_aead01
crypto_user01
diff --git a/testcases/kernel/crypto/af_alg03.c b/testcases/kernel/crypto/af_alg03.c
new file mode 100644
index 000000000..240c52835
--- /dev/null
+++ b/testcases/kernel/crypto/af_alg03.c
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2019 Google LLC
+ */
+
+/*
+ * Regression test for commit e57121d08c38 ("crypto: chacha20poly1305 - validate
+ * the digest size"). This test verifies that the rfc7539 template can't be
+ * instantiated with a hash algorithm whose digest size is not 16 bytes.
+ */
+
+#include "tst_test.h"
+#include "tst_af_alg.h"
+
+static void run(void)
+{
+ tst_require_alg("aead", "rfc7539(chacha20,poly1305)");
+ tst_require_alg("hash", "sha256");
+
+ if (tst_have_alg("aead", "rfc7539(chacha20,sha256)")) {
+ tst_res(TFAIL,
+ "instantiated rfc7539 template with wrong digest size");
+ } else {
+ tst_res(TPASS,
+ "couldn't instantiate rfc7539 template with wrong digest size");
+ }
+}
+
+static struct tst_test test = {
+ .test_all = run,
+};
--
2.21.0.225.g810b269d1ac-goog
More information about the ltp
mailing list