-1
$\begingroup$

I know that HMAC supports or guarantees both authentication and integrity, but does it also provide confidentiality?

$\endgroup$
2
  • 2
    $\begingroup$ If you have trouble reading free online sources such as Wikipedia, you can try your local ones, and check out publications such as FIPS-* and NIST-SP-800-* from NIST, all before flooding more pointless questions here. $\endgroup$ – DannyNiu Oct 7 '20 at 12:22
  • 1
    $\begingroup$ For example, it is deterministic so it leaks equality of messages. Prepending some unique per message (e.g. random) nonce should fix that. $\endgroup$ – Fractalice Oct 7 '20 at 14:14
3
$\begingroup$

No, it is not providing confidentiality as it is not encrypting your message but fingerprinting it. It provides authentication and integrity because only the creator (or the one who knows the secret) can check the fingerprint for validity. Though the creator doesn't know which of the two qualities is compromised if the validation fails.

$\endgroup$
0
$\begingroup$

Basically any PRF can be made to generate a key stream in counter mode. So if HMAC is the only thing you have then it can be used to encrypt messages. Simply said: you hash a counter and use the output as key stream, which is XOR'ed with the plaintext to get the ciphertext.

HMAC and hashes are often used to create Deterministic Random Bit Generators, which act as stream ciphers if you don't reseed. Practically speaking, don't ever use a DRBG for this purpose though, I'm just making a point that such usage is not unheard of.

However, HMAC by itself is not an encryption algorithm and as such cannot directly encrypt messages, and it not meant to do so. Encryption is what you need to obtain confidentiality through cryptography. Although you can create a stream cipher from it, it would be highly inefficient.

$\endgroup$

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