条件
- 目的
- 为需要认证的数据产生一个指纹。
- 满足条件
- 输入任意长
- 输出固定长
- 易于软硬件实现
安全条件
- 单向性
- 已知
x
,易求H(x)
; - 已知
H(x)
,求x
是计算上不可行的。
- 已知
- 抗弱碰撞性(重要)
- 已知
x
,找出y(y!=x)
使得H(x)=H(y)
计算上不可行。
- 已知
- 抗强碰撞性(重要)
- 找出任意两个不同的输入
x
和y
,使得H(x)=H(y)
在计算上不可行。
- 找出任意两个不同的输入
迭代型哈希函数
- 结构
CV
称为链接变量。
SHA-1
算法概述
- 输入
- 小于
2^64
比特长的任意消息,划分为512
比特长的分组。
- 小于
- 输出
160
比特长的消息摘要。
- 框图
压缩函数
-
包含
4
轮处理过程; -
每轮处理过程由
20
步迭代运算组成; -
迭代运算:
A , B , C , D , E ← ( E + f t ( B , C , D ) + C L S 5 ( A ) + W t + K t ) , A , C L S 30 ( B ) , C , D t : N u m b e r o f i t e r a t i o n s f t ( B , C , D ) : T h e b a s i c l o g i c f u n c t i o n u s e d i n s t e p − t i t e r a t i o n C L S s : C i r c u l a t e s s b i t t o t h e l e f t W t : A 32 b i t e x t r a l o n g w o r d e x p o r t e d f r o m t h e c u r r e n t g r o u p K t : A d d i t i v e c o n s t a n t + : + % 2 32 A,B,C,D,E\leftarrow (E+f_t(B,C,D)+CLS_5(A)+W_t+K_t),A,CLS_{30}(B),C,D\\ t:Number\ of\ iterations\\ f_t(B,C,D):The\ basic\ logic\ function\ used\ in\ step-t\ iteration\\ CLS_s:Circulates\ s\ bit\ to\ the\ left\\ W_t:A\ 32\ bit\ extra\ long\ word\ exported\ from\ the\ current\ group\\ K_t:Additive\ constant\\ +:+\%2^{32} A,B,C,D,E←(E+ft(B,C,D)+CLS5(A)+Wt+Kt),A,CLS30(B),C,Dt:Number of iterationsft(B,C,D):The basic logic function used in step−t iterationCLSs:Circulates s bit to the leftWt:A 32 bit extra long word exported from the current groupKt:Additive constant+:+%232
-
基本逻辑
- 输入为
3
个32
比特的字 - 输出为
1
个32
比特的字
- 输入为
SM3
算法描述
- 输入
- 数据长度为
l
(l<2^64
)。
- 数据长度为
- 输出
- 哈希值长度为
256
比特。
- 哈希值长度为
算法对数据先填充,再进行迭代压缩生成哈希值。
- 填充
- 使填充后的数据长度为
512
的整数倍。 - 中间补零。
- 最后
64
位为总长度的二进制表示。
- 使填充后的数据长度为
CBC构造认证码
M
e
s
s
a
g
e
:
m
=
(
m
1
,
m
2
,
.
.
.
,
m
n
)
C
h
e
c
k
c
o
d
e
:
r
=
m
n
+
1
=
m
1
⊕
.
.
.
⊕
m
n
A
u
t
h
e
n
t
i
c
a
t
i
o
n
c
o
d
e
:
C
n
+
1
b
e
l
o
w
Message:m=(m_1,m_2,...,m_n)\\ Check\ code:r=m_{n+1}=m_1\oplus ...\oplus m_n\\ Authentication\ code:C_{n+1}\ below
Message:m=(m1,m2,...,mn)Check code:r=mn+1=m1⊕...⊕mnAuthentication code:Cn+1 below