use an array instead of a byte slice for Connection IDs

This commit is contained in:
Marten Seemann
2022-08-28 16:05:56 +03:00
parent 9e0f9e62ff
commit 1aced95d41
47 changed files with 530 additions and 487 deletions

View File

@@ -18,7 +18,7 @@ var _ = Describe("Initial AEAD using AES-GCM", func() {
Expect(splitHexString("dead beef")).To(Equal([]byte{0xde, 0xad, 0xbe, 0xef}))
})
connID := protocol.ConnectionID(splitHexString("0x8394c8f03e515708"))
connID := protocol.ParseConnectionID(splitHexString("0x8394c8f03e515708"))
DescribeTable("computes the client key and IV",
func(v protocol.VersionNumber, expectedClientSecret, expectedKey, expectedIV []byte) {
@@ -160,7 +160,7 @@ var _ = Describe("Initial AEAD using AES-GCM", func() {
Context(fmt.Sprintf("using version %s", v), func() {
It("seals and opens", func() {
connectionID := protocol.ConnectionID{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef}
connectionID := protocol.ParseConnectionID([]byte{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef})
clientSealer, clientOpener := NewInitialAEAD(connectionID, protocol.PerspectiveClient, v)
serverSealer, serverOpener := NewInitialAEAD(connectionID, protocol.PerspectiveServer, v)
@@ -175,8 +175,8 @@ var _ = Describe("Initial AEAD using AES-GCM", func() {
})
It("doesn't work if initialized with different connection IDs", func() {
c1 := protocol.ConnectionID{0, 0, 0, 0, 0, 0, 0, 1}
c2 := protocol.ConnectionID{0, 0, 0, 0, 0, 0, 0, 2}
c1 := protocol.ParseConnectionID([]byte{0, 0, 0, 0, 0, 0, 0, 1})
c2 := protocol.ParseConnectionID([]byte{0, 0, 0, 0, 0, 0, 0, 2})
clientSealer, _ := NewInitialAEAD(c1, protocol.PerspectiveClient, v)
_, serverOpener := NewInitialAEAD(c2, protocol.PerspectiveServer, v)
@@ -186,7 +186,7 @@ var _ = Describe("Initial AEAD using AES-GCM", func() {
})
It("encrypts und decrypts the header", func() {
connID := protocol.ConnectionID{0xde, 0xca, 0xfb, 0xad}
connID := protocol.ParseConnectionID([]byte{0xde, 0xca, 0xfb, 0xad})
clientSealer, clientOpener := NewInitialAEAD(connID, protocol.PerspectiveClient, v)
serverSealer, serverOpener := NewInitialAEAD(connID, protocol.PerspectiveServer, v)