From 92b1278860746c4e7a1531e00412cda4763d33c6 Mon Sep 17 00:00:00 2001 From: David Hofmann <65802756+david-04@users.noreply.github.com> Date: Sat, 4 May 2024 15:41:02 +1000 Subject: [PATCH] Rename en/decrypt.sh to en/decrypt --- .gitignore | 4 ++-- .gpg2f/scripts/gpg2f.sh | 4 ++-- .gpg2f/scripts/pass-gpg-shim.sh | 11 ++++++----- CHANGELOG.md | 4 ++++ README.md | 34 ++++++++++++++++----------------- decrypt.sh => decrypt | 6 +++--- decrypt.bat | 2 +- encrypt.sh => encrypt | 6 +++--- encrypt.bat | 2 +- 9 files changed, 39 insertions(+), 34 deletions(-) rename decrypt.sh => decrypt (64%) rename encrypt.sh => encrypt (64%) diff --git a/.gitignore b/.gitignore index b7050db..599425e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,8 @@ !/.gitignore !/CHANGELOG.md !/decrypt.bat -!/decrypt.sh +!/decrypt !/encrypt.bat -!/encrypt.sh +!/encrypt !/LICENSE !/README.md diff --git a/.gpg2f/scripts/gpg2f.sh b/.gpg2f/scripts/gpg2f.sh index 9fc8edf..68c150e 100755 --- a/.gpg2f/scripts/gpg2f.sh +++ b/.gpg2f/scripts/gpg2f.sh @@ -63,8 +63,8 @@ function gpg2f_main() { function gpg2f_display_syntax_help() { echo "gpg2f - Symmetric multifactor-encryption with GnuPG" echo "" - echo "Syntax: encrypt.sh [--debug] [file]" - echo " or: decrypt.sh [--debug] [file]" + echo "Syntax: encrypt [--debug] [file]" + echo " or: decrypt [--debug] [file]" echo "" echo "Encrypt stdin to the given [file] or decrypt the given [file] to stdout." echo "If [file] is not given, encrypt to stdout or decrypt from stdin." diff --git a/.gpg2f/scripts/pass-gpg-shim.sh b/.gpg2f/scripts/pass-gpg-shim.sh index e24c2e4..85bef44 100755 --- a/.gpg2f/scripts/pass-gpg-shim.sh +++ b/.gpg2f/scripts/pass-gpg-shim.sh @@ -125,7 +125,7 @@ function gpg2f_passwordstore_shim_list_secret_keys_with_colons_and_fingerprint() #----------------------------------------------------------------------------------------------------------------------- function gpg2f_passwordstore_shim_encrypt() { - gpg2f_passwordstore_shim_encrypt_or_decrypt "encrypt.sh" "$1" + gpg2f_passwordstore_shim_encrypt_or_decrypt "encrypt" "$1" return $? } @@ -136,14 +136,14 @@ function gpg2f_passwordstore_shim_encrypt() { #----------------------------------------------------------------------------------------------------------------------- function gpg2f_passwordstore_shim_decrypt() { - gpg2f_passwordstore_shim_encrypt_or_decrypt "decrypt.sh" "$1" + gpg2f_passwordstore_shim_encrypt_or_decrypt "decrypt" "$1" return $? } #----------------------------------------------------------------------------------------------------------------------- # Encrypt or decrypt content #----------------------------------------------------------------------------------------------------------------------- -# $1 ... name of the script ("encrypt.sh" or "decrypt.sh") +# $1 ... name of the script ("encrypt" or "decrypt") # $2 ... input file (decrypt stdin if not set or an empty string) #----------------------------------------------------------------------------------------------------------------------- @@ -184,9 +184,10 @@ function gpg2f_passwordstore_shim_get_absolute_path() { } #----------------------------------------------------------------------------------------------------------------------- -# Locate the encrypt.sh script in the closest parent directory of the given file (or the current directory if not set) +# Locate the encrypt or decrypt script in the closest parent directory of the given file (or the current directory if +# not set) #----------------------------------------------------------------------------------------------------------------------- -# $1 ... name of the script ("encrypt.sh" or "decrypt.sh") +# $1 ... name of the script ("encrypt" or "decrypt") # $2 ... optional: absolute path of the file to encrypt or decrypt #----------------------------------------------------------------------------------------------------------------------- diff --git a/CHANGELOG.md b/CHANGELOG.md index ea75555..abaa2d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [1.0.3](https://github.com/david-04/gpg2f/releases/tag/v1.0.3) (2024-05-04) + +- Rename `encrypt.sh` and `decrypt.sh` to `encrypt` and `decrypt` + ## [1.0.2](https://github.com/david-04/gpg2f/releases/tag/v1.0.2) (2024-04-25) - Automatically include the `.env` file (if it exists in the root directory) diff --git a/README.md b/README.md index 82676f0..4449a5a 100644 --- a/README.md +++ b/README.md @@ -43,13 +43,13 @@ git clone --depth 1 https://github.com/david-04/gpg2f.git Upgrading to a newer release involves either downloading and extracting it over the previous installation or running `git pull` in the cloned repository. After extracting/cloning/updating the application, make the following scripts executable: ```shell -chmod +x decrypt.sh encrypt.sh `find .gpg2f -name '*.sh'` +chmod +x decrypt encrypt `find .gpg2f -name '*.sh'` ``` To verify that all required programs are installed and working, run the command below. When prompted for a password, enter `x` (a single lowercase letter). ```shell -echo "Hello world!" | ./encrypt.sh +echo "Hello world!" | ./encrypt ``` The command might abort with an error like this: @@ -61,7 +61,7 @@ gpg2: command not found By default, `gpg2f` uses the command `gpg2` to run the GNU Privacy Guard. If it's installed under a different name (e.g. `gpg`), open the `settings.sh` and update the `GPG2F_GPG_CMD` variable on top of the file. Then try to encrypt again: ```shell -echo "Hello world!" | ./encrypt.sh +echo "Hello world!" | ./encrypt ``` If everything works, the encrypted content is printed to the terminal: @@ -79,10 +79,10 @@ EsLm++P9gVghMSghGXDLsC7DI4M7fqjF5Y1wPdlLSTHaov0= Now verify, that encrypted content can also be decrypted again: ```shell -echo "Hello world!" | ./encrypt.sh | ./decrypt.sh +echo "Hello world!" | ./encrypt | ./decrypt ``` -This should print the original message `Helow world!` +This should print the original message `Hello world!` ## Configuration @@ -153,7 +153,7 @@ When encrypting (second variable), `gpg2f` will decrypt the static key and perfo Try to encrypt a message. This might prompt for the passphrase of `.keys/static-key.gpg` (unless it's already cached) and should then require a touch of the YubiKey: ```shell -echo "Hello world!" | ./encrypt.sh test.gpg +echo "Hello world!" | ./encrypt test.gpg ``` Verify that the content was encrypted correctly: @@ -177,7 +177,7 @@ jwkp+RaJEno6EQ9QVMAsTnG9frSVQn/YijjjHGsi4dGr13M= Unplug the YubiKey and verify that the locally stored backup of the HMAC secret key can be used to decrypt the file. This might again prompt for the passphrases of `.keys/static-key.gpg` and `.keys/hmac-secret-key.gpg`. ```shell -./decrypt.sh test.gpg +./decrypt test.gpg ``` This command should should produce the original `Hello world!` message. @@ -195,7 +195,7 @@ export GPG2F_DERIVE_ENCRYPTION_KEY_CMD=("${GPG2F_DERIVE_DECRYPTION_KEY_CMD[@]}") Verify that it works by en- and decrypting a message: ```shell -echo "Hello world!" | ./encrypt.sh | ./decrypt.sh +echo "Hello world!" | ./encrypt | ./decrypt ``` This might prompt for the passphrase of `.keys/static-key.gpg`. Both operations should also require a touch of the YubiKey. That is, the YubiKey needs to be touched twice to complete the full cycle. @@ -218,24 +218,24 @@ The duration is configured in seconds. For example, set it to `600` to cache pas ## Usage -Use `encrypt.sh` (or `encrypt.bat` on Windows) to encrypt content. The plain text is always read from `stdin`. The encrypted content can be written to either `stdout` or a file: +Use `encrypt` (or `encrypt.bat` on Windows) to encrypt content. The plain text is always read from `stdin`. The encrypted content can be written to either `stdout` or a file: ```shell # Encrypt stdin to stdout -echo "Hello world!" | ./encrypt.sh +echo "Hello world!" | ./encrypt # Encrypt stdin to a file -echo "Hello world!" | ./encrypt.sh my-file.gpg +echo "Hello world!" | ./encrypt my-file.gpg ``` -Use `decrypt.sh` (or `decrypt.bat` on Windows) to decrypt content. The encrypted content can be read from `stdin` or a file and the plain text is always written to `stdout`: +Use `decrypt` (or `decrypt.bat` on Windows) to decrypt content. The encrypted content can be read from `stdin` or a file and the plain text is always written to `stdout`: ```shell # Decrypt a file to stdou -./decrypt.sh my-file.gpg +./decrypt my-file.gpg # Decrypt stdin to stdou -cat ./my-file.gpg | ./decrypt.sh +cat ./my-file.gpg | ./decrypt ``` Both commands need to be run from the application's root directory. They can't be invoked from a different directory. @@ -243,7 +243,7 @@ Both commands need to be run from the application's root directory. They can't b The commands can also be called with the `--debug` option. This causes `gpg2f` to print diagnostic information for trouble-shooting: ```shell -echo "Hello world!" | ./encrypt.sh --debug | ./decrypt.sh --debug +echo "Hello world!" | ./encrypt --debug | ./decrypt --debug ``` Please note that this will not only display derived keys (that are specific to the seed) but also the decrypted static key. It is recommended to create and use temporary keys when trouble-shooting configuration issues. @@ -262,9 +262,9 @@ gpg2f +-- [...] <= custom directories for encrypted files | +-- decrypt.bat <= commands to encrypt or decrypt -+-- decrypt.sh ++-- decrypt +-- encrypt.bat -+-- encrypt.sh ++-- encrypt | +-- settings.sh <= configure keys and factors to use diff --git a/decrypt.sh b/decrypt similarity index 64% rename from decrypt.sh rename to decrypt index f65a80e..d8aae54 100755 --- a/decrypt.sh +++ b/decrypt @@ -1,10 +1,10 @@ #!/usr/bin/env bash # shellcheck disable=SC2317 -[[ "$1" == "decrypt.sh" ]] && shift +[[ "$1" == "decrypt" ]] && shift -if [[ ! -f "decrypt.sh" ]]; then - echo "ERROR: decrypt.sh can only be invoked in its own directory (current working directory: $(pwd))" >&2 +if [[ ! -f "./decrypt" ]]; then + echo "ERROR: decrypt can only be invoked in its own directory (current working directory: $(pwd))" >&2 return 1 2>/dev/null || exit 1 elif [[ ! -f ".gpg2f/scripts/gpg2f.sh" ]]; then echo "ERROR: $(pwd)/.gpg2f/scripts/gpg2f.sh does not exist" >&2 diff --git a/decrypt.bat b/decrypt.bat index b133976..d4b2555 100644 --- a/decrypt.bat +++ b/decrypt.bat @@ -1,3 +1,3 @@ @echo off set GPG2F_DECRYPT_DIRECTORY=%~dp0 -env %GPG2F_DECRYPT_DIRECTORY:\=/%decrypt.sh %* +env %GPG2F_DECRYPT_DIRECTORY:\=/%decrypt %* diff --git a/encrypt.sh b/encrypt similarity index 64% rename from encrypt.sh rename to encrypt index 09a8082..d8eeb35 100755 --- a/encrypt.sh +++ b/encrypt @@ -1,10 +1,10 @@ #!/usr/bin/env bash # shellcheck disable=SC2317 -[[ "$1" == "encrypt.sh" ]] && shift +[[ "$1" == "encrypt" ]] && shift -if [[ ! -f "encrypt.sh" ]]; then - echo "ERROR: encrypt.sh can only be invoked in its own directory (current working directory: $(pwd))" >&2 +if [[ ! -f "./encrypt" ]]; then + echo "ERROR: encrypt can only be invoked in its own directory (current working directory: $(pwd))" >&2 return 1 2>/dev/null || exit 1 elif [[ ! -f ".gpg2f/scripts/gpg2f.sh" ]]; then echo "ERROR: $(pwd)/.gpg2f/scripts/gpg2f.sh does not exist" >&2 diff --git a/encrypt.bat b/encrypt.bat index 791771e..3cc0236 100644 --- a/encrypt.bat +++ b/encrypt.bat @@ -1,3 +1,3 @@ @echo off set GPG2F_ENCRYPT_DIRECTORY=%~dp0 -env %GPG2F_ENCRYPT_DIRECTORY:\=/%encrypt.sh %* +env %GPG2F_ENCRYPT_DIRECTORY:\=/%encrypt %*