# 基于ARM处理器的AES缓存攻击技术研究Research on AES Cache Attack Technology Based on ARM Processor

Cache攻击是一种强大的攻击工具，能够根据Cache泄露的内存访问模式获取用户的私密信息，比如用户的键盘输入、加密的密钥等。在Intel x86平台上，已经有针对AES、DES加密算法的Cache攻击实现，但是在Android平台上，由于Cache结构、指令集、Cache替换策略等与Intel x86有很多差别，因此攻击难度较大。本文基于Android平台，以AES加密算法作为攻击对象，通过引入假设检验，降低随机误差对实验结果的影响，最终获取AES全部密钥。最后对AES异步攻击方式进行探索。

Abstract: Cache attack is a powerful attack tool that can access the user’s private information based on the memory access mode revealed by the Cache, such as the user’s keyboard input, encryption keys, etc. On Intel x86 platform, there have been Cache attack implementations aiming at AES, DES encryption algorithm, but on the Android platform, the structure of the Cache, instruction Set and Cache replacement strategy have a lot of differences from that of Intel x86, so Cache attack on mobile devices is difficult. This paper reduces the impact of random error of the experimental results on the Android platform by introducing hypothesis testing, eventually getting all AES key bytes. Then this paper explores the asynchronous attack mode.

2. 相关技术

2.1. 计时方式

get_time方法能够返回精确的系统时间，图1通过POSIX提供的接口测量访存和访问Cache的时间差距。该实验首先通过get_time函数统计50,000次Cache命中(蓝色柱状图)和Cache缺失(红色柱状图)的时间，然后将测量得到的时间统计到一张图中。其中图表的横坐标表示统计时间，单位为纳秒，纵坐标为在单个时间点上统计的次数。

2.2. 驱逐策略

Table 1. POSIX timing

Figure 1. Cache hit and miss experiment

3. 同步攻击

AES攻击

AES执行过程中对各个Table的查表操作是对其进行Cache攻击的切入点，对于相同的密钥k，对于不同的明文p进行加密时，根据计算，会访问到各个Table中不同索引位置，如果Cache中没有缓存相应位置的数据时，会将该数据以及其周围的数据加载到其内存所对应的Cache Set的某一个line中，加载的数据块大小与Cache line大小相等。本文针对Lenovo k51c78测试机进行实验，其Cache line大小为64字节，Table中的每项数据为4字节。加密过程中每次访问Table中的数据时，会将其周围共16个数据项加载到同一个Cache line中。因此，如果T0中起始数据所在内存对应Cache中某一Set a中某一Cache line的起始位置，则T0中索引前16项的数据都将映射到Set a中，而索引第16至第32项数据将映射到Set a + 1中，Table中索引为i的数据将映射到的 Set索引为a + (i/16)。

Table 2. Evicting Algorithm

Figure 2. The map between AES table and Cache

Figure 3. The result of AES first 8 bytes in first round attack

Figure 4. The result of AES last 8 bytes in first round attack

Table 3. The indices of AES in second round

Table 4. The result of ( k 0 , k 5 , k 10 , k 15 ) in second round

Table 5. The result of ( k 4 , k 9 , k 14 , k 3 ) in second round

Table 6. The result of ( k 8 , k 13 , k 2 , k 7 ) in second round

Table 7. The result of ( k 12 , k 1 , k 6 , k 11 ) in second round

4. 异步攻击设计

5. 结束语

[1] Kocher, P.C. (1996) Timing Attacks on Implementations of Diffie-Hellman, RSA, DSS, and Other Systems. International Cryptology Conference on Advances in Cryptology, 1109, 104-113.

[2] Kelsey, J., Schneier, B., Wagner, D., et al. (1998) Side Channel Cryptanalysis of Product Ciphers. European Symposium on Research in Computer Security, Louvain-La-Neuve, 16-18 September 1998, 97-110.

[3] Page, D. (2002) Theoretical Use of Cache Memory as a Cryptanalytic Side-Channel. Technical Report CSTR-02-003, Department of Computer Science, University of Bristol. http://www.cs.bris.ac.uk/Publications/pub_info.jsp?id=1000625

[4] Wu, W.L., He, Y.P., Feng, D.G. and Qing, S.H. (2002) Power Attack of Mars and Rijndael. Journal of Software, 13, 532-536. (In Chinese with English Abstract) http://www.jos.org.cn/1000-9825/13/532.htm

[5] Zhou, Y.B. and Feng, D.G. (2005) Side-Channel Attacks: Ten Years after Its Publication and the Impacts on Cryptographic Module Security Testing. Proceedings of the NIST Physical Security Workshop, 1-34.

[6] Hou, F.Y., Gu, D.W. and Lin, X.Y. (2007) Cache-Based Attacks against AES: Research Progress. Information Security and Communications Privacy, 8, 41-43. (In Chinese with English Abstract)

[7] Deng, G.M., Zhao, Q., Zhang, P. and Chen, K.Y. (2008) Cache Hit Side Channel Attack Based on AES. Computer Engineering, 34, 113-114. (In Chinese with English Abstract)

[8] Bonneau, J. and Mironov, I. (2006) Cache-Collision Timing Attacks against AES. In: Goubin, L. and Matsui, M., Eds., Proceedings of the Cryptographic Hardware and Embedded Systems (CHES 2006), LNCS 4249, Berlin, Springer-Verlag, 201-215.
https://doi.org/10.1007/11894063_16

[9] Li, B., Hu, Y.P. and Zhong, M.F. (2008) Time-Based Cache attacks on AES. Computer Engineering, 34, 141-143. (In Chinese with English Abstract)

[10] Bernstein, D.J. (2005) Cache-Timing Attacks on AES. http://cr.yp.to/papers.html\#cachetiming

[11] Lipp, M., Gruss, D., Spreitzer, R., et al. (2015) ARMageddon: Cache Attacks on Mobile Devices. Mundo Electrónico, 6, 60-65.

Top