github.com/geph-official/geph2@v0.22.6-0.20210211030601-f527cb59b0df/libs/niaucchi4/crypto_test.go (about) 1 package niaucchi4 2 3 import ( 4 "crypto/rand" 5 "testing" 6 ) 7 8 func BenchmarkRandNonce(b *testing.B) { 9 for i := 0; i < b.N; i++ { 10 rand.Read(make([]byte, 16)) 11 } 12 } 13 14 func BenchmarkTunStateEncDec(b *testing.B) { 15 ts1 := &tunstate{isserv: true} 16 ts2 := &tunstate{isserv: false} 17 ts1.deriveKeys(make([]byte, 32)) 18 ts2.deriveKeys(make([]byte, 32)) 19 for i := 0; i < b.N; i++ { 20 ct := ts1.Encrypt(make([]byte, 1024)) 21 _, err := ts2.Decrypt(ct) 22 if err != nil { 23 panic(err) 24 } 25 } 26 }