DPA contest v4 攻击

DPA contest v4 攻击

DPA contest v4收集了10 0000条trace,trace只涉及了AES-256 RSM 第一轮的加密。AES-256 RSM是在一个连接到SASEBO-W板的ATMega-163智能卡上实现的。

AES RSM介绍

AES-256 RSM 添加了掩码保护,Subbytes操作被替换成了嵌入掩码的版本 MaskedSubBytes:
M a s k e d S u b B y t e s i ( X ) = S u b B y t e s ( X ⊕ M i ) ⊕ M i + 1 MaskedSubBytes_i(X) = SubBytes(X \oplus M_i)\oplus M_{i+1} MaskedSubBytesi(X)=SubBytes(XMi)Mi+1
其中掩码 M i M_i Mi是公开的:
M i ∈ 0 , 15 = { 0 x 00 , 0 x 0 f , 0 x 36 , 0 x 39 , 0 x 53 , 0 x 5 c , 0 x 65 , 0 x6a , 0 x 95 , 0 x 9 a , 0 xa3 , 0 x x c , 0xf6 , 0 x c9 , 0 xf0 , 0 xff } . \begin{aligned} M_{i \in 0,15}= & \{0\text{x}00,0\text{x}0f, 0\text{x}36,0\text{x}39,0\text{x}53,0\text{x}5c, 0\text{x}65,0\text{x6a}, \\ & 0\text{x}95,0\text{x}9a, 0\text{xa3}, 0x\text{x}c, \text{0xf6}, 0x\text{c9}, 0\text{xf0},0\text{xff}\} . \end{aligned} Mi0,15={0x00,0x0f,0x36,0x39,0x53,0x5c,0x65,0x6a,0x95,0x9a,0xa3,0xxc,0xf6,0xc9,0xf0,0xff}.


AES RSM实现

AES RSM 泄露分析

在AES 256 RSM实现第一轮中X首先异或 M a s k Mask Mask得到 X ′ X' X,然后用 X ′ X' X异或 R o u n d K e y RoundKey RoundKey最后经过 M a s k e d S u b B y t e s MaskedSubBytes MaskedSubBytes。分析$ MaskedSubBytes_i$的输入输出的异或:
X [ i ] ⊕ M i ⊕ R o u n d K e y 1 [ i ] M a s k e d S u b B y t e s i ( X [ i ] ⊕ R o u n d K e y 1 [ i ] ⊕ M i ⊕ M i ) ⊕ M i + 1 = X [ i ] ⊕ R o u n d K e y 1 [ i ] ⊕ S u b B y t e s i ( X [ i ] ⊕ R o u n d K e y 1 [ i ] ) ⊕ M i ⊕ M i + 1 \begin{align*} X[i]\oplus M_i\oplus RoundKey_1[i]{ Masked}SubBytes_i(X[i]\oplus RoundKey_1[i]\oplus M_i \oplus M_i)\oplus M_{i+1}\\ =X[i]\oplus RoundKey_1[i]\oplus SubBytes_i(X[i]\oplus RoundKey_1[i])\oplus M_i\oplus M_{i+1} \end{align*} X[i]MiRoundKey1[i]MaskedSubBytesi(X[i]RoundKey1[i]MiMi)Mi+1=X[i]RoundKey1[i]SubBytesi(X[i]RoundKey1[i])MiMi+1
M i ⊕ M i + 1 M_i\oplus M_{i+1} MiMi+1是不均匀的!
M i ⊕ M i + 1 i ∈ 0 , 15 = { 0 x0f , 0 x39 , 0 x0f , 0 x6a , 0 x0f , 0 x39 , 0 x0f , 0 xff , 0 x0f , 0 x39 , 0 x0f , 0 x6a , 0 x0f , 0 x39 , 0 x0f , 0 xff } . \begin{align*} \underset{i\in 0,15}{M_i\oplus M_{i+1}}= & \{0\text{x0f},0\text{x39}, 0\text{x0f},0\text{x6a},0\text{x0f},0\text{x39},0\text{x0f},0\text{xff},\\ & 0\text{x0f},0\text{x39}, 0\text{x0f},0\text{x6a}, 0\text{x0f},0\text{x39},0\text{x0f},0\text{xff}\} . \end{align*} i0,15MiMi+1={0x0f,0x39,0x0f,0x6a,0x0f,0x39,0x0f,0xff,0x0f,0x39,0x0f,0x6a,0x0f,0x39,0x0f,0xff}.
8 个 0x0f, 4 个 0x39, 2 个0x6a, 2 个 0xff, 分布不均匀!

所以我们利用的泄露模型为:
H = X ⊕ R o u n d K e y 1 ⊕ S B o x ( X ⊕ R o u n d K e y 1 ) H=X \oplus RoundKey_1 \oplus SBox(X \oplus RoundKey_1) H=XRoundKey1SBox(XRoundKey1)
利用上式可以消除掩码的保护。
使用1000个trace 求平均值画出波形,可以发现200 μ s \mu s μs到 400 μ s \mu s μs 是 Subbytes的过程,可以大致分辨出16个state分别操作的过程如下图:在这里插入图片描述

使用10000条trace,针对明文的第一字节们进行测试,测试 X [ 1 ] ⊕ R o u n d K e y 1 ∗ [ 1 ] ⊕ S u b B y t e s i ( X [ 1 ] ⊕ R o u n d K e y 1 ∗ [ 1 ] ) X[1]\oplus RoundKey_1^{*}[1]\oplus SubBytes_i(X[1]\oplus RoundKey_1^{*}[1]) X[1]RoundKey1[1]SubBytesi(X[1]RoundKey1[1])与trace的相关度( R o u n d K e y 1 ∗ RoundKey_1^{*} RoundKey1是真实的轮密钥),发现正确密钥对应的相关度是可与其他错误密钥明显区分开。明文的其他字节与trace的相关度图也类似的形状。

在这里插入图片描述

实施攻击

根据DPA Contest 的规则,密钥的猜测必须是稳定的。这意味着,当算法在继续使用更多trace时,能够持续保持其正确的密钥,密钥稳定的阈值固定在100。
在此条件下恢复第一轮密钥 K K K的各个字节所需要的trace条数如下:

密钥字节number of traces
K[0]200
K[1]529
K[2]442
K[3]401
K[4]401
K[5]401
K[6]423
K[7]401
K[8]643
K[9]948
K[10]511
K[11]423
K[12]835
K[13]504
K[14]471
K[15]401

攻击在Python下实施,由于需要不断计算皮尔逊相关系数(Pearson correlation coefficient),十分耗时,所以恢复正确密钥花费了11h。

攻击代码的改进

由于测信道攻击中频繁使用科学计算,所以为了方便一直使用 python,但
python 实在太慢,然后了解并学习了 C++的科学计算库 Eigen。
Eigen 是一个高层次的 C ++库,有效支持线性代数,矩阵和矢量运算,数
值分析及其相关的算法。
使用 eigen 库实现与上周攻击 DPA Contest v4 的 python 程序相同的功能。
在 python 版本的攻击程序运行 11h 才完成,而利用 Eigen 库编写的 C++程序只
需要 64 分钟,速度提升 10 倍之多。

在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值