{-# LANGUAGE PackageImports #-}
module Codec.Encryption.OpenPGP.Internal.HOBlockCipher
( HOBlockCipher (..)
) where
import Data.ByteArray (ByteArray, ByteArrayAccess)
import qualified Data.ByteString as B
import qualified "crypton" Crypto.Cipher.Types as CCT
import Codec.Encryption.OpenPGP.Types.Internal.Errors
( CipherError (..)
)
class HOBlockCipher cipher where
cipherInit :: ByteArray key => key -> Either CipherError cipher
cipherName :: cipher -> String
cipherKeySize :: cipher -> CCT.KeySizeSpecifier
blockSize :: cipher -> Int
ecbEncrypt
:: cipher -> B.ByteString -> Either CipherError B.ByteString
ecbDecrypt
:: cipher -> B.ByteString -> Either CipherError B.ByteString
cfbEncrypt
:: cipher
-> B.ByteString
-> B.ByteString
-> Either CipherError B.ByteString
cfbDecrypt
:: cipher
-> B.ByteString
-> B.ByteString
-> Either CipherError B.ByteString
paddedCfbEncrypt
:: cipher
-> B.ByteString
-> B.ByteString
-> Either CipherError B.ByteString
paddedCfbEncrypt = cipher -> ByteString -> ByteString -> Either CipherError ByteString
forall cipher.
HOBlockCipher cipher =>
cipher -> ByteString -> ByteString -> Either CipherError ByteString
cfbEncrypt
paddedCfbDecrypt
:: cipher
-> B.ByteString
-> B.ByteString
-> Either CipherError B.ByteString
paddedCfbDecrypt = cipher -> ByteString -> ByteString -> Either CipherError ByteString
forall cipher.
HOBlockCipher cipher =>
cipher -> ByteString -> ByteString -> Either CipherError ByteString
cfbDecrypt
aeadInit
:: CCT.AEADMode
-> cipher
-> B.ByteString
-> Either CipherError (CCT.AEAD cipher)
aeadInit AEADMode
_ cipher
_ ByteString
_ = CipherError -> Either CipherError (AEAD cipher)
forall a b. a -> Either a b
Left CipherError
CipherAEADInitUnsupported
aeadSimpleEncrypt
:: (ByteArray pt, ByteArrayAccess aad)
=> CCT.AEAD cipher
-> aad
-> pt
-> Int
-> (CCT.AuthTag, pt)
aeadSimpleEncrypt AEAD cipher
_ aad
_ pt
_ Int
_ = [Char] -> (AuthTag, pt)
forall a. HasCallStack => [Char] -> a
error [Char]
"aeadSimpleEncrypt not supported"
aeadSimpleDecrypt
:: (ByteArray ct, ByteArrayAccess aad)
=> CCT.AEAD cipher
-> aad
-> ct
-> CCT.AuthTag
-> Maybe ct
aeadSimpleDecrypt AEAD cipher
_ aad
_ ct
_ AuthTag
_ = Maybe ct
forall a. Maybe a
Nothing