南昌大学学报(工科版)2024,Vol.46Issue(2) :185-192.

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

Implementation of SM4 cryptographic algorithm based on the MetaCrypto platform

肖超恩 许弘可 郑玉崝 王建新 张磊 程心雨
南昌大学学报(工科版)2024,Vol.46Issue(2) :185-192.

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

Implementation of SM4 cryptographic algorithm based on the MetaCrypto platform

肖超恩 1许弘可 1郑玉崝 1王建新 1张磊 1程心雨1
扫码查看

作者信息

  • 1. 北京电子科技学院,北京 100070
  • 折叠

摘要

针对现有通用编程语言在实现密码算法时存在编程难度大和可维护性差等问题,提出了一种基于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实现库基本一致.

Abstract

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密码算法/MetaCrypto平台/Python语言映射接口/代码映射

Key words

SM4 block cipher/MetaCrypto platform/Python mapping interface/code mapping

引用本文复制引用

基金项目

中央高校基本科研业务费资金资助项目(328202205)

中央高校基本科研业务费(应用研究类)(2023A03)

教育部新工科研究与实践项目(E-AQGABQ20202704)

北京高等教育"本科教学改革创新项目"(202110018002)

北京电子科技学院一流学科建设项目(20210064Z0401)

北京电子科技学院一流学科建设项目(20210056Z0402)

出版年

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

南昌大学学报(工科版)

影响因子:0.319
ISSN:1006-0456
段落导航相关论文