t_cgdconfig.sh revision 1.2 1 # $NetBSD: t_cgdconfig.sh,v 1.2 2022/08/12 10:48:44 riastradh Exp $
2 #
3 # Copyright (c) 2022 The NetBSD Foundation, Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
26 #
27
28 atf_test_case storedkey
29 storedkey_head()
30 {
31 atf_set descr "Test key generation with storedkey"
32 }
33 storedkey_body()
34 {
35 cat <<EOF >params
36 algorithm adiantum;
37 iv-method encblkno1;
38 keylength 256;
39 verify_method none;
40 keygen storedkey key AAABAJtnmp3XZspMBAFpCYnB8Hekn0 \
41 gj5cDVngslfGLSqwcy;
42 EOF
43 atf_check -o inline:'m2eanddmykwEAWkJicHwd6SfSCPlwNWeCyV8YtKrBzI=\n' \
44 cgdconfig -t params
45 }
46
47 atf_test_case storedkeys
48 storedkeys_head()
49 {
50 atf_set descr "Test multiple stored keys with cgd.conf"
51 }
52 storedkeys_body()
53 {
54 cat <<EOF >wd0e
55 algorithm adiantum;
56 iv-method encblkno1;
57 keylength 256;
58 verify_method none;
59 keygen storedkey key AAABAJtnmp3XZspMBAFpCYnB8Hekn0 \
60 gj5cDVngslfGLSqwcy;
61 EOF
62 cat <<EOF >ld1e
63 algorithm adiantum;
64 iv-method encblkno1;
65 keylength 256;
66 verify_method none;
67 keygen storedkey key AAABAK1pbgIayXftX0RQ3AaMK4YEd/ \
68 fowKwQbENxpu3o1k9m;
69 EOF
70 cat <<EOF >cgd.conf
71 cgd0 /dev/wd0e wd0e
72 cgd1 /dev/ld1e ld1e
73 EOF
74 cat <<EOF >expected
75 /dev/wd0e: m2eanddmykwEAWkJicHwd6SfSCPlwNWeCyV8YtKrBzI=
76 /dev/ld1e: rWluAhrJd+1fRFDcBowrhgR39+jArBBsQ3Gm7ejWT2Y=
77 EOF
78 atf_check -o file:expected cgdconfig -T -f cgd.conf
79 }
80
81 atf_test_case storedkey2a
82 storedkey2a_head()
83 {
84 atf_set descr "Test key generation with combined storedkeys"
85 }
86 storedkey2a_body()
87 {
88 cat <<EOF >params
89 algorithm adiantum;
90 iv-method encblkno1;
91 keylength 256;
92 verify_method none;
93 keygen storedkey key AAABAJtnmp3XZspMBAFpCYnB8Hekn0 \
94 gj5cDVngslfGLSqwcy;
95 keygen storedkey key AAABAK1pbgIayXftX0RQ3AaMK4YEd/ \
96 fowKwQbENxpu3o1k9m;
97 EOF
98 atf_check -o inline:'Ng70n82vvaFbRTnVj03b8aDov8slbMXySFTajzp9SFQ=\n' \
99 cgdconfig -t params
100 }
101
102 atf_test_case storedkey2b
103 storedkey2b_head()
104 {
105 atf_set descr "Test key generation with combined storedkeys, reversed"
106 }
107 storedkey2b_body()
108 {
109 cat <<EOF >params
110 algorithm adiantum;
111 iv-method encblkno1;
112 keylength 256;
113 verify_method none;
114 keygen storedkey key AAABAK1pbgIayXftX0RQ3AaMK4YEd/ \
115 fowKwQbENxpu3o1k9m;
116 keygen storedkey key AAABAJtnmp3XZspMBAFpCYnB8Hekn0 \
117 gj5cDVngslfGLSqwcy;
118 EOF
119 atf_check -o inline:'Ng70n82vvaFbRTnVj03b8aDov8slbMXySFTajzp9SFQ=\n' \
120 cgdconfig -t params
121 }
122
123 atf_init_test_cases()
124 {
125 atf_add_test_case storedkey
126 atf_add_test_case storedkey2a
127 atf_add_test_case storedkey2b
128 atf_add_test_case storedkeys
129 }
130