Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 10dc63c

Browse files
committed
Merge pull request #328 from ocheron/aead-thunks
Avoid thunk leak with AEAD state
2 parents d494081 + 18ae7a7 commit 10dc63c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Crypto/Cipher/Types/AEAD.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ data AEADModeImpl st = AEADModeImpl
2727
-- | Authenticated Encryption with Associated Data algorithms
2828
data AEAD cipher = forall st . AEAD
2929
{ aeadModeImpl :: AEADModeImpl st
30-
, aeadState :: st
30+
, aeadState :: !st
3131
}
3232

3333
-- | Append some header information to an AEAD context
3434
aeadAppendHeader :: ByteArrayAccess aad => AEAD cipher -> aad -> AEAD cipher
35-
aeadAppendHeader (AEAD impl st) aad = AEAD impl $ (aeadImplAppendHeader impl) st aad
35+
aeadAppendHeader (AEAD impl st) aad = AEAD impl $ aeadImplAppendHeader impl st aad
3636

3737
-- | Encrypt some data and update the AEAD context
3838
aeadEncrypt :: ByteArray ba => AEAD cipher -> ba -> (ba, AEAD cipher)
39-
aeadEncrypt (AEAD impl st) ba = second (AEAD impl) $ (aeadImplEncrypt impl) st ba
39+
aeadEncrypt (AEAD impl st) ba = second (AEAD impl) $ aeadImplEncrypt impl st ba
4040

4141
-- | Decrypt some data and update the AEAD context
4242
aeadDecrypt :: ByteArray ba => AEAD cipher -> ba -> (ba, AEAD cipher)
43-
aeadDecrypt (AEAD impl st) ba = second (AEAD impl) $ (aeadImplDecrypt impl) st ba
43+
aeadDecrypt (AEAD impl st) ba = second (AEAD impl) $ aeadImplDecrypt impl st ba
4444

4545
-- | Finalize the AEAD context and return the authentication tag
4646
aeadFinalize :: AEAD cipher -> Int -> AuthTag
47-
aeadFinalize (AEAD impl st) n = (aeadImplFinalize impl) st n
47+
aeadFinalize (AEAD impl st) = aeadImplFinalize impl st
4848

4949
-- | Simple AEAD encryption
5050
aeadSimpleEncrypt :: (ByteArrayAccess aad, ByteArray ba)

0 commit comments

Comments
 (0)