|
In cryptography, CMAC (Cipher-based Message Authentication Code) is a block cipher-based message authentication code algorithm. It may be used to provide assurance of the authenticity and, hence, the integrity of binary data. This mode of operation fixes security deficiencies of CBC-MAC (CBC-MAC is secure only for fixed-length messages). The core of the CMAC algorithm is a variation of CBC-MAC that Black and Rogaway proposed and analyzed under the name XCBC and submitted to NIST. The XCBC algorithm efficiently addresses the security deficiencies of CBC-MAC, but requires three keys. Iwata and Kurosawa proposed an improvement of XCBC and named the resulting algorithm One-Key CBC-MAC (OMAC) in their papers. They later submitted OMAC1, a refinement of OMAC, and additional security analysis. The OMAC algorithm reduces the amount of key material required for XCBC. CMAC is equivalent to OMAC1. To generate an ℓ-bit CMAC tag (''t'') of a message (''m'') using a ''b''-bit block cipher (''E'') and a secret key (''k''), one first generates two ''b''-bit sub-keys (''k''1 and ''k''2) using the following algorithm (this is equivalent to multiplication by ''x'' and ''x''2 in a finite field GF(2''b'')). Let ≪ denote the standard left-shift operator and ⊕ denote exclusive or: # Calculate a temporary value ''k''0 = ''Ek''(0). # If msb(''k''0) = 0, then ''k''1 = ''k''0 ≪ 1, else ''k''1 = (''k''0 ≪ 1) ⊕ ''C''; where ''C'' is a certain constant that depends only on ''b''. (Specifically, ''C'' is the non-leading coefficients of the lexicographically first irreducible degree-''b'' binary polynomial with the minimal number of ones.) # If msb(''k''1) = 0, then ''k''2 = ''k''1 ≪ 1, else ''k''2 = (''k''1 ≪ 1) ⊕ ''C''. # Return keys (''k''1, ''k''2) for the MAC generation process. As a small example, suppose ''b'' = 4, ''C'' = 00112, and ''k''0 = ''Ek''(0) = 01012. Then ''k''1 = 10102 and ''k''2 = 0100 ⊕ 0011 = 01112. The CMAC tag generation process is as follows: # Divide message into ''b''-bit blocks ''m'' = ''m''1 ∥ ... ∥ ''m''''n''−1 ∥ ''mn'' where ''m''1, ..., ''m''''n''−1 are complete blocks. (The empty message is treated as 1 incomplete block.) # If ''mn'' is a complete block then ''mn''′ = ''k''1 ⊕ ''mn'' else ''mn''′ = ''k''2 ⊕ (''mn''∥ 10...02). # Let ''c''0 = 00…02. # For ''i'' = 1, ..., ''n-1'', calculate ''ci'' = ''Ek''(''c''''i''−1 ⊕ ''mi''). # ''cn'' = ''Ek''(''c''''n''−1 ⊕ ''mn''′) # Output ''t'' = msbℓ(''cn''). The verification process is as follows: # Use the above algorithm to generate the tag. # Check that the generated tag is equal to the received tag. ==Implementations== * Python implementation () * Ruby implementation (cmac-rb ) 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「CMAC」の詳細全文を読む スポンサード リンク
|