cache the ephermal key for up to 1 min

fixes #136
This commit is contained in:
Lucas Clemente
2016-07-28 19:07:57 +02:00
parent 769655c43e
commit af56ff2aca
5 changed files with 92 additions and 7 deletions

View File

@@ -0,0 +1,30 @@
package handshake
import (
"time"
"github.com/lucas-clemente/quic-go/crypto"
"github.com/lucas-clemente/quic-go/protocol"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Ephermal KEX", func() {
It("has a consistent KEX", func() {
kex1 := getEphermalKEX()
Expect(kex1).ToNot(BeNil())
kex2 := getEphermalKEX()
Expect(kex2).ToNot(BeNil())
Expect(kex1).To(Equal(kex2))
})
It("changes KEX", func() {
kexLifetime = time.Millisecond
defer func() {
kexLifetime = protocol.EphermalKeyLifetime
}()
kex := getEphermalKEX()
Expect(kex).ToNot(BeNil())
Eventually(func() crypto.KeyExchange { return getEphermalKEX() }).ShouldNot(Equal(kex))
})
})