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 tst_require_alg("aead", "rfc7539(chacha20,poly1305)");
19 tst_require_alg("hash", "sha256");
20
21 if (tst_try_alg("aead", "rfc7539(chacha20,sha256)") != ENOENT) {
22 tst_res(TFAIL,
23 "instantiated rfc7539 template with wrong digest size");
24 } else {
25 tst_res(TPASS,
26 "couldn't instantiate rfc7539 template with wrong digest size");
27 }
28 }
29
30 static struct tst_test test = {
31 .test_all = run,
32 .tags = (const struct tst_tag[]) {
33 {"linux-git", "e57121d08c38"},
34 {}
35 }
36 };
37