MAC message authentication code

MAC message authentication code

1. Introduction

MAC means Message Authentication Code. Security relies on the Hash function.

  • Both parties can be authenticated
  • Data integrity check

2. Process

  • The key used by the sender and receiver is the same. The sender Sender uses the hash function and key to encrypt the message, and calculates the message authentication code.
  • Send the calculated message authentication code and message to the receiver Receiver
  • The receiver calculates the message authentication code in the same way after receiving the message.
  • The receiver Receiver compares the calculated message authentication code with the message authentication code sent by the sender Sender.
    insert image description here

3. Calculation method

  • Use existing encryption algorithms, such as DES, to directly encrypt the digest value.
  • Use a dedicated MAC algorithm. HMAC (Hash-based Message Authentication Code), which is based on MD5 or SHA-1, takes the key and data as input at the same time when calculating the hash value, and adopts the method of secondary hash iteration. The actual calculation method is as follows:
    HMAC (K, M)=H(K⊕opad∣H(K⊕ipad∣M))
    Note: opad and Ipad are strings composed of several 0x5c and 0x36 respectively. ∣ indicates connection operation

There may be some mistakes in the writing, welcome to criticize and correct.

Guess you like

Origin blog.csdn.net/qq_43589852/article/details/125751191