-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaestest.sh
executable file
·46 lines (38 loc) · 1.64 KB
/
aestest.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
#!/usr/bin/env bash
password='I X@X@ Nickelback <3'
plaintext="Hello World"
plaintext_filename="plain.txt"
if [ ! -e "${plaintext_filename}" ]; then
echo -n "Hello World" > $plaintext_filename
fi
if [ -x ./target/release/aes-256-cbc ]; then
bin="./target/release/aes-256-cbc";
else
bin="./target/debug/aes-256-cbc";
fi
#auth=--key-filename "${key_filename}"
#auth=--password "${password}"
set -e
for i in $(seq 10); do
export key_filename="key${i}.yaml";
export cyphertext_filename="cyphertext${i}.yaml";
${bin} generate --key-filename "${key_filename}" --password "${password}";
done
for i in $(seq 10); do
export key_filename="key${i}.yaml";
export cyphertext_filename="cyphertext${i}.aes";
${bin} encrypt --key-filename "${key_filename}" --input-filename "${plaintext_filename}" --output-filename "${cyphertext_filename}"
${bin} decrypt --key-filename "${key_filename}" --input-filename "${cyphertext_filename}" --output-filename "${plaintext_filename}"
test "$(cat $plaintext_filename)" == "${plaintext}"
done
# every key should decrypt every file since the key is derived
for i in $(seq 10); do
for j in $(seq 10); do
export key_filename="key${j}.yaml";
export cyphertext_filename="cyphertext${i}.aes";
echo "${key_filename}: ${cyphertext_filename}"
${bin} decrypt --key-filename "${key_filename}" --input-filename "${cyphertext_filename}" --output-filename "${plaintext_filename}"
${bin} decrypt --password "${password}" --input-filename "${cyphertext_filename}" --output-filename "${plaintext_filename}"
test "$(cat $plaintext_filename)" == "${plaintext}"
done
done