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