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

Test if password is correct #182

Open
andreineculau opened this issue Aug 23, 2024 · 1 comment
Open

Test if password is correct #182

andreineculau opened this issue Aug 23, 2024 · 1 comment

Comments

@andreineculau
Copy link
Collaborator

When using the wrong password, you end up with dirty secret files.
Beyond checking for dirty secret files after "smudging", how would you check if the password/cipher is correct without touching the workspace?

@jmurty
Copy link
Collaborator

jmurty commented Sep 1, 2024

Transcrypt isn't built to check for a correct password. To do so, it would need to track extra metadata information to detect successful or failed decryption based on the decrypted file containing or matching that metadata.

The easiest way I can think of to check for a correct password without looking at the resultant workspace files is to create a file with consistent name and known content in your repo(s), run just the smudge command directly with Transcrypt, and confirm the known content is present in the result from the smudge command.

You would need to set the minimum required Transcrypt Git config options for this to work, but you could do it like this (using this repo's sensitive_file as an example):

# Set Git config options required by transcrypt

git config transcrypt.password 'correct horse battery staple'
git config transcrypt.cipher aes-256-cbc
git config transcrypt.openssl-path openssl

# Run 'smudge' command directly. You must provide:
# - the encrypted file's contents via stdin
# - the context name (default) and the encrypted file's name via command arguments

cat sensitive_file | ./transcrypt smudge context=default sensitive_file

# Check for known content in the decrypted file

cat sensitive_file | ./transcrypt smudge context=default sensitive_file | grep -q '^I just wanna'
# $? == 0

git config transcrypt.password 'wrong password'
cat sensitive_file | ./transcrypt smudge context=default sensitive_file | grep -q '^I just wanna'
# $? == 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants