-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Welcome to botan-low
--   
--   Low-level bindings to the <a>Botan</a> cryptography library.
--   
--   <pre>
--   Botan's goal is to be the best option for cryptography in C++ by offering the
--   tools necessary to implement a range of practical systems, such as TLS protocol,
--   X.509 certificates, modern AEAD ciphers, PKCS#11 and TPM hardware support,
--   password hashing, and post quantum crypto schemes.
--   </pre>
--   
--   For more information, see the <a>README on Github</a>
@package botan-low
@version 0.2.0.1


-- | This module is based on the <a>Return codes</a> section of the C Botan
--   FFI documentation.
module Botan.Low.Error
data BotanErrorCode

-- | Convert an error code into a string. Returns "Unknown error" if the
--   error code is not a known one.
botanErrorDescription :: BotanErrorCode -> IO ByteString
newtype BotanErrorMessage
BotanErrorMessage :: ByteString -> BotanErrorMessage

-- | Returns a static string stored in a thread local variable which
--   contains the last exception message thrown. WARNING: This string
--   buffer is overwritten on the next call to the FFI layer
botanErrorLastExceptionMessage :: IO BotanErrorMessage

-- | The SomeBotanException type is the root of the botan exception type
--   hierarchy.
data SomeBotanException
SomeBotanException :: e -> SomeBotanException
toBotanException :: Exception e => e -> SomeException
fromBotanException :: Exception e => SomeException -> Maybe e
data InvalidInputException
InvalidInputException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> InvalidInputException
data BadMACException
BadMACException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> BadMACException
data InsufficientBufferSpaceException
InsufficientBufferSpaceException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> InsufficientBufferSpaceException
data StringConversionException
StringConversionException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> StringConversionException
data ExceptionThrownException
ExceptionThrownException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> ExceptionThrownException
data OutOfMemoryException
OutOfMemoryException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> OutOfMemoryException
data SystemErrorException
SystemErrorException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> SystemErrorException
data InternalErrorException
InternalErrorException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> InternalErrorException
data BadFlagException
BadFlagException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> BadFlagException
data NullPointerException
NullPointerException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> NullPointerException
data BadParameterException
BadParameterException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> BadParameterException
data KeyNotSetException
KeyNotSetException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> KeyNotSetException
data InvalidKeyLengthException
InvalidKeyLengthException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> InvalidKeyLengthException
data InvalidObjectStateException
InvalidObjectStateException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> InvalidObjectStateException
data NotImplementedException
NotImplementedException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> NotImplementedException
data InvalidObjectException
InvalidObjectException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> InvalidObjectException
data UnknownException
UnknownException :: BotanErrorCode -> BotanErrorMessage -> CallStack -> UnknownException


-- | Pseudo-random number generation.
module Botan.Low.RNG
newtype RNG
MkRNG :: ForeignPtr BotanRNGStruct -> RNG
[foreignPtr] :: RNG -> ForeignPtr BotanRNGStruct
type RNGType = ByteString
withRNG :: RNG -> (BotanRNG -> IO a) -> IO a

-- | Initialize a random number generator object
--   
--   rng_type has the possible values:
--   
--   <ul>
--   <li>"system": system RNG</li>
--   <li>"user": userspace RNG</li>
--   <li>"user-threadsafe": userspace RNG, with internal locking</li>
--   <li>"rdrand": directly read RDRAND</li>
--   </ul>
--   
--   Set rng_type to null to let the library choose some default.
rngInit :: RNGType -> IO RNG

-- | Destroy a random number generator object immediately
rngDestroy :: RNG -> IO ()

-- | Get random bytes from a random number generator
rngGet :: RNG -> Int -> IO ByteString

-- | Get random bytes from system random number generator
systemRNGGet :: Int -> IO ByteString

-- | Reseed a random number generator
--   
--   Uses the System_RNG as a seed generator.
rngReseed :: RNG -> Int -> IO ()

-- | Reseed a random number generator
rngReseedFromRNG :: RNG -> RNG -> Int -> IO ()

-- | Add some seed material to a random number generator
rngAddEntropy :: RNG -> ByteString -> IO ()
pattern SystemRNG :: RNGType
pattern UserRNG :: RNGType
pattern UserThreadsafeRNG :: RNGType
pattern RDRandRNG :: RNGType


-- | Generate and validate Bcrypt password hashes
module Botan.Low.Bcrypt

-- | Create a password hash using Bcrypt
--   
--   <pre>
--   rng &lt;- rngInit "user"
--   digest &lt;- bcryptGenerate password rng 12
--   </pre>
--   
--   Output is formatted bcrypt $2a$...
bcryptGenerate :: BcryptPassword -> RNG -> BcryptWorkFactor -> IO BcryptDigest

-- | Check a previously created password hash
--   
--   <pre>
--   valid &lt;- bcryptIsValid password digest
--   if valid ...
--   </pre>
--   
--   Returns True iff this password/hash combination is valid, False if the
--   combination is not valid (but otherwise well formed), and otherwise
--   throws an exception on error.
bcryptIsValid :: BcryptPassword -> BcryptDigest -> IO Bool

-- | A work factor to slow down guessing attacks.
type BcryptWorkFactor = Int

-- | Should not cause noticable CPU usage
pattern BcryptFast :: BcryptWorkFactor

-- | May cause noticable CPU usage
pattern BcryptGood :: BcryptWorkFactor

-- | May block for several seconds
pattern BcryptStrong :: BcryptWorkFactor

-- | A bcrypt password.
type BcryptPassword = ByteString

-- | A bcrypt-hashed password digest.
type BcryptDigest = ByteString


module Botan.Low.MPI
newtype MP
MkMP :: ForeignPtr BotanMPStruct -> MP
[foreignPtr] :: MP -> ForeignPtr BotanMPStruct
withMP :: MP -> (BotanMP -> IO a) -> IO a
mpInit :: IO MP
mpDestroy :: MP -> IO ()
mpToHex :: MP -> IO ByteString
mpToStr :: MP -> Int -> IO ByteString
mpClear :: MP -> IO ()
mpSetFromInt :: MP -> Int -> IO ()
mpSetFromMP :: MP -> MP -> IO ()
mpCopy :: MP -> IO MP
mpSetFromStr :: MP -> ByteString -> IO ()
mpSetFromRadixStr :: MP -> ByteString -> Int -> IO ()
mpNumBits :: MP -> IO Int
mpNumBytes :: MP -> IO Int
mpToBin :: MP -> IO ByteString
mpFromBin :: MP -> ByteString -> IO ()
mpToWord32 :: MP -> IO Word32
mpIsPositive :: MP -> IO Bool
mpIsNegative :: MP -> IO Bool
mpFlipSign :: MP -> IO ()
mpIsZero :: MP -> IO Bool
mpAddWord32 :: MP -> MP -> Word32 -> IO ()
mpSubWord32 :: MP -> MP -> Word32 -> IO ()
mpAdd :: MP -> MP -> MP -> IO ()
mpSub :: MP -> MP -> MP -> IO ()
mpMul :: MP -> MP -> MP -> IO ()
mpDiv :: MP -> MP -> MP -> MP -> IO ()
mpModMul :: MP -> MP -> MP -> MP -> IO ()
mpEqual :: MP -> MP -> IO Bool
mpCmp :: MP -> MP -> IO Int
mpSwap :: MP -> MP -> IO ()
mpPowMod :: MP -> MP -> MP -> MP -> IO ()
mpLeftShift :: MP -> MP -> Int -> IO ()
mpRightShift :: MP -> MP -> Int -> IO ()
mpModInverse :: MP -> MP -> MP -> IO ()
mpRandBits :: MP -> RNG -> Int -> IO ()
mpRandRange :: MP -> RNG -> MP -> MP -> IO ()
mpGCD :: MP -> MP -> MP -> IO ()
mpIsPrime :: MP -> RNG -> Int -> IO Bool
mpGetBit :: MP -> Int -> IO Bool
mpSetBit :: MP -> Int -> IO ()
mpClearBit :: MP -> Int -> IO ()


-- | Hash functions are one-way functions, which map data of arbitrary size
--   to a fixed output length. Most of the hash functions in Botan are
--   designed to be cryptographically secure, which means that it is
--   computationally infeasible to create a collision (finding two inputs
--   with the same hash) or preimages (given a hash output, generating an
--   arbitrary input with the same hash). But note that not all such hash
--   functions meet their goals, in particular MD4 and MD5 are trivially
--   broken. However they are still included due to their wide adoption in
--   various protocols.
--   
--   Using a hash function is typically split into three stages:
--   initialization, update, and finalization (often referred to as a IUF
--   interface). The initialization stage is implicit: after creating a
--   hash function object, it is ready to process data. Then update is
--   called one or more times. Calling update several times is equivalent
--   to calling it once with all of the arguments concatenated. After
--   completing a hash computation (eg using hashFinal), the internal state
--   is reset to begin hashing a new message.
module Botan.Low.Hash
newtype Hash
MkHash :: ForeignPtr BotanHashStruct -> Hash
[foreignPtr] :: Hash -> ForeignPtr BotanHashStruct
type HashName = ByteString
type HashDigest = ByteString
withHash :: Hash -> (BotanHash -> IO a) -> IO a
hashInit :: HashName -> IO Hash
hashDestroy :: Hash -> IO ()
hashName :: Hash -> IO HashDigest
hashBlockSize :: Hash -> IO Int
hashOutputLength :: Hash -> IO Int
hashCopyState :: Hash -> IO Hash
hashUpdate :: Hash -> ByteString -> IO ()
hashFinal :: Hash -> IO HashDigest
hashUpdateFinalize :: Hash -> ByteString -> IO HashDigest
hashUpdateFinalizeClear :: Hash -> ByteString -> IO HashDigest
hashClear :: Hash -> IO ()
pattern BLAKE2b :: HashName
blake2b :: (Ord a, Num a, Show a) => a -> HashName
pattern Keccak1600 :: HashName
keccak1600 :: (Eq a, Num a, Show a) => a -> HashName
pattern GOST_34_11 :: HashName
pattern MD4 :: HashName
pattern MD5 :: HashName
pattern RIPEMD160 :: HashName
pattern SHA1 :: HashName
pattern SHA224 :: HashName
pattern SHA256 :: HashName
pattern SHA384 :: HashName
pattern SHA512 :: HashName
pattern SHA512_256 :: HashName
pattern SHA3 :: HashName
sha3 :: (Eq a, Num a, Show a) => a -> HashName
pattern SHAKE128 :: HashName
shake128 :: Show a => a -> HashName
pattern SHAKE256 :: HashName
shake256 :: Show a => a -> HashName
pattern SM3 :: HashName
pattern Skein512 :: HashName
skein512 :: Show a => a -> HashName -> HashName
pattern Streebog256 :: HashName
pattern Streebog512 :: HashName
pattern Whirlpool :: HashName
pattern Parallel :: HashName
pattern Comb4P :: HashName
pattern Adler32 :: HashName
pattern CRC24 :: HashName
pattern CRC32 :: HashName
cryptohashes :: [HashName]
checksums :: [HashName]
allHashes :: [HashName]


-- | This module is based on the <a>Password Based Key Deriviation</a>
--   section of the C++ API reference.
module Botan.Low.PwdHash

-- | Derive a cryptographic key from a passphrase using algorithm-specific
--   parameters
--   
--   NOTE: the interpretation of parameters <tt>param1</tt>,
--   <tt>param2</tt>, and <tt>param3</tt> are different depending on the
--   PBKDF algorithm that is picked. See the documentation of the
--   <a><tt>from_params</tt></a> C++ function for more information about
--   the meaning of the parameters.
pwdhash :: PBKDFName -> Int -> Int -> Int -> Int -> ByteString -> ByteString -> IO ByteString

-- | Derive a cryptographic key from a passphrase using algorithm-specific
--   parameters that are tuned automatically for a desired running time of
--   the algorithm.
--   
--   NOTE: for the <tt>Argon2</tt> and <tt>Scrypt</tt> PBKDF algorithms,
--   <a>pwdhashTimed</a> returns parameters in a different order than the
--   order in which they should be passed to <a>pwdhash</a>. This is a
--   known issue with the Botan C++ library. See
--   <a>https://github.com/randombit/botan/issues/2144</a> for more
--   information.
--   
--   <a>pwdhashTimed</a> always returns parameters in this order:
--   
--   <pre>
--   (iterations, parallelism, memoryParam)
--   </pre>
--   
--   <a>pwdhash</a> shoulds be given parameters in this order for the
--   <tt>Argon2</tt> and <tt>Scrypt</tt> algorithms:
--   
--   <pre>
--   param1 = memoryParam
--   param2 = iterations
--   param3 = parallelism
--   </pre>
pwdhashTimed :: PBKDFName -> Int -> Int -> ByteString -> ByteString -> IO (Int, Int, Int, ByteString)

-- | The name of a key derivation scheme used as a PBKDF algorithm
type PBKDFName = ByteString

-- | <pre>
--   &gt;&gt;&gt; PBKDF2
--   "PBKDF2"
--   </pre>
pattern PBKDF2 :: PBKDFName

-- | <pre>
--   &gt;&gt;&gt; pbkdf2 SHA256
--   "PBKDF2(SHA-256)"
--   </pre>
--   
--   NOTE: "PBKDF(HMAC(SHA-256))" is equivalent to "PBKDF(SHA-256)".
--   <a>pbkdf2</a> always outputs the latter given a hash function name.
pbkdf2 :: HashName -> PBKDFName

-- | <pre>
--   &gt;&gt;&gt; Scrypt
--   "Scrypt"
--   </pre>
pattern Scrypt :: PBKDFName

-- | <pre>
--   &gt;&gt;&gt; Argon2d
--   "Argon2d"
--   </pre>
pattern Argon2d :: PBKDFName

-- | <pre>
--   &gt;&gt;&gt; Argon2i
--   "Argon2i"
--   </pre>
pattern Argon2i :: PBKDFName

-- | <pre>
--   &gt;&gt;&gt; Argon2id
--   "Argon2id"
--   </pre>
pattern Argon2id :: PBKDFName

-- | <pre>
--   &gt;&gt;&gt; Bcrypt_PBKDF
--   "Bcrypt-PBKDF"
--   </pre>
pattern Bcrypt_PBKDF :: PBKDFName

-- | <pre>
--   &gt;&gt;&gt; OpenPGP_S2K
--   "OpenPGP-S2K"
--   </pre>
pattern OpenPGP_S2K :: PBKDFName

-- | <pre>
--   &gt;&gt;&gt; openPGP_S2K SHA256
--   "OpenPGP-S2K(SHA-256)"
--   </pre>
openPGP_S2K :: HashName -> PBKDFName


-- | Public key cryptography is a collection of techniques allowing for
--   encryption, signatures, and key agreement.
module Botan.Low.PubKey
newtype PrivKey
MkPrivKey :: ForeignPtr BotanPrivKeyStruct -> PrivKey
[foreignPtr] :: PrivKey -> ForeignPtr BotanPrivKeyStruct
data CheckKeyFlags
CheckKeyNormalTests :: CheckKeyFlags
CheckKeyExpensiveTests :: CheckKeyFlags
checkKeyFlags :: CheckKeyFlags -> Word32
data PrivKeyExportFlags
PrivKeyExportDER :: PrivKeyExportFlags
PrivKeyExportPEM :: PrivKeyExportFlags
privKeyExportFlags :: PrivKeyExportFlags -> Word32
withPrivKey :: PrivKey -> (BotanPrivKey -> IO a) -> IO a

-- | Create a new private key
privKeyCreate :: ByteString -> ByteString -> RNG -> IO PrivKey

-- | Input currently assumed to be PKCS #8 structure; Set password to NULL
--   to indicate no encryption expected Starting in 2.8.0, the rng
--   parameter is unused and may be set to null
privKeyLoad :: ByteString -> ByteString -> IO PrivKey
privKeyDestroy :: PrivKey -> IO ()
privKeyAlgoName :: PrivKey -> IO ByteString

-- | Check the validity of a private key
privKeyCheckKey :: PrivKey -> RNG -> CheckKeyFlags -> IO ()

-- | Get arbitrary named fields from public or private keys
privKeyGetField :: MP -> PrivKey -> ByteString -> IO ()

-- | On input *out_len is number of bytes in out[] On output *out_len is
--   number of bytes written (or required) If out is not big enough no
--   output is written, *out_len is set and 1 is returned Returns 0 on
--   success and sets If some other error occurs a negative integer is
--   returned.
privKeyExport :: PrivKey -> PrivKeyExportFlags -> IO ByteString
privKeyExportPubKey :: PrivKey -> IO PubKey
newtype PubKey
MkPubKey :: ForeignPtr BotanPubKeyStruct -> PubKey
[foreignPtr] :: PubKey -> ForeignPtr BotanPubKeyStruct
withPubKey :: PubKey -> (BotanPubKey -> IO a) -> IO a
pubKeyLoad :: ByteString -> IO PubKey
pubKeyDestroy :: PubKey -> IO ()
pubKeyAlgoName :: PubKey -> IO ByteString
pubKeyCheckKey :: PubKey -> RNG -> CheckKeyFlags -> IO Bool
pubKeyEstimatedStrength :: PubKey -> IO Int
pubKeyFingerprint :: PubKey -> HashName -> IO ByteString

-- | Get arbitrary named fields from public or private keys
pubKeyGetField :: MP -> PubKey -> ByteString -> IO ()
pubKeyExport :: PubKey -> PubKeyExportFlags -> IO ByteString
type PKName = ByteString
pattern RSA :: PKName
pattern SM2 :: PKName
pattern ElGamal :: PKName
pattern DSA :: PKName
pattern ECDSA :: PKName
pattern ECKCDSA :: PKName
pattern ECGDSA :: PKName
pattern GOST_34_10 :: PKName
pattern Ed25519 :: PKName
pattern XMSS :: PKName
pattern DH :: PKName
pattern ECDH :: PKName
pattern Curve25519 :: PKName
pattern Dilithium :: PKName
pattern Kyber :: PKName
pattern McEliece :: PKName
type DLGroupName = ByteString
pattern FFDHE_IETF_2048 :: DLGroupName
pattern FFDHE_IETF_3072 :: DLGroupName
pattern FFDHE_IETF_4096 :: DLGroupName
pattern FFDHE_IETF_6144 :: DLGroupName
pattern FFDHE_IETF_8192 :: DLGroupName
pattern MODP_IETF_1024 :: DLGroupName
pattern MODP_IETF_1536 :: DLGroupName
pattern MODP_IETF_2048 :: DLGroupName
pattern MODP_IETF_3072 :: DLGroupName
pattern MODP_IETF_4096 :: DLGroupName
pattern MODP_IETF_6144 :: DLGroupName
pattern MODP_IETF_8192 :: DLGroupName
pattern MODP_SRP_1024 :: DLGroupName
pattern MODP_SRP_1536 :: DLGroupName
pattern MODP_SRP_2048 :: DLGroupName
pattern MODP_SRP_3072 :: DLGroupName
pattern MODP_SRP_4096 :: DLGroupName
pattern MODP_SRP_6144 :: DLGroupName
pattern MODP_SRP_8192 :: DLGroupName
pattern DSA_JCE_1024 :: DLGroupName
pattern DSA_BOTAN_2048 :: DLGroupName
pattern DSA_BOTAN_3072 :: DLGroupName
type ECGroupName = ByteString
pattern Secp160k1 :: ECGroupName
pattern Secp160r1 :: ECGroupName
pattern Secp160r2 :: ECGroupName
pattern Secp192k1 :: ECGroupName
pattern Secp192r1 :: ECGroupName
pattern Secp224k1 :: ECGroupName
pattern Secp224r1 :: ECGroupName
pattern Secp256k1 :: ECGroupName
pattern Secp256r1 :: ECGroupName
pattern Secp384r1 :: ECGroupName
pattern Secp521r1 :: ECGroupName
pattern Brainpool160r1 :: ECGroupName
pattern Brainpool192r1 :: ECGroupName
pattern Brainpool224r1 :: ECGroupName
pattern Brainpool256r1 :: ECGroupName
pattern Brainpool320r1 :: ECGroupName
pattern Brainpool384r1 :: ECGroupName
pattern Brainpool512r1 :: ECGroupName
pattern X962_p192v2 :: ECGroupName
pattern X962_p192v3 :: ECGroupName
pattern X962_p239v1 :: ECGroupName
pattern X962_p239v2 :: ECGroupName
pattern X962_p239v3 :: ECGroupName
pattern Gost_256A :: ECGroupName
pattern Gost_512A :: ECGroupName
pattern Frp256v1 :: ECGroupName
pattern Sm2p256v1 :: ECGroupName
type XMSSName = ByteString
pattern XMSS_SHA2_10_256 :: XMSSName
pattern XMSS_SHA2_16_256 :: XMSSName
pattern XMSS_SHA2_20_256 :: XMSSName
pattern XMSS_SHA2_10_512 :: XMSSName
pattern XMSS_SHA2_16_512 :: XMSSName
pattern XMSS_SHA2_20_512 :: XMSSName
pattern XMSS_SHAKE_10_256 :: XMSSName
pattern XMSS_SHAKE_16_256 :: XMSSName
pattern XMSS_SHAKE_20_256 :: XMSSName
pattern XMSS_SHAKE_10_512 :: XMSSName
pattern XMSS_SHAKE_16_512 :: XMSSName
pattern XMSS_SHAKE_20_512 :: XMSSName

-- | Encoding Method for Encryption
--   
--   WARNING: Name is not completely accurate, may be changed to
--   PKEncryptParams
type EMEName = ByteString
pattern EME_RAW :: EMEName
pattern EME_PKCS1_v1_5 :: EMEName
pattern EME_OAEP :: EMEName
eme_raw :: EMEName
eme_pkcs1_v1_5 :: EMEName
eme_oaep :: HashName -> EMEName
eme_hash :: HashName -> EMEName
eme_sm2EncParam :: HashName -> EMEName

-- | Encoding Method for Signature with Appendix
--   
--   WARNING: Name is not completely accurate, may be changed to
--   PKSignParams
type EMSAName = ByteString
emsa_none :: EMSAName
emsa_emsa4 :: HashName -> EMSAName
emsa_hash :: HashName -> EMSAName
emsa_ed25519Pure :: EMSAName
emsa_ed25519Prehashed :: EMSAName
emsa_ed25519GnuPG :: HashName -> EMSAName
emsa_sm2SignParam :: ByteString -> HashName -> EMSAName
createPrivKey :: (Ptr BotanPrivKey -> IO CInt) -> IO PrivKey
createPubKey :: (Ptr BotanPubKey -> IO CInt) -> IO PubKey
mkPrivKeyLoad1_name :: (Ptr BotanPrivKey -> BotanMP -> ConstPtr CChar -> IO CInt) -> MP -> ByteString -> IO PrivKey
mkPrivKeyLoad3 :: (Ptr BotanPrivKey -> BotanMP -> BotanMP -> BotanMP -> IO CInt) -> MP -> MP -> MP -> IO PrivKey
mkPrivKeyLoad4 :: (Ptr BotanPrivKey -> BotanMP -> BotanMP -> BotanMP -> BotanMP -> IO CInt) -> MP -> MP -> MP -> MP -> IO PrivKey
mkPubKeyLoad2 :: (Ptr BotanPubKey -> BotanMP -> BotanMP -> IO CInt) -> MP -> MP -> IO PubKey
mkPubKeyLoad2_name :: (Ptr BotanPubKey -> BotanMP -> BotanMP -> ConstPtr CChar -> IO CInt) -> MP -> MP -> ByteString -> IO PubKey
mkPubKeyLoad3 :: (Ptr BotanPubKey -> BotanMP -> BotanMP -> BotanMP -> IO CInt) -> MP -> MP -> MP -> IO PubKey
mkPubKeyLoad4 :: (Ptr BotanPubKey -> BotanMP -> BotanMP -> BotanMP -> BotanMP -> IO CInt) -> MP -> MP -> MP -> MP -> IO PubKey


module Botan.Low.PubKey.X25519
privKeyLoadX25519 :: ByteString -> IO PrivKey
pubKeyLoadX25519 :: ByteString -> IO PubKey
privKeyX25519GetPrivKey :: PrivKey -> IO ByteString
pubKeyX25519GetPubKey :: PubKey -> IO ByteString


module Botan.Low.PubKey.Sign
newtype Sign
MkSign :: ForeignPtr BotanPKOpSignStruct -> Sign
[foreignPtr] :: Sign -> ForeignPtr BotanPKOpSignStruct
data SigningFlags
StandardFormatSignature :: SigningFlags
DERFormatSignature :: SigningFlags
signingFlags :: SigningFlags -> Word32
withSign :: Sign -> (BotanPKOpSign -> IO a) -> IO a
signCreate :: PrivKey -> EMSAName -> SigningFlags -> IO Sign
signDestroy :: Sign -> IO ()
signOutputLength :: Sign -> IO Int
signUpdate :: Sign -> ByteString -> IO ()

-- | Finish signing
--   
--   Depending on the algorithm, signatures produced using
--   StandardFormatSignature may have trailing null bytes.
signFinish :: Sign -> RNG -> IO ByteString


module Botan.Low.PubKey.Verify
newtype Verify
MkVerify :: ForeignPtr BotanPKOpVerifyStruct -> Verify
[foreignPtr] :: Verify -> ForeignPtr BotanPKOpVerifyStruct
withVerify :: Verify -> (BotanPKOpVerify -> IO a) -> IO a
verifyCreate :: PubKey -> EMSAName -> SigningFlags -> IO Verify
verifyDestroy :: Verify -> IO ()
verifyUpdate :: Verify -> ByteString -> IO ()
verifyFinish :: Verify -> ByteString -> IO Bool

module Botan.Low.PubKey.SM2
privKeyLoadSM2 :: MP -> ByteString -> IO PrivKey
pubKeyLoadSM2 :: MP -> MP -> ByteString -> IO PubKey


module Botan.Low.PubKey.RSA
privKeyLoadRSA :: MP -> MP -> MP -> IO PrivKey
privKeyLoadRSA_PKCS1 :: ByteString -> IO PrivKey
privKeyRSAGetPrivKey :: PrivKey -> Word32 -> IO ByteString
pubKeyLoadRSA :: MP -> MP -> IO PubKey


module Botan.Low.PubKey.Encrypt
newtype Encrypt
MkEncrypt :: ForeignPtr BotanPKOpEncryptStruct -> Encrypt
[foreignPtr] :: Encrypt -> ForeignPtr BotanPKOpEncryptStruct
withEncrypt :: Encrypt -> (BotanPKOpEncrypt -> IO a) -> IO a
encryptCreate :: PubKey -> EMEName -> IO Encrypt
encryptDestroy :: Encrypt -> IO ()
encryptOutputLength :: Encrypt -> Int -> IO Int
encrypt :: Encrypt -> RNG -> ByteString -> IO ByteString


module Botan.Low.PubKey.ElGamal
privKeyCreateElGamal :: RNG -> Int -> Int -> IO PrivKey
privKeyLoadElGamal :: MP -> MP -> MP -> IO PrivKey
pubKeyLoadElGamal :: MP -> MP -> MP -> IO PubKey


module Botan.Low.PubKey.Ed25519
privKeyLoadEd25519 :: ByteString -> IO PrivKey
pubKeyLoadEd25519 :: ByteString -> IO PubKey
privKeyEd25519GetPrivKey :: PrivKey -> IO ByteString
pubKeyEd25519GetPubKey :: PubKey -> IO ByteString

module Botan.Low.PubKey.ECDSA
privKeyLoadECDSA :: MP -> ByteString -> IO PrivKey
pubKeyLoadECDSA :: MP -> MP -> ByteString -> IO PubKey

module Botan.Low.PubKey.ECDH
privKeyLoadECDH :: MP -> ByteString -> IO PrivKey
pubKeyLoadECDH :: MP -> MP -> ByteString -> IO PubKey


module Botan.Low.PubKey.Decrypt
newtype Decrypt
MkDecrypt :: ForeignPtr BotanPKOpDecryptStruct -> Decrypt
[foreignPtr] :: Decrypt -> ForeignPtr BotanPKOpDecryptStruct
withDecrypt :: Decrypt -> (BotanPKOpDecrypt -> IO a) -> IO a
decryptCreate :: PrivKey -> EMEName -> IO Decrypt
decryptDestroy :: Decrypt -> IO ()
decryptOutputLength :: Decrypt -> Int -> IO Int
decrypt :: Decrypt -> ByteString -> IO ByteString


module Botan.Low.PubKey.DSA
privKeyCreateDSA :: RNG -> Int -> Int -> IO PrivKey
privKeyLoadDSA :: MP -> MP -> MP -> MP -> IO PrivKey
pubKeyLoadDSA :: MP -> MP -> MP -> MP -> IO PubKey


module Botan.Low.PubKey.DH
privKeyLoadDH :: MP -> MP -> MP -> IO PrivKey
pubKeyLoadDH :: MP -> MP -> MP -> IO PubKey


-- | One time password schemes are a user authentication method that relies
--   on a fixed secret key which is used to derive a sequence of short
--   passwords, each of which is accepted only once. Commonly this is used
--   to implement two-factor authentication (2FA), where the user
--   authenticates using both a conventional password (or a public key
--   signature) and an OTP generated by a small device such as a mobile
--   phone.
module Botan.Low.HOTP
newtype HOTP
MkHOTP :: ForeignPtr BotanHOTPStruct -> HOTP
[foreignPtr] :: HOTP -> ForeignPtr BotanHOTPStruct
type HOTPHashName = HashName
type HOTPCounter = Word64
type HOTPCode = Word32
withHOTP :: HOTP -> (BotanHOTP -> IO a) -> IO a
hotpInit :: ByteString -> HashName -> Int -> IO HOTP
hotpDestroy :: HOTP -> IO ()
hotpGenerate :: HOTP -> HOTPCounter -> IO HOTPCode
hotpCheck :: HOTP -> HOTPCode -> HOTPCounter -> Int -> IO (Bool, HOTPCounter)
pattern HOTP_SHA1 :: HOTPHashName
pattern HOTP_SHA256 :: HOTPHashName
pattern HOTP_SHA512 :: HOTPHashName
hotpHashes :: [HOTPHashName]


-- | Format preserving encryption (FPE) refers to a set of techniques for
--   encrypting data such that the ciphertext has the same format as the
--   plaintext. For instance, you can use FPE to encrypt credit card
--   numbers with valid checksums such that the ciphertext is also an
--   credit card number with a valid checksum, or similarly for bank
--   account numbers, US Social Security numbers, or even more general
--   mappings like English words onto other English words.
--   
--   The scheme currently implemented in botan is called FE1, and described
--   in the paper Format Preserving Encryption by Mihir Bellare, Thomas
--   Ristenpart, Phillip Rogaway, and Till Stegers. FPE is an area of
--   ongoing standardization and it is likely that other schemes will be
--   included in the future.
--   
--   To encrypt an arbitrary value using FE1, you need to use a ranking
--   method. Basically, the idea is to assign an integer to every value you
--   might encrypt. For instance, a 16 digit credit card number consists of
--   a 15 digit code plus a 1 digit checksum. So to encrypt a credit card
--   number, you first remove the checksum, encrypt the 15 digit value
--   modulo 1015, and then calculate what the checksum is for the new
--   (ciphertext) number. Or, if you were encrypting words in a dictionary,
--   you could rank the words by their lexicographical order, and choose
--   the modulus to be the number of words in the dictionary.
module Botan.Low.FPE
newtype FPE
MkFPE :: ForeignPtr BotanFPEStruct -> FPE
[foreignPtr] :: FPE -> ForeignPtr BotanFPEStruct
data FPEFlags
FPENone :: FPEFlags
FPEFE1CompatMode :: FPEFlags
fPEFlags :: FPEFlags -> Word32
withFPE :: FPE -> (BotanFPE -> IO a) -> IO a

-- | Initialize a FE1 FPE context
fpeInitFE1 :: MP -> ByteString -> Int -> FPEFlags -> IO FPE
fpeDestroy :: FPE -> IO ()

-- | Encrypt the <tt>x</tt> value in-place
--   
--   NOTE: Mutates the MP
fpeEncrypt :: FPE -> MP -> ByteString -> IO ()

-- | Decrypt the <tt>x</tt> value in-place
--   
--   NOTE: Mutates the MP
fpeDecrypt :: FPE -> MP -> ByteString -> IO ()


-- | This module is based on the <a>Block Ciphers</a> section of the C
--   Botan FFI documentation, and on the <a>Block Ciphers</a> section of
--   the C++ API reference.
module Botan.Low.BlockCipher

-- | A mutable block cipher object
newtype BlockCipher
MkBlockCipher :: ForeignPtr BotanBlockCipherStruct -> BlockCipher
[foreignPtr] :: BlockCipher -> ForeignPtr BotanBlockCipherStruct

-- | Block cipher name type
type BlockCipherName = ByteString

-- | A block cipher secret key
type BlockCipherKey = ByteString

-- | A block cipher ciphertext
type BlockCipherCiphertext = ByteString
withBlockCipher :: BlockCipher -> (BotanBlockCipher -> IO a) -> IO a

-- | Initialize a block cipher object
blockCipherInit :: BlockCipherName -> IO BlockCipher

-- | Destroy a block cipher object immediately
blockCipherDestroy :: BlockCipher -> IO ()

-- | Get the name of a block cipher.
--   
--   This function is not guaranteed to return the same exact value as used
--   to initialize the context.
blockCipherName :: BlockCipher -> IO BlockCipherName

-- | Return the block size of a block cipher.
blockCipherBlockSize :: BlockCipher -> IO Int

-- | Get the key specification of a block cipher
--   
--   Returns the minimum, maximum, and modulo of valid keys.
blockCipherGetKeyspec :: BlockCipher -> IO (Int, Int, Int)

-- | Set the key for a block cipher
--   
--   Throws an error if the key is not valid.
blockCipherSetKey :: BlockCipher -> BlockCipherKey -> IO ()

-- | Encrypt one or more blocks with a block cipher
--   
--   Precondition: the length of the plaintext should be a multiple of the
--   block size, or this function throws an error.
blockCipherEncryptBlocks :: BlockCipher -> ByteString -> IO BlockCipherCiphertext

-- | Decrypt one or more blocks with a block cipher.
--   
--   Precondition: the length of the ciphertext should be a multiple of the
--   block size, or this function throws an error.
--   
--   If an incorrect key was set, the content of the decrypted plaintext is
--   unspecified.
blockCipherDecryptBlocks :: BlockCipher -> BlockCipherCiphertext -> IO ByteString

-- | Reinitializes a block cipher
--   
--   You must call blockCipherSetKey in order to use the block cipher
--   again.
blockCipherClear :: BlockCipher -> IO ()
pattern AES128 :: BlockCipherName
pattern AES192 :: BlockCipherName
pattern AES256 :: BlockCipherName
pattern ARIA128 :: BlockCipherName
pattern ARIA192 :: BlockCipherName
pattern ARIA256 :: BlockCipherName
pattern Blowfish :: BlockCipherName
pattern Camellia128 :: BlockCipherName
pattern Camellia192 :: BlockCipherName
pattern Camellia256 :: BlockCipherName
pattern Cascade :: BlockCipherName

-- | <pre>
--   &gt;&gt;&gt; cascade Serpent AES256
--   "Cascade(Serpent,AES-256)"
--   </pre>
cascade :: BlockCipherName -> BlockCipherName -> BlockCipherName
pattern CAST128 :: BlockCipherName
pattern DES :: BlockCipherName
pattern TripleDES :: BlockCipherName
pattern GOST_28147_89 :: BlockCipherName
pattern IDEA :: BlockCipherName
pattern Lion :: BlockCipherName

-- | <pre>
--   &gt;&gt;&gt; lion SHA1 "RC4" Nothing
--   "Lion(SHA-1,RC4)"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lion SHA1 "RC4" (Just 64)
--   "Lion(SHA-1,RC4,64)"
--   </pre>
lion :: HashName -> ByteString -> Maybe Word -> BlockCipherName
pattern Noekeon :: BlockCipherName
pattern SEED :: BlockCipherName
pattern Serpent :: BlockCipherName
pattern SHACAL2 :: BlockCipherName
pattern SM4 :: BlockCipherName
pattern Threefish512 :: BlockCipherName
pattern Twofish :: BlockCipherName
blockCiphers :: [BlockCipherName]
blockCipher128s :: [BlockCipherName]
allBlockCiphers :: [BlockCipherName]


-- | A Message Authentication Code algorithm computes a tag over a message
--   utilizing a shared secret key. Thus a valid tag confirms the
--   authenticity and integrity of the message. Only entities in possession
--   of the shared secret key are able to verify the tag.
--   
--   Note
--   
--   When combining a MAC with unauthenticated encryption mode, prefer to
--   first encrypt the message and then MAC the ciphertext. The alternative
--   is to MAC the plaintext, which depending on exact usage can suffer
--   serious security issues. For a detailed discussion of this issue see
--   the paper “The Order of Encryption and Authentication for Protecting
--   Communications” by Hugo Krawczyk
--   
--   The Botan MAC computation is split into five stages.
--   
--   <ul>
--   <li>Instantiate the MAC algorithm.</li>
--   <li>Set the secret key.</li>
--   <li>Process IV.</li>
--   <li>Process data.</li>
--   <li>Finalize the MAC computation.</li>
--   </ul>
module Botan.Low.MAC
newtype MAC
MkMAC :: ForeignPtr BotanMACStruct -> MAC
[foreignPtr] :: MAC -> ForeignPtr BotanMACStruct
type MACName = ByteString
type MACKey = ByteString
type MACNonce = ByteString
type MACDigest = ByteString
withMAC :: MAC -> (BotanMAC -> IO a) -> IO a

-- | Initialize a message authentication code object
macInit :: MACName -> IO MAC
macDestroy :: MAC -> IO ()

-- | Get the name of this MAC
macName :: MAC -> IO ByteString

-- | Writes the output length of the message authentication code to
--   *output_length
macOutputLength :: MAC -> IO Int

-- | Get the key length limits of this auth code
macGetKeyspec :: MAC -> IO (Int, Int, Int)

-- | Sets the key on the MAC
macSetKey :: MAC -> ByteString -> IO ()

-- | Sets the nonce on the MAC
macSetNonce :: MAC -> ByteString -> IO ()

-- | Send more input to the message authentication code
macUpdate :: MAC -> ByteString -> IO ()

-- | Finalizes the MAC computation and writes the output to
--   out[0:botan_mac_output_length()] then reinitializes for computing
--   another MAC as if botan_mac_clear had been called.
macFinal :: MAC -> IO MACDigest

-- | Reinitializes the state of the MAC computation. A MAC can be computed
--   (with update/final) immediately.
macClear :: MAC -> IO ()
pattern CMAC :: MACName
cmac :: BlockCipherName -> MACName
pattern GMAC :: MACName
gmac :: BlockCipherName -> MACName
pattern HMAC :: MACName
hmac :: BlockCipherName -> MACName
pattern Poly1305 :: MACName
pattern SipHash :: MACName
sipHash :: Int -> Int -> MACName
pattern X9_19_MAC :: MACName


-- | Key derivation functions are used to turn some amount of shared secret
--   material into uniform random keys suitable for use with symmetric
--   algorithms. An example of an input which is useful for a KDF is a
--   shared secret created using Diffie-Hellman key agreement.
--   
--   Typically a KDF is also used with a salt and a label. The salt should
--   be some random information which is available to all of the parties
--   that would need to use the KDF; this could be performed by setting the
--   salt to some kind of session identifier, or by having one of the
--   parties generate a random salt and including it in a message.
--   
--   The label is used to bind the KDF output to some specific context. For
--   instance if you were using the KDF to derive a specific key referred
--   to as the “message key” in the protocol description, you might use a
--   label of “FooProtocol v2 MessageKey”. This labeling ensures that if
--   you accidentally use the same input key and salt in some other
--   context, you still use different keys in the two contexts.
module Botan.Low.KDF
type KDFName = ByteString
kdf :: KDFName -> Int -> ByteString -> ByteString -> ByteString -> IO ByteString
pattern HKDF :: KDFName
hkdf :: HashName -> KDFName
pattern HKDF_Extract :: KDFName
hkdf_extract :: KDFName -> KDFName
pattern HKDF_Expand :: KDFName
hkdf_expand :: KDFName -> KDFName
pattern KDF2 :: KDFName
kdf2 :: KDFName -> KDFName
pattern KDF1_18033 :: KDFName
kdf1_18033 :: KDFName -> KDFName
pattern KDF1 :: KDFName
kdf1 :: KDFName -> KDFName
pattern TLS_12_PRF :: KDFName
tls_12_prf :: KDFName -> KDFName
pattern X9_42_PRF :: KDFName
x9_42_prf :: KDFName -> KDFName
pattern SP800_108_Counter :: KDFName
sp800_108_counter :: KDFName -> KDFName
pattern SP800_108_Feedback :: KDFName
sp800_108_feedback :: KDFName -> KDFName
pattern SP800_108_Pipeline :: KDFName
sp800_108_pipeline :: KDFName -> KDFName
pattern SP800_56A :: KDFName
sp800_56A :: KDFName -> KDFName
pattern SP800_56C :: KDFName
sp800_56C :: KDFName -> KDFName
kdfs :: [KDFName]


module Botan.Low.PubKey.KeyEncapsulation
type KEMSharedKey = ByteString
type KEMEncapsulatedKey = ByteString
newtype KEMEncrypt
MkKEMEncrypt :: ForeignPtr BotanPKOpKEMEncryptStruct -> KEMEncrypt
[foreignPtr] :: KEMEncrypt -> ForeignPtr BotanPKOpKEMEncryptStruct
withKEMEncrypt :: KEMEncrypt -> (BotanPKOpKEMEncrypt -> IO a) -> IO a
kemEncryptDestroy :: KEMEncrypt -> IO ()
kemEncryptCreate :: PubKey -> KDFName -> IO KEMEncrypt
kemEncryptSharedKeyLength :: KEMEncrypt -> Int -> IO Int
kemEncryptEncapsulatedKeyLength :: KEMEncrypt -> IO Int
kemEncryptCreateSharedKey :: KEMEncrypt -> RNG -> ByteString -> Int -> IO (KEMSharedKey, KEMEncapsulatedKey)
newtype KEMDecrypt
MkKEMDecrypt :: ForeignPtr BotanPKOpKEMDecryptStruct -> KEMDecrypt
[foreignPtr] :: KEMDecrypt -> ForeignPtr BotanPKOpKEMDecryptStruct
withKEMDecrypt :: KEMDecrypt -> (BotanPKOpKEMDecrypt -> IO a) -> IO a
kemDecryptDestroy :: KEMDecrypt -> IO ()
kemDecryptCreate :: PrivKey -> KDFName -> IO KEMDecrypt
kemDecryptSharedKeyLength :: KEMDecrypt -> Int -> IO Int
kemDecryptSharedKey :: KEMDecrypt -> ByteString -> KEMEncapsulatedKey -> Int -> IO KEMSharedKey


module Botan.Low.PubKey.KeyAgreement
newtype KeyAgreement
MkKeyAgreement :: ForeignPtr BotanPKOpKeyAgreementStruct -> KeyAgreement
[foreignPtr] :: KeyAgreement -> ForeignPtr BotanPKOpKeyAgreementStruct
withKeyAgreement :: KeyAgreement -> (BotanPKOpKeyAgreement -> IO a) -> IO a
keyAgreementCreate :: PrivKey -> KDFName -> IO KeyAgreement
keyAgreementDestroy :: KeyAgreement -> IO ()
keyAgreementExportPublic :: PrivKey -> IO ByteString
keyAgreementSize :: KeyAgreement -> IO Int
keyAgreement :: KeyAgreement -> ByteString -> ByteString -> IO ByteString


-- | NIST specifies two mechanisms for wrapping (encrypting) symmetric keys
--   using another key. The first (and older, more widely supported) method
--   requires the input be a multiple of 8 bytes long. The other allows any
--   length input, though only up to 2**32 bytes.
--   
--   These algorithms are described in NIST SP 800-38F, and RFCs 3394 and
--   5649.
--   
--   These functions take an arbitrary 128-bit block cipher. NIST only
--   allows these functions with AES, but any 128-bit cipher will do and
--   some other implementations (such as in OpenSSL) do also allow other
--   ciphers.
--   
--   Use AES for best interop.
module Botan.Low.KeyWrap
nistKeyWrapEncode :: BlockCipherName -> Int -> ByteString -> ByteString -> IO ByteString
nistKeyWrapDecode :: BlockCipherName -> Int -> ByteString -> ByteString -> IO ByteString


-- | A block cipher by itself, is only able to securely encrypt a single
--   data block. To be able to securely encrypt data of arbitrary length, a
--   mode of operation applies the block cipher’s single block operation
--   repeatedly to encrypt an entire message.
module Botan.Low.Cipher
newtype Cipher
MkCipher :: ForeignPtr BotanCipherStruct -> Cipher
[foreignPtr] :: Cipher -> ForeignPtr BotanCipherStruct
type CipherName = ByteString
type CipherKey = ByteString
type CipherNonce = ByteString
data CipherInitFlags
CipherMaskDirection :: CipherInitFlags
CipherEncrypt :: CipherInitFlags
CipherDecrypt :: CipherInitFlags
cipherInitFlags :: CipherInitFlags -> Word32
data CipherUpdateFlags
CipherUpdate :: CipherUpdateFlags
CipherFinal :: CipherUpdateFlags
cipherUpdateFlags :: CipherUpdateFlags -> Word32
withCipher :: Cipher -> (BotanCipher -> IO a) -> IO a

-- | Initialize a cipher object
cipherInit :: CipherName -> CipherInitFlags -> IO Cipher

-- | Destroy the cipher object immediately
cipherDestroy :: Cipher -> IO ()

-- | Return the name of the cipher object
cipherName :: Cipher -> IO CipherName

-- | Return the output length of this cipher, for a particular input
--   length.
--   
--   WARNING: This function is of limited use. From the C++ docs: /** *
--   Returns the size of the output if this transform is used to process a
--   * message with input_length bytes. In most cases the answer is
--   precise. * If it is not possible to precise (namely for CBC
--   decryption) instead an * upper bound is returned. */ We need to
--   explicitly calculate padding + tag length
cipherOutputLength :: Cipher -> Int -> IO Int

-- | Return if the specified nonce length is valid for this cipher NOTE:
--   This just always seems to return <a>True</a>, even for -1 and maxBound
cipherValidNonceLength :: Cipher -> Int -> IO Bool

-- | Get the tag length of the cipher (0 for non-AEAD modes)
cipherGetTagLength :: Cipher -> IO Int

-- | Get the default nonce length of this cipher
cipherGetDefaultNonceLength :: Cipher -> IO Int

-- | Return the update granularity of the cipher; botan_cipher_update must
--   be called with blocks of this size, except for the final.
cipherGetUpdateGranularity :: Cipher -> IO Int

-- | Return the ideal update granularity of the cipher. This is some
--   multiple of the update granularity, reflecting possibilities for
--   optimization.
--   
--   Some ciphers (ChaChaPoly, EAX) may consume less input than the
--   reported ideal granularity
cipherGetIdealUpdateGranularity :: Cipher -> IO Int

-- | Get information about the key lengths.

-- | <i>Deprecated: Prefer cipherGetKeyspec.</i>
cipherQueryKeylen :: Cipher -> IO (Int, Int)

-- | Get information about the supported key lengths.
cipherGetKeyspec :: Cipher -> IO (Int, Int, Int)

-- | Set the key for this cipher object
cipherSetKey :: Cipher -> ByteString -> IO ()

-- | Reset the message specific state for this cipher. Without resetting
--   the keys, this resets the nonce, and any state associated with any
--   message bits that have been processed so far.
--   
--   It is conceptually equivalent to calling botan_cipher_clear followed
--   by botan_cipher_set_key with the original key.
cipherReset :: Cipher -> IO ()

-- | Set the associated data. Will fail if cipher is not an AEAD
cipherSetAssociatedData :: Cipher -> ByteString -> IO ()

-- | Begin processing a new message using the provided nonce
cipherStart :: Cipher -> ByteString -> IO ()

-- | "Encrypt some data"
--   
--   This function is ill-documented.
--   
--   See the source for authoritative details:
--   <a>https://github.com/randombit/botan/blob/72dc18bbf598f2c3bef81a4fb2915e9c3c524ac4/src/lib/ffi/ffi_cipher.cpp#L133</a>
--   
--   Some ciphers (ChaChaPoly, EAX) may consume less input than the
--   reported ideal granularity
cipherUpdate :: Cipher -> CipherUpdateFlags -> Int -> ByteString -> IO (Int, ByteString)

-- | Encrypt and finalize a complete piece of data.
--   
--   This is not a canonical Botan C/C++ function.
cipherEncrypt :: Cipher -> ByteString -> IO ByteString

-- | Encrypt and finalize a complete piece of data.
--   
--   This is not a canonical Botan C/C++ function.
cipherDecrypt :: Cipher -> ByteString -> IO ByteString

-- | Reset the key, nonce, AD and all other state on this cipher object
cipherClear :: Cipher -> IO ()
type CipherMode = ByteString
cbcMode :: BlockCipherName -> CBCPaddingName -> CipherName
cfbMode :: BlockCipherName -> CipherName
cfbModeWith :: BlockCipherName -> Int -> CipherName
xtsMode :: BlockCipherName -> CipherName
type CBCPaddingName = ByteString
pattern PKCS7 :: CBCPaddingName
pattern OneAndZeros :: CBCPaddingName
pattern X9_23 :: CBCPaddingName
pattern ESP :: CBCPaddingName
pattern CTS :: CBCPaddingName
pattern NoPadding :: CBCPaddingName
type AEADName = CipherName
pattern ChaCha20Poly1305 :: CipherName
chaCha20Poly1305 :: AEADName
type AEADMode = ByteString
gcmMode :: BlockCipherName -> AEADName
gcmModeWith :: BlockCipherName -> Int -> AEADName
ocbMode :: BlockCipherName -> AEADName
ocbModeWith :: BlockCipherName -> Int -> AEADName
eaxMode :: BlockCipherName -> AEADName
eaxModeWith :: BlockCipherName -> Int -> AEADName
sivMode :: BlockCipherName -> AEADName
ccmMode :: BlockCipherName -> AEADName
ccmModeWith :: BlockCipherName -> Int -> Int -> AEADName

-- | <i>Deprecated: Moving from botan-low to botan</i>
cipherEncryptOnline :: Cipher -> ByteString -> IO ByteString

-- | <i>Deprecated: Moving from botan-low to botan</i>
cipherDecryptOnline :: Cipher -> ByteString -> IO ByteString
cipherModes :: [CipherName]
cbcPaddings :: [CBCPaddingName]
aeads :: [AEADName]
allCiphers :: [CipherName]
instance GHC.Classes.Eq Botan.Low.Cipher.CipherInitFlags
instance GHC.Classes.Eq Botan.Low.Cipher.CipherUpdateFlags
instance GHC.Internal.Show.Show Botan.Low.Cipher.CipherInitFlags
instance GHC.Internal.Show.Show Botan.Low.Cipher.CipherUpdateFlags


-- | This module is based on the <a>Secure Remote Password</a> section of
--   the C++ API reference.
module Botan.Low.SRP6
newtype SRP6ServerSession
MkSRP6ServerSession :: ForeignPtr BotanSRP6ServerSessionStruct -> SRP6ServerSession
[foreignPtr] :: SRP6ServerSession -> ForeignPtr BotanSRP6ServerSessionStruct
withSRP6ServerSession :: SRP6ServerSession -> (BotanSRP6ServerSession -> IO a) -> IO a

-- | Initialize an SRP-6 server session object
srp6ServerSessionInit :: IO SRP6ServerSession

-- | Frees all resources of the SRP-6 server session object
srp6ServerSessionDestroy :: SRP6ServerSession -> IO ()

-- | SRP-6 Server side step 1
--   
--   NOTE: this function should be not be invoked twice on the same server
--   session. Regardless of the result of the first invocation, the second
--   invocation will result in an error. See
--   <a>https://github.com/randombit/botan/issues/5112</a> for more
--   information. If a second invocation can not be prevented, try it on a
--   newly initialised server session instead.
srp6ServerSessionStep1 :: SRP6ServerSession -> SRP6Verifier -> DLGroupName -> HashName -> RNG -> IO SRP6BValue

-- | SRP-6 Server side step 2
srp6ServerSessionStep2 :: SRP6ServerSession -> SRP6AValue -> DLGroupName -> IO SRP6SharedSecret

-- | Generate a new SRP-6 verifier
srp6GenerateVerifier :: Identifier -> Password -> Salt -> DLGroupName -> HashName -> IO SRP6Verifier

-- | SRP6a Client side
srp6ClientAgree :: Identifier -> Password -> DLGroupName -> HashName -> Salt -> SRP6BValue -> RNG -> IO (SRP6AValue, SRP6SharedSecret)

-- | Return the size, in bytes, of the prime associated with group_id
--   
--   This function can be used to determine the size of output buffers for
--   generated keys in the SRP6 algorithm. Such buffers need to be
--   allocated before calling SRP6 functions. An example of such a buffer
--   is the <tt>verifier[]</tt> buffer in the <a>srp6GenerateVerifier</a>
--   function. In <tt>botan-low</tt>, such buffers are created internally
--   using <a>srp6GroupSize</a>, without requiring input from you (the
--   user).
srp6GroupSize :: DLGroupName -> IO Int
type SRP6Verifier = ByteString
type SRP6BValue = ByteString
type SRP6AValue = ByteString
type SRP6SharedSecret = ByteString
pattern MODP_SRP_1024 :: DLGroupName
pattern MODP_SRP_1536 :: DLGroupName
pattern MODP_SRP_2048 :: DLGroupName
pattern MODP_SRP_3072 :: DLGroupName
pattern MODP_SRP_4096 :: DLGroupName
pattern MODP_SRP_6144 :: DLGroupName
pattern MODP_SRP_8192 :: DLGroupName


-- | One time password schemes are a user authentication method that relies
--   on a fixed secret key which is used to derive a sequence of short
--   passwords, each of which is accepted only once. Commonly this is used
--   to implement two-factor authentication (2FA), where the user
--   authenticates using both a conventional password (or a public key
--   signature) and an OTP generated by a small device such as a mobile
--   phone.
module Botan.Low.TOTP
newtype TOTP
MkTOTP :: ForeignPtr BotanTOTPStruct -> TOTP
[foreignPtr] :: TOTP -> ForeignPtr BotanTOTPStruct
type TOTPHashName = HashName
type TOTPTimestep = Word64
type TOTPTimestamp = Word64
type TOTPCode = Word32
withTOTP :: TOTP -> (BotanTOTP -> IO a) -> IO a

-- | Initialize a TOTP instance
--   
--   NOTE: Digits should be 6-8
totpInit :: ByteString -> TOTPHashName -> Int -> TOTPTimestep -> IO TOTP
totpDestroy :: TOTP -> IO ()

-- | Generate a TOTP code for the provided timestamp
totpGenerate :: TOTP -> TOTPTimestamp -> IO TOTPCode

-- | Verify a TOTP code
totpCheck :: TOTP -> TOTPCode -> TOTPTimestamp -> Int -> IO Bool
pattern TOTP_SHA1 :: TOTPHashName
pattern TOTP_SHA256 :: TOTPHashName
pattern TOTP_SHA512 :: TOTPHashName
totpHashes :: [TOTPHashName]


-- | This module is based on the <a>Utility Functions</a> section of the C
--   Botan FFI documentation.
module Botan.Low.Utility

-- | Returns 0 if x[0..len] == y[0..len], -1 otherwise.
constantTimeCompare :: ByteString -> ByteString -> Int -> IO Bool
scrubMem :: Ptr a -> Int -> IO ()
data HexEncodingFlags
HexUpperCase :: HexEncodingFlags
HexLowerCase :: HexEncodingFlags
hexEncode :: ByteString -> HexEncodingFlags -> IO Text
hexDecode :: Text -> IO ByteString
base64Encode :: ByteString -> IO Text
base64Decode :: Text -> IO ByteString


-- | This module is based on the <a>Versioning</a> section of the C Botan
--   FFI documentation.
module Botan.Low.Version

-- | Returns the version of the currently supported FFI API. This is
--   expressed in the form YYYYMMDD of the release date of this version of
--   the API.
botanFFIAPIVersion :: IO Int

-- | Returns <a>True</a> iff the FFI version specified is supported by this
--   library, otherwise returns <a>False</a>.
--   
--   The expression <tt><a>botanFFIAPIVersion</a> &gt;&gt;=
--   <a>botanFFISupportsAPI</a></tt> will always evaluate to <a>True</a>. A
--   particular version of the library may also support other (older)
--   versions of the FFI API.
botanFFISupportsAPI :: Int -> IO Bool
botanVersionString :: IO ByteString

-- | Returns the major version of the library
botanVersionMajor :: IO Int

-- | Returns the minor version of the library
botanVersionMinor :: IO Int

-- | Returns the patch version of the library
botanVersionPatch :: IO Int

-- | Returns the date this version was released as an integer YYYYMMDD, or
--   0 if an unreleased version
botanVersionDatestamp :: IO Int


-- | This module is based on the <a>View Functions</a> section of the C
--   Botan FFI documentation.
module Botan.Low.View
type BotanViewBinFn ctx = BotanViewContext ctx -> ConstPtr Word8 -> CSize -> CInt
type BotanViewBinCallback ctx = FunPtr BotanViewBinFn ctx
viewBin :: BotanViewBinFn ctx -> (BotanViewBinCallback ctx -> IO a) -> IO a
type BotanViewStrFn ctx = BotanViewContext ctx -> ConstPtr CChar -> CSize -> CInt
type BotanViewStrCallback ctx = FunPtr BotanViewStrFn ctx
viewStr :: BotanViewStrFn ctx -> (BotanViewStrCallback ctx -> IO a) -> IO a


-- | A certificate is a binding between some identifying information
--   (called a subject) and a public key. This binding is asserted by a
--   signature on the certificate, which is placed there by some authority
--   (the issuer) that at least claims that it knows the subject named in
--   the certificate really “owns” the private key corresponding to the
--   public key in the certificate.
--   
--   The major certificate format in use today is X.509v3, used for
--   instance in the Transport Layer Security (TLS) protocol.
module Botan.Low.X509
newtype X509Cert
MkX509Cert :: ForeignPtr BotanX509CertStruct -> X509Cert
[foreignPtr] :: X509Cert -> ForeignPtr BotanX509CertStruct
withX509Cert :: X509Cert -> (BotanX509Cert -> IO a) -> IO a
x509CertLoad :: ByteString -> IO X509Cert
x509CertLoadFile :: FilePath -> IO X509Cert

-- | Destroy an x509 cert object immediately
x509CertDestroy :: X509Cert -> IO ()
x509CertDup :: X509Cert -> IO X509Cert
x509CertGetTimeStarts :: X509Cert -> IO ByteString
x509CertGetTimeExpires :: X509Cert -> IO ByteString
x509CertNotBefore :: X509Cert -> IO Word64
x509CertNotAfter :: X509Cert -> IO Word64
x509CertGetPubKeyFingerprint :: X509Cert -> HashName -> IO ByteString
x509CertGetSerialNumber :: X509Cert -> IO ByteString
x509CertGetAuthorityKeyId :: X509Cert -> IO ByteString
x509CertGetSubjectKeyId :: X509Cert -> IO ByteString
x509CertGetPublicKeyBits :: X509Cert -> IO ByteString
x509CertGetPublicKey :: X509Cert -> IO PubKey
x509CertGetIssuerDN :: X509Cert -> ByteString -> Int -> IO ByteString
x509CertGetSubjectDN :: X509Cert -> ByteString -> Int -> IO ByteString
x509CertToString :: X509Cert -> IO ByteString

-- | NOTE: This function lacks documentation, and it is unknown whether
--   this is setting a value (as implied by Z-botan), or whether it is
--   using either a negative error or INVALID_IDENTIFIER to return a bool.
--   
--   Note: unexplained function, best-guess implementation
x509CertAllowedUsage :: X509Cert -> [X509KeyConstraints] -> IO Bool

-- | Check if the certificate matches the specified hostname via
--   alternative name or CN match. RFC 5280 wildcards also supported.
--   
--   Note: unexplained function, best-guess implementation
x509CertHostnameMatch :: X509Cert -> ByteString -> IO Bool

-- | Returns 0 if the validation was successful, 1 if validation failed,
--   and negative on error. A status code with details is written to
--   *validation_result
--   
--   Intermediates or trusted lists can be null Trusted path can be null
x509CertVerify :: X509Cert -> [X509Cert] -> [X509Cert] -> Maybe FilePath -> Int -> ByteString -> Word64 -> IO (Bool, Int)
x509CertValidationStatus :: Int -> IO (Maybe ByteString)
data X509KeyConstraints
NoConstraints :: X509KeyConstraints
DigitalSignature :: X509KeyConstraints
NonRepudiation :: X509KeyConstraints
KeyEncipherment :: X509KeyConstraints
DataEncipherment :: X509KeyConstraints
KeyAgreement :: X509KeyConstraints
KeyCertSign :: X509KeyConstraints
CRLSign :: X509KeyConstraints
EncipherOnly :: X509KeyConstraints
DecipherOnly :: X509KeyConstraints
x509KeyConstraints :: X509KeyConstraints -> CUInt
x509KeyConstraintsList :: [X509KeyConstraints] -> CUInt
newtype X509CRL
MkX509CRL :: ForeignPtr BotanX509CRLStruct -> X509CRL
[foreignPtr] :: X509CRL -> ForeignPtr BotanX509CRLStruct
withX509CRL :: X509CRL -> (BotanX509CRL -> IO a) -> IO a
x509CRLLoad :: ByteString -> IO X509CRL
x509CRLLoadFile :: FilePath -> IO X509CRL
x509CRLDestroy :: X509CRL -> IO ()

-- | Given a CRL and a certificate, check if the certificate is revoked on
--   that particular CRL
x509IsRevoked :: X509CRL -> X509Cert -> IO Bool

-- | Different flavor of <a>botan_x509_cert_verify</a>, supports revocation
--   lists. CRLs are passed as an array, same as intermediates and trusted
--   CAs
x509CertVerifyWithCLR :: X509Cert -> [X509Cert] -> [X509Cert] -> [X509CRL] -> Maybe FilePath -> Int -> ByteString -> Word64 -> IO (Bool, Int)
type DistinguishedName = ByteString


-- | Forward error correction takes an input and creates multiple “shares”,
--   such that any K of N shares is sufficient to recover the entire
--   original input.
module Botan.Low.ZFEC

-- | is more <tt>raw</tt>.
type ZFECShare = (Int, ByteString)

-- | Encode some bytes with certain ZFEC parameters.
--   
--   NOTE: The length in bytes of input must be a multiple of K
zfecEncode :: Int -> Int -> ByteString -> IO [ZFECShare]

-- | Decode some previously encoded shares using certain ZFEC parameters.
--   
--   NOTE: There must be at least K shares of equal length
zfecDecode :: Int -> Int -> [ZFECShare] -> IO ByteString
