1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright 2019 Google LLC
4 * Copyright (c) Linux Test Project, 2019-2021
5 */
6
7 /*
8 * Regression test for commit e57121d08c38 ("crypto: chacha20poly1305 - validate
9 * the digest size"). This test verifies that the rfc7539 template can't be
10 * instantiated with a hash algorithm whose digest size is not 16 bytes.
11 */
12
13 #include "tst_test.h"
14 #include "tst_af_alg.h"
15
run(void)16 static void run(void)
17 {
18 int ret;
19
20 tst_require_alg("aead", "rfc7539(chacha20,poly1305)");
21 tst_require_alg("hash", "sha256");
22
23 ret = tst_try_alg("aead", "rfc7539(chacha20,sha256)");
24 if (ret != ENOENT && ret != EINVAL) {
25 tst_res(TFAIL,
26 "instantiated rfc7539 template with wrong digest size");
27 } else {
28 tst_res(TPASS,
29 "couldn't instantiate rfc7539 template with wrong digest size");
30 }
31 }
32
33 static struct tst_test test = {
34 .test_all = run,
35 .tags = (const struct tst_tag[]) {
36 {"linux-git", "e57121d08c38"},
37 {}
38 }
39 };
40