]> git.scottworley.com Git - overonion/commitdiff
Fold reverse into overonion
authorScott Worley <scottworley@scottworley.com>
Sun, 22 Oct 2017 04:25:09 +0000 (21:25 -0700)
committerScott Worley <scottworley@scottworley.com>
Sun, 22 Oct 2017 04:29:06 +0000 (21:29 -0700)
overonion now does what "double-overonion" used to do.
Full keys are now one self-contained file.

double-overonion [deleted file]
overonion
overonion-make-key

diff --git a/double-overonion b/double-overonion
deleted file mode 100755 (executable)
index afd4ebb..0000000
+++ /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
index 271938c8d05e8de5ceab2a1562132493ccdd59de..c77ea94fbcfc699ca16bf789062a338c13decb21 100755 (executable)
--- a/overonion
+++ b/overonion
@@ -40,10 +40,12 @@ function go() {
   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 |
index ff094721f5e03a1a82418c48111c1419e701936a..7d0ff1ac6b69d9d61ef57c6ec594f1261e0174ce 100755 (executable)
@@ -33,9 +33,20 @@ if [[ -e "$keyfile" ]];then
   exit 1
 fi
 
   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