implement AES-GCM as AEAD

This commit is contained in:
Lucas Clemente
2016-04-14 09:56:39 +02:00
parent 3588f24ad4
commit 8b7e2744da
6 changed files with 139 additions and 9 deletions

View File

@@ -15,7 +15,7 @@ var _ = Describe("Crypto/NullAEAD", func() {
hash := []byte{0x98, 0x9b, 0x33, 0x3f, 0xe8, 0xde, 0x32, 0x5c, 0xa6, 0x7f, 0x9c, 0xf7}
cipherText := append(hash, plainText...)
aead := &NullAEAD{}
r, err := aead.Open(aad, bytes.NewReader(cipherText))
r, err := aead.Open(0, aad, bytes.NewReader(cipherText))
Expect(err).ToNot(HaveOccurred())
res, err := ioutil.ReadAll(r)
Expect(err).ToNot(HaveOccurred())
@@ -28,7 +28,7 @@ var _ = Describe("Crypto/NullAEAD", func() {
hash := []byte{0x98, 0x9b, 0x33, 0x3f, 0xe8, 0xde, 0x32, 0x5c, 0xa6, 0x7f, 0x9c, 0xf7}
cipherText := append(hash, plainText...)
aead := &NullAEAD{}
_, err := aead.Open(aad, bytes.NewReader(cipherText))
_, err := aead.Open(0, aad, bytes.NewReader(cipherText))
Expect(err).To(HaveOccurred())
})
@@ -37,7 +37,7 @@ var _ = Describe("Crypto/NullAEAD", func() {
plainText := []byte("They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood.")
b := &bytes.Buffer{}
aead := &NullAEAD{}
aead.Seal(b, aad, plainText)
aead.Seal(0, b, aad, plainText)
Expect(b.Bytes()).To(Equal(append([]byte{0x98, 0x9b, 0x33, 0x3f, 0xe8, 0xde, 0x32, 0x5c, 0xa6, 0x7f, 0x9c, 0xf7}, []byte("They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood.")...)))
})
})