Skip to content

Commit 7fc2efb

Browse files
committed
Simplified HMAC explanation
The original HMAC explanation was somewhat convoluted. I've separated the two steps more clearly, and made sure to mention every term of the formula. Also added spacing to the outer parentheses in the formula to make it more clear where the boundary is of the outer H()
1 parent edd0846 commit 7fc2efb

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

crypto.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ HMAC is a function of both the key and the input text. An approach to
607607
calculating HMACs has been standardized by NIST and takes the
608608
following form:
609609

610-
HMAC = H((K⊕opad) || H((K⊕ipad) || text))
610+
HMAC = H( (K⊕opad) || H((K⊕ipad) || text) )
611611

612612
H is the hash function, K is the key, and opad (output pad) and ipad
613613
(input pad) are well-known strings that are XORed (⊕) with the key. ||
@@ -618,12 +618,13 @@ book. However, this approach has been proved to be secure as long as
618618
the underlying hash function H has the appropriate
619619
collision-resistance properties outlined above. Note that the HMAC
620620
takes a hash function *H* that is not keyed, and turns it into a keyed
621-
hash by using the key (XORed with another string, *ipad*) as the first
622-
block to be fed into the hash function. The output of
623-
the keyed hash is then itself subjected to another keyed hash (again
624-
by XORing the key with a string and using that as the first block fed
625-
to the hash). The two passes of the keyed-hash function are important
626-
to the proof of security for this HMAC construction.
621+
hash by applying the hashing function *H* twice. First the key (XORed
622+
with a string, *ipad*) is prepended to the message, which is
623+
then fed into the hash function. The output of this keyed hash is then
624+
itself subjected to another keyed hash (again by XORing the key with
625+
a string, *opad*, and prepending that to the output of the first keyed hash).
626+
The two passes of the keyed-hash function are important to the proof
627+
of security for this HMAC construction.
627628

628629
.. let's delete this incorrect pic for now; unclear if a new picture
629630
adds much

0 commit comments

Comments
 (0)