AES_128_CBC and AES_128_CTR algorithm

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》。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值