Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I am making a tool for myself where I intend to store cipher text. I wish to use AES together with arbitrary sized keys to create these cipher text strings. The idea is to use a cryptographic hash like SHA256 to compensate for the key length issue.

Is this a sound way of doing things?

Also, since the output domain of SHA256 is much larger than any key a "normal" person can remember, does this add security if an attacker gets hold of the password digest from for example a computer?

share|improve this question
    
Why not just use GPG? GPG is infinitely less likely to get the details wrong than you are by building something yourself. –  Stephen Touset Jan 30 at 21:06
1  
That is what I am doing right now, but I would like something that fits my needs in terms of updating, deleting and encrypting entities. Also it's a personal project to learn etc. –  Mogget Jan 31 at 7:29
add comment

1 Answer 1

up vote 1 down vote accepted

Is this a sound way of doing things?

Depends. Where do the keys come from? If they come from a user's memory (e.g., a password) then no. The reason for this is that a simple hash if fairly fast to compute. Typically we recommend people use something like PBKDF2 or scrypt as they run through thousands of iterations. The effect of this is that computing this function once is still fairly fast and user won't notice the delay. Trying to brute force it, however, involves computing the function many, many times. This slows down a brute force attacker significantly. Also, scrypt in particular was designed to be slow on hardware. That means attackers can't throw a GPU or other hardware device at the problem to speed it up.

Also since the output domain of sha256 is much larger than any key a "normal" person can remember, does this add security if an attacker gets hold of the password digest from for example a computer?

No. We often measure security in bits. In particular, bits of entropy. A deterministic function (like sha256) cannot create entropy.

share|improve this answer
1  
Specifically, entropy is a measure of the unknowable parts of a process used to generate a secret. It is not a direct property of the secret itself, and can never be increased through a deterministic process (such as a hash). –  Stephen Touset Jan 30 at 21:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.