]>
git.scottworley.com Git - overonion/blob - overonion
271938c8d05e8de5ceab2a1562132493ccdd59de
9 die
"usage: overonion e|d keyfile"
12 if [[ "$mode" != e
&& "$mode" != d
]];then
13 die
"Use 'e' for encrypt or 'd' for decrypt"
16 if [[ ! -e "$keyfile" ]];then
17 die
"Keyfile not found"
19 if [[ ! -r "$keyfile" ]];then
20 die
"Cannot read keyfile"
23 num_layers
=$(wc -l < "$keyfile")
24 if (( num_layers
< 20 ));then
25 die
"Keyfile doesn't have enough layers to be an onion"
28 if [[ "$mode" == e
]];then
29 first_layer
=$num_layers
40 if (( layer
== 0 || layer
> num_layers
));then
43 operation
=$(sed -n "${layer}s/ .*//p" "$keyfile")
44 if [[ "$operation" == openssl
-enc ]];then
45 openssl enc
$openssl_decrypt "-$(sed -rn "${layer}s/[^ ]+ ([^ ]+) .*/\\1/p" "$keyfile")" \
46 -pass fd:37 37< <(sed -rn "${layer}s
/^
[^
]+ [^
]+ //p
" "$keyfile")
48 die "Unknown operation
"
50 go $(( layer + next_layer ))