module Botan.BlockCipher.SM4
( SM4(..)
, SM4SecretKey(..)
, pattern SM4SecretKey
, getSM4SecretKey
, SM4Ciphertext(..)
, sm4Encrypt
, sm4Decrypt
, sm4EncryptLazy
, sm4DecryptLazy
) where

import qualified Data.ByteString as ByteString
import qualified Data.ByteString.Lazy as Lazy
import qualified Data.Text as Text

import qualified Botan.BlockCipher as Botan
import qualified Botan.Utility as Botan

import Botan.Prelude hiding (Ciphertext, LazyCiphertext)

import Botan.BlockCipher.Class
import Botan.Types.Class
import Botan.RNG

-- SM4 type

data SM4

newtype instance SecretKey SM4 = MkSM4SecretKey GSecretKey
    deriving newtype (SecretKey SM4 -> SecretKey SM4 -> Bool
(SecretKey SM4 -> SecretKey SM4 -> Bool)
-> (SecretKey SM4 -> SecretKey SM4 -> Bool) -> Eq (SecretKey SM4)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SecretKey SM4 -> SecretKey SM4 -> Bool
== :: SecretKey SM4 -> SecretKey SM4 -> Bool
$c/= :: SecretKey SM4 -> SecretKey SM4 -> Bool
/= :: SecretKey SM4 -> SecretKey SM4 -> Bool
Eq, Eq (SecretKey SM4)
Eq (SecretKey SM4) =>
(SecretKey SM4 -> SecretKey SM4 -> Ordering)
-> (SecretKey SM4 -> SecretKey SM4 -> Bool)
-> (SecretKey SM4 -> SecretKey SM4 -> Bool)
-> (SecretKey SM4 -> SecretKey SM4 -> Bool)
-> (SecretKey SM4 -> SecretKey SM4 -> Bool)
-> (SecretKey SM4 -> SecretKey SM4 -> SecretKey SM4)
-> (SecretKey SM4 -> SecretKey SM4 -> SecretKey SM4)
-> Ord (SecretKey SM4)
SecretKey SM4 -> SecretKey SM4 -> Bool
SecretKey SM4 -> SecretKey SM4 -> Ordering
SecretKey SM4 -> SecretKey SM4 -> SecretKey SM4
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: SecretKey SM4 -> SecretKey SM4 -> Ordering
compare :: SecretKey SM4 -> SecretKey SM4 -> Ordering
$c< :: SecretKey SM4 -> SecretKey SM4 -> Bool
< :: SecretKey SM4 -> SecretKey SM4 -> Bool
$c<= :: SecretKey SM4 -> SecretKey SM4 -> Bool
<= :: SecretKey SM4 -> SecretKey SM4 -> Bool
$c> :: SecretKey SM4 -> SecretKey SM4 -> Bool
> :: SecretKey SM4 -> SecretKey SM4 -> Bool
$c>= :: SecretKey SM4 -> SecretKey SM4 -> Bool
>= :: SecretKey SM4 -> SecretKey SM4 -> Bool
$cmax :: SecretKey SM4 -> SecretKey SM4 -> SecretKey SM4
max :: SecretKey SM4 -> SecretKey SM4 -> SecretKey SM4
$cmin :: SecretKey SM4 -> SecretKey SM4 -> SecretKey SM4
min :: SecretKey SM4 -> SecretKey SM4 -> SecretKey SM4
Ord, Int -> SecretKey SM4 -> ShowS
[SecretKey SM4] -> ShowS
SecretKey SM4 -> String
(Int -> SecretKey SM4 -> ShowS)
-> (SecretKey SM4 -> String)
-> ([SecretKey SM4] -> ShowS)
-> Show (SecretKey SM4)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SecretKey SM4 -> ShowS
showsPrec :: Int -> SecretKey SM4 -> ShowS
$cshow :: SecretKey SM4 -> String
show :: SecretKey SM4 -> String
$cshowList :: [SecretKey SM4] -> ShowS
showList :: [SecretKey SM4] -> ShowS
Show, ByteString -> Maybe (SecretKey SM4)
SecretKey SM4 -> ByteString
(SecretKey SM4 -> ByteString)
-> (ByteString -> Maybe (SecretKey SM4))
-> Encodable (SecretKey SM4)
forall a.
(a -> ByteString) -> (ByteString -> Maybe a) -> Encodable a
$cencode :: SecretKey SM4 -> ByteString
encode :: SecretKey SM4 -> ByteString
$cdecode :: ByteString -> Maybe (SecretKey SM4)
decode :: ByteString -> Maybe (SecretKey SM4)
Encodable)

pattern SM4SecretKey :: ByteString -> SecretKey SM4
pattern $mSM4SecretKey :: forall {r}. SecretKey SM4 -> (ByteString -> r) -> ((# #) -> r) -> r
$bSM4SecretKey :: ByteString -> SecretKey SM4
SM4SecretKey bytes = MkSM4SecretKey (MkGSecretKey bytes)

getSM4SecretKey :: SecretKey SM4 -> ByteString
getSM4SecretKey :: SecretKey SM4 -> ByteString
getSM4SecretKey (SM4SecretKey ByteString
bs) = ByteString
bs

type SM4SecretKey = SecretKey SM4

newtype instance Ciphertext SM4 = MkSM4Ciphertext GCiphertext
    deriving newtype (Ciphertext SM4 -> Ciphertext SM4 -> Bool
(Ciphertext SM4 -> Ciphertext SM4 -> Bool)
-> (Ciphertext SM4 -> Ciphertext SM4 -> Bool)
-> Eq (Ciphertext SM4)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
== :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
$c/= :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
/= :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
Eq, Eq (Ciphertext SM4)
Eq (Ciphertext SM4) =>
(Ciphertext SM4 -> Ciphertext SM4 -> Ordering)
-> (Ciphertext SM4 -> Ciphertext SM4 -> Bool)
-> (Ciphertext SM4 -> Ciphertext SM4 -> Bool)
-> (Ciphertext SM4 -> Ciphertext SM4 -> Bool)
-> (Ciphertext SM4 -> Ciphertext SM4 -> Bool)
-> (Ciphertext SM4 -> Ciphertext SM4 -> Ciphertext SM4)
-> (Ciphertext SM4 -> Ciphertext SM4 -> Ciphertext SM4)
-> Ord (Ciphertext SM4)
Ciphertext SM4 -> Ciphertext SM4 -> Bool
Ciphertext SM4 -> Ciphertext SM4 -> Ordering
Ciphertext SM4 -> Ciphertext SM4 -> Ciphertext SM4
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Ciphertext SM4 -> Ciphertext SM4 -> Ordering
compare :: Ciphertext SM4 -> Ciphertext SM4 -> Ordering
$c< :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
< :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
$c<= :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
<= :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
$c> :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
> :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
$c>= :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
>= :: Ciphertext SM4 -> Ciphertext SM4 -> Bool
$cmax :: Ciphertext SM4 -> Ciphertext SM4 -> Ciphertext SM4
max :: Ciphertext SM4 -> Ciphertext SM4 -> Ciphertext SM4
$cmin :: Ciphertext SM4 -> Ciphertext SM4 -> Ciphertext SM4
min :: Ciphertext SM4 -> Ciphertext SM4 -> Ciphertext SM4
Ord, Int -> Ciphertext SM4 -> ShowS
[Ciphertext SM4] -> ShowS
Ciphertext SM4 -> String
(Int -> Ciphertext SM4 -> ShowS)
-> (Ciphertext SM4 -> String)
-> ([Ciphertext SM4] -> ShowS)
-> Show (Ciphertext SM4)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Ciphertext SM4 -> ShowS
showsPrec :: Int -> Ciphertext SM4 -> ShowS
$cshow :: Ciphertext SM4 -> String
show :: Ciphertext SM4 -> String
$cshowList :: [Ciphertext SM4] -> ShowS
showList :: [Ciphertext SM4] -> ShowS
Show, ByteString -> Maybe (Ciphertext SM4)
Ciphertext SM4 -> ByteString
(Ciphertext SM4 -> ByteString)
-> (ByteString -> Maybe (Ciphertext SM4))
-> Encodable (Ciphertext SM4)
forall a.
(a -> ByteString) -> (ByteString -> Maybe a) -> Encodable a
$cencode :: Ciphertext SM4 -> ByteString
encode :: Ciphertext SM4 -> ByteString
$cdecode :: ByteString -> Maybe (Ciphertext SM4)
decode :: ByteString -> Maybe (Ciphertext SM4)
Encodable)

pattern SM4Ciphertext :: ByteString -> Ciphertext SM4
pattern $mSM4Ciphertext :: forall {r}.
Ciphertext SM4 -> (ByteString -> r) -> ((# #) -> r) -> r
$bSM4Ciphertext :: ByteString -> Ciphertext SM4
SM4Ciphertext bs = MkSM4Ciphertext (MkGCiphertext bs)

getSM4Ciphertext :: Ciphertext SM4 -> ByteString
getSM4Ciphertext :: Ciphertext SM4 -> ByteString
getSM4Ciphertext (SM4Ciphertext ByteString
bs) = ByteString
bs

type SM4Ciphertext = Ciphertext SM4

newtype instance LazyCiphertext SM4 = MkSM4LazyCiphertext GLazyCiphertext
    deriving newtype (LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
(LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool)
-> (LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool)
-> Eq (LazyCiphertext SM4)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
== :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
$c/= :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
/= :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
Eq, Eq (LazyCiphertext SM4)
Eq (LazyCiphertext SM4) =>
(LazyCiphertext SM4 -> LazyCiphertext SM4 -> Ordering)
-> (LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool)
-> (LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool)
-> (LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool)
-> (LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool)
-> (LazyCiphertext SM4 -> LazyCiphertext SM4 -> LazyCiphertext SM4)
-> (LazyCiphertext SM4 -> LazyCiphertext SM4 -> LazyCiphertext SM4)
-> Ord (LazyCiphertext SM4)
LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
LazyCiphertext SM4 -> LazyCiphertext SM4 -> Ordering
LazyCiphertext SM4 -> LazyCiphertext SM4 -> LazyCiphertext SM4
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Ordering
compare :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Ordering
$c< :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
< :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
$c<= :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
<= :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
$c> :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
> :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
$c>= :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
>= :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> Bool
$cmax :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> LazyCiphertext SM4
max :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> LazyCiphertext SM4
$cmin :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> LazyCiphertext SM4
min :: LazyCiphertext SM4 -> LazyCiphertext SM4 -> LazyCiphertext SM4
Ord, Int -> LazyCiphertext SM4 -> ShowS
[LazyCiphertext SM4] -> ShowS
LazyCiphertext SM4 -> String
(Int -> LazyCiphertext SM4 -> ShowS)
-> (LazyCiphertext SM4 -> String)
-> ([LazyCiphertext SM4] -> ShowS)
-> Show (LazyCiphertext SM4)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LazyCiphertext SM4 -> ShowS
showsPrec :: Int -> LazyCiphertext SM4 -> ShowS
$cshow :: LazyCiphertext SM4 -> String
show :: LazyCiphertext SM4 -> String
$cshowList :: [LazyCiphertext SM4] -> ShowS
showList :: [LazyCiphertext SM4] -> ShowS
Show, ByteString -> Maybe (LazyCiphertext SM4)
LazyCiphertext SM4 -> ByteString
(LazyCiphertext SM4 -> ByteString)
-> (ByteString -> Maybe (LazyCiphertext SM4))
-> Encodable (LazyCiphertext SM4)
forall a.
(a -> ByteString) -> (ByteString -> Maybe a) -> Encodable a
$cencode :: LazyCiphertext SM4 -> ByteString
encode :: LazyCiphertext SM4 -> ByteString
$cdecode :: ByteString -> Maybe (LazyCiphertext SM4)
decode :: ByteString -> Maybe (LazyCiphertext SM4)
Encodable, Encodable (LazyCiphertext SM4)
ByteString -> Maybe (LazyCiphertext SM4)
LazyCiphertext SM4 -> ByteString
Encodable (LazyCiphertext SM4) =>
(LazyCiphertext SM4 -> ByteString)
-> (ByteString -> Maybe (LazyCiphertext SM4))
-> LazyEncodable (LazyCiphertext SM4)
forall a.
Encodable a =>
(a -> ByteString) -> (ByteString -> Maybe a) -> LazyEncodable a
$cencodeLazy :: LazyCiphertext SM4 -> ByteString
encodeLazy :: LazyCiphertext SM4 -> ByteString
$cdecodeLazy :: ByteString -> Maybe (LazyCiphertext SM4)
decodeLazy :: ByteString -> Maybe (LazyCiphertext SM4)
LazyEncodable)

pattern SM4LazyCiphertext :: Lazy.ByteString -> LazyCiphertext SM4
pattern $mSM4LazyCiphertext :: forall {r}.
LazyCiphertext SM4 -> (ByteString -> r) -> ((# #) -> r) -> r
$bSM4LazyCiphertext :: ByteString -> LazyCiphertext SM4
SM4LazyCiphertext lbs = MkSM4LazyCiphertext (MkGLazyCiphertext lbs)

getSM4LazyCiphertext :: LazyCiphertext SM4 -> Lazy.ByteString
getSM4LazyCiphertext :: LazyCiphertext SM4 -> ByteString
getSM4LazyCiphertext (SM4LazyCiphertext ByteString
bs) = ByteString
bs

type SM4LazyCiphertext = LazyCiphertext SM4

instance HasSecretKey SM4 where
    
    secretKeySpec :: SizeSpecifier (SecretKey SM4)
    secretKeySpec :: SizeSpecifier (SecretKey SM4)
secretKeySpec = SizeSpecifier () -> SizeSpecifier (SecretKey SM4)
forall a b. SizeSpecifier a -> SizeSpecifier b
coerceSizeSpec (SizeSpecifier () -> SizeSpecifier (SecretKey SM4))
-> SizeSpecifier () -> SizeSpecifier (SecretKey SM4)
forall a b. (a -> b) -> a -> b
$ BlockCipher -> SizeSpecifier ()
Botan.blockCipherKeySpec BlockCipher
Botan.sm4

instance (MonadRandomIO m )=> SecretKeyGen SM4 m where

    newSecretKey :: MonadRandomIO m => m (SecretKey SM4)
    newSecretKey :: MonadRandomIO m => m (SecretKey SM4)
newSecretKey = ByteString -> SecretKey SM4
SM4SecretKey (ByteString -> SecretKey SM4) -> m ByteString -> m (SecretKey SM4)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SizeSpecifier (SecretKey SM4) -> m ByteString
forall (m :: * -> *) a.
MonadRandomIO m =>
SizeSpecifier a -> m ByteString
newSized (forall alg. HasSecretKey alg => SizeSpecifier (SecretKey alg)
secretKeySpec @SM4)
    
    newSecretKeyMaybe :: MonadRandomIO m => Int -> m (Maybe (SecretKey SM4))
    newSecretKeyMaybe :: MonadRandomIO m => Int -> m (Maybe (SecretKey SM4))
newSecretKeyMaybe Int
i = (ByteString -> SecretKey SM4)
-> Maybe ByteString -> Maybe (SecretKey SM4)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> SecretKey SM4
SM4SecretKey (Maybe ByteString -> Maybe (SecretKey SM4))
-> m (Maybe ByteString) -> m (Maybe (SecretKey SM4))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SizeSpecifier (SecretKey SM4) -> Int -> m (Maybe ByteString)
forall (m :: * -> *) a.
MonadRandomIO m =>
SizeSpecifier a -> Int -> m (Maybe ByteString)
newSizedMaybe (forall alg. HasSecretKey alg => SizeSpecifier (SecretKey alg)
secretKeySpec @SM4) Int
i

instance HasCiphertext SM4 where

instance BlockCipher SM4 where

    blockCipherEncrypt :: SecretKey SM4 -> ByteString -> Maybe (Ciphertext SM4)
    blockCipherEncrypt :: SecretKey SM4 -> ByteString -> Maybe (Ciphertext SM4)
blockCipherEncrypt (SM4SecretKey ByteString
k) = (ByteString -> Ciphertext SM4)
-> Maybe ByteString -> Maybe (Ciphertext SM4)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Ciphertext SM4
SM4Ciphertext (Maybe ByteString -> Maybe (Ciphertext SM4))
-> (ByteString -> Maybe ByteString)
-> ByteString
-> Maybe (Ciphertext SM4)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BlockCipher -> ByteString -> ByteString -> Maybe ByteString
Botan.blockCipherEncrypt BlockCipher
Botan.sm4 ByteString
k

    blockCipherDecrypt :: SecretKey SM4 -> Ciphertext SM4 -> Maybe ByteString
    blockCipherDecrypt :: SecretKey SM4 -> Ciphertext SM4 -> Maybe ByteString
blockCipherDecrypt (SM4SecretKey ByteString
k) (SM4Ciphertext ByteString
ct) = BlockCipher -> ByteString -> ByteString -> Maybe ByteString
Botan.blockCipherDecrypt BlockCipher
Botan.sm4 ByteString
k ByteString
ct

instance HasLazyCiphertext SM4 where

instance IncrementalBlockCipher SM4 where

    blockCipherEncryptLazy :: SecretKey SM4 -> Lazy.ByteString -> Maybe (LazyCiphertext SM4)
    blockCipherEncryptLazy :: SecretKey SM4 -> ByteString -> Maybe (LazyCiphertext SM4)
blockCipherEncryptLazy (SM4SecretKey ByteString
k) = (ByteString -> LazyCiphertext SM4)
-> Maybe ByteString -> Maybe (LazyCiphertext SM4)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> LazyCiphertext SM4
SM4LazyCiphertext (Maybe ByteString -> Maybe (LazyCiphertext SM4))
-> (ByteString -> Maybe ByteString)
-> ByteString
-> Maybe (LazyCiphertext SM4)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BlockCipher -> ByteString -> ByteString -> Maybe ByteString
Botan.blockCipherEncryptLazy BlockCipher
Botan.sm4 ByteString
k

    blockCipherDecryptLazy :: SecretKey SM4 -> LazyCiphertext SM4 -> Maybe Lazy.ByteString
    blockCipherDecryptLazy :: SecretKey SM4 -> LazyCiphertext SM4 -> Maybe ByteString
blockCipherDecryptLazy (SM4SecretKey ByteString
k) (SM4LazyCiphertext ByteString
ct) = BlockCipher -> ByteString -> ByteString -> Maybe ByteString
Botan.blockCipherDecryptLazy BlockCipher
Botan.sm4 ByteString
k ByteString
ct

-- SM4 blockCipher

sm4Encrypt :: SecretKey SM4 -> ByteString -> Maybe SM4Ciphertext
sm4Encrypt :: SecretKey SM4 -> ByteString -> Maybe (Ciphertext SM4)
sm4Encrypt = SecretKey SM4 -> ByteString -> Maybe (Ciphertext SM4)
forall bc.
BlockCipher bc =>
SecretKey bc -> ByteString -> Maybe (Ciphertext bc)
blockCipherEncrypt

sm4Decrypt :: SecretKey SM4 -> SM4Ciphertext -> Maybe ByteString
sm4Decrypt :: SecretKey SM4 -> Ciphertext SM4 -> Maybe ByteString
sm4Decrypt = SecretKey SM4 -> Ciphertext SM4 -> Maybe ByteString
forall bc.
BlockCipher bc =>
SecretKey bc -> Ciphertext bc -> Maybe ByteString
blockCipherDecrypt

sm4EncryptLazy :: SecretKey SM4 -> Lazy.ByteString -> Maybe SM4LazyCiphertext
sm4EncryptLazy :: SecretKey SM4 -> ByteString -> Maybe (LazyCiphertext SM4)
sm4EncryptLazy = SecretKey SM4 -> ByteString -> Maybe (LazyCiphertext SM4)
forall bc.
IncrementalBlockCipher bc =>
SecretKey bc -> ByteString -> Maybe (LazyCiphertext bc)
blockCipherEncryptLazy

sm4DecryptLazy :: SecretKey SM4 -> SM4LazyCiphertext -> Maybe Lazy.ByteString
sm4DecryptLazy :: SecretKey SM4 -> LazyCiphertext SM4 -> Maybe ByteString
sm4DecryptLazy = SecretKey SM4 -> LazyCiphertext SM4 -> Maybe ByteString
forall bc.
IncrementalBlockCipher bc =>
SecretKey bc -> LazyCiphertext bc -> Maybe ByteString
blockCipherDecryptLazy