]> git.scottworley.com Git - overonion/blame - overonion-make-key
Name key size
[overonion] / overonion-make-key
CommitLineData
c5ab018d
SW
1#!/bin/bash
2
61aa2da8
SW
3key_size=99
4
c5ab018d
SW
5ciphers=(
6 bf-cbc bf-cfb bf-ecb bf-ofb
7 cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb
8 des-cbc des-cfb des-ofb des-ecb
9 des-ede-cbc des-ede des-ede-cfb des-ede-ofb
10 des-ede3-cbc des-ede3 des-ede3-cfb des-ede3-ofb
11 idea-cbc idea-cfb idea-ecb idea-ofb
12 rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc2-64-cbc rc2-40-cbc
13 rc4 rc4-40
14 rc5-cbc rc5-cfb rc5-ecb rc5-ofb
15 aes-128-cbc aes-128-cfb aes-128-cfb1 aes-128-cfb8 aes-128-ecb aes-128-ofb
16 aes-192-cbc aes-192-cfb aes-192-cfb1 aes-192-cfb8 aes-192-ecb aes-192-ofb
17 aes-256-cbc aes-256-cfb aes-256-cfb1 aes-256-cfb8 aes-256-ecb aes-256-ofb
18)
19
20umask 077
21
b88d75ad
SW
22random_source="/dev/random"
23if [[ "$1" == '--make_INSECURE_key' ]];then
24 shift
25 random_source="/dev/urandom"
26fi
27
c5ab018d 28if (( $# != 1));then
291948a5 29 echo "usage: overonion-make-key keyfile" >&2
c5ab018d
SW
30 exit 1
31fi
32keyfile=$1
33if [[ -e "$keyfile" ]];then
291948a5 34 echo "That keyfile already exists. I refuse to overwrite it." >&2
c5ab018d
SW
35 exit 1
36fi
37
5ed90197
SW
38keys_needed=$((${#ciphers[*]} * 2))
39keys_generated=0
40
41function generate_keys() {
42 while read -r cipher;do
43 echo -n $'\r'"Generating key $((++keys_generated))/$keys_needed" >&2
61aa2da8 44 echo "openssl-enc $cipher $(head -c "$key_size" "$random_source" | base64 --wrap=0 )"
5ed90197
SW
45 done < <( IFS=$'\n'; shuf <<< "${ciphers[*]}"; )
46}
47
48{
49 generate_keys
50 echo "reverse"
51 generate_keys
52} > "$keyfile"
53
54echo 2>&1