module Botan.Hash.Streebog
( Streebog256(..)
, Streebog256Digest(..)
, streebog256
, streebog256Lazy
, Streebog512(..)
, Streebog512Digest(..)
, streebog512
, streebog512Lazy
) 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

-- Streebog256 type

data Streebog256

newtype instance Digest Streebog256 = Streebog256Digest
    { Digest Streebog256 -> ByteString
getStreebog256ByteString :: ByteString {- ByteVector n -} }
    deriving newtype (Digest Streebog256 -> Digest Streebog256 -> Bool
(Digest Streebog256 -> Digest Streebog256 -> Bool)
-> (Digest Streebog256 -> Digest Streebog256 -> Bool)
-> Eq (Digest Streebog256)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Digest Streebog256 -> Digest Streebog256 -> Bool
== :: Digest Streebog256 -> Digest Streebog256 -> Bool
$c/= :: Digest Streebog256 -> Digest Streebog256 -> Bool
/= :: Digest Streebog256 -> Digest Streebog256 -> Bool
Eq, Eq (Digest Streebog256)
Eq (Digest Streebog256) =>
(Digest Streebog256 -> Digest Streebog256 -> Ordering)
-> (Digest Streebog256 -> Digest Streebog256 -> Bool)
-> (Digest Streebog256 -> Digest Streebog256 -> Bool)
-> (Digest Streebog256 -> Digest Streebog256 -> Bool)
-> (Digest Streebog256 -> Digest Streebog256 -> Bool)
-> (Digest Streebog256 -> Digest Streebog256 -> Digest Streebog256)
-> (Digest Streebog256 -> Digest Streebog256 -> Digest Streebog256)
-> Ord (Digest Streebog256)
Digest Streebog256 -> Digest Streebog256 -> Bool
Digest Streebog256 -> Digest Streebog256 -> Ordering
Digest Streebog256 -> Digest Streebog256 -> Digest Streebog256
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 Streebog256 -> Digest Streebog256 -> Ordering
compare :: Digest Streebog256 -> Digest Streebog256 -> Ordering
$c< :: Digest Streebog256 -> Digest Streebog256 -> Bool
< :: Digest Streebog256 -> Digest Streebog256 -> Bool
$c<= :: Digest Streebog256 -> Digest Streebog256 -> Bool
<= :: Digest Streebog256 -> Digest Streebog256 -> Bool
$c> :: Digest Streebog256 -> Digest Streebog256 -> Bool
> :: Digest Streebog256 -> Digest Streebog256 -> Bool
$c>= :: Digest Streebog256 -> Digest Streebog256 -> Bool
>= :: Digest Streebog256 -> Digest Streebog256 -> Bool
$cmax :: Digest Streebog256 -> Digest Streebog256 -> Digest Streebog256
max :: Digest Streebog256 -> Digest Streebog256 -> Digest Streebog256
$cmin :: Digest Streebog256 -> Digest Streebog256 -> Digest Streebog256
min :: Digest Streebog256 -> Digest Streebog256 -> Digest Streebog256
Ord)

type Streebog256Digest = Digest Streebog256

instance Show (Digest Streebog256) where
    show :: Digest Streebog256 -> String
    show :: Digest Streebog256 -> String
show (Streebog256Digest 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 Streebog256 where
    hash :: ByteString -> Digest Streebog256
    hash :: ByteString -> Digest Streebog256
hash = ByteString -> Digest Streebog256
Streebog256Digest (ByteString -> Digest Streebog256)
-> (ByteString -> ByteString) -> ByteString -> Digest Streebog256
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash -> ByteString -> ByteString
Botan.hash Hash
Botan.streebog256

instance IncrementalHash Streebog256 where
    hashLazy :: Lazy.ByteString -> Digest Streebog256
    hashLazy :: ByteString -> Digest Streebog256
hashLazy = ByteString -> Digest Streebog256
Streebog256Digest (ByteString -> Digest Streebog256)
-> (ByteString -> ByteString) -> ByteString -> Digest Streebog256
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash -> ByteString -> ByteString
Botan.hashLazy Hash
Botan.streebog256

-- Streebog256 hash

streebog256 :: ByteString -> Streebog256Digest
streebog256 :: ByteString -> Digest Streebog256
streebog256 = ByteString -> Digest Streebog256
forall hash. Hash hash => ByteString -> Digest hash
hash

streebog256Lazy :: Lazy.ByteString -> Streebog256Digest
streebog256Lazy :: ByteString -> Digest Streebog256
streebog256Lazy = ByteString -> Digest Streebog256
forall hash. IncrementalHash hash => ByteString -> Digest hash
hashLazy

-- Streebog512 type

data Streebog512

newtype instance Digest Streebog512 = Streebog512Digest
    { Digest Streebog512 -> ByteString
getStreebog512ByteString :: ByteString {- ByteVector n -} }
    deriving newtype (Digest Streebog512 -> Digest Streebog512 -> Bool
(Digest Streebog512 -> Digest Streebog512 -> Bool)
-> (Digest Streebog512 -> Digest Streebog512 -> Bool)
-> Eq (Digest Streebog512)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Digest Streebog512 -> Digest Streebog512 -> Bool
== :: Digest Streebog512 -> Digest Streebog512 -> Bool
$c/= :: Digest Streebog512 -> Digest Streebog512 -> Bool
/= :: Digest Streebog512 -> Digest Streebog512 -> Bool
Eq, Eq (Digest Streebog512)
Eq (Digest Streebog512) =>
(Digest Streebog512 -> Digest Streebog512 -> Ordering)
-> (Digest Streebog512 -> Digest Streebog512 -> Bool)
-> (Digest Streebog512 -> Digest Streebog512 -> Bool)
-> (Digest Streebog512 -> Digest Streebog512 -> Bool)
-> (Digest Streebog512 -> Digest Streebog512 -> Bool)
-> (Digest Streebog512 -> Digest Streebog512 -> Digest Streebog512)
-> (Digest Streebog512 -> Digest Streebog512 -> Digest Streebog512)
-> Ord (Digest Streebog512)
Digest Streebog512 -> Digest Streebog512 -> Bool
Digest Streebog512 -> Digest Streebog512 -> Ordering
Digest Streebog512 -> Digest Streebog512 -> Digest Streebog512
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 Streebog512 -> Digest Streebog512 -> Ordering
compare :: Digest Streebog512 -> Digest Streebog512 -> Ordering
$c< :: Digest Streebog512 -> Digest Streebog512 -> Bool
< :: Digest Streebog512 -> Digest Streebog512 -> Bool
$c<= :: Digest Streebog512 -> Digest Streebog512 -> Bool
<= :: Digest Streebog512 -> Digest Streebog512 -> Bool
$c> :: Digest Streebog512 -> Digest Streebog512 -> Bool
> :: Digest Streebog512 -> Digest Streebog512 -> Bool
$c>= :: Digest Streebog512 -> Digest Streebog512 -> Bool
>= :: Digest Streebog512 -> Digest Streebog512 -> Bool
$cmax :: Digest Streebog512 -> Digest Streebog512 -> Digest Streebog512
max :: Digest Streebog512 -> Digest Streebog512 -> Digest Streebog512
$cmin :: Digest Streebog512 -> Digest Streebog512 -> Digest Streebog512
min :: Digest Streebog512 -> Digest Streebog512 -> Digest Streebog512
Ord)

type Streebog512Digest = Digest Streebog512

instance Show (Digest Streebog512) where
    show :: Digest Streebog512 -> String
    show :: Digest Streebog512 -> String
show (Streebog512Digest 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 Streebog512 where
    hash :: ByteString -> Digest Streebog512
    hash :: ByteString -> Digest Streebog512
hash = ByteString -> Digest Streebog512
Streebog512Digest (ByteString -> Digest Streebog512)
-> (ByteString -> ByteString) -> ByteString -> Digest Streebog512
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash -> ByteString -> ByteString
Botan.hash Hash
Botan.streebog512

instance IncrementalHash Streebog512 where
    hashLazy :: Lazy.ByteString -> Digest Streebog512
    hashLazy :: ByteString -> Digest Streebog512
hashLazy = ByteString -> Digest Streebog512
Streebog512Digest (ByteString -> Digest Streebog512)
-> (ByteString -> ByteString) -> ByteString -> Digest Streebog512
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash -> ByteString -> ByteString
Botan.hashLazy Hash
Botan.streebog512

-- Streebog512 hash

streebog512 :: ByteString -> Streebog512Digest
streebog512 :: ByteString -> Digest Streebog512
streebog512 = ByteString -> Digest Streebog512
forall hash. Hash hash => ByteString -> Digest hash
hash

streebog512Lazy :: Lazy.ByteString -> Streebog512Digest
streebog512Lazy :: ByteString -> Digest Streebog512
streebog512Lazy = ByteString -> Digest Streebog512
forall hash. IncrementalHash hash => ByteString -> Digest hash
hashLazy