From bc12e329c5d99b8e5ae2f87d9fbb49e6331c00b3 Mon Sep 17 00:00:00 2001 From: Sun Yimin Date: Tue, 14 May 2024 17:09:36 +0800 Subject: [PATCH] =?UTF-8?q?Updated=20SM2=E5=8A=A0=E8=A7=A3=E5=AF=86?= =?UTF-8?q?=E6=80=A7=E8=83=BD=20(markdown)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SM2加解密性能.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/SM2加解密性能.md b/SM2加解密性能.md index ea64188..b7182ae 100644 --- a/SM2加解密性能.md +++ b/SM2加解密性能.md @@ -1 +1,28 @@ -//TODO \ No newline at end of file +# SM2加密性能分析 +![image](https://github.com/emmansun/gmsm/assets/7235232/37614d26-8a86-40ad-a44b-88edc97278c0) + +按SM2加密算法流程来看, +* 第1、2、3、4步属于SM2椭圆曲线计算; +* 第5步是KDF操作,其主要也是SM3哈希计算; +* 第6步是异或操作; +* 第7步是SM3哈希计算; + +SM2加密的性能主要是由上述7步计算共同决定的,关于SM2椭圆曲线计算,这里不作讨论。第6步异或操作,相对最简单、耗时也最少。第7步SM3哈希计算,其耗时随待加密数据长度增加而增加。我们来看看性能数据: + +**SM2加密(明文长度不超过32字节,使第5-7步影响最小)**: +``` +goos: windows +goarch: amd64 +pkg: github.com/emmansun/gmsm/sm2 +cpu: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz +BenchmarkLessThan32_SM2 +BenchmarkLessThan32_SM2-6 + 17731 67668 ns/op 712 B/op 12 allocs/op +``` + +**第5步KDF**: +``` +``` + + +