AES_128_CBC and AES_128_CTR algorithm

來源:互聯網
上載者:User

AES 演算法,分組長度為128 bit,密鑰長度可為128、192、256 bit。

AES_128_CBC(Cipher Block Chaining)
1、The total number of bits in the plaintext must be a multiple of the block size, 128bit。
      加密就是將各段加密然後拼接起來,再在頭上加上IV,輸入包含:aes key、IV、plaintext | padding,輸出為:ciphertext;
      解密時,輸入包括:aes key、IV、ciphertext,輸出為:plaintext。

2、CBC Encryption: C1 = CIPHK(P1 ⊕ IV);
                                  Cj  = CIPHK(Pj  ⊕ Cj-1)            for   j = 2 … n.
        CBC Decryption: P1 = CIPH-1K(C1) ⊕ IV;
                                   Pj = CIPH -1K(Cj)  ⊕ Cj-1       for j = 2 … n
       其中 IV 是128 bits,其產生參考《sp800-38a.pdf》p27;
       padding 具體參考《sp800-38a.pdf》p24 和 《rfc 2630》,我沒搞清楚;
       CIPHK 指的是 aes128 的加密函數,CIPH -1K 指的是 aes128 的解密函數。

3、圖示
      請看《sp800-38a.pdf》 p17。

 

AES_128_CTR(Counter)

1、The total number of bits in the message is (n-1)b+u, where 1≤ u≤ b。
      加密就是各段加密拼接,再在頭上加上initial counter。輸入包含:aes key、initial counter、plaintext,輸出為:ciphertext;
      解密時,輸入包括:aes key、initial counter、ciphertext,其輸出為:plaintext。

2、 CTR Encryption: Oj    = CIPHK(Tj)                 for j = 1, 2 … n;
                                 Cj    = Pj ⊕ Oj                      for j = 1, 2 … n-1;
                                 C*n = P*n ⊕ MSBu(On).
       CTR Decryption: Oj    = CIPHK(Tj)                 for j = 1, 2 … n;
                                 Pj    = Cj ⊕ Oj                       for j = 1, 2 … n-1;
                                 P*n = C*n ⊕ MSBu(On).
       其中 initial counter 即 T1 是 128 bits,其產生參考《sp800-38a.pdf》p26;
       T2....Tn 的產生是通過 Incrementing Function,參考 《sp800-38a.pdf》p25,其實就是在原基礎上加 1;
       CIPHK 指的是 aes128 的加密函數;
       MSB 指的是 Most Significant Bit。

3、圖示
      請看《sp800-38a.pdf》 p23。

 

本文所有東西均歸納自《sp800-38a.pdf》。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.