RISC-V-Based Hardware-Software Co-Designed Full-Stack Acceleration Algorithm for SM4
Abstract
Due to the extensive use of Internet of Things (IoT) and edge computing, the necessity of data security in embedded devices is increasing. As a national commercial block cipher standard, the SM4 algorithm is very important for maintaining the security of information. Therefore, its efficient implementation is crucial. However, the basic instruction set of the open-source RISC-V architecture is not efficient in handling the main nonlinear S-box transformations and compound rotation operations in SM4. In this paper, a comprehensive optimization approach for SM4 based on the RISC-V architecture is presented. First, special SM4 acceleration instructions are designed by utilizing the RISC-V custom instruction extension mechanism, which can effectively eliminate the performance problems and reduce the side-channel attacks caused by the table lookup operations. Secondly, by combining an improved bit-slicing technique with SIMD instructions to rearrange the data flow, the parallel throughput has been greatly enhanced. Finally, specific instruction scheduling optimizations suitable for the dual-issue pipeline architecture of the SiFive U74 processor are carried out. Experimental results show that on the SiFive U74 platform, the proposed scheme can make the SM4 encryption speed reach 7.0 CPB (Cycles Per Byte), which demonstrates a significant improvement in performance compared to the traditional software methods. This method can well satisfy the requirements for both high-speed and low-power encryption.
References
- Kwon, H., Kim, H., Eum, S., & Seo, H. (2022). Optimized implementation of SM4 on AVR microcontrollers, RISC-V processors, and ARM processors.IEEE Access, 10, 80225–80233.
- Zhang, J., Ma, M., & Wang, P. (2018). Fast implementation for SM4 cipher algorithm based on bit-slice technology.International Conference on Smart Computing and Communication, 104–113.
- Cheng, H., Großschädl, J., Marshall, B., Page, D., & Pham, T. (2022). RISC-V instruction set extensions for lightweight symmetric cryptography.IACR Transactions on Cryptographic Hardware and Embedded Systems (TCHES).
- Saarinen, M.-J. O. (2020). A lightweight ISA extension for AES and SM4.arXiv preprint arXiv:2002.07041.
- Wang, C., Ding, Y., Huang, C., & Song, L. (2024). Bitsliced optimization of SM4 algorithm with the SIMD instruction set.Journal of Computer Research and Development, 61(8), 2097–2109.
- Marshall, B., Page, D., & Pham, T. H. (2020). Implementing the draft RISC-V scalar cryptography extensions.HASP@MICRO 2020.
- Szymkowiak, T., Isufi, E., & Saarinen, M.-J. O. (2024). Marian: An open-source implementation of the RISC-V vector cryptography extension.RISC-V Summit North America 2024.
- RISC-V Cryptography Extensions Task Group. (2021).RISC-V cryptography extensions volume I: Scalar & entropy source instructions.
- Stoffelen, K. (2019). Efficient cryptography on the RISC-V architecture.Progress in Cryptology – LATINCRYPT 2019, pp. 323–340.
- SiFive, Inc.SiFive U74 core complex manual.
- 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.
- Adomnicai, A., & Peyrin, T. (2021). Fixslicing AES-like ciphers: New bitsliced AES speed records on ARM-Cortex M and RISC-V.IACR Transactions on Cryptographic Hardware and Embedded Systems, 2021(1), 402–425.
- Nişancı, G., Flikkema, P. G., & Yalçın, T. (2022). Symmetric cryptography on RISC-V: Performance evaluation of standardized algorithms.Cryptography, 6(3), 41.