I've been pondering how to deal with passwords lately. I'd been using a password manager for awhile, but this means I can't access anything I use it for from a machine where it isn't installed (or where I can't install things). I got to thinking that sha256 is available pretty much everywhere, so a pw generator based on that would be as portable as possible. (I might even write an html file, keep it on a thumbdrive, and load it on a browser on any machine, using JS functions to do the hashing...) Here's a bash implementation:
#/bin/bash
echo -n "Code: " && read CODE
echo -n "Password: " && read -s PASSWORD
for i in `seq 5 -1 1`; do
clear && echo $i
sleep 1
done &
for j in `seq 1024 -1 1`; do
PASSWORD=$(sha256sum <<<"${CODE}${PASSWORD}")
done
wait
clear && echo "typing"
xdotool - <<<"sleep 0.5 type ${PASSWORD::${1:-20}}aA@2"
sleep 0.5
clear
echo "done"
sleep 1
clear
The idea is that a user inputs a code related to the needed password (gmail, bank1, se-security, etc...a list of these could be stored in a file online or anywhere, as it's not a secret), and also a master password. (The command line argument truncates the password if necessary since some websites don't allow 24 characters). The script hashes the concatenation of these strings, and appends 'aA@2' to make password rules happy. It types it out (vulnerable to keyloggers, I guess?) rather than using the clipboard to avoid obvious problems with having a password in the clipboard.
So, my main two questions are:
Is this idea (hashing a pw/code combo to get the "real pw") terrible for some security reason?- If the overall idea is ok, is there any noticable security problem with my implementation?
Regarding question 2, I think I've covered the basics, i.e., no echoing the password as it's typed, and handing strings to sha256 sum and xdotool as stdin so that they're not cli arguments (which can be viewed using, e.g., ps).
Also, the reason for iterating through 1024 runs of sha256sum is just to make cracking slow (I don't think this can be parallelized...but I'm no expert). My thinking is that if someone manages to get one of the output passwords in the clear, I don't want them to be able to brute force my master password, even given the output, the algorithm, and the id code associated with the password.
I know there are key derivation hashing algos that do much of this already, but I don't think they'd be as common as sha256 (even any smartphone browser will to sha256 sum calculations, I think). I'm aiming for maximum portability/flexibility here.
Thanks!
Edit: I think I'm satisfied by that link (and others I've read) that the overall idea isn't too terrible, so I've struck out the first question. I'd still like more info about implementation.