首页|基于MetaCrypto平台的SM4密码算法实现

基于MetaCrypto平台的SM4密码算法实现

扫码查看
针对现有通用编程语言在实现密码算法时存在编程难度大和可维护性差等问题,提出了一种基于MetaCrypto平台的密码算法实现方式.基于MetaCrypto平台的MCL元语言和映射原理,实现了SM4 密码算法模型和Python语言映射接口,完成了从SM4 密码算法模型到Python语言的代码生成;对映射为Python平台的SM4 算法进行正确性验证和加/解密速率测试,并比较了x86 架构、ARM架构、LoongArch架构下的加/解密速率.实验结果显示MetaCrypto平台输出的SM4 密码算法结果与官方参考文档的测试向量完全相同,验证了其正确性;在实现加/解密速率方面,基于 64 Kbit的数据量在x86 架构CPU下达到了 0.327 Mbit·s-1,在ARM架构CPU下达到了0.254 Mbit·s-1,在LoongArch架构CPU下达到了 0.145 Mbit·s-1,与GMSSL-Python实现库基本一致.
Implementation of SM4 cryptographic algorithm based on the MetaCrypto platform
To solve the problems of programming difficulty and poor maintainability of existing general-purpose programming languages while implementing cryptographic algorithms,a cryptographic algorithm implementation based on the MetaCrypto platform was proposed.Based on MCL metalanguage and the mapping principle of the MetaCrypto platform,the SM4 block cipher model and the Python mapping interface were implemented,and the code generation from SM4 cryptographic algorithm model to Python language was completed.Then the correctness and rate test of the SM4 algorithm mapped to Python platform were verified,and the encryption and decryption rates under x86,ARM and LoongArch architecture were compared.The implementation results showed that the SM4 cryptographic algorithm output by the MetaCrypto platform was the same as the test vector in the official reference document,which verified its correctness.In terms of implementation rate,the data volume based on 64 Kbit reached 0.327 Mbit·s-1 in x86 CPU,0.254 Mbit·s-1 in ARM CPU,and 0.145 Mbit·s-1 in LoongArch CPU,which were consistent with the GMSSL-Python implementation library.

SM4 block cipherMetaCrypto platformPython mapping interfacecode mapping

肖超恩、许弘可、郑玉崝、王建新、张磊、程心雨

展开 >

北京电子科技学院,北京 100070

SM4密码算法 MetaCrypto平台 Python语言映射接口 代码映射

中央高校基本科研业务费资金资助项目中央高校基本科研业务费(应用研究类)教育部新工科研究与实践项目北京高等教育"本科教学改革创新项目"北京电子科技学院一流学科建设项目北京电子科技学院一流学科建设项目

3282022052023A03E-AQGABQ2020270420211001800220210064Z040120210056Z0402

2024

南昌大学学报(工科版)
南昌大学

南昌大学学报(工科版)

影响因子:0.319
ISSN:1006-0456
年,卷(期):2024.46(2)