I am making a system for storing hashed version of some secrets. I have read through dropbox's blog about how they store their passwords, and have taken inspiration from what they are doing.
Dropbox, as far as I understand, does this:
- Get password
- One-way hash with SHA512 (to combat possible truncation of password in bcrypt)
- One-way hash with bcrypt
- Two-way encrypt with AES256 password based encryption with global server-side password
- Store in database.
I see one potential weakness with this system in point 4.
When using the server side password-based encryption, encrypting the bcrypt value, will the predictable bcrypt headers weaken the strategy?
The bcrypt hash looks something like this:
The start, header, will most likely always be the same for the same system:
$2a$10$. Of course, they might be some other value, but they are most likely shared among all your stored password hashes.
Thus, for the password-based encryption system, an attacker could then look for patterns matching this header, and potentially find your encryption password.
Would a better approach be to extract the bcrypt headers, and then encrypt the remaining salt + hash only?
As far as I understand this will not have any predictable component, and thus be more secure.
I am doing this in java currently. Maybe there are some pre-existing solutions for this type of problem?
(PS. I am fairly new to cryptography, so please correct me if I use the wrong jargon/tags etc.)