summaryrefslogtreecommitdiff
path: root/src/crypto/reflibs/Crypto/Cipher/ChaChaPoly1305.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2026-11-08 15:40:59 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2026-11-08 20:41:24 +0100
commita69cd845e9daa95527b6c497dd7c75293bbeb917 (patch)
treed8f9a657d723811dd27d9c840620151ea5fb181e /src/crypto/reflibs/Crypto/Cipher/ChaChaPoly1305.hs
parentaefa4b4dc76c3feaab223ff7afe1293c7434fae0 (diff)
Remove ByteArray constraints from internal crypto API
Diffstat (limited to 'src/crypto/reflibs/Crypto/Cipher/ChaChaPoly1305.hs')
-rw-r--r--src/crypto/reflibs/Crypto/Cipher/ChaChaPoly1305.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/crypto/reflibs/Crypto/Cipher/ChaChaPoly1305.hs b/src/crypto/reflibs/Crypto/Cipher/ChaChaPoly1305.hs
index 7f0ef20..9071d9f 100644
--- a/src/crypto/reflibs/Crypto/Cipher/ChaChaPoly1305.hs
+++ b/src/crypto/reflibs/Crypto/Cipher/ChaChaPoly1305.hs
@@ -54,17 +54,17 @@ aeadAppendAAD aad st = st { stAAD = stAAD st ++ [ aad ] }
aeadFinalizeAAD :: AeadState -> AeadState
aeadFinalizeAAD = id
-encrypt :: ByteArray ba => ba -> AeadState -> ( ba, AeadState )
+encrypt :: ByteString -> AeadState -> ( ByteString, AeadState )
encrypt ptext st =
let Nonce nonce = stNonce st
- ( ctext, mac ) = P.encrypt (B.concat $ stAAD st) (stKey st) nonce (convert ptext)
- in ( convert ctext, st { stAuth = Just $ Auth mac } )
+ ( ctext, mac ) = P.encrypt (B.concat $ stAAD st) (stKey st) nonce ptext
+ in ( ctext, st { stAuth = Just $ Auth mac } )
-decrypt :: ByteArray ba => ( ba, Auth ) -> AeadState -> Maybe ba
+decrypt :: ( ByteString, Auth ) -> AeadState -> Maybe ByteString
decrypt ( ctext, auth ) st = do
let Nonce nonce = stNonce st
Auth mac = auth
- fmap convert $ P.decrypt (B.concat $ stAAD st) (stKey st) nonce ( convert ctext, mac )
+ P.decrypt (B.concat $ stAAD st) (stKey st) nonce ( ctext, mac )
aeadFinalize :: AeadState -> Auth
aeadFinalize st = case stAuth st of