From: Scott Worley Date: Sun, 22 Oct 2017 04:25:09 +0000 (-0700) Subject: Fold reverse into overonion X-Git-Url: http://git.scottworley.com/overonion/commitdiff_plain/5ed90197acc28a11c20c9e901201c49f3272d77d Fold reverse into overonion overonion now does what "double-overonion" used to do. Full keys are now one self-contained file. --- diff --git a/double-overonion b/double-overonion deleted file mode 100755 index afd4ebb..0000000 --- a/double-overonion +++ /dev/null @@ -1,23 +0,0 @@ -#!/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 diff --git a/overonion b/overonion index 271938c..c77ea94 100755 --- a/overonion +++ b/overonion @@ -40,10 +40,12 @@ function go() { 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") + elif [[ "$operation" == reverse ]];then + reverse else die "Unknown operation" fi | diff --git a/overonion-make-key b/overonion-make-key index ff09472..7d0ff1a 100755 --- a/overonion-make-key +++ b/overonion-make-key @@ -33,9 +33,20 @@ if [[ -e "$keyfile" ]];then exit 1 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