2002年,CHARI等人[1]利用能量消耗与正在处理的数据有关这一基本事实[2],提出了模板攻击的概念。模板攻击方法使用多元正态分布对采集到的数据特征进行刻画,在模板攻击中,假设攻击者可以对被攻击设备的特征进行刻画,如攻击者拥有一台与被攻击设备类型相同的设备,利用该设备,攻击者根据不同数据和固化的密钥来执行加密操作,即观察加密设备的具体物理实现,并记录对应的能耗信息,然后将与(数据,密钥)相对应的能量迹进行分组,估算多元正态分布的均值向量和协方差矩阵,并由此发起攻击。模板攻击是一种重要的侧信道攻击方法,与传统的简单能量分析[3]、相关性能量分析[4]和差分能量分析[5]等相比,模板攻击在实际的密码算法破译中拥有更强的区分能力,因此,其受到研究人员的广泛关注[6-7]。
近年来,随着物联网技术的快速发展,各种资源受限的设备(如无线传感器等)被广泛应用。由于资源受限设备大多计算与存储资源少,因此在数据安全存储、传输或处理方面存在严重的安全隐患。为解决资源受限环境下的数据安全问题,轻量级密码技术[8-10]应运而生。2019年,JAGDISH等人提出一种新的轻量级分组密码算法DoT[11]。与著名的轻量级分组密码算法SIMON[12]相比,DoT在软件与硬件实现方面更为简单。DoT密码算法整体采用SP结构[13]以及轻型的线性及非线性运算部件,在硬件实现时仅需993个等效门。设计者声称DoT算法可以抵御多种传统数学攻击,如线性密码攻击[14]、差分密码攻击[15]等,然而,该算法在实现中是否足以抵御模板攻击仍有待探索。本文基于汉明重量模型,结合DoT算法的结构及S盒的特点,将DOT算法S盒的输出作为中间值进行密钥恢复,提出一种针对DoT算法的模板攻击方法。
1 DoT算法描述DoT密码算法[11]整体结构采用SPN设计,其明文分组为64 bit,根据密钥数据长度的不同将该算法分为2种版本,即80 bit的DOT-80和128 bit的DOT-128。对于不同的密钥长度,DoT算法使用不同的密钥编排算法。DoT算法的加密和解密过程均使用31轮的轮函数迭代运算,每一个轮函数包括轮密钥加(AddRoundkey)、半字节代换(SubCells)和P置换(Permutation)3个步骤,如图 1所示。
|
Download:
|
| 图 1 DoT密码算法的轮函数 Fig. 1 Round function of DoT cipher algorithm | |
DoT密码算法的主密钥是80 bit,记为
1)
| $ \mathrm{K}\mathrm{E}\mathrm{Y} <<<13 $ |
2) 低8位
| $ \left[{K}_{3}{K}_{2}{K}_{1}{K}_{0}\right]\leftarrow \mathrm{S}\left[{K}_{3}{K}_{2}{K}_{1}{K}_{0}\right] $ |
| $ \left[{K}_{7}{K}_{6}{K}_{5}{K}_{4}\right]\leftarrow \mathrm{S}\left[{K}_{7}{K}_{6}{K}_{5}{K}_{4}\right] $ |
3) 将
| $ \left[{K}_{63}{K}_{62}{K}_{61}{K}_{60}{K}_{59}\right]\leftarrow \left[{K}_{63}{K}_{62}{K}_{61}{K}_{60}{K}_{59}\right]\oplus \mathrm{R}{\mathrm{C}}^{i} $ |
半字节代换是一个非线性变换操作,其将内部状态中的每一个半字节非线性变换为另一个半字节。DoT中使用4 bit密码S盒,即4 bit输入和4 bit输出,如表 1所示。
|
下载CSV 表 1 4 bit密码S盒 Table 1 4 bit cryptographic S-box |
置换层的功能是加强数据扩散,其本质上是一个线性部件。DoT算法中采用字节的置换层包含2次置换和1次循环移位,如图 1所示。
2 模板攻击 2.1 模板攻击的基本思想密码设备所产生的物理泄露种类多样,如时间序列[16]、能耗[17]和电磁辐射[18]等。近年来的侧信道分析结果表明,能耗攻击仍然是使用最多的一种攻击。模板攻击分析设备在实现加密操作过程中发生的物理泄露,这种泄露在统计上依赖所涉及密钥操作的中间值,从而使得从测量信息泄露所得的数据来推断密钥成为可能。需要注意的是,实现模板攻击有一个重要的假设前提,即攻击者能够完全控制一个和被攻击设备几乎完全类似的设备,可以不受限制地多次调用该设备,且参数由自己设定。这个假设前提有可能实现,原因是被攻击设备通常是标准设备,与其类似的设备可以通过合法途径获得。
在上述假设的基础上,攻击者可以通过该设备对算法中间值的汉明重量构建模板,然后用同样的方法在被攻击设备运行时获取能耗信息并与已构建好的模板进行匹配。匹配效果最好的模板对应的汉明重量就是可能正确的汉明重量,然后根据每一次的匹配结果得出所有可能的候选密钥集合,进行取交集操作,最后筛选出的一个密钥就是所求正确密钥。
2.2 基于汉明重量的模板攻击模板攻击分为模板刻画和密钥恢复2个阶段[19],本书将进行具体阐述。
2.2.1 模板刻画攻击者选定一个中间值,求出该中间值所有可能的汉明重量,通过使用一组密钥和明文计算出一个汉明重量为
假设攻击者使用密钥
| $ {M}_{(i, k)}=\frac{\sum \limits_{j=1}^{m}{T}_{(j, k)}}{m} $ |
攻击者计算出每个样本点的均值,通过计算得到汉明重量为
| $ {\boldsymbol{M}}_{i}=\{{M}_{(i, 1)}, {M}_{(i, 2)}, \cdots , {M}_{(i, n)}\} $ |
其中,
攻击者在目标设备上用所求密钥对同一个明文
值得注意的是,测量得到的每一条能量迹都含有噪声,如果攻击者不对能量迹作预处理,噪声可能会严重影响密钥恢复阶段的成功率。因此,攻击者要对加密进行多次重复操作,通过求均值的方式来降低噪声的影响。最后,使用均值能量迹与模板进行匹配以恢复正确密钥。
3 针对DoT分组密码的模板攻击本文针对DoT的软件实现进行攻击测试。在攻击中,选择DoT第一轮执行S盒的输出作为中间值,并采用汉明重量模型构建模板。因为DoT在设备上执行时是每2个S盒相合并以进行运算,所以是以字节为单位,每一个字节为8 bit,因此,需要分别构建
|
Download:
|
| 图 2 模板攻击流程 Fig. 2 Procedure of template attack | |
针对DoT的模板攻击步骤如下:
步骤1 选择一个用于建立模板的密钥
步骤2 随机选取一个明文
步骤3 采用最小二乘法,将所得均值能量迹
|
下载CSV
表 2 汉明重量 |
步骤4 选取另一个不同的明文
本文测试环境选用WindowsXP系统,算法实现使用MathMagic侧信道分析仪,其中,处理器选用STC89C52,并用MM_SCA软件进行波形分析。
在测试过程中,在MathMagic侧信道分析仪的STC89C52处理器上实现DoT算法。将采样率设置为
|
Download:
|
| 图 3 模板曲线 Fig. 3 Template curves | |
|
Download:
|
| 图 4 波形匹配 Fig. 4 Waveforms matching | |
本文在STC89C52处理器上进行实验,选择6组明文和一个固定的密钥,如下:
| $ \mathrm{k}\mathrm{e}\mathrm{y}=0\mathrm{x}112233\cdots \mathrm{D}\mathrm{D}\mathrm{E}\mathrm{E}\mathrm{F}\mathrm{F}00 $ |
在实际攻击中,真正的密钥是未知的,本文中的真正密钥用来验证实验结果是否正确。在恢复第一个字节时,用6组明文的第一个字节
在第一次测试时,模板匹配得到
| $ \begin{array}{l}\{0\mathrm{x}0\mathrm{B}, 0\mathrm{x}0\mathrm{D}, 0\mathrm{x}\mathrm{11, 0}\mathrm{x}\mathrm{16, 0}\mathrm{x}\mathrm{17, 0}\mathrm{x}\mathrm{19, 0}\mathrm{x}1\mathrm{A}, 0\mathrm{x}1\mathrm{E}, \\ 0\mathrm{x}1\mathrm{F}, 0\mathrm{x}\mathrm{21, 0}\mathrm{x}\mathrm{24, 0}\mathrm{x}\mathrm{27, 0}\mathrm{x}\mathrm{29, 0}\mathrm{x}2\mathrm{B}, 0\mathrm{x}2\mathrm{D}, 0\mathrm{x}2\mathrm{F}, \\ 0\mathrm{x}\mathrm{36, 0}\mathrm{x}\mathrm{37, 0}\mathrm{x}\mathrm{39, 0}\mathrm{x}\mathrm{41, 0}\mathrm{x}\mathrm{45, 0}\mathrm{x}\mathrm{48, 0}\mathrm{x}4\mathrm{C}, 0\mathrm{x}4\mathrm{F}, \\ 0\mathrm{x}\mathrm{51, 0}\mathrm{x}\mathrm{64, 0}\mathrm{x}6\mathrm{F}, 0\mathrm{x}\mathrm{75, 0}\mathrm{x}\mathrm{76, 0}\mathrm{x}7\mathrm{B}, 0\mathrm{x}7\mathrm{E}, 0\mathrm{x}7\mathrm{F}, \\ 0\mathrm{x}8\mathrm{E}, 0\mathrm{x}8\mathrm{F}, 0\mathrm{x}\mathrm{95, 0}\mathrm{x}9\mathrm{B}, 0\mathrm{x}\mathrm{A}\mathrm{0, 0}\mathrm{x}\mathrm{A}\mathrm{1, 0}\mathrm{x}\mathrm{A}\mathrm{5, 0}\mathrm{x}\mathrm{A}\mathrm{A}, \\ 0\mathrm{x}\mathrm{A}\mathrm{B}, 0\mathrm{x}\mathrm{A}\mathrm{E}, 0\mathrm{x}\mathrm{B}\mathrm{C}, 0\mathrm{x}\mathrm{D}\mathrm{1, 0}\mathrm{x}\mathrm{D}\mathrm{7, 0}\mathrm{x}\mathrm{D}\mathrm{C}, 0\mathrm{x}\mathrm{D}\mathrm{D}, \\ 0\mathrm{x}\mathrm{D}\mathrm{E}, 0\mathrm{x}\mathrm{E}\mathrm{1, 0}\mathrm{x}\mathrm{E}\mathrm{9, 0}\mathrm{x}\mathrm{E}\mathrm{A}, 0\mathrm{x}\mathrm{E}\mathrm{D}, 0\mathrm{x}\mathrm{E}\mathrm{E}, 0\mathrm{x}\mathrm{E}\mathrm{F}, \\ 0\mathrm{x}\mathrm{F}\mathrm{3, 0}\mathrm{x}\mathrm{F}\mathrm{D}\}\end{array} $ |
在第二次测试时,模板匹配得到
| $ \begin{array}{l}\{0\mathrm{x}11, \mathrm{ }0\mathrm{x}21, \mathrm{ }0\mathrm{x}2\mathrm{F}, \mathrm{ }0\mathrm{x}45, \mathrm{ }0\mathrm{x}48, \mathrm{ }0\mathrm{X}4\mathrm{F}, \mathrm{ }\mathrm{ }0\mathrm{x}51, \mathrm{ }\mathrm{ }0\mathrm{x}6\mathrm{F}, \\ 0\mathrm{x}\mathrm{76, 0}\mathrm{x}7\mathrm{B}, 0\mathrm{x}7\mathrm{F}, 0\mathrm{x}8\mathrm{F}, 0\mathrm{x}\mathrm{A}\mathrm{1, 0}\mathrm{x}\mathrm{A}\mathrm{5, 0}\mathrm{x}\mathrm{A}\mathrm{B}, 0\mathrm{x}\mathrm{E}9, \mathrm{ }\\ 0\mathrm{x}\mathrm{F}3\}\end{array} $ |
在第三次测试时,模板匹配得到
| $ \{0\mathrm{x}\mathrm{11, 0}\mathrm{x}\mathrm{21, 0}\mathrm{x}2\mathrm{F}, 0\mathrm{x}\mathrm{51, 0}\mathrm{x}8\mathrm{F}\} $ |
在第四次测试时,模板匹配得到
| $ \left\{0\mathrm{x}\mathrm{11, 0}\mathrm{x}2\mathrm{F}\right\} $ |
在第五次测试时,模板匹配得到
| $ \left\{0\mathrm{x}\mathrm{11, 0}\mathrm{x}2\mathrm{F}\right\} $ |
在第六次测试时,模板匹配得到
| $ \left\{0\mathrm{x}11\right\} $ |
经过上述6次筛选测试,最终捕获正确的8 bit密钥。
5 模板攻击抵御方法任何对抗侧信道攻击的方法都是使加密设备消耗的能量不依赖密码算法执行加密时出现的中间值,掩码技术[22]是一种著名的防护对策,其通过随机化设备处理的中间值来实现这一目标。掩码防护方法通常在算法级上进行防御,其优点是可以直接作用在密码算法的输入或输出的中间状态值上,而不必改变密码设备的硬件器件。本文提出一种对DoT密码S盒的输入和输出进行掩码防护的方法。通常情况下可以将S盒分为软件实现和硬件实现2种方式。文献[23]指出掩码的密码硬件实现可能会降低其实现速度。因此,本文采用软件实现方法对DoT算法进行掩码防护。
DoT算法的S盒软件实现是通过使用查找表T,对于每个输入变量
|
Download:
|
| 图 5 DoT掩码后的图形化描述 Fig. 5 Graphical description of masked DoT | |
基于以上掩码方法,本文针对DoT密码算法进行编译实现,并进行相应的模板攻击。注意到,掩码中引入了随机数,导致敌手无法通过模板攻击中的中间值计算直接捕获正确密钥,实际测试结果也证实了这一点。
6 结束语本文基于汉明重量模型,利用DoT算法结构及密码S盒的特点,提出一种针对DoT算法的模板攻击方法。实验结果表明,DoT算法在该模板攻击下具有脆弱性。为了抵御这一攻击,本文设计一种DoT算法S盒掩码方案,测试结果验证了其有效性。下一步将针对DoT密码算法设计高效的门限掩码防护方案。
| [1] |
CHARI S, RAO J R, ROHATGI P.Template attacks[EB/OL].[2020-01-15]. https://www.semanticscholar.org/paper/Template-Attacks-Chari-Rao/f7a0d42044b26be8d509310ba20fd8d665943eba?p2df.
|
| [2] |
MANGARD S, OSWALD E, POPP T.Power analysis attacks[M]. Translated by FENG Dengguo, ZHOU Yongbin, LIU Jiye, et al.Beijing: Science Press, 2010.(in Chinese) MANGARD S, OSWALD E, POPP T. 能量分析攻击[M]. 冯登国, 周永彬, 刘继业, 等译. 北京: 科学出版社, 2010. |
| [3] |
OSWALD E. Enhancing simple power-analysis attacks on elliptic curve cryptosystems[J]. Cryptographic Hardware and Embedded Systems, 2002, 2523: 82-97. |
| [4] |
BRIER E, CLAVIER C, OLIVIER F.Correlation power analysis with a leakage model[C]//Proceedings of International Workshop on Cryptographic Hardware and Embedded Systems.Berlin, Germany: Springer, 2004: 16-29.
|
| [5] |
KOCHER P C, JAFFE J, JUN B.Differential power analysis[M]. Berlin, Germany: Springer, 2007.
|
| [6] |
ZHANG Shaohui, WU Liji, ZHANG Xiangmin, et al.A template attack-resistant masking scheme for RC4 based on FPGA[C]//Proceedings of the 11th International Conference on Computational Intelligence and Security.Washington D.C., USA: IEEE Press, 2015: 16-25.
|
| [7] |
HU Yongbo, ZHENG Yeyang, YU Jun. A new template attack method of advanced encryption standard[J]. Computer Engineering, 2013, 39(8): 166-168. (in Chinese) 胡永波, 郑业扬, 俞军. 一种新的高级加密标准模板攻击方法[J]. 计算机工程, 2013, 39(8): 166-168. |
| [8] |
EISENBARTH T, KUMAR S. A survey of lightweight-cryptography implementations[J]. IEEE Design & Test of Computers Magazine, 2007, 24(6): 522-533. |
| [9] |
BANIK S, PANDEY S K, PEYRIN T, et al.GIFT: a small present[C]//Proceedings of International Conference on Cryptographic Hardware and Embedded Systems.Berlin, Germany: Springer, 2017: 15-29.
|
| [10] |
ZHUKOV A.Lightweight cryptography: modern development paradigms[EB/OL].[2020-01-15]. https://dl.acm.org/doi/epdf/10.1145/2799979.2799981.
|
| [11] |
JAGDISH P, GAURAV B, KUMAR S K.DoT: a new ultra-lightweight SP network encryption design for resource-constrained environment[C]//Proceedings of International Conference on Data Engineering and Communication Technology.Berlin, Germany: Springer, 2019: 145-169.
|
| [12] |
YANG G, ZHU B, SUDER V, et al.The simeck family of lightweight block ciphers[C]//Proceedings of International Workshop on Cryptographic Hardware and Embedded Systems.Berlin, Germany: Springer, 2015: 125-148.
|
| [13] |
NECHVATAL J, BARKER E, BASSHAM L, et al. Report on the development of the advanced encryption standard[J]. Journal of Research of the National Institute of Standards and Technology, 2001, 106(3): 14-25. |
| [14] |
MATSUI M.Linear cryptanalysis method for DES cipher[M]. Berlin, Germany: Springer, 1994.
|
| [15] |
BIHAM E, SHAMIR A. Differential cryptanalysis of DES-like cryptosystems[J]. Journal of Cryptology, 1991, 4(1): 3-72. DOI:10.1007/BF00630563 |
| [16] |
KOCHER P C.Timing attacks on implementations of Diffie-Hellman, RSA, DSS, and other systems[C]//Proceedings of the 16th Annual International Cryptology Conference on Advances in Cryptology.Berlin, Germany: Springer, 1999: 598-631.
|
| [17] |
KELSEY J, SCHNEIER B, WAGNER D, et al.Side channel cryptanalysis of product ciphers[C]//Proceedings of European Symposium on Research in Computer Security.Berlin, Germany: Springer, 1998: 455-468.
|
| [18] |
GANDOLFI K, MOURTEL C, OLIVIER F.Electromagnetic analysis: concrete results[C]//Proceedings of International Workshop on Cryptographic Hardware and Embedded Systems.Berlin, Germany: Springer, 2001: 251-261.
|
| [19] |
OU Changhai, WANG Zhu, HUANG Weiqing, et al. Amplified template attacks on cryptographic devices using Hamming weight model[J]. Journal of Cryptologic Research, 2015, 2(5): 477-486. (in Chinese) 欧长海, 王竹, 黄伟庆, 等. 基于汉明重量模型的密码设备放大模板攻击[J]. 密码学报, 2015, 2(5): 477-486. |
| [20] |
TIAN Long, LIU Zongtian. Piecewise line fitting with least square method[J]. Computer Science, 2012, 39(S1): 482-484. (in Chinese) 田垅, 刘宗田. 最小二乘法分段直线拟合[J]. 计算机科学, 2012, 39(S1): 482-484. |
| [21] |
ENDERLEIN J. Maximum-likelihood criterion and single-molecule detection[J]. Applied Optics, 1995, 34(3): 514-515. DOI:10.1364/AO.34.000514 |
| [22] |
STANDAERT F, ROUVROY G, QUISQUATER J J.FPGA implementations of the DES and triple-DES masked against power analysis attacks[EB/OL].[2020-02-15]. https://static.aminer.org/pdf/PDF/000/214/572/design_strategies_and_modified_descriptions_to_optimize_cipher_fpga_implementations.pdf.
|
| [23] |
NORBERT P, ELISABETH O, STEFAN M.A masked AES ASIC implementation[EB/OL].[2020-02-15]. https://www.semanticscholar.org/paper/A-Masked-AES-ASIC-Implementation-%E2%88%97-Pramstaller-Oswald/935f6b3b0489de79ddcee51bb4c8741dde5b3c40.
|
2021, Vol. 47
