Linked Questions
23 questions linked to/from Why is $H(k\mathbin\Vert x)$ not a secure MAC construction?
2 votes
1 answer
3k views
Why does appending a message to a key before hashing not guarantee integrity? [duplicate]
I want to guarantee the integrity of a message $m$. My first thought is to append the message to an integrity key $k$ and hash it as $H(k\,||\,m)$. However, I have been told that this is not totally ...
1 vote
0 answers
839 views
Why does HMAC use the hash twice? [duplicate]
According to the HMAC specification in RFC2104, an HMAC is computed in the following way: HMAC(K, text) = H(K XOR opad, H(K XOR ipad, text)) where ...
0 votes
1 answer
426 views
Difference between HMAC-SHA1(key, msg) vs SHA1(key + msg) [duplicate]
Is there any practical difference from using HMAC-SHA1(key, msg) vs SHA1(key + msg) as a way to verify the authenticity/...
1 vote
0 answers
54 views
School exercise on untrusted channel comunication [duplicate]
Possible Duplicate: Why is H(k||x) not a secure MAC construction? I've the following problem: two parties, A and B, share a secret key Kab. M is a plaintext message, H an unkeyed hash function A ...
42 votes
4 answers
55k views
What are preimage resistance and collision resistance, and how can the lack thereof be exploited?
What is "preimage resistance", and how can the lack thereof be exploited? How is this different from collision resistance, and are there any known preimage attacks that would be considered feasible?
29 votes
2 answers
26k views
HMAC vs MAC functions
I've read definitions of MAC and HMAC, but can't say I've completely grasped the differences. What are principle differences? When to use one and when the other?(Typical Use Cases)
25 votes
2 answers
5k views
Is H(k||length||x) a secure MAC construction?
If $H$ is a typical secure hash function, then $(k,x) \mapsto H(k \mathbin\| x)$ is not a secure MAC construction, because given a known plaintext $x_1$ and its MAC $m_1$, an attacker can extend $k \...
17 votes
2 answers
9k views
Why is h(m||k) insecure?
Here is the post that explains the failure for doing h(k||m) and I understand it. But I don't understand how h(m||k) is subjected to collison attack, or birthday attack. Please explain?
13 votes
2 answers
2k views
How is HMAC(message,key) more secure than Hash(key1+message+key2)
I understand how for hash functions which are vulnerable to length extension attacks (such as SHA1 and SHA2) it is safer to use a HMAC construction. What I don't understand is, how or why is $\...
7 votes
2 answers
452 views
Security difference between $\mathrm{Keccak}(k\mathbin\|x)$ and $\mathrm{Keccak}(x\mathbin\|k)$
$\require{begingroup}\begingroup \DeclareMathOperator{\keccak}{\mathrm{Keccak}} \DeclareMathOperator{\concat}{\|} $According to Keccak's website, $\keccak(k \concat x)$ is safe: Unlike SHA-1 and SHA-...
1 vote
3 answers
740 views
Understanding MACs and why cleartext is sent over
Assume both Alice and Bob have a symmetrical key, let's call it $k$. They agree on a cryptographic hash function, let's call it $\mathsf{HASH}$. Now Alice wants to send an authenticated message. She ...
2 votes
1 answer
837 views
Is this DIY remote lock protocol secure?
I need your advice on following scheme of exchange protocol between remote lock and key. I'm planning to use following algorithm: Key generates unique value that never repeats (in reality it's just ...
5 votes
1 answer
849 views
Authenticate a short message with redundant encryption instead of using a MAC?
I have a short message that’s exactly 128 bits of length. The message serves as a time-limited authorization token for a database. It contains a permission profile ID (64 bits) and an issue timestamp (...
6 votes
2 answers
324 views
Possible problems in using a hash algorithm to construct a stream cipher
I'll define an example hash-based stream cipher as such: $H: \{0,1\}^* \rightarrow \{0,1\}^{256}$ is the hash function. $K=\{0,1\}^{256}$ is the secret key. $N=\{0,1\}^{128}$ is the nonce. $C=\{0,1\}^{...
2 votes
1 answer
597 views
Does pepper *require* an HMAC?
Assume you are already given a properly-salted, password hash $X$ from some slow PBKDF (e.g., like Argon2id). Now, you want to apply some large (~256-bit) secret "pepper" $S$ to it before storing it ...