aboutsummaryrefslogtreecommitdiff
path: root/cryptfs/openssl_aead.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-10-06 22:27:37 +0200
committerJakob Unterwurzacher2015-10-06 22:27:37 +0200
commita3d286069f989dd16c6f91930a0df9fedfa2dd64 (patch)
treef4f27e09c63b5d777b14fa448c149f0132fffbae /cryptfs/openssl_aead.go
parent45ea8aa5463942b0b777fcc0b354cef5821c908d (diff)
Use block number as authentication data
Diffstat (limited to 'cryptfs/openssl_aead.go')
-rw-r--r--cryptfs/openssl_aead.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/cryptfs/openssl_aead.go b/cryptfs/openssl_aead.go
index 9baa6d5..1ec7c48 100644
--- a/cryptfs/openssl_aead.go
+++ b/cryptfs/openssl_aead.go
@@ -63,10 +63,6 @@ func (be opensslGCM) Seal(dst, nonce, plaintext, data []byte) []byte {
// The ciphertext and dst may alias exactly or not at all.
func (be opensslGCM) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) {
- if len(data) > 0 {
- panic("Extra data is not supported")
- }
-
l := len(ciphertext)
tag := ciphertext[l-AUTH_TAG_LEN : l]
ciphertext = ciphertext[0 : l-AUTH_TAG_LEN]
@@ -76,6 +72,10 @@ func (be opensslGCM) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) {
if err != nil {
return nil, err
}
+ err = dctx.ExtraData(data)
+ if err != nil {
+ return nil, err
+ }
part, err := dctx.DecryptUpdate(ciphertext)
if err != nil {
return nil, err
@@ -90,10 +90,6 @@ func (be opensslGCM) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) {
return nil, err
}
plainBuf.Write(part)
- err = dctx.ExtraData(data)
- if err != nil {
- return nil, err
- }
return plainBuf.Bytes(), nil
}