CN101764687A - Ucps协议中采用aes算法对数据流加解密的硬件实现方法 - Google Patents

Ucps协议中采用aes算法对数据流加解密的硬件实现方法 Download PDF

Info

Publication number
CN101764687A
CN101764687A CN200810044186A CN200810044186A CN101764687A CN 101764687 A CN101764687 A CN 101764687A CN 200810044186 A CN200810044186 A CN 200810044186A CN 200810044186 A CN200810044186 A CN 200810044186A CN 101764687 A CN101764687 A CN 101764687A
Authority
CN
China
Prior art keywords
aes
algorithm
sbox
key
aes192
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN200810044186A
Other languages
English (en)
Inventor
罗佳明
袁世强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Huahong Integrated Circuit Co Ltd
Original Assignee
Shanghai Huahong Integrated Circuit Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Huahong Integrated Circuit Co Ltd filed Critical Shanghai Huahong Integrated Circuit Co Ltd
Priority to CN200810044186A priority Critical patent/CN101764687A/zh
Publication of CN101764687A publication Critical patent/CN101764687A/zh
Pending legal-status Critical Current

Links

Images

Landscapes

  • Storage Device Security (AREA)

Abstract

本发明公开了一种UCPS协议中采用AES算法对数据流加解密的硬件实现方法,将整个加密过程分解为多级流水线,每级流水线根据采用的密钥长度分组和应用的速度来确定,在每级流水线的输出端用寄存器进行暂存处理。本发明能够有效实现加密数据的高安全性,提高运算速度,很好地解决UCPS协议中大数据流的实时加解密问题。经过试验验证本发明比非流水线的AES算法快12~13倍。

Description

UCPS协议中采用AES算法对数据流加解密的硬件实现方法
技术领域
本发明涉及多媒体领域,特别是涉及一种UCPS协议(Unified ContentProtection System统一数字保护协议)中采用AES算法对数据流加解密的硬件实现方法。
背景技术
中国的统一数字保护协议,简称UCPS协议,是我国提出的具有自主知识产权的数字保护协议,该协议可以用于便携式多媒体设备到高清数字电视的各种多媒体设备上。它的提出一方面为绕开HDCP(High-bandwidthDigital Content Protection高带宽数字内容保护规范)的专利壁垒,另一方面也是为适应中国这个庞大的数字多媒体市场而开发的适合中国国情的数字保护协议。
AES(Advanced Encrypt ion Standard高级加密标准)算法是应用于UCPS协议中对输入音视频数据流进行实时加解密保护的。在UCPS协议中,源端和接收端需要在两部分用到AES算法,第一次是在加解密密钥生成时,需要通过调用AES算法来产生加解密密钥;第二次是在音视频数据流加解密时,需要通过调用AES算法来实时地加解密音视频数据。第一次使用的AES算法对速度要求不高,因为它只是每次认证完成时被调用使用,而第二次使用的AES算法却对速度的要求很高,基本上要求每个像素时钟运行产生一次密文数据。
AES算法由美国国家标准与技术研究所(NIST)于1997年提出征集,最终选定比利时研究者Vincent Rijmen和Joan Daemen发明的Rijndael算法,并于2001年正式发布。Rijndael算法本质上是一种对称分组密码体制,采用代替和置换网络,也是一种迭代分组密码,其分组长度和密钥长度都是可变的。密钥长度通常采用128位、192位或256位,相应的迭代轮数为10轮、12轮或14轮,相应的密钥、分组和轮数的组合对应关系如表1所示。Rijndael算法汇聚了安全性能、效率、可实现性和灵活性等优点,最大的优点就是可以给出算法的最佳差分特征的概率,并分析算法抵抗差分密码分析及线形密码分析的能力。
表1:AES的密钥、分组和轮数的组合对应关系
  标准   密钥长度(个字)   分组大小(个字)   轮数(次)
  AES-128   4   4   10
  AES-192   6   4   12
  AES-256   8   4   14
发明内容
本发明要解决的技术问题是提供一种UCPS协议中采用AES算法对数据流加解密的硬件实现方法,能够有效实现加密数据的高安全性,提高运算速度,很好地解决UCPS协议中大数据流的实时加解密问题。
为解决上述技术问题,本发明的UCPS协议中采用AES算法对数据流加解密的硬件实现方法是采用如下技术方案实现的,将整个加密过程分解为多级流水线,每级流水线根据采用的密钥长度分组和应用的速度来确定,在每级流水线的输出端用寄存器进行暂存处理。
如果时间要求不是实时的,即不是要求一个时钟出一组密文,则可以减少流水线的级数,具体减少的数目可以根据所能容忍的时钟来设计。
采用本发明的方法,可以满足128位和192位密钥长度,提高了UCPS系统中音视频数据流的加解密速度,而且算法采用计数器模式(CTR模式)的AES分组密码操作模式,具有很高的安全性,极大降低UCPS系统的被攻击性,实现加密数据的高安全性。
由于可以用多级流水线作业模式,提高了算法的运行速度;特别是由于采用了通常CPU运算的流水线作业方式,因此运算速度也大幅度提高,这样很圆满的解决了UCPS系统中大数据流的实时加解密问题。本发明在完成硬件实现并用FPGA(Field Programmeble Gate Array现场可编程门阵列)进行了验证后,验证结果说明比非流水线的AES算法快12~13倍。
附图说明
下面结合附图与具体实施方式对本发明作进一步详细的说明:
图1是AES的加密和解密过程图;
图2是AES算法流程图;
图3是AES-128算法仿真波形图;
图4是AES-192算法仿真波形图;图5是本发明一实施例示意图。
具体实施方式
基于UCPS协议对算法的实现和运行提出了很高的要求,在综合考虑后,本发明采用流水线型高速AES算法实现音视频数据流的加解密。
(1)AES算法原理
AES算法采用Square结构,即一种迭代式分组密码,其分组长度和密钥长度可以是128位、192位或256位。它的轮变换由4个不同的变换组成,具体表现为一套查表和异或操作。
以AES-128为例,加密的基本模块是5个在4x4字节阵列(称为态)上的不同的可逆变换。态a的第i行、第j列的元素表示为ai,j,其下标均从0开始。
线形变换θ:
θ是一个具有4个并行线形变换的混合操作,它对一个态的四行中的每一行单独进行操作。定义
Figure G2008100441865D0000041
θ就是一个模多项式的乘法:
b = θ ( a ) ⇔ b i ( x ) = c ( x ) · a i ( x ) ⊕ mod ( x 4 + 1 ) 公式(1)
c(x)的逆等于由下式给出的多项式d(x):
d(x)·c(x)=1mod(x4+1)    公式(2)
非线性变换γ:
γ是一个非线性的字节代替,它对所有的字节操作相同,即:
γ : b = γ ( a ) ⇔ b i , j = S γ ( a i , j ) 公式(3)
其中Sγ是一个不可逆的8位代替表或者S盒。γ的逆由逆代替Sγ -1作用于一个态的所有字节组成。因此Rijndael中的γ变换就是SubBytes()。
字节换位π:
π的效果就是一个态的行和列相互交换位置,即:
π : b = π ( a ) ⇔ b i , j = a j , i 公式(4)
π是一个对合换位(Involution),因此π-1=π。Rijndael中的π变换就是ShiftRow()。
按位轮密钥加σ:
σ[kt]由一个轮密钥kt的按位加组成,即:
σ [ k t ] : b = σ [ k t ] ( a ) ⇔ b = a ⊕ k t 公式(5)
σ[kt]的逆即是本身。
轮密钥推导(Evolution)ψ:
轮密钥kt由加密密钥k经过如下方式推导得出:k0=K,别的轮密钥通过不可逆的仿射变换ψ迭代推导而来:
ψ:kt=ψ(kt-1)    公式(6)
AES的加密函数:
模块由轮变换ρ[kt]组成:
ρ[kt]=σ(kt)оπоγоθ    公式(7)
Square的加密被定义成在密钥加操作σ[k0]和θ-1之前进行8轮变换:
Square[k]=ρ[k8]оρ[k7]оρ[k6]оρ[k5]оρ[k4]оρ[k3]оρ[k2]оρ[k1]оσ[k0]оθ-1公式(8)
AES的解密函数:
定义逆加密的轮变换为:
ρ′[kt]=σ(kt)оπоγ-1оθ-1    公式(9)
Square的解密函数被定义为:
Square-1[k]=ρ′[k8]оρ′[k7]оρ′[k6]оρ′[k5]оρ′[k4]оρ′[k3]оρ′[k2]оρ′[k1]оσ[k0]оθ公式(10)
因此,该逆加密就等于加密变换中用γ和θ分别代替γ-1和θ-1
(2)算法基本变换
具体到算法实现,AES算法中的加密算法可以分为S盒变换SubBytes()、列混合变换Mixcolumns()、行移位运算ShiftRow()、轮密钥加变换AddRoundKey()等四个环节步骤。AES的解密算法与加密算法相比除了轮密钥加AddRoundKey()不变外,其余的字节变为求逆变换,即逆S盒变换InvSubBytes()、逆行移位运算InvShiftRow()、逆列混合变换InvMixcolumns()。
AES算法总的执行过程如图1所示,该执行过程来源于标准AES算法原理。AES算法的流程图如图2所示,该流程图来源于标准AES算法原理。
S盒变换SubBytes():
S盒变换是一个基于S盒的非线性置换,用于将输入或中间态的每一个字节通过一个简单的查表操作,将其映射为另一个字节。映射的方法是:把输入字节高四位作为S盒的行值,低四位作为S盒的列值,然后取出S盒中对应行和列的元素作为输出。
S盒变换SubBytes()的伪代码如下:
SubBytes(byte state[4,Nc],Nc)
begin
for r=0 step 1 to 3
for c=0 step 1 to Nc-1
state[r,c]=Sbox[state[r,c]]
end for
end for
end
逆S盒变换InvSubBytes():
逆S盒变换是一个基于逆S盒的非线性置换,要用到仿射变换的逆变换,然后再计算乘法逆。仿射变换的逆变换为:
b i = b ( i + 2 ) mod 8 ′ ⊕ b ( i + 5 ) mod 8 ′ ⊕ b ( i + 7 ) mod 8 ′ ⊕ d i 公式(11)
列混合变换Mixcolumns():
Mixcolumns()实现逐列混合,其方法是:
s′(x)=c(x)·s(x)mod(x4+1)    公式(12)
其中c(x)={03}·x3+{01}·x2+{01}x+{02},{}内的数表示字节,s′(x)=s′0,c+s′1,c·x+s′2,c·x2+s′3,c·x3;s(x)=s0,c+s1,c·x+s2,c·x2+s3,c·x3。s′0,c代表c(x)与s(x)相乘后x的指数mod(x4+1)等于0的项的系数之和。
Mixcolumns()的伪代码描述如下:
function[31:0]mix_col;
  input[7:0]s0,s1,s2,s3;
    begin
      mix_col[31:24]=xtime(s0)^xtime(s1)^s1^s2^s3;//s0*2+s1*3+s2+s3
      mix_col[23:16]=s0^xtime(s1)^xtime(s2)^s2^s3;//s0+s1*2+s2*3+s3
      mix_col[15:08]=s0^s1^xtime(s2)^xtime(s3)^s3;//s0+s1+s2*2+s3*3
      mix_col[07:00]=xtime(s0)^s0^s1^s2^xtime(s3);//s0*3+s1+s2+s3*2
    end
endfunction
function[7:0]xtime;//byte multiply 2
  input[7:0]b;xtime={b[6:0],1’b0}^(8’h1b&{8{b[7]}});
endfunction
逆列混合变换InvMixcolumns():
逆列混合的处理方法与列混合类似,每一列都通过与一个固定的多项式d(x)相乘进行变换,定义为:
s′(x)=d(x)·s(x)mod(x4+1)    公式(13)
其中d(x)是c(x)模x4+1的逆,即:
d(x)={0b}·x3+{0d}·x2+{09}x+{0e}    公式(14)
行移位运算ShiftRow():
移位运算ShiftRow()完成基于行的循环移位操作,变换规则是行移位变换作用在中间态的行上,第0行不动,第1行循环左移1个字节,第2行循环左移2个字节,第3行循环左移3个字节。
ShiftRow()的伪代码描述如下:
ShiftRows(byte state[4,Nc],Nc)
begin
byte t[Nc]
for r=1 step 1 to 3
for c=0 step 1 to Nc-1
t[c]=state{r,(c+h(r,Nc))mod Nc}
end for
for c=0 step 1 to Nc-1
state[r,c]=t[c]
end for
end for
end
逆行移位运算InvShiftRow()
逆行移位运算InvShiftRow()与行移位相反,变换规则是将态state的后三行按相反的方向进行移位操作,即第0行不动,第1行循环右移1个字节,第2行循环右移2个字节,第3行循环右移3个字节。
轮密钥加变换AddRoundKey():
AddRoundKey()用于将输入或中间态S的每一列与一个密钥字ki进行按位异或,每一个密钥由Nb个字组成,c(x)表示第c(x)轮的第c(x)个轮密钥字,轮密钥加变换可表示为:
[ s 0 , c &prime; , s 1 , c &prime; , s 2 , c &prime; , s 3 , c &prime; ] = [ s 0 , c &prime; , s 1 , c &prime; , s 2 , c &prime; , s 3 , c &prime; ] &CirclePlus; [ w [ r * Nb + c ] ] ( 0 &le; r < N r , 0 &le; c < N b ) 公式(15)
AddRoundKey()的伪代码描述如下:
Module addroundkey(aes_key_enable,aes_key,w0,w1,w2,w3,cryptograph);
always@(posedge clock or negedge reset)
begin
  if(reset==0)
    begin
      cryptograph    <=#1 0;
    end
else
    begin
      if(aes_out=1)
          begin
            cryptograph[127:120]<=state00_sr^w0[31:24];
            cryptograph[119:112]<=state01_sr^w0[23:16];
            cryptograph[111:104]<=state02_sr^w0[15:08];
            cryptograph[103:096]<=state03_sr^w0[07:00];
            cryptograph[095:088]<=state10_sr^w1[31:24];
            cryptograph[087:080]<=state11_sr^w1[23:16];
            cryptograph[079:072]<=state12_sr^w1[15:08];
            cryptograph[071:064]<=state13_sr^w1[07:00];
            cryptograph[063:056]<=state20_sr^w2[31:24];
            cryptograph[055:0481<=state21_sr^w2[23:16];
            cryptograph[047:040]<=state22_sr^w2[15:08];
            cryptograph[039:032]<=state23_sr^w2[07:00];
            cryptograph[031:024]<=state30_sr^w3[31:24];
            cryptograph[023:016]<=state31_sr^w3[23:16];
            cryptograph[015:008]<=state32_sr^w3[15:08];
        cryptograph[007:000]<=state33_sr^w3[07:00];
      end
    end
  end
aes_key u1(.enable(aes_key_enable),
           .key(aes_key),
           .wo_0(w0),
           .wo_1(w1),
           .wo_2(w2),
           .wo_3(w3));
endmodule
密钥扩展:
AES密钥扩展的输入是4个字,每个字32位,共128位(以AES-128位算法为例),输入密钥被直接复制到扩展密钥数组的前4个字中,得到w[0],w[1],w[2],w[3];然后每次用4个字填充扩展密钥数组余下的部分。扩展密钥数组中,w[i]的值依赖于w[i-1]和w[i-4](i≥4)。对w数组中下标不为4的倍数的元素,只是简单的异或,其逻辑关系为:
w [ i ] = w [ i - 1 ] &CirclePlus; w [ i - 4 ] 公式(16)
其中:i不为4的倍数。
对w数组中下标为4的倍数的元素,采用如下的计算方法:
i.RotWord():将前一个字的4个字节循环左移一个字节。
ii.SubWord():基于S盒对输入字(步骤的结果)中的每个字节进行S代替。
iii.将步骤ii的结果再与轮常量Rcon[i]相异或。
iiii.将步骤iii的结果再与w[i-4]异或,即:
w [ i ] = SubWord ( RotWord ( w [ i - 1 ] ) ) &CirclePlus; Rcon [ i / 4 ] &CirclePlus; w [ i - 4 ] 公式(17)
其中:i为4的倍数。
密钥扩展的伪代码如下:
module aes_key(enable,key,w[0],w[1],w[2],w[3]);
always@(posedge clock or negedge reset)
 begin
  if(reset==0)
    w[0]=0;
    w[1]=0;
    w[2]=0;
    w[3]=0;
  else
    w[0]=enable?key[127:096]:w[0]^subword^rcon;
    w[1]=enable?key[095:064]:w[0]^w[1]^subword^rcon;
    w[2]=enable?key[063:032]:w[0]^w[2]^w[1]^subword^rcon;
    w[3]=enable?key[031:000]:w[0]^w[3]^w[2]^w[1]^subword^rcon;
  end
aes_sbox u0(.a(w[23:16]),.d(subword[31:24]));
aes_sbox u1(.a(w[15:08]),.d(subword[23:16]));
aes_sbox u2(.a(w[07:00]),.d(subword[15:08]));
aes_sbox u3(.a(w[31:24]),.d(subword[07:00]));
aes_rcon r0(.enable(enable),.kout(rcon));
endmodule
(3)流水线(pipeline)设计:
流水线的设计方法已经在高性能的、需要经常进行大规模运算的系统中得到广泛的应用,如CPU(中央处理器)等。目前流行的CPU,如Intel的奔腾处理器在指令的读取和执行周期中充分地运用了流水线技术以提高它们的性能。高性能的DSP(数字信号处理)系统也在它的构件(building-block functions)中使用了流水线设计技术。
所谓流水线设计实际上就是把规模大、层次多的组合逻辑电路分为若干个级,在每一级插入寄存器组暂存中间数据,这样将庞大耗时逻辑划分为若干级,每一级相互间可以独立运行。K级的流水线就是从组合逻辑的输入到输出恰好有K个寄存器组(每一级都有一个寄存器组)。上一级的输出是下一级的输入,且无反馈的电路。所以流水线结构是提高组合逻辑吞吐量从而增强计算性能的一个重要办法。
参见图5所示,本发明中,由于要对音视频数据进行实时加解密,所以可以考虑使用流水线来设计。以AES-128来看,将整个算法划分为10级,每级插入16个8位的寄存器(共128位)用来暂存输出,这样,可以做到每个时钟输出一组128位的加/解密数据,也就是说可以做到数据实时加解密;如果是AES-192,则可以设计成12级流水线,每级插入24个8位的寄存器(共192位)用来暂存输出,同样可以做到将实时数据依次输入算法模块;经过10/或12个时钟延迟处理后,再依次按时钟输出。
AES-128的程序伪代码是:
module aes128_pipeline_top(clk,aes_enable,data_enable,aes_key,plain_data,aes_out,cryptograph);
input        aes_enable;     //算法启动信号
input[127:0] aes_key;        //算法密钥
input[127:0] plain_data;     //算法加解密数据
input        data_enable;    //加密数据输入使能信号
output       aes_out;        //密文输出使能信号
output[127:0]cryptograph;    //密文数据
reg[7:0]state10,state11,state12,state13,state14,state15,state16,state17,state18,state19,state1a,state1b,state1c,state1d,state1e,state1f;//共10x16个八位每级流水线输出寄存器
wire[7:0]state10_sb,state11_sb,state12_sb,state13_sb,state14_sb,state15_sb,state16_sb,state17_sb,state18_sb,state19_sb,state1a_sb,state1b_sb,state1c_sb,state1d_sb,state1e_sb,state1f_sb;//共10x16个八位S盒替换后结果线网
wire    [7:0]state10_mc,state11_mc,state12_mc,state13_mc,state14_mc,state15_mc,state16_mc,state17_mc,state18_mc,state19_mc,state1a_mc,state1b_mc,state1c_mc,state1d_mc,state1e_mc,state1f_mc;//共10x16个八位列混合后结果线网
reg    [31:0]w00,w01,w02,w03;//扩展密钥流
//以下为密钥加密流水线
always@(posedge clk)//第一级流水线
    begin
      state1f<=w03[007:000]^data[007:000];state1e<=w03[015:008]^data[015:008];
      state1d<=w03[023:016]^data[023:016];state1c<=w03[031:024]^data[031:024];
      state1b<=w02[007:000]^data[039:032];state1a<=w02[015:008]^data[047:040];
      state19<=w02[023:016]^data[055:048];state18<=w02[031:024]^data[063:056];
      state17<=w01[007:000]^data[071:064];state16<=w01[015:008]^data[079:072];
      state15<=w01[023:016]^data[087:080];state14<=w01[031:024]^data[095:088];
      state13<=w00[007:000]^data[103:096];state12<=w00[015:008]^data[111:104];
      state11<=w00[023:016]^data[119:112];state10<=w00[031:024]^data[127:120];
    end
always@(posedge clk)
    begin
      state20<=state10_mc^w10[31:24];state21<=state11_mc^w10[23:16];
      state22<=state12_mc^w10[15:08];state23<=state13_mc^w10[07:00];
      state24<=state14_mc^w11[31:24];state25<=state15_mc^w11[23:16];
      state26<=state16_mc^w11[15:08];state27<=state17_mc^w11[07:00];
      state28<=state18_mc^w12[31:24];state29<=state19_mc^w12[23:16];
      state2a<=state1a_mc^w12[15:08];state2b<=state1b_mc^w12[07:00];
      state2c<=state1c_mc^w13[31:24];state2d<=state1d_mc^w13[23:16];
    state2e<=state1e_mc^w13[15:08];state2f<=state1f_mc^w13[07:00];
end
assign{state10_mc,state11_mc,state12_mc,state13_mc}=mix_co1(state10_sb,state15_sb,state1a_sb,state1f_sb);
assign{state14_mc,state15_mc,state16_mc,state17_mc}=mix_col(state14_sb,state19_sb,state1e_sb,state13_sb);
assign{state18_mc,state19_mc,state1a_mc,state1b_mc}=mix_col(state18_sb,state1d_sb,state12_sb,state17_sb);
assign{state1c_mc,state1d_mc,state1e_mc,state1f_mc}=mix_col(state1c_sb,state11_sb,state16_sb,state1b_sb);//第一级列混合函数
//第一级S盒替换函数
aes192_sbox us10(.a(state10),.d(state10_sb));aes192_sbox us11(.a(state11),.d(state11_sb));
aes192_sbox us12(.a(state12),.d(state12_sb));aes192_sbox us13(.a(state13),.d(state13_sb));
aes192_sbox us14(.a(state14),.d(state14_sb));aes192_sbox us15(.a(state15),.d(state15_sb));
aes192_sbox us16(.a(state16),.d(state16_sb));aes192_sbox us17(.a(state17),.d(state17_sb));
aes192_sbox us18(.a(state18),.d(state18_sb));aes192_sbox us19(.a(state19),.d(state19_sb));
aes192_sbox us1a(.a(state1a),.d(state1a_sb));aes192_sbox us1b(.a(state1b),.d(state1b_sb));
aes192_sbox us1c(.a(state1c),.d(state1c_sb));aes192_sbox us1d(.a(state1d),.d(state1d_sb));
aes192_sbox us1e(.a(state1e),.d(state1e_sb));aes192_sbox us1f(.a(state1d),.d(state1f_sb));
//第二级流水线开始
always@(posedge clk)
  begin
    state30<=state20_mc^w20[31:24];state31<=state21_mc^w20[23:16];
    state32<=state22_mc^w20[15:08];state33<=state23_mc^w20[07:00];
    state34<=state24_mc^w21[31:24];state35<=state25_mc^w21[23:16];
    state36<=state26_mc^w21[15:08];state37<=state27_mc^w21[07:00];
    state38<=state28_mc^w22[31:24];state39<=state29_mc^w22[23:16];
    state3a<=state2a_mc^w22[15:08];state3b<=state2b_mc^w22[07:00];
    state3c<=state2c_mc^w23[31:24];state3d<=state2d_mc^w23[23:16];
    state3e<=state2e_mc^w23[15:08];state3f<=state2f_mc^w23[07:00];
    end
assign{state20_mc,state21_mc,state22_mc,state23_mc}=mix_col(state20_sb,state25_sb,state2a_sb,state2f_sb);//第二级列混合函数
assign{state24_mc,state25_mc,state26_mc,state27_mc}=mix_col(state24_sb,state29_sb,state2e_sb,state23_sb);
assign{state28_mc,state29_mc,state2a_mc,state2b_mc}=mix_col(state28_sb,state2d_sb,state22_sb,state27_sb);
assign{state2c_mc,state2d_mc,state2e_mc,state2f_mc}=mix_col(state2c_sb,state21_sb,state26_sb,state2b_sb);
aes192_sbox us20(.a(state20),.d(state20_sb));aes192_sbox us21(.a(state21),.d(state21_sb));
aes192_sbox us22(.a(state22),.d(state22_sb));aes192_sbox us23(.a(state23),.d(state23_sb));
aes192_sbox us24(.a(state24),.d(state24_sb));aes192_sbox us25(.a(state25),.d(state25_sb));
aes192_sbox us26(.a(state26),.d(state26_sb));aes192_sbox us27(.a(state27),.d(state27_sb));
aes192_sbox us28(.a(state28),.d(state28_sb));aes192_sbox us29(.a(state29),.d(state29_sb));
aes192_sbox us2a(.a(state2a),.d(state2a_sb));aes192_sbox us2b(.a(state2b),.d(state2b_sb));
aes192_sbox us2c(.a(state2c),.d(state2c_sb));aes192_sbox us2d(.a(state2d),.d(state2d_sb));
aes192_sbox us2e(.a(state2e),.d(state2e_sb));aes192_sbox us2f(.a(state2f),.d(state2f_sb));
//第三级流水线开始
……
//第九级流水线开始
aes192_sbox usa0(.a(statea0),.d(statea0_sb));aes192_sbox usa1(.a(statea1),.d(statea1_sb));
aes192_sbox usa2(.a(statea2),.d(statea2_sb));aes192_sbox usa3(.a(statea3),.d(statea3_sb));
aes192_sbox usa4(.a(statea4),.d(statea4_sb));aes192_sbox usa5(.a(statea5),.d(statea5_sb));
aes192_sbox usa6(.a(statea6),.d(statea6_sb));aes192_sbox usa7(.a(statea7),.d(statea7_sb));
aes192_sbox usa8(.a(statea8),.d(statea8_sb));aes192_sbox usa9(.a(statea9),.d(statea9_sb));
aes192_sbox usaa(.a(stateaa),.d(stateaa_sb));aes192_sbox usab(.a(stateab),.d(stateab_sb));
aes192_sbox usac(.a(stateac),.d(stateac_sb));aes192_sbox usad(.a(statead),.d(statead_sb));
aes192_sbox usae(.a(stateae),.d(stateae_sb));aes192_sbox usaf(.a(stateaf),.d(stateaf_sb));
//第十级流水线:密文输出
always@(posedge clk)
    if(aes_out==1)begin
        cryptograph[127:120]<=statea0_sb^wa0[31:24];
        cryptograph[119:112]<=statea5_sb^wa0[23:16];
        cryptograph[111:104]<=stateaa_sb^wa0[15:08];
        cryptograph[103:096]<=stateaf_sb^wa0[07:00];
        cryptograph[095:088]<=statea4_sb^wa1[31:24];
        cryptograph[087:080]<=statea9_sb^wa1[23:16];
        cryptograph[079:072]<=stateae_sb^wa1[15:08];
        cryptograph[071:064]<=statea3_sb^wa1[07:00];
        cryptograph[063:056]<=statea8_sb^wa2[31:24];
        cryptograph[055:048]<=statead_sb^wa2[23:16];
        cryptograph[047:040]<=statea2_sb^wa2[15:08];
        cryptograph[039:032]<=statea7_sb^wa2[07:00];
        cryptograph[031:024]<=stateac_sb^wa3[31:24];
        cryptograph[023:016]<=statea1_sb^wa3[23:16];
        cryptograph[015:008]<=statea6_sb^wa3[15:08];
        cryptograph[007:000]<=stateab_sb^wa3[07:00];
  end
endmodule
试验测试
在试验测试过程中,采用非流水线的AES算法和本发明的流水线AES算法进行对比。从两个方面对比,一是给定相同的输入数据,然后对比两种算法输出数据是否一致;二面是给定相同的输入和相同的输出数据,然后计算两种算法所需的运算时间速度。通过使用Xilinx公司FPGA芯片,建立测试验证平台电路板系统,使用Modelsim6.1SE软件进行仿真。仿真环境P4、1GM内存,联想启天M4880计算机。图3和图4分别给出了采用本发明的方法后,AES-128算法和AES-192算法的仿真波形图。
数据对比
AES-128算法:
第一组:
key=128’h2b7e151628aed2a6abf7158809cf4f3c;
data=128’h3243f6a8885a308d313198a2e0370734;
cryptograph=128’h 3925841d02dc09fbdc118597196a0b32;
第二组:
key=128’h2357111317192329abccdefadbeec102;
data=128’h1234567890abcdef1234567890abcedf;
cryptograph=128’h b6cc4e1a304c0bf9f098677129177799;
第三组:
key=128’hffff ffff ffff ffff ffff ffff ffff ffff;
data=128’h1234567890abcdef1234567890abcedf;
cryptograph=128’h7c4eb5a4d81717b3b0bda9408fB12f81;
第四组:
key=128’h2b7e151628aed2a6abf7158809cf4f3c;
data=128’h1234567890abcdef1234567890abcedf;
cryptograph=128’h1fea5ac968b3a8861730e5ae6880543f;
第五组:
key=128’h2357111317192329abccdefadbeec102;
data=128’h3243f6a8885a308d313198a2e0370734;
cryptograph=128’he767683f7c8701baa0e5e12f80388adb;
AES-192算法:
第一组:
key=192’h00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17;
data=128’h00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff;
cryptograph=128’hdd a9 7c a4 86 4c df e0 6e af 70 a0 ec 0d 71 91;
第二组:
key=192’h00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17;
data=128’h1234567890abcdef1234567890abcedf;
cryptograph=128’h4f b3 32 a8 88 bd 22 9a 66 d5 fa 7e 56 ea 9b aa;
第三组:
key=192’h 2357111317192329abccdefadbeec 102236790dac2befa29;
data=128’h1234567890abcdef1234567890abcedf;
cryptograph=128’h9071933eee5367e38b25b3c90aeb52b5;
第四组:
key=192’h 2357111317192329abccdefadbeec 102236790dac2befa29;
data=128’h00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff;
cryptograph=128’hdd4e1fc202ea096a6afdb5c9725277c5;
第五组:
key=192’h ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff;
data=128’h1234567890abcdef1234567890abcedf;
cryptograph=128’ha8a1feb79578025a788a2347adf2b67b;
第六组:
key=192’h ffff  ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff;
data=128’h00112233445566778899aabbccddeeff;
cryptograph=128’ha3e0b4b314b298e6e2bc3cc3319e2ea8;
运算时间对比
对于非流水线的AES算法和流水线的AES算法,实现后的运行速度对比如下:
表2:AES非流水线与流水线运行速度比较
  算法   非流水线(时钟数)   流水线(时钟数)
  AES-128   12   1
  算法   非流水线(时钟数)   流水线(时钟数)
  AES-192   14   1
根据表2数据对比测试可以看出,本发明的流水线AES算法得出的结果与通常的AES算法得出的结果一致;计算运行速度提高十多倍以上,大大提高了算法的加密效率,这说明本发明所提出的流水线AES算法针对UCPS中数据流加解密的算法模型是有效可行的,算法原理也是设计正确的。
以上结合具体实施例对本发明进行了详细的说明,这些并非构成对本发明的限制。在不脱离本发明原理的情况下,本领域的技术人员还可作出许多变形和改进,这些也应属于本发明的保护范围。

Claims (3)

1.一种UCPS协议中采用AES算法对数据流加解密的硬件实现方法,其特征在于:将整个加密过程分解为多级流水线,每级流水线根据采用的密钥长度分组和应用的速度来确定,在每级流水线的输出端用寄存器进行暂存处理。
2.如权利要求1所述的方法,其特征在于:当密钥长度为128位时,所述流水线分为10级,每级插入16个8位的寄存器用于暂存输出,经过10个时钟延迟处理后再依次按时钟输出。
3.如权利要求1所述的方法,其特征在于:当密钥长度为192位时,所述流水线分为12级,每级插入24个8位的寄存器用于暂存输出,经过12个时钟延迟处理后再依次按时钟输出。
CN200810044186A 2008-12-25 2008-12-25 Ucps协议中采用aes算法对数据流加解密的硬件实现方法 Pending CN101764687A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200810044186A CN101764687A (zh) 2008-12-25 2008-12-25 Ucps协议中采用aes算法对数据流加解密的硬件实现方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200810044186A CN101764687A (zh) 2008-12-25 2008-12-25 Ucps协议中采用aes算法对数据流加解密的硬件实现方法

Publications (1)

Publication Number Publication Date
CN101764687A true CN101764687A (zh) 2010-06-30

Family

ID=42495684

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200810044186A Pending CN101764687A (zh) 2008-12-25 2008-12-25 Ucps协议中采用aes算法对数据流加解密的硬件实现方法

Country Status (1)

Country Link
CN (1) CN101764687A (zh)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102664729A (zh) * 2012-04-28 2012-09-12 中山大学 一种基于fpga的aes加解密网络通讯装置及其实现方法
CN102932155A (zh) * 2012-12-05 2013-02-13 北京华虹集成电路设计有限责任公司 一种支持采用硬件加密算法的高速存储控制soc芯片
CN103516684A (zh) * 2012-06-26 2014-01-15 中兴通讯股份有限公司 一种对数据包进行处理的方法及装置
CN105356996A (zh) * 2015-12-14 2016-02-24 联想(北京)有限公司 一种密文处理方法、电子设备及密文处理装置
CN106487500A (zh) * 2017-01-04 2017-03-08 盛科网络(苏州)有限公司 采用流水线实现aes算法处理的方法
CN107086910A (zh) * 2017-03-24 2017-08-22 中国科学院计算技术研究所 一种针对神经网络处理的权重加解密方法和系统
CN107679409A (zh) * 2017-09-29 2018-02-09 深圳大学 一种数据加密的加速方法和系统
CN109491280A (zh) * 2017-09-13 2019-03-19 合肥海本蓝科技有限公司 一种实现软硬件互锁的装置

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102664729B (zh) * 2012-04-28 2014-12-31 中山大学 一种基于fpga的aes加解密网络通讯装置及其实现方法
CN102664729A (zh) * 2012-04-28 2012-09-12 中山大学 一种基于fpga的aes加解密网络通讯装置及其实现方法
CN103516684B (zh) * 2012-06-26 2017-11-17 中兴通讯股份有限公司 一种对数据包进行处理的方法及装置
CN103516684A (zh) * 2012-06-26 2014-01-15 中兴通讯股份有限公司 一种对数据包进行处理的方法及装置
CN102932155A (zh) * 2012-12-05 2013-02-13 北京华虹集成电路设计有限责任公司 一种支持采用硬件加密算法的高速存储控制soc芯片
CN105356996B (zh) * 2015-12-14 2018-11-09 联想(北京)有限公司 一种密文处理方法、电子设备及密文处理装置
CN105356996A (zh) * 2015-12-14 2016-02-24 联想(北京)有限公司 一种密文处理方法、电子设备及密文处理装置
CN106487500A (zh) * 2017-01-04 2017-03-08 盛科网络(苏州)有限公司 采用流水线实现aes算法处理的方法
CN107086910A (zh) * 2017-03-24 2017-08-22 中国科学院计算技术研究所 一种针对神经网络处理的权重加解密方法和系统
US11521048B2 (en) 2017-03-24 2022-12-06 Institute Of Computing Technology, Chinese Academy Of Sciences Weight management method and system for neural network processing, and neural network processor
CN109491280A (zh) * 2017-09-13 2019-03-19 合肥海本蓝科技有限公司 一种实现软硬件互锁的装置
CN109491280B (zh) * 2017-09-13 2020-08-07 合肥海本蓝科技有限公司 一种实现软硬件互锁的装置
CN107679409A (zh) * 2017-09-29 2018-02-09 深圳大学 一种数据加密的加速方法和系统
CN107679409B (zh) * 2017-09-29 2021-02-23 深圳大学 一种数据加密的加速方法和系统

Similar Documents

Publication Publication Date Title
Borkar et al. FPGA implementation of AES algorithm
Srinivas et al. FPGA based hardware implementation of AES Rijndael algorithm for Encryption and Decryption
CN101764687A (zh) Ucps协议中采用aes算法对数据流加解密的硬件实现方法
US9189425B2 (en) Protecting look up tables by mixing code and operations
CN104333446B (zh) 一种新型超轻量级qtl分组密码实现方法
US8718280B2 (en) Securing keys of a cipher using properties of the cipher process
US20120254625A1 (en) Protecting states of a cryptographic process using group automorphisms
US8675866B2 (en) Multiplicative splits to protect cipher keys
US20160359618A1 (en) Using state reordering to protect against white box attacks
Rawal Advanced encryption standard (AES) and it’s working
Manoj Kumar et al. Implementation of a High-Speed and High-Throughput Advanced Encryption Standard.
Buell Modern symmetric ciphers—Des and Aes
JP6136325B2 (ja) 暗号処理装置、暗号処理方法およびプログラム
Bajaj et al. AES algorithm for encryption
John Cryptography for resource constrained devices: A survey
Hasamnis et al. implementation of AES as a custom hardware using NIOS II processor
Soumya et al. Design and implementation of Rijndael encryption algorithm based on FPGA
Gnanambika et al. AES-128 bit algorithm using fully pipelined architecture for secret communication
Suratwala et al. A Comparative VHDL Implementation of Advanced Encryption Standard Algorithm on FPGA
Jaiswal et al. Implementation of AES as a Reconfigurable Cryptographic Embedded system using MicroBlaze & Xilinx ISE
Kaur et al. IMPLEMENTATION OF AES ALGORITHM ON FPGA FOR LOW AREA CONSUMPTION.
Sharma et al. Design of an efficient architecture for advanced encryption standard algorithm using systolic structures
Jain et al. An Inner Round Pipeline Architecture Hardware Core for AES
Banik et al. Efficient and Secure Encryption for FPGAs in the Cloud
Ball Jr The Examination of AES S-Box Implementations Using Composite Field Arithmetic on FPGAs

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20100630