I have concerns regarding truncated SHA-256 hashes in an application I am building at the moment:
secret - the full 256-bit SHA-256 result of hashing 16 random bytes
public - a unique identifier for an object.
hash - the output of
SHA-256(secret || - || public)
prefix - the first 8 characters (32-bit) of hex encoded
secret is generated once and remains constant throughout the lifecycle of the scenario.
It is not known to the attacker
Identifiers for all objects (
publics) are known to the attacker.
prefix will be the base for further computation and information retrieval for a given object.
The first 4 bytes (32 bit) of
hash have to be sufficient for that.
It is important that a potential attacker cannot generate a valid
prefix for a given
The attacker's utopia is to find
secret so they can generate a valid
hash for every object.
This is unrealistic to brute force (computation would take forever).
However, because only the first 32 bit of
hash matter, is there a mechanic / cryptographic attribute, that makes it feasible for the attacker to guess / compute a valid
secret that would allow them to generate
prefix values for given
secret = 'af8b81c94d68...' (256-bit) public = '123456' hash = 'fe13c815ab44...' (256-bit) prefix = hash[0...8] = 'fe13c815'
Can the attacker guess
secret such that they would end up with a valid
Can the attacker use that guessed, validated
secret and compute
prefix values for different