summaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/cryptoutil/oae2.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/cryptoutil/oae2.go b/internal/cryptoutil/oae2.go
index 2819852..4e667b7 100644
--- a/internal/cryptoutil/oae2.go
+++ b/internal/cryptoutil/oae2.go
@@ -60,7 +60,6 @@ func (o *oae2) nonce(nonce []byte, lastBlock bool) error {
return errors.New("counter overflowed (64 bits??)")
}
binary.BigEndian.PutUint64(nonce[noncePrefixSize:], o.i)
- o.i++
if lastBlock {
nonce[gcmNonceSize-1] = 1
}
@@ -73,6 +72,7 @@ func (o *oae2) encryptBlock(out, block []byte, lastBlock bool) ([]byte, error) {
return nil, err
}
encrypted := o.aead.Seal(out, nonce, block, o.additionalData)
+ o.i++
o.additionalData = nil
return encrypted, nil
}
@@ -83,8 +83,12 @@ func (o *oae2) decryptBlock(out, block []byte, lastBlock bool) ([]byte, error) {
return nil, err
}
decrypted, err := o.aead.Open(out, nonce, block, o.additionalData)
+ if err != nil {
+ return nil, err
+ }
+ o.i++
o.additionalData = nil
- return decrypted, err
+ return decrypted, nil
}
// An EncryptingWriter encrypts data in segments using the STREAM construction