define a function to tell if a QUIC version uses the TLS 1.3 handshake

This commit is contained in:
Marten Seemann
2017-09-22 19:47:08 +07:00
parent c78a4b2b73
commit 8312e766ed
5 changed files with 18 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ import "github.com/lucas-clemente/quic-go/internal/protocol"
// NewNullAEAD creates a NullAEAD
func NewNullAEAD(p protocol.Perspective, v protocol.VersionNumber) AEAD {
if v == protocol.VersionTLS {
if v.UsesTLS() {
return &nullAEADFNV64a{}
}
return &nullAEADFNV128a{

View File

@@ -26,6 +26,11 @@ var SupportedVersions = []VersionNumber{
Version35,
}
// UsesTLS says if this QUIC version uses TLS 1.3 for the handshake
func (vn VersionNumber) UsesTLS() bool {
return vn == VersionTLS
}
// VersionNumberToTag maps version numbers ('32') to tags ('Q032')
func VersionNumberToTag(vn VersionNumber) uint32 {
v := uint32(vn)

View File

@@ -6,6 +6,15 @@ import (
)
var _ = Describe("Version", func() {
It("says if a version supports TLS", func() {
Expect(Version35.UsesTLS()).To(BeFalse())
Expect(Version36.UsesTLS()).To(BeFalse())
Expect(Version37.UsesTLS()).To(BeFalse())
Expect(Version38.UsesTLS()).To(BeFalse())
Expect(Version39.UsesTLS()).To(BeFalse())
Expect(VersionTLS.UsesTLS()).To(BeTrue())
})
It("converts tags to numbers", func() {
Expect(VersionTagToNumber('Q' + '1'<<8 + '2'<<16 + '3'<<24)).To(Equal(VersionNumber(123)))
})