1
$\begingroup$

In my application, I am generating a big random number and publishing a SHA256 hash of it. After the hash it published (but not the secret), anyone can submit any number, and the system will calculate and present them a SHA256 hash of the number derived by concatenating their number at the end of the secret number from my system (SHA256(A+B)). The result of that operation should not be guessable without the secret number.

I am wondering if there are any security concerns with this approach that I should be weary about, such as if the random number is of certain length, would that make the result guessable? Or is this approach cryptographically safe?

$\endgroup$
4
  • $\begingroup$ What's the security goal of the overall scheme? In particular, if it's to prevent anyone else from later pretending to have known the secret before you published it, how do you plan to stop a potential pretender from simply relaying all queries to you? $\endgroup$ Oct 20, 2013 at 13:12
  • $\begingroup$ @IlmariKaronen To prevent anyone from knowing a result of a hash for particular input before they query the system. In other words, as long as the secret is not known, the result of SHA256(A+B) for non-empty B should be unknowable before someone sends a query with B to the system. $\endgroup$
    – ThePiachu
    Oct 20, 2013 at 19:33
  • $\begingroup$ That's not really a goal in the sense I meant -- it's, at best, the means of reaching some goal that you haven't told us. But fair enough -- if that's all you need, then Ricky's suggestion of using HMAC should do fine. $\endgroup$ Oct 21, 2013 at 16:33
  • $\begingroup$ @IlmariKaronen At the moment I can't disclose what is the practical application of this, but the technical side of it is generating hashes of a secret number and a given number that are unknown before the operation takes place despite the hash of the secret number being known. $\endgroup$
    – ThePiachu
    Oct 22, 2013 at 1:45

1 Answer 1

3
$\begingroup$

The security concern is that the result of that operation will be guessable without the secret number, since the later part of that answer explains why it also applies to SHA-256.
(Also, $\:$ SHA256(A+"") = SHA256(A)$\:$.)

The random number should be long enough to make brute-force highly infeasible.
If it is and you publish HMAC(A,"") and present them with the values of HMAC(A,B),
then the result of those operations should not be guessable for non-empty strings B.

$\endgroup$
1
  • $\begingroup$ And if you don't want to exclude the empty string, you can always, say, publish HMAC(A, "0") and return HMAC(A, "1" || B) when given B. $\endgroup$ Oct 21, 2013 at 16:36

Your Answer

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

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