@@ -158,107 +158,3 @@ func hexDecode(t *testing.T, s string) []byte {
158158 }
159159 return b
160160}
161-
162- func BenchmarkGenerateKeyECDH (b * testing.B ) {
163- for _ , curve := range []string {"P-256" , "P-384" , "P-521" , "X25519" } {
164- b .Run (curve , func (b * testing.B ) {
165- b .ReportAllocs ()
166- b .ResetTimer ()
167- for i := 0 ; i < b .N ; i ++ {
168- _ , _ , err := cng .GenerateKeyECDH (curve )
169- if err != nil {
170- b .Fatal (err )
171- }
172- }
173- })
174- }
175- }
176-
177- func BenchmarkECDH (b * testing.B ) {
178- for _ , curve := range []string {"P-256" , "P-384" , "P-521" , "X25519" } {
179- b .Run (curve , func (b * testing.B ) {
180- aliceKey , _ , err := cng .GenerateKeyECDH (curve )
181- if err != nil {
182- b .Fatal (err )
183- }
184- bobKey , _ , err := cng .GenerateKeyECDH (curve )
185- if err != nil {
186- b .Fatal (err )
187- }
188- bobPub , err := bobKey .PublicKey ()
189- if err != nil {
190- b .Fatal (err )
191- }
192- b .ReportAllocs ()
193- b .ResetTimer ()
194- for i := 0 ; i < b .N ; i ++ {
195- _ , err := cng .ECDH (aliceKey , bobPub )
196- if err != nil {
197- b .Fatal (err )
198- }
199- }
200- })
201- }
202- }
203-
204- func BenchmarkNewPrivateKeyECDH (b * testing.B ) {
205- for _ , curve := range []string {"P-256" , "P-384" , "P-521" , "X25519" } {
206- b .Run (curve , func (b * testing.B ) {
207- _ , privBytes , err := cng .GenerateKeyECDH (curve )
208- if err != nil {
209- b .Fatal (err )
210- }
211- b .ReportAllocs ()
212- b .ResetTimer ()
213- for i := 0 ; i < b .N ; i ++ {
214- _ , err := cng .NewPrivateKeyECDH (curve , privBytes )
215- if err != nil {
216- b .Fatal (err )
217- }
218- }
219- })
220- }
221- }
222-
223- func BenchmarkNewPublicKeyECDH (b * testing.B ) {
224- for _ , curve := range []string {"P-256" , "P-384" , "P-521" , "X25519" } {
225- b .Run (curve , func (b * testing.B ) {
226- key , _ , err := cng .GenerateKeyECDH (curve )
227- if err != nil {
228- b .Fatal (err )
229- }
230- pub , err := key .PublicKey ()
231- if err != nil {
232- b .Fatal (err )
233- }
234- pubBytes := pub .Bytes ()
235- b .ReportAllocs ()
236- b .ResetTimer ()
237- for i := 0 ; i < b .N ; i ++ {
238- _ , err := cng .NewPublicKeyECDH (curve , pubBytes )
239- if err != nil {
240- b .Fatal (err )
241- }
242- }
243- })
244- }
245- }
246-
247- func BenchmarkPublicKeyECDH (b * testing.B ) {
248- for _ , curve := range []string {"P-256" , "P-384" , "P-521" , "X25519" } {
249- b .Run (curve , func (b * testing.B ) {
250- key , _ , err := cng .GenerateKeyECDH (curve )
251- if err != nil {
252- b .Fatal (err )
253- }
254- b .ReportAllocs ()
255- b .ResetTimer ()
256- for i := 0 ; i < b .N ; i ++ {
257- _ , err := key .PublicKey ()
258- if err != nil {
259- b .Fatal (err )
260- }
261- }
262- })
263- }
264- }
0 commit comments