HMAC definition (RFC2104)

xiaoxiao2021-03-06  57

Defining HMAC requires an encrypted hash function (represented as h) and a key K. We assume that H is a hash function encrypted with a basic iterative compression function. We use B to represent the word length of the data block. (Segmentation data block word length B = 64 mentioned above), using L to represent the output data word length of the hash function (L = 16 in MD5, L = 20 in SHA-1). The length of the identification key can be any positive integer value that is less than or equal to the word block. If the key length used in the application is larger than B, first use the hash function h to act on it, then the L length string output with H is used as the key actually used in the HMAC. In general, the recommended minimum key K length is L word length. (Equal to the length of the output data of H). See Part III for more detailed information. We will define two fixed and different strings ipad, opad: ('i', 'o' sign inside and outside) ipad = the byte 0x36 repeated b Times opad = the byte 0x5c repeated b Times. Calculate 'Text' HMAC: h (k xor opad, h (k xor ipad, text)) is the following steps:

(1) Add 0 to the key K to create a string of a child B. (For example, if the word length is 20 bytes, b = 60 bytes, then 44 zero-byte 0x00 will be added later)

(2) Different or calculate the string of the B word length generated by the previous step.

(3) Pack the data stream Text into the result string of the second step.

(4) Use H to act on the data stream generated in the third step.

(5) Different or operate the B-word long string generated by the first step.

(6) Fill the result of the fourth step into the result of the fifth step.

(7) Use h to act on the data stream generated in the sixth step, output the final result

转载请注明原文地址:https://www.9cbs.com/read-112605.html

New Post(0)