overonion now does what "double-overonion" used to do.
Full keys are now one self-contained file.
+++ /dev/null
-#!/bin/bash
-
-if (( $# != 3));then
- echo "usage: double-overonion e|d keyfile1 keyfile2"
- exit 1
-fi
-mode=$1
-if [[ "$mode" != e && "$mode" != d ]];then
- echo "Use 'e' for encrypt or 'd' for decrypt"
- exit 1
-fi
-keyfile1=$2
-keyfile2=$3
-
-function oo() {
- "$(dirname "$0")/overonion" "$mode" "$@"
-}
-
-if [[ "$mode" == e ]];then
- oo "$keyfile2" | reverse | oo "$keyfile1"
-else
- oo "$keyfile1" | reverse | oo "$keyfile2"
-fi
if (( layer == 0 || layer > num_layers ));then
cat
else
if (( layer == 0 || layer > num_layers ));then
cat
else
- operation=$(sed -n "${layer}s/ .*//p" "$keyfile")
+ operation=$(sed -n "${layer}{;s/ .*//;p;}" "$keyfile")
if [[ "$operation" == openssl-enc ]];then
openssl enc $openssl_decrypt "-$(sed -rn "${layer}s/[^ ]+ ([^ ]+) .*/\\1/p" "$keyfile")" \
-pass fd:37 37< <(sed -rn "${layer}s/^[^ ]+ [^ ]+ //p" "$keyfile")
if [[ "$operation" == openssl-enc ]];then
openssl enc $openssl_decrypt "-$(sed -rn "${layer}s/[^ ]+ ([^ ]+) .*/\\1/p" "$keyfile")" \
-pass fd:37 37< <(sed -rn "${layer}s/^[^ ]+ [^ ]+ //p" "$keyfile")
+ elif [[ "$operation" == reverse ]];then
+ reverse
else
die "Unknown operation"
fi |
else
die "Unknown operation"
fi |
-i=0
-while read -r cipher;do
- echo -n $'\r'"Generating key $((++i))/${#ciphers[*]}" >&2
- cat >> "$keyfile" <<< "openssl-enc $cipher $(head -c 99 "$random_source" | base64 --wrap=0 )"
-done < <( IFS=$'\n'; shuf <<< "${ciphers[*]}"; )
-echo >&2
+keys_needed=$((${#ciphers[*]} * 2))
+keys_generated=0
+
+function generate_keys() {
+ while read -r cipher;do
+ echo -n $'\r'"Generating key $((++keys_generated))/$keys_needed" >&2
+ echo "openssl-enc $cipher $(head -c 99 "$random_source" | base64 --wrap=0 )"
+ done < <( IFS=$'\n'; shuf <<< "${ciphers[*]}"; )
+}
+
+{
+ generate_keys
+ echo "reverse"
+ generate_keys
+} > "$keyfile"
+
+echo 2>&1