I have been educating myself recently about the SHA-2 hashing algorithm, and in the midst of this pursuit, I've encountered a question:

This algorithm uses a set of constant hexadecimal values, derived from the cube root of prime numbers, as a starting point for the process. Because these values can be known to anyone, does this not open some level of vulnerability to the hashed values? Would it not be better to use a set of less predictable values?

I don't know a great deal about cryptography, so forgive me if this question is silly in some way I do not understand, but I am very curious about the answer.

EDIT: I'm not asking why they are constant. I understand how hashing works and what it is used for. I am asking if the security of the algorithm would be increased if constant but unknowable (to the outside) values were used instead of the array of constants currently used.

  • $\begingroup$ If the constants were not constant, you could not use the hash function without keying it, so it would not be a hash function but something else. You can read up on en.wikipedia.org/wiki/Nothing_up_my_sleeve_number $\endgroup$
    – Thomas
    Jan 23, 2014 at 0:33
  • 1
    $\begingroup$ possible duplicate of Why are these specific values used to initialise the hash buffer in SHA-512? $\endgroup$ Jan 23, 2014 at 8:57
  • $\begingroup$ For SHA-2, the round constants are based on cube roots of primes, the initial hash value is based on square roots of primes $\endgroup$ Jan 23, 2014 at 9:48
  • $\begingroup$ I understand that they have to be constant. That is not what I am asking. There are ways to make the values constant, but not transparent to someone trying to break the hash; a system that selects various constants based on the cube roots of primes based on the unicode values of the chars in the initial string, for instance. $\endgroup$
    – user37745
    Jan 23, 2014 at 15:50
  • $\begingroup$ So, you're suggesting that the attacker be allowed to select those constants? After all, during an attack, the attacker is submitting values to hash; if those 'constants' depend on the values, the attacker can, by selecting the appropriate initial string, he gets to pick the 'constants' that the hash function will use. $\endgroup$
    – poncho
    Jan 23, 2014 at 19:46

1 Answer 1


Would it not be better to use a set of less predictable values?

Actually, there aren't any "unpredictable values".

SHA-2 is a hash function (actually, it's a family of 6 hash functions; we'll ignore that point for now); a hash function is designed so that anyone can compute it.

One use of a hash function is during signature generation and verification; typically, the signer takes the message, and hashes it, and then applies the signature operation to the hash. Then, the verifier takes the message, hashes it, and then verifies the hash against the signature. If the verifier could not compute this hash, he could not verify that the signature corresponded to this message.

Because of this, the entire specification of SHA-2 must be made public, so that the verifier (and anyone else) can compute it. That is, any internal table values must also be public, because they are needed to compute the hash function.

Because we're going to tell everyone what the values are, they aren't, in any sense, unpredictable.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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