作者投稿和查稿 主编审稿 专家审稿 编委审稿 远程编辑

计算机工程 ›› 2023, Vol. 49 ›› Issue (9): 109-117. doi: 10.19678/j.issn.1000-3428.0065750

• 网络空间安全 • 上一篇    下一篇

基于Transformer的SM4算法工作模式识别

池亚平1,2, 岳梓岩1, 林雨衡1   

  1. 1. 北京电子科技学院 网络空间安全系, 北京 100070
    2. 中国科学院网络测评技术重点实验室, 北京 100093
  • 收稿日期:2022-09-14 出版日期:2023-09-15 发布日期:2022-12-13
  • 作者简介:

    池亚平(1969—),女,教授,主研方向为虚拟化安全、可信计算、加密技术、软件定义网络

    岳梓岩、硕士研究生

    林雨衡,硕士研究生

  • 基金资助:
    国家重点研发计划(2018YFB1004100)

Working Mode Recognition for SM4 Algorithm Based on Transformer

Yaping CHI1,2, Ziyan YUE1, Yuheng LIN1   

  1. 1. Department of Cyberspace Security, Beijing Electronics Science and Technology Institute, Beijing 100070, China
    2. Key Laboratory of Network Assessment Technology, Chinese Academy of Sciences, Beijing 100093, China
  • Received:2022-09-14 Online:2023-09-15 Published:2022-12-13

摘要:

密码算法识别是开展密码设备监管、密码分析等工作的前提,在对现有密码算法识别方案进行总结和分析的基础上,利用K近邻(KNN)算法和随机性检测工具分析SM4分组密码算法不同工作模式下密文识别准确率低的原因。针对现有方案在SM4算法多种工作模式密文混合场景下识别准确率低的现状,证明深度学习应用于SM4分组密码算法工作模式识别问题的可行性,提出一种基于Transformer的SM4算法工作模式密文识别方案。在ECB、CBC、CFB、OFB、CTR工作模式下对文件进行批量加密,密文文件经过数据预处理形成密文数据集,然后输入Transformer模型进行五分类识别。实验结果表明,SM4算法5种工作模式在密文混合场景下识别准确率达到94.94%,证明所提方案可有效提升SM4分组密码算法5种工作模式在密文混合场景下的识别准确率。将密文数据集输入卷积神经网络、循环神经网络、ResNet进行对比实验,结果表明,相较于这3种传统神经网络,基于自注意力机制的Transformer模型识别准确率分别提升18.38、26.96、10.44个百分点。

关键词: 密码算法识别, SM4算法, 工作模式, 深度学习, Transformer模型

Abstract:

Cipher algorithm recognition is a prerequisite for cryptanalysis and supervision of cryptographic equipment. Based on the summary and analyses of existing cipher algorithm recognition schemes, this study uses the K-Nearest Neighbor(KNN) algorithm and a randomness detection tool to analyze the reason for the low recognition accuracy of ciphertext in different working modes of the SM4 block cipher algorithm. To address the low recognition accuracy of correct recognition in the existing ciphertext mixed scenario scheme in multiple working modes of the SM4 block cipher algorithm, the study verifies the feasibility of applying deep learning to the working mode recognition problem of the SM4 block cipher algorithm, thereby proposing a recognition scheme based on the Transformer model. The recognition scheme encrypts files in batches in Electronic CodeBook(ECB), Cipher Block Chaining(CBC), Cipher FeedBack(CFB), Output FeedBack(OFB), and CounTeR(CTR) working modes. Subsequently, the ciphertext files undergo data preprocessing to form a ciphertext dataset which is then input into the Transformer model for five-category recognition. After analyzing and comparing this experiment with similar work in the existing literature, the recognition accuracy of the SM4 algorithm reaches 94.94% for the ciphertext-mixed scenario of five working modes, demonstrating that the scheme can effectively improve recognition accuracy. Finally, the ciphertext dataset is input into the three traditional neural network structures, Convolutional Neural Network(CNN), Recurrent Neural Network(RNN), and ResNet, for comparative experiments. The experimental results show that, compared with these three traditional neural network, the recognition accuracy of the self-attention-based Transformer model increased by 18.38, 26.96, and 10.44 percentage points, respectively.

Key words: cipher algorithm recognition, SM4 algorithm, working mode, deep learning, Transformer model