module Botan.Hash.SM3
( SM3(..)
, SM3Digest(..)
, sm3
, sm3Lazy
) where
import qualified Data.ByteString as ByteString
import qualified Data.ByteString.Lazy as Lazy
import qualified Data.Text as Text
import qualified Botan.Hash as Botan
import qualified Botan.Utility as Botan
import Botan.Hash.Class
import Botan.Prelude
data SM3
newtype instance Digest SM3 = SM3Digest
{ Digest SM3 -> ByteString
getSM3ByteString :: ByteString }
deriving newtype (Digest SM3 -> Digest SM3 -> Bool
(Digest SM3 -> Digest SM3 -> Bool)
-> (Digest SM3 -> Digest SM3 -> Bool) -> Eq (Digest SM3)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Digest SM3 -> Digest SM3 -> Bool
== :: Digest SM3 -> Digest SM3 -> Bool
$c/= :: Digest SM3 -> Digest SM3 -> Bool
/= :: Digest SM3 -> Digest SM3 -> Bool
Eq, Eq (Digest SM3)
Eq (Digest SM3) =>
(Digest SM3 -> Digest SM3 -> Ordering)
-> (Digest SM3 -> Digest SM3 -> Bool)
-> (Digest SM3 -> Digest SM3 -> Bool)
-> (Digest SM3 -> Digest SM3 -> Bool)
-> (Digest SM3 -> Digest SM3 -> Bool)
-> (Digest SM3 -> Digest SM3 -> Digest SM3)
-> (Digest SM3 -> Digest SM3 -> Digest SM3)
-> Ord (Digest SM3)
Digest SM3 -> Digest SM3 -> Bool
Digest SM3 -> Digest SM3 -> Ordering
Digest SM3 -> Digest SM3 -> Digest SM3
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 :: Digest SM3 -> Digest SM3 -> Ordering
compare :: Digest SM3 -> Digest SM3 -> Ordering
$c< :: Digest SM3 -> Digest SM3 -> Bool
< :: Digest SM3 -> Digest SM3 -> Bool
$c<= :: Digest SM3 -> Digest SM3 -> Bool
<= :: Digest SM3 -> Digest SM3 -> Bool
$c> :: Digest SM3 -> Digest SM3 -> Bool
> :: Digest SM3 -> Digest SM3 -> Bool
$c>= :: Digest SM3 -> Digest SM3 -> Bool
>= :: Digest SM3 -> Digest SM3 -> Bool
$cmax :: Digest SM3 -> Digest SM3 -> Digest SM3
max :: Digest SM3 -> Digest SM3 -> Digest SM3
$cmin :: Digest SM3 -> Digest SM3 -> Digest SM3
min :: Digest SM3 -> Digest SM3 -> Digest SM3
Ord)
type SM3Digest = Digest SM3
instance Show (Digest SM3) where
show :: Digest SM3 -> String
show :: Digest SM3 -> String
show (SM3Digest ByteString
bytes) = Text -> String
Text.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ ByteString -> HexCase -> Text
Botan.hexEncode ByteString
bytes HexCase
Botan.Lower
instance Hash SM3 where
hash :: ByteString -> Digest SM3
hash :: ByteString -> Digest SM3
hash = ByteString -> Digest SM3
SM3Digest (ByteString -> Digest SM3)
-> (ByteString -> ByteString) -> ByteString -> Digest SM3
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash -> ByteString -> ByteString
Botan.hash Hash
Botan.sm3
instance IncrementalHash SM3 where
hashLazy :: Lazy.ByteString -> Digest SM3
hashLazy :: ByteString -> Digest SM3
hashLazy = ByteString -> Digest SM3
SM3Digest (ByteString -> Digest SM3)
-> (ByteString -> ByteString) -> ByteString -> Digest SM3
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash -> ByteString -> ByteString
Botan.hashLazy Hash
Botan.sm3
sm3 :: ByteString -> SM3Digest
sm3 :: ByteString -> Digest SM3
sm3 = ByteString -> Digest SM3
forall hash. Hash hash => ByteString -> Digest hash
hash
sm3Lazy :: Lazy.ByteString -> SM3Digest
sm3Lazy :: ByteString -> Digest SM3
sm3Lazy = ByteString -> Digest SM3
forall hash. IncrementalHash hash => ByteString -> Digest hash
hashLazy