Research Article

System-Level Optimization and Co-Design of the SM4 Algorithm for RISC-V

Dawei Zhang1, Xueyong Liu2,*
1. James Cook University
2. Institute of Microelectronics, Chinese Academy of Sciences, Beijing, China

* Corresponding author: [email protected]

Abstract

In response to issues such as high computational latency and excessive energy consumption encountered when implementing the SM4 algorithm on general-purpose RISC-V processors, this paper proposes an assembly-level system optimization and hardware-software co-design scheme tailored for the RISC-V platform. Optimization is conducted at both the instruction level and the architectural level. First, memory access operations and inter-instruction dependencies are reduced through techniques including S-box lookup table reuse, shift-XOR instruction reordering, and lightweight pipelining. Next, modular assembly implementations are developed for the T-transformation, T′-transformation, and key expansion, with unified register conventions and calling interfaces established. Then, register rotation and loop unrolling mechanisms are introduced to enhance data reuse and lower control overhead. Finally, a hardware-friendly instruction sequence and interface specification are designed to facilitate smooth migration to custom instructions or coprocessor extensions in the future. Experimental results show that, compared to the C implementation, the optimized assembly version reduces the total instruction count by 37.5% and the cycle count by 54.2%, yielding an overall performance gain of 2.2-fold. Notably, the efficiency of the T′-transformation improves by nearly 3.9-fold. Without additional hardware cost, the proposed approach significantly boosts the execution efficiency of SM4 on RISC-V. It thus provides a systematic optimization path for embedded cryptographic implementations that ensures performance, scalability, and portability.

Keywords: SM4; RISC-V; Assembly-level Optimization; Hardware-Software Co-design; System-level Optimization
Published: July 14, 2026
DOI: 10.54254/2755-2721/2026.GU35297
Volume: ACE Vol.248
pp. 91-102
Download PDF

References

  1. Chen, R., & Li, B. (2022). Exploration of the high-efficiency hardware architecture of SM4-CCM for IoT applications. Electronics, 11(6), 935. https: //doi.org/10.3390/electronics11060935
  2. Abed, S., Jaffal, R., Mohd, B. J., & Alshayeji, M. (2021). Performance evaluation of the SM4 cipher based on field-programmable gate array implementation. IET Circuits, Devices & Systems, 15(2), 121-135. https: //doi.org/10.1049/cds2.12011
  3. Yang, S., Shao, L., Huang, J., & Zou, W. (2023). Design and implementation of low-power IoT RISC-V processor with hybrid encryption accelerator. Electronics, 12(20), 4222. https: //doi.org/10.3390/electronics12204222
  4. Zhang, X., Liu, B., Zhao, Y., Hu, X., Shen, Z., Zheng, Z., Liu, Z., Chong, K.-S., Yu, G., Wang, C., & Zou, X. (2022). Design and analysis of area and energy efficient reconfigurable cryptographic accelerator for securing IoT devices. Sensors, 22(23), 9160. https: //doi.org/10.3390/s22239160
  5. Kwon, H., Kim, H., Eum, S., Sim, M., Kim, H., Lee, W.-K., Hu, Z., & Seo, H. (2022). Optimized implementation of SM4 on AVR microcontrollers, RISC-V processors, and ARM processors. IEEE Access, 10, 80225-80233.
  6. Nişancı, G., Flikkema, P. G., & Yalçın, T. (2022). Symmetric cryptography on RISC-V: Performance evaluation of standardized algorithms. Cryptography, 6(3), 41. https: //doi.org/10.3390/cryptography6030041
  7. Wang, J., Wang, H., Qiu, X., & Chen, Y. (2024). Design of module reuse SM4 cipher coprocessor based on RISC-V. Integrated Circuits and Embedded Systems, 24(10), 49-55. https: //doi.org/10.20193/j.ices2097-4191.2024.0019
  8. Saarinen, M.-J. O. (2020). A lightweight ISA extension for AES and SM4. arXiv. https: //arxiv.org/abs/2002.07041
  9. Cui, E., Li, T., & Wei, Q. (2023). RISC-V instruction set architecture extensions: A survey. IEEE Access, 11, 24696-24711. https: //doi.org/10.1109/ACCESS.2023.3246491
  10. Uzuner, H., & Kavun, E. B. (2024). NLU-V: A family of instruction set extensions for efficient symmetric cryptography on RISC-V. Cryptography, 8(1), 9. https: //doi.org/10.3390/cryptography8010009
  11. Li, R.-S., Peng, P., Shao, Z.-Y., et al. (2023). Evaluating RISC-V vector instruction set architecture extension with computer vision workloads. Journal of Computer Science and Technology, 38(4), 807-820. https: //doi.org/10.1007/s11390-023-1266-6
  12. Marshall, B., Page, D., & Pham, T. H. (2020). Implementing the draft RISC-V scalar cryptography extensions. In Proceedings of the 9th International Workshop on Hardware and Architectural Support for Security and Privacy (HASP '20) (pp. 1-8). ACM. https: //doi.org/10.1145/3458903.3458904
  13. Hu, X., Yu, Y., Tu, Y., Wang, J., Chen, S., Bao, Y., Zhang, T., Xing, Y., & Zheng, S. (2025). A secure and efficient white-box implementation of SM4. Entropy, 27(1), 1. https: //doi.org/10.3390/e27010001
  14. Gong, H., & Ju, T. (2024). Distributed power analysis attack on SM4 encryption chip. Scientific Reports, 14, 1007. https: //doi.org/10.1038/s41598-023-50220-2
  15. Fu, L., & Jin, C. (2022). Improved linear cryptanalysis on 25-round SMS4. IET Communications, 16(14), 1643-1653. https: //doi.org/10.1049/cmu2.12365