Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working towards Transcrypt version 3 with support for PBKDF2 key-derivation #162

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
727fe60
Switch version to 3.0.0-alpha1
jmurty Apr 1, 2023
48139c6
Update copyright notices
jmurty Apr 1, 2023
3b62803
Define magic salted prefix values (plaintext and B64) as constants
jmurty Apr 1, 2023
3b303f2
Centralise loading of transcrypt config settings and conversion into …
jmurty Apr 1, 2023
4dbd3c2
Add code comment documentation
jmurty Apr 1, 2023
f15a08a
Add support for setting and using new arguments for PBKDF2: --kdf --d…
jmurty Apr 2, 2023
4122237
Make file encryption logic reusable
jmurty Apr 2, 2023
ec4bc96
At init, generate project salt for PBKDF2 file encryption as a passwo…
jmurty Apr 2, 2023
e99f2f4
Don't prompt user to enable key-derivation function when they specifi…
jmurty Apr 2, 2023
a93b01d
Update tests to separate those that will be specific to non-KDF (lega…
jmurty Apr 2, 2023
baa4703
Include kdf settings in configuration display
jmurty Apr 2, 2023
e358b80
Fix tests following tweaks to display of configuration
jmurty Apr 2, 2023
034786a
Keep "_" separator character for iteration count for config and displ…
jmurty Apr 3, 2023
04603d0
Remove last remaining hard-coded use of outdated md5 hash algorithm, …
jmurty Apr 3, 2023
226db82
Validate digest, kdf, and iterations configuration settings
jmurty Apr 3, 2023
51a08e8
Rekey example sensitive_file to use PBKDF2
jmurty Apr 3, 2023
57f8fdd
Ubuntu 18.04 is no longer supported for GitHub Workflow tests
jmurty Apr 3, 2023
835c993
Merge branch 'main' into towards-version-3
jmurty Jul 16, 2023
a37d016
Abandon bad idea to derive project salt from password for KDF, use ra…
jmurty Jul 16, 2023
2dafed1
Include KDF information in interactive feedback for confirming config…
jmurty Jul 16, 2023
669dc57
Reduce default iteration count for PBKDF2 from 1 million to 256k, whi…
jmurty Jul 16, 2023
8008363
Rekey example sensitive file to use project salt and 256k iterations …
jmurty Jul 16, 2023
4f48214
Fix the few PBDKF2 tests to work for the new project salt approach
jmurty Jul 16, 2023
dd02ca4
Don't prompt user about which KDF to use since we only support "pbkdf…
jmurty Jul 16, 2023
0497f61
Fix lint warning causing build failure
jmurty Jul 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2014-2019, Aaron Bull Schaefer <aaron@elasticdog.com>
Copyright (c) 2020-2023, James Murty <james@murty.co>
Copyright (c) 2014-2020, Aaron Bull Schaefer <aaron@elasticdog.com>
Copyright (c) 2011, Woody Gilk <woody.gilk@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,26 @@ repository. The owner of the origin repository can dump the credentials for you
by running the `--display` command line option:

$ transcrypt --display
The current repository was configured using transcrypt v0.2.0

The current repository was configured using transcrypt version 3.0.0-alpha1
and has the following configuration:

CONTEXT: default
CIPHER: aes-256-cbc
PASSWORD: correct horse battery staple
GIT_WORK_TREE: transcrypt
GIT_DIR: transcrypt/.git
GIT_ATTRIBUTES: transcrypt/.gitattributes

CONTEXT: default
CIPHER: aes-256-cbc
DIGEST: sha512
KDF: pbkdf2
ITERATIONS: 256_000
PROJECT SALT: 5J0QY8uOTe7/B9eYSJ2kOy91
PASSWORD: correct horse battery staple

Copy and paste the following command to initialize a cloned repository:

transcrypt -c aes-256-cbc -p 'correct horse battery staple'
transcrypt -c aes-256-cbc -md sha512 -k pbkdf2 -n 256_000 \
-ps 5J0QY8uOTe7/B9eYSJ2kOy91 -p 'correct horse battery staple'

Once transcrypt has stored the matching credentials, it will force a checkout of
any exising encrypted files in order to decrypt them.
Expand Down Expand Up @@ -200,6 +210,25 @@ directory.
the symmetric cipher to utilize for encryption;
defaults to aes-256-cbc

-md, --digest=DIGEST
the message digest used to hash the salted password;
defaults to sha512
Use md5 for compatibility with transcrypt versions < 3

-k, --kdf=KEY_DERIVATION_FUNCTION
a key-derivation function to use for strongest encryption;
defaults to pbkdf2
If enabled, all users will need Transcrypt 3+ and modern OpenSSL

-n, --iter=ITERATIONS
when using a key-derivation function, its number of iterations;
defaults to 256_000

-ps, --salt=PROJECT_SALT
when using a key-derivation function, an extra value to
strengthen per-file salt values;
defaults to 18 random base64 characters

-p, --password=PASSWORD
the password to derive the key from;
defaults to 30 random base64 characters
Expand Down Expand Up @@ -344,6 +373,7 @@ to encrypt a file \_top-secret* in a "super" context:
transcrypt is provided under the terms of the
[MIT License](https://en.wikipedia.org/wiki/MIT_License).

Copyright &copy; 2020-2023, [James Murty](mailto:james@murty.co).
Copyright &copy; 2014-2020, [Aaron Bull Schaefer](mailto:aaron@elasticdog.com).

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion contrib/packaging/pacman/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Maintainer: Aaron Bull Schaefer <aaron@elasticdog.com>
pkgname=transcrypt
pkgver=2.3.0-pre
pkgver=3.0.0-alpha1
pkgrel=1
pkgdesc='A script to configure transparent encryption of files within a Git repository'
arch=('any')
Expand Down
80 changes: 40 additions & 40 deletions sensitive_file
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
U2FsdGVkX1//6vyAEUROfUrBgZuXaA15WddyGnu4qyMwDAzBjDpLwEqdK+lGuahk
zcurTKIJ36gmdZSd5f2928EQaHGdusIRGzjWfWQ720UUTYzERPuJxGVQSXZIA7a4
o7t2LdFOloWw5g3SRWn+cPBt8lvLkuVuA4x+B4MuzBR0qq7qsk5Qvywfuk2In4Fh
gWMWnUFDpdO/dUPefgZ1okXwWmb2bna7hr7j7Q1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jCSctLEk/VP/h9nIn
HrYLxxbsg3vYBiLC0b4aVSCYFyEP/0v5Wp6X+DD/iQvWZ3VwwHQ/GcFIoKtsXmJo
y2A4/x706PLqIr05DjSaaerTelfqXexF5uOkpRzwIDA7Ox1ivHD1mYnstEian7aF
QF2KI0pYhG3qOEEdti+TNQDyMPzSFKOtnSuwiKL7nGsI7+8FDIdMlnQZ5z/mDX9Q
Jg7FgawPAeJ07JXI68/FutkSIXxbVazh7gYyIvLZFXpMUe5g8N2v4msTZin9Y4XT
5VrhmzSk+4OA8PkK2rnkAI99r05WLnCZ3UGKu4Vsq4sY7Z+gwfepoMy7eJOZPxzN
QAundOnNVFI4uCTBDCoAHtJVRmHXu8e/XBjUYlLHcnISxM2nuyvi4H+pZ96Gg4PJ
vAiYuTdsI7GSo+G0Ha0xVIXsH/WJH+YV2uzkIzNecbJUIFkh9C05T7TT1EHGZCyU
suZO0FLlN/qTFuZFfeqBFRhnCfgKLPlGAJ+GmCQnKxbY8R3YUzGU5FOVPW9vykfS
GsaN2D2yI3S3YjuOOIpjHA==
21 changes: 16 additions & 5 deletions tests/_test_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ function cleanup_all {
rm -f "$BATS_TEST_DIRNAME"/sensitive_file
}

function init_transcrypt {
"$BATS_TEST_DIRNAME"/../transcrypt --cipher=aes-256-cbc --password='abc 123' --yes
}

function encrypt_named_file {
filename="$1"
content=$2
Expand All @@ -59,10 +55,25 @@ function encrypt_named_file {
run git commit -m "Encrypt file \"$filename\""
}

function init_transcrypt_no_kdf {
"$BATS_TEST_DIRNAME"/../transcrypt --cipher=aes-256-cbc --password='abc 123' --yes
}

function init_transcrypt {
"$BATS_TEST_DIRNAME"/../transcrypt --cipher=aes-256-cbc --digest sha512 --kdf pbkdf2 --iter 99 --salt 5J0Q --password='abc 123' --yes
}

function setup {
pushd "$BATS_TEST_DIRNAME" || exit 1
init_git_repo
if [[ ! "$SETUP_SKIP_INIT_TRANSCRYPT" ]]; then

if [[ "$SETUP_SKIP_INIT_TRANSCRYPT" ]]; then
return
fi

if [[ "$SETUP_INIT_TRANSCRYPT_NO_KDF" ]]; then
init_transcrypt_no_kdf
else
init_transcrypt
fi
}
Expand Down
11 changes: 10 additions & 1 deletion tests/test_cleanup.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
load "$BATS_TEST_DIRNAME/_test_helper.bash"

SECRET_CONTENT="My secret content"
SECRET_CONTENT_ENC="U2FsdGVkX1/6ilR0PmJpAyCF7iG3+k4aBwbgVd48WaQXznsg42nXbQrlWsf/qiCg"

# Example generation:
# - Using project salt: 5J0Q
# - Generate file key
# openssl dgst -hmac "sensitive_file:5J0Q" -sha256 sensitive_file | tr -d '\r\n' | tail -c16
# => ec32c0fbf2261d18
# - Encrypt file
# cat sensitive_file | ENC_PASS='abc 123' openssl enc -e -a -aes-256-cbc -md sha512 -pass env:ENC_PASS -pbkdf2 -iter 99 -S ec32c0fbf2261d18
# => U2FsdGVkX1+NiURgsIjgkwyiBw0TSC8WhhDRly2h4x2exuwjay6y/nOahblrBL62
SECRET_CONTENT_ENC="U2FsdGVkX1+NiURgsIjgkwyiBw0TSC8WhhDRly2h4x2exuwjay6y/nOahblrBL62"

@test "cleanup: transcrypt -f flush clears cached plaintext" {
encrypt_named_file sensitive_file "$SECRET_CONTENT"
Expand Down
8 changes: 4 additions & 4 deletions tests/test_contexts.bats → tests/test_contexts_no_kdf.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SUPER_SECRET_CONTENT_ENC="U2FsdGVkX1+dAkIV/LAKXMmqjDNOGoOVK8Rmhw9tUnbR4dwBDglpkX
function setup {
pushd "$BATS_TEST_DIRNAME" || exit 1
init_git_repo
init_transcrypt
init_transcrypt_no_kdf

# Init transcrypt with 'super-secret' context
"$BATS_TEST_DIRNAME"/../transcrypt --context=super-secret --cipher=aes-256-cbc --password=321cba --yes
Expand Down Expand Up @@ -86,9 +86,9 @@ function teardown {
[ "$status" -eq 0 ]
[ "${lines[0]}" = "The current repository was configured using transcrypt version $VERSION" ]
[ "${lines[1]}" = "and has the following configuration for context 'super-secret':" ]
[ "${lines[5]}" = " CONTEXT: super-secret" ]
[ "${lines[6]}" = " CIPHER: aes-256-cbc" ]
[ "${lines[7]}" = " PASSWORD: 321cba" ]
[ "${lines[5]}" = " CONTEXT: super-secret" ]
[ "${lines[6]}" = " CIPHER: aes-256-cbc" ]
[ "${lines[7]}" = " PASSWORD: 321cba" ]
[ "${lines[8]}" = "The repository has 2 contexts: default super-secret" ]
[ "${lines[9]}" = "Copy and paste the following command to initialize a cloned repository for context 'super-secret':" ]
[ "${lines[10]}" = " transcrypt -C super-secret -c aes-256-cbc -p '321cba'" ]
Expand Down
3 changes: 3 additions & 0 deletions tests/test_crypt.bats → tests/test_crypt_no_kdf.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

load "$BATS_TEST_DIRNAME/_test_helper.bash"

# Custom setup: use no-KDF init transcrypt
SETUP_INIT_TRANSCRYPT_NO_KDF=1

SECRET_CONTENT="My secret content"
SECRET_CONTENT_ENC="U2FsdGVkX1/6ilR0PmJpAyCF7iG3+k4aBwbgVd48WaQXznsg42nXbQrlWsf/qiCg"

Expand Down
34 changes: 17 additions & 17 deletions tests/test_init.bats → tests/test_init_no_kdf.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ SETUP_SKIP_INIT_TRANSCRYPT=1
}

@test "init: creates .gitattributes" {
init_transcrypt
init_transcrypt_no_kdf
[ -f .gitattributes ]
run cat .gitattributes
[ "${lines[0]}" = "#pattern filter=crypt diff=crypt merge=crypt" ]
}

@test "init: creates scripts in .git/crypt/" {
init_transcrypt
init_transcrypt_no_kdf
[ -d .git/crypt ]
[ -f .git/crypt/transcrypt ]
}

@test "init: applies git config" {
init_transcrypt
init_transcrypt_no_kdf
VERSION=$(../transcrypt -v | awk '{print $2}')

[ "$(git config --get transcrypt.version)" = "$VERSION" ]
Expand All @@ -53,48 +53,48 @@ SETUP_SKIP_INIT_TRANSCRYPT=1
}

@test "init: show details for --display" {
init_transcrypt
init_transcrypt_no_kdf
VERSION=$(../transcrypt -v | awk '{print $2}')

run ../transcrypt --display
[ "$status" -eq 0 ]
[[ "${output}" = *"The current repository was configured using transcrypt version $VERSION"* ]]
[[ "${output}" = *" CIPHER: aes-256-cbc"* ]]
[[ "${output}" = *" PASSWORD: abc 123"* ]]
[[ "${output}" = *" CIPHER: aes-256-cbc"* ]]
[[ "${output}" = *" PASSWORD: abc 123"* ]]
[[ "${output}" = *" transcrypt -c aes-256-cbc -p 'abc 123'"* ]]
}

@test "init: show details for -d" {
init_transcrypt
init_transcrypt_no_kdf
VERSION=$(../transcrypt -v | awk '{print $2}')

run ../transcrypt -d
[ "$status" -eq 0 ]
[[ "${output}" = *"The current repository was configured using transcrypt version $VERSION"* ]]
[[ "${output}" = *" CIPHER: aes-256-cbc"* ]]
[[ "${output}" = *" PASSWORD: abc 123"* ]]
[[ "${output}" = *" CIPHER: aes-256-cbc"* ]]
[[ "${output}" = *" PASSWORD: abc 123"* ]]
[[ "${output}" = *" transcrypt -c aes-256-cbc -p 'abc 123'"* ]]
}

@test "init: respects core.hooksPath setting" {
git config core.hooksPath ".git/myhooks"
[ "$(git config --get core.hooksPath)" = '.git/myhooks' ]

init_transcrypt
init_transcrypt_no_kdf
[ -d .git/myhooks ]
[ -f .git/myhooks/pre-commit ]

VERSION=$(../transcrypt -v | awk '{print $2}')
run ../transcrypt --display
[ "$status" -eq 0 ]
[[ "${output}" = *"The current repository was configured using transcrypt version $VERSION"* ]]
[[ "${output}" = *" CIPHER: aes-256-cbc"* ]]
[[ "${output}" = *" PASSWORD: abc 123"* ]]
[[ "${output}" = *" CIPHER: aes-256-cbc"* ]]
[[ "${output}" = *" PASSWORD: abc 123"* ]]
[[ "${output}" = *" transcrypt -c aes-256-cbc -p 'abc 123'"* ]]
}

@test "init: transcrypt.openssl-path config setting defaults to 'openssl'" {
init_transcrypt
init_transcrypt_no_kdf
[ "$(git config --get transcrypt.openssl-path)" = 'openssl' ]
}

Expand All @@ -104,7 +104,7 @@ SETUP_SKIP_INIT_TRANSCRYPT=1
}

@test "init: --set-openssl-path is applied during upgrade" {
init_transcrypt
init_transcrypt_no_kdf
[ "$(git config --get transcrypt.openssl-path)" = 'openssl' ]

# Set openssl path
Expand All @@ -116,7 +116,7 @@ SETUP_SKIP_INIT_TRANSCRYPT=1
}

@test "init: transcrypt.openssl-path config setting is retained with --upgrade" {
init_transcrypt
init_transcrypt_no_kdf
[ "$(git config --get transcrypt.openssl-path)" = 'openssl' ]

# Set openssl path
Expand All @@ -136,7 +136,7 @@ SETUP_SKIP_INIT_TRANSCRYPT=1
# Set a custom location for the crypt/ directory
git config transcrypt.crypt-dir /tmp/crypt

init_transcrypt
init_transcrypt_no_kdf

# Confirm crypt/ directory is populated in custom location
[ ! -d .git/crypt ]
Expand All @@ -152,7 +152,7 @@ SETUP_SKIP_INIT_TRANSCRYPT=1
# Set a custom location for the crypt/ directory
git config transcrypt.crypt-dir /tmp/crypt

init_transcrypt
init_transcrypt_no_kdf

SECRET_CONTENT="My secret content"
SECRET_CONTENT_ENC="U2FsdGVkX1/6ilR0PmJpAyCF7iG3+k4aBwbgVd48WaQXznsg42nXbQrlWsf/qiCg"
Expand Down
Loading
Loading