-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaes-keygen.sh
More file actions
executable file
·44 lines (32 loc) · 1.04 KB
/
aes-keygen.sh
File metadata and controls
executable file
·44 lines (32 loc) · 1.04 KB
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
#!/bin/bash -e
apiToken=**COPY API TOKEN**
outFile=outfile.csv
keySize=32
ivSize=16
testKeys=1
let totSize=$keySize+$ivSize
curl "https://api-eus.qrypt.com/api/v1/quantum-entropy?size=100" \
-H "accept: application/json" \
-H "Authorization: Bearer $apiToken" \
| jq --raw-output -j '.random[]' \
| base64 --decode \
> tmp.qrand
#for OSX, len=$(stat -f %z tmp.qrand)
len=$(stat -c %s tmp.qrand)
echo "KEY, IV" > $outFile
for (( i=0; i<len/totSize; i++ ));
do
let keyOffset=$totSize*i
let ivOffset=$totSize*i+$keySize
aeskey="$(xxd -c 1000000 -ps -s $keyOffset -l $keySize)"
aesiv="$(xxd -c 1000000 -ps -s $ivOffset -l $ivSize)"
echo "$aeskey, $aesiv" >> $outFile
#test keys
if [ $testKeys ]; then
echo 'test data' > plaintext.txt
openssl enc -nosalt -e -aes-256-cbc -iv $aesiv -K $aeskey -in plaintext.txt -out ciphertext.txt
openssl enc -nosalt -d -aes-256-cbc -iv $aesiv -K $aeskey -in ciphertext.txt > /dev/null
fi
done < tmp.qrand
rm tmp.qrand
echo 'success!'