Created
September 8, 2020 12:52
-
-
Save agail/8f7ca4ea1b6fe82780c3f28c8880345b to your computer and use it in GitHub Desktop.
Fixed decryption + some spelling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- keepout.sh.txt 2020-09-08 13:08:33.124744273 +0200 | |
+++ keepout.sh 2020-09-08 14:12:39.126369975 +0200 | |
@@ -112,7 +112,7 @@ | |
# -salt | |
# __DATA__ | |
# | |
-# Encryption defaults used by "keepout" (file magic, cypher, hashing digest, | |
+# Encryption defaults used by "keepout" (file magic, cipher, hashing digest | |
# and pbkdf2 iteration count) can only be set inside the script, at this time. | |
# Change these will not effect the scripts ability to decrypt existing | |
# 'keepout' files. The order of the options does not matter. | |
@@ -146,7 +146,7 @@ | |
# -nosalt | |
# __DATA__ | |
# | |
-# A special cypher of -none can also be used to convert unencrypted file into | |
+# A special cipher of -none can also be used to convert unencrypted file into | |
# a 'keepout' file. All other encryption settings options are ignored. This | |
# can be useful in some special circumstances, like reading an initial file | |
# using keepout, to later saved it with the keepout's current default | |
@@ -182,7 +182,7 @@ | |
# use "keepout" for file encryption. Specifically my "ks" script. | |
# | |
# Latest version can be downloaded from | |
-# https://antofthy.gitlab.io/softwre/#keepout | |
+# https://antofthy.gitlab.io/software/#keepout | |
# | |
# ---------------------------------------------------------------------------- | |
# Encryption Options.... | |
@@ -190,7 +190,7 @@ | |
# OpenSSL version needed by this script and for these options | |
openssl_need='1.1.1' | |
-# Encryption Cypher and Digest | |
+# Encryption Cipher and Digest | |
filemagic='KeepOut' # Must be 7 characters, a newline is added on output. | |
cipher='aes-256-cbc' # Cipher to encrypt with, checked below | |
digest='sha512' # Digest to hash password, checked below | |
@@ -206,7 +206,7 @@ | |
min_iteration=100000 # Decrypt warning if iteration count is less than this! | |
key_timeout=1800 # How long (secs) to cache password for (for file editing). | |
-# Other "openssl" options for Encrypting (do not set '-iter' here ) | |
+# Other "openssl" options for Encrypting (do not set '-iter' here) | |
# These are not actually required (-salt is default, and -iter enabled -pbkdf2) | |
# but it is recommended that thay be included to make the option use clear. | |
options=( -salt -pbkdf2 ) | |
@@ -288,21 +288,21 @@ | |
while [ $# -gt 0 ]; do | |
case "$1" in | |
- -\?|-help|--help) Help ;; # Basic help | |
- -doc|--doc) Doc ;; # The whole manual | |
+ -\?|-help|--help) Help ;; # Basic help | |
+ -doc|--doc) Doc ;; # The whole manual | |
-d|--decrypt) DECRYPT=true ;; | |
- -key|--key) shift; KEY="$1" ;; # password caching key | |
- -clear|--clear) CLEAR=true ;; # clear the key from cache | |
- -pass|--pass) shift; PASS="$1" ;; # openssl password method (no cache) | |
+ -key|--key) shift; KEY="$1" ;; # password caching key | |
+ -clear|--clear) CLEAR=true ;; # clear the key from cache | |
+ -pass|--pass) shift; PASS="$1" ;; # openssl password method (no cache) | |
- --) shift; break ;; # forced end of user options | |
+ --) shift; break ;; # forced end of user options | |
-*) Usage "Unknown option \"$1\"" ;; | |
- *) break ;; # unforced end of user options | |
+ *) break ;; # unforced end of user options | |
esac | |
- shift # next option | |
+ shift # next option | |
done | |
(( $# > 0 )) && Usage "Too Many Arguments" | |
@@ -390,8 +390,10 @@ | |
[a-z][a-z0-9-]*) ;; # it is a posible digest | |
*) Error "Invalid digest argument in input file" ;; | |
esac | |
- if openssl dgst -list | sed '1d; s/ *$//; s/ */\n/g;' | | |
- grep -q "^-$value$" | |
+ #if openssl dgst -list | sed '1d; s/ *$//; s/ */\n/g;' | * remark: invalid syntax | |
+ # grep -q "^-$value$" * remark: invalid regex ^-$ | |
+ if openssl list -digest-commands | sed '1d; s/ *$//; s/ */\n/g;' | | |
+ grep -q "^$value$" | |
then options=( "${options[@]}" "$option" "$value" ) | |
else Error "Unknown digest argument used in input file" | |
fi | |
@@ -400,7 +402,7 @@ | |
# This could be the cipher to use (or an invalid option) | |
case "$option" in | |
*[^a-z0-9-]*) # option should be lower case, numbers or dashes | |
- Error "Unknwon option in input file header" ;; | |
+ Error "Unknown option in input file header" ;; | |
esac | |
if openssl enc -ciphers | sed '1d; s/ *$//; s/ */\n/g;' | | |
grep -q "^$option$" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment