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

[feature] Allow sym to use a password protected key without interactive input #12

Closed
kigster opened this issue Mar 13, 2017 · 0 comments

Comments

@kigster
Copy link
Owner

kigster commented Mar 13, 2017

Right now if the key is password protected, the following fails:

echo "hello" | sym -d -k mykey

Because it attempts to read the password from STDIN, which is hijacked by the data stream.

Additionally, in the deployed environment, it would be super nice if sym was able to read the password from somewhere secure, and apply it to the key in, say, environment variable.

Possible solutions:

  • support $SYM_KEY_PASSWORD environment variable for reading in key password if needed
  • on each host install a random key that's used to encrypt/decrypt the password of the actual key. Say, sym installs its default set of random passwords in application's root, in ./.sym/meta. This file would look like this:
EF307IsQZCRhuRWRTUsy4P9zn_xNCNCMEcURhYOzBPU=
QMhWPsAoOu70CqX5g-_ZpIB32470wGIY6Izk6GWcubo=
....
_KrLp2iIFihpk8QaWbzcpMC5e2ULL-zuyAv--dy9jKg=

with the total of 128 keys installed.

Then, given any password sym can md5 the password, convert to binary, and take the last (or first) eight bits — these bits would point to the row in the metafile containing the key. So now we can determine the key based on the md5 of the actual password. We give sym a real password and tell it to encrypt it with the meta key, and store it in ./.sym/config. But we write two things in that file: last 8 bits of the md5 concatenated with the encrypted password.

To restore this, sym will read the config file, grab the first 8 bytes, based on that determine the key, and decrypt the stored value. The result will be the password used to decrypt the actual key used for data decryption. This method bypasses having to provide the password interactively via a somewhat convoluted scheme.

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

1 participant