-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest_compatibility.sh
executable file
·164 lines (133 loc) · 4.67 KB
/
test_compatibility.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash
make -C ref-hrss701 {test/keypair,test/encap,test/decap}
make -C avx2-hrss701 {test/keypair,test/encap,test/decap}
PKBYTES=1138
SKBYTES=1450
KEYBYTES=32
BYTES=1138
keyfile=$(mktemp)
ciphertextandkey=$(mktemp)
ciphertext=$(mktemp)
key=$(mktemp)
for keygen in {"ref-hrss701","avx2-hrss701"}; do
for encap in {"ref-hrss701","avx2-hrss701"}; do
for decap in {"ref-hrss701","avx2-hrss701"}; do
echo -n "Testing with keygen: ${keygen}, encap: ${encap}, decap: ${decap}.. "
${keygen}/test/keypair > ${keyfile}
head -c ${PKBYTES} ${keyfile} | ${encap}/test/encap > ${ciphertextandkey}
head -c ${BYTES} ${ciphertextandkey} > ${ciphertext}
tail -c ${SKBYTES} ${keyfile} | cat - ${ciphertext} | ${decap}/test/decap > ${key}
k1sum=$(tail -c ${KEYBYTES} ${ciphertextandkey} | md5sum | cut -f 1 -d' ')
k2sum=$(md5sum ${key} | cut -f 1 -d' ')
if [ ${k1sum} == ${k2sum} ]
then
echo "succeeded!"
else
echo "failed!"
fi
done
done
done
rm ${keyfile}
rm ${ciphertextandkey}
rm ${ciphertext}
rm ${key}
make -C ref-hps2048509 {test/keypair,test/encap,test/decap}
make -C avx2-hps2048509 {test/keypair,test/encap,test/decap}
PKBYTES=699
SKBYTES=935
KEYBYTES=32
BYTES=699
keyfile=$(mktemp)
ciphertextandkey=$(mktemp)
ciphertext=$(mktemp)
key=$(mktemp)
for keygen in {"ref-hps2048509","avx2-hps2048509"}; do
for encap in {"ref-hps2048509","avx2-hps2048509"}; do
for decap in {"ref-hps2048509","avx2-hps2048509"}; do
echo -n "Testing with keygen: ${keygen}, encap: ${encap}, decap: ${decap}.. "
${keygen}/test/keypair > ${keyfile}
head -c ${PKBYTES} ${keyfile} | ${encap}/test/encap > ${ciphertextandkey}
head -c ${BYTES} ${ciphertextandkey} > ${ciphertext}
tail -c ${SKBYTES} ${keyfile} | cat - ${ciphertext} | ${decap}/test/decap > ${key}
k1sum=$(tail -c ${KEYBYTES} ${ciphertextandkey} | md5sum | cut -f 1 -d' ')
k2sum=$(md5sum ${key} | cut -f 1 -d' ')
if [ ${k1sum} == ${k2sum} ]
then
echo "succeeded!"
else
echo "failed!"
fi
done
done
done
rm ${keyfile}
rm ${ciphertextandkey}
rm ${ciphertext}
rm ${key}
make -C ref-hps2048677 {test/keypair,test/encap,test/decap}
make -C avx2-hps2048677 {test/keypair,test/encap,test/decap}
PKBYTES=930
SKBYTES=1234
KEYBYTES=32
BYTES=930
keyfile=$(mktemp)
ciphertextandkey=$(mktemp)
ciphertext=$(mktemp)
key=$(mktemp)
for keygen in {"ref-hps2048677","avx2-hps2048677"}; do
for encap in {"ref-hps2048677","avx2-hps2048677"}; do
for decap in {"ref-hps2048677","avx2-hps2048677"}; do
echo -n "Testing with keygen: ${keygen}, encap: ${encap}, decap: ${decap}.. "
${keygen}/test/keypair > ${keyfile}
head -c ${PKBYTES} ${keyfile} | ${encap}/test/encap > ${ciphertextandkey}
head -c ${BYTES} ${ciphertextandkey} > ${ciphertext}
tail -c ${SKBYTES} ${keyfile} | cat - ${ciphertext} | ${decap}/test/decap > ${key}
k1sum=$(tail -c ${KEYBYTES} ${ciphertextandkey} | md5sum | cut -f 1 -d' ')
k2sum=$(md5sum ${key} | cut -f 1 -d' ')
if [ ${k1sum} == ${k2sum} ]
then
echo "succeeded!"
else
echo "failed!"
fi
done
done
done
rm ${keyfile}
rm ${ciphertextandkey}
rm ${ciphertext}
rm ${key}
make -C ref-hps4096821 {test/keypair,test/encap,test/decap}
make -C avx2-hps4096821 {test/keypair,test/encap,test/decap}
PKBYTES=1230
SKBYTES=1590
KEYBYTES=32
BYTES=1230
keyfile=$(mktemp)
ciphertextandkey=$(mktemp)
ciphertext=$(mktemp)
key=$(mktemp)
for keygen in {"ref-hps4096821","avx2-hps4096821"}; do
for encap in {"ref-hps4096821","avx2-hps4096821"}; do
for decap in {"ref-hps4096821","avx2-hps4096821"}; do
echo -n "Testing with keygen: ${keygen}, encap: ${encap}, decap: ${decap}.. "
${keygen}/test/keypair > ${keyfile}
head -c ${PKBYTES} ${keyfile} | ${encap}/test/encap > ${ciphertextandkey}
head -c ${BYTES} ${ciphertextandkey} > ${ciphertext}
tail -c ${SKBYTES} ${keyfile} | cat - ${ciphertext} | ${decap}/test/decap > ${key}
k1sum=$(tail -c ${KEYBYTES} ${ciphertextandkey} | md5sum | cut -f 1 -d' ')
k2sum=$(md5sum ${key} | cut -f 1 -d' ')
if [ ${k1sum} == ${k2sum} ]
then
echo "succeeded!"
else
echo "failed!"
fi
done
done
done
rm ${keyfile}
rm ${ciphertextandkey}
rm ${ciphertext}
rm ${key}