{-# LINE 1 "src/Botan/Bindings/PubKey.hsc" #-}
{-|
Module      : Botan.Bindings.PubKey
Description : Public key cryptography
Copyright   : (c) Leo D, 2023
License     : BSD-3-Clause
Maintainer  : leo@apotheca.io
Stability   : experimental
Portability : POSIX

Public key cryptography is a collection of techniques allowing
for encryption, signatures, and key agreement.
-}

{-# LANGUAGE CApiFFI #-}

module Botan.Bindings.PubKey where

import Botan.Bindings.MPI
import Botan.Bindings.Prelude
import Botan.Bindings.RNG
import Botan.Bindings.View



-- | Opaque PrivKey struct
data {-# CTYPE "botan/ffi.h" "struct botan_privkey_struct" #-} BotanPrivKeyStruct

-- | Botan PrivKey object
newtype {-# CTYPE "botan/ffi.h" "botan_privkey_t" #-} BotanPrivKey
    = MkBotanPrivKey { BotanPrivKey -> Ptr BotanPrivKeyStruct
runBotanPrivKey :: Ptr BotanPrivKeyStruct }
        deriving newtype (BotanPrivKey -> BotanPrivKey -> Bool
(BotanPrivKey -> BotanPrivKey -> Bool)
-> (BotanPrivKey -> BotanPrivKey -> Bool) -> Eq BotanPrivKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BotanPrivKey -> BotanPrivKey -> Bool
== :: BotanPrivKey -> BotanPrivKey -> Bool
$c/= :: BotanPrivKey -> BotanPrivKey -> Bool
/= :: BotanPrivKey -> BotanPrivKey -> Bool
Eq, Eq BotanPrivKey
Eq BotanPrivKey
-> (BotanPrivKey -> BotanPrivKey -> Ordering)
-> (BotanPrivKey -> BotanPrivKey -> Bool)
-> (BotanPrivKey -> BotanPrivKey -> Bool)
-> (BotanPrivKey -> BotanPrivKey -> Bool)
-> (BotanPrivKey -> BotanPrivKey -> Bool)
-> (BotanPrivKey -> BotanPrivKey -> BotanPrivKey)
-> (BotanPrivKey -> BotanPrivKey -> BotanPrivKey)
-> Ord BotanPrivKey
BotanPrivKey -> BotanPrivKey -> Bool
BotanPrivKey -> BotanPrivKey -> Ordering
BotanPrivKey -> BotanPrivKey -> BotanPrivKey
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 :: BotanPrivKey -> BotanPrivKey -> Ordering
compare :: BotanPrivKey -> BotanPrivKey -> Ordering
$c< :: BotanPrivKey -> BotanPrivKey -> Bool
< :: BotanPrivKey -> BotanPrivKey -> Bool
$c<= :: BotanPrivKey -> BotanPrivKey -> Bool
<= :: BotanPrivKey -> BotanPrivKey -> Bool
$c> :: BotanPrivKey -> BotanPrivKey -> Bool
> :: BotanPrivKey -> BotanPrivKey -> Bool
$c>= :: BotanPrivKey -> BotanPrivKey -> Bool
>= :: BotanPrivKey -> BotanPrivKey -> Bool
$cmax :: BotanPrivKey -> BotanPrivKey -> BotanPrivKey
max :: BotanPrivKey -> BotanPrivKey -> BotanPrivKey
$cmin :: BotanPrivKey -> BotanPrivKey -> BotanPrivKey
min :: BotanPrivKey -> BotanPrivKey -> BotanPrivKey
Ord, Ptr BotanPrivKey -> IO BotanPrivKey
Ptr BotanPrivKey -> Int -> IO BotanPrivKey
Ptr BotanPrivKey -> Int -> BotanPrivKey -> IO ()
Ptr BotanPrivKey -> BotanPrivKey -> IO ()
BotanPrivKey -> Int
(BotanPrivKey -> Int)
-> (BotanPrivKey -> Int)
-> (Ptr BotanPrivKey -> Int -> IO BotanPrivKey)
-> (Ptr BotanPrivKey -> Int -> BotanPrivKey -> IO ())
-> (forall b. Ptr b -> Int -> IO BotanPrivKey)
-> (forall b. Ptr b -> Int -> BotanPrivKey -> IO ())
-> (Ptr BotanPrivKey -> IO BotanPrivKey)
-> (Ptr BotanPrivKey -> BotanPrivKey -> IO ())
-> Storable BotanPrivKey
forall b. Ptr b -> Int -> IO BotanPrivKey
forall b. Ptr b -> Int -> BotanPrivKey -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: BotanPrivKey -> Int
sizeOf :: BotanPrivKey -> Int
$calignment :: BotanPrivKey -> Int
alignment :: BotanPrivKey -> Int
$cpeekElemOff :: Ptr BotanPrivKey -> Int -> IO BotanPrivKey
peekElemOff :: Ptr BotanPrivKey -> Int -> IO BotanPrivKey
$cpokeElemOff :: Ptr BotanPrivKey -> Int -> BotanPrivKey -> IO ()
pokeElemOff :: Ptr BotanPrivKey -> Int -> BotanPrivKey -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO BotanPrivKey
peekByteOff :: forall b. Ptr b -> Int -> IO BotanPrivKey
$cpokeByteOff :: forall b. Ptr b -> Int -> BotanPrivKey -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> BotanPrivKey -> IO ()
$cpeek :: Ptr BotanPrivKey -> IO BotanPrivKey
peek :: Ptr BotanPrivKey -> IO BotanPrivKey
$cpoke :: Ptr BotanPrivKey -> BotanPrivKey -> IO ()
poke :: Ptr BotanPrivKey -> BotanPrivKey -> IO ()
Storable)

-- | Frees all resources of the PrivKey object
foreign import capi safe "botan/ffi.h &botan_privkey_destroy"
    botan_privkey_destroy
        :: FinalizerPtr BotanPrivKeyStruct

pattern BOTAN_PK_RSA
    ,   BOTAN_PK_SM2
    ,   BOTAN_PK_ELGAMAL
    ,   BOTAN_PK_DSA
    ,   BOTAN_PK_ECDSA
    ,   BOTAN_PK_ECKCDSA
    ,   BOTAN_PK_ECGDSA
    ,   BOTAN_PK_GOST_34_10
    ,   BOTAN_PK_ED25519
    ,   BOTAN_PK_XMSS
    ,   BOTAN_PK_DH
    ,   BOTAN_PK_ECDH
    ,   BOTAN_PK_CURVE25519
    ,   BOTAN_PK_DILITHIUM
    ,   BOTAN_PK_KYBER
    -- ,   BOTAN_PK_SPHINCSPLUS
    ,   BOTAN_PK_MCELIECE
    ::  (Eq a, IsString a) => a

pattern $mBOTAN_PK_RSA :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_RSA :: forall a. (Eq a, IsString a) => a
BOTAN_PK_RSA            = "RSA"
pattern $mBOTAN_PK_SM2 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_SM2 :: forall a. (Eq a, IsString a) => a
BOTAN_PK_SM2            = "SM2"
pattern $mBOTAN_PK_ELGAMAL :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_ELGAMAL :: forall a. (Eq a, IsString a) => a
BOTAN_PK_ELGAMAL        = "ElGamal"
pattern $mBOTAN_PK_DSA :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_DSA :: forall a. (Eq a, IsString a) => a
BOTAN_PK_DSA            = "DSA"
pattern $mBOTAN_PK_ECDSA :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_ECDSA :: forall a. (Eq a, IsString a) => a
BOTAN_PK_ECDSA          = "ECDSA"
pattern $mBOTAN_PK_ECKCDSA :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_ECKCDSA :: forall a. (Eq a, IsString a) => a
BOTAN_PK_ECKCDSA        = "ECKCDSA"
pattern $mBOTAN_PK_ECGDSA :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_ECGDSA :: forall a. (Eq a, IsString a) => a
BOTAN_PK_ECGDSA         = "ECGDSA"
pattern $mBOTAN_PK_GOST_34_10 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_GOST_34_10 :: forall a. (Eq a, IsString a) => a
BOTAN_PK_GOST_34_10     = "GOST-34.10"
pattern $mBOTAN_PK_ED25519 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_ED25519 :: forall a. (Eq a, IsString a) => a
BOTAN_PK_ED25519        = "Ed25519"
pattern $mBOTAN_PK_XMSS :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_XMSS :: forall a. (Eq a, IsString a) => a
BOTAN_PK_XMSS           = "XMSS"
pattern $mBOTAN_PK_DH :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_DH :: forall a. (Eq a, IsString a) => a
BOTAN_PK_DH             = "DH"
pattern $mBOTAN_PK_ECDH :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_ECDH :: forall a. (Eq a, IsString a) => a
BOTAN_PK_ECDH           = "ECDH"
pattern $mBOTAN_PK_CURVE25519 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_CURVE25519 :: forall a. (Eq a, IsString a) => a
BOTAN_PK_CURVE25519     = "Curve25519"
pattern $mBOTAN_PK_DILITHIUM :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_DILITHIUM :: forall a. (Eq a, IsString a) => a
BOTAN_PK_DILITHIUM      = "Dilithium"
pattern $mBOTAN_PK_KYBER :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_KYBER :: forall a. (Eq a, IsString a) => a
BOTAN_PK_KYBER          = "Kyber"
-- pattern BOTAN_PK_SPHINCSPLUS    = "SPHINCS+"
pattern $mBOTAN_PK_MCELIECE :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PK_MCELIECE :: forall a. (Eq a, IsString a) => a
BOTAN_PK_MCELIECE       = "McEliece"

pattern BOTAN_XMSS_SHA2_10_256
    ,   BOTAN_XMSS_SHA2_16_256
    ,   BOTAN_XMSS_SHA2_20_256
    ,   BOTAN_XMSS_SHA2_10_512
    ,   BOTAN_XMSS_SHA2_16_512
    ,   BOTAN_XMSS_SHA2_20_512
    ,   BOTAN_XMSS_SHAKE_10_256
    ,   BOTAN_XMSS_SHAKE_16_256
    ,   BOTAN_XMSS_SHAKE_20_256
    ,   BOTAN_XMSS_SHAKE_10_512
    ,   BOTAN_XMSS_SHAKE_16_512
    ,   BOTAN_XMSS_SHAKE_20_512
    ::  (Eq a, IsString a) => a

pattern $mBOTAN_XMSS_SHA2_10_256 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHA2_10_256 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHA2_10_256 = "XMSS-SHA2_10_256"
pattern $mBOTAN_XMSS_SHA2_16_256 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHA2_16_256 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHA2_16_256 = "XMSS-SHA2_16_256"
pattern $mBOTAN_XMSS_SHA2_20_256 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHA2_20_256 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHA2_20_256 = "XMSS-SHA2_20_256"
pattern $mBOTAN_XMSS_SHA2_10_512 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHA2_10_512 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHA2_10_512 = "XMSS-SHA2_10_512"
pattern $mBOTAN_XMSS_SHA2_16_512 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHA2_16_512 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHA2_16_512 = "XMSS-SHA2_16_512"
pattern $mBOTAN_XMSS_SHA2_20_512 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHA2_20_512 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHA2_20_512 = "XMSS-SHA2_20_512"
pattern $mBOTAN_XMSS_SHAKE_10_256 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHAKE_10_256 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHAKE_10_256 = "XMSS-SHAKE_10_256"
pattern $mBOTAN_XMSS_SHAKE_16_256 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHAKE_16_256 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHAKE_16_256 = "XMSS-SHAKE_16_256"
pattern $mBOTAN_XMSS_SHAKE_20_256 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHAKE_20_256 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHAKE_20_256 = "XMSS-SHAKE_20_256"
pattern $mBOTAN_XMSS_SHAKE_10_512 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHAKE_10_512 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHAKE_10_512 = "XMSS-SHAKE_10_512"
pattern $mBOTAN_XMSS_SHAKE_16_512 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHAKE_16_512 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHAKE_16_512 = "XMSS-SHAKE_16_512"
pattern $mBOTAN_XMSS_SHAKE_20_512 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_XMSS_SHAKE_20_512 :: forall a. (Eq a, IsString a) => a
BOTAN_XMSS_SHAKE_20_512 = "XMSS-SHAKE_20_512"

pattern BOTAN_ECGROUP_SECP_160_K1
    ,   BOTAN_ECGROUP_SECP_160_R1
    ,   BOTAN_ECGROUP_SECP_160_R2
    ,   BOTAN_ECGROUP_SECP_192_K1
    ,   BOTAN_ECGROUP_SECP_192_R1
    ,   BOTAN_ECGROUP_SECP_224_K1
    ,   BOTAN_ECGROUP_SECP_224_R1
    ,   BOTAN_ECGROUP_SECP_256_K1
    ,   BOTAN_ECGROUP_SECP_256_R1
    ,   BOTAN_ECGROUP_SECP_384_R1
    ,   BOTAN_ECGROUP_SECP_521_R1
    ,   BOTAN_ECGROUP_BRAINPOOL_160_R1
    ,   BOTAN_ECGROUP_BRAINPOOL_192_R1
    ,   BOTAN_ECGROUP_BRAINPOOL_224_R1
    ,   BOTAN_ECGROUP_BRAINPOOL_256_R1
    ,   BOTAN_ECGROUP_BRAINPOOL_320_R1
    ,   BOTAN_ECGROUP_BRAINPOOL_384_R1
    ,   BOTAN_ECGROUP_BRAINPOOL_512_R1
    ,   BOTAN_ECGROUP_X962_P192_V2
    ,   BOTAN_ECGROUP_X962_P192_V3
    ,   BOTAN_ECGROUP_X962_P239_V1
    ,   BOTAN_ECGROUP_X962_P239_V2
    ,   BOTAN_ECGROUP_X962_P239_V3
    ,   BOTAN_ECGROUP_GOST_256A
    ,   BOTAN_ECGROUP_GOST_512A
    ,   BOTAN_ECGROUP_FRP_256_V1
    ,   BOTAN_ECGROUP_SM2_P256_V1
    ::  (Eq a, IsString a) => a

pattern $mBOTAN_ECGROUP_SECP_160_K1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SECP_160_K1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SECP_160_K1 = "secp160k1"
pattern $mBOTAN_ECGROUP_SECP_160_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SECP_160_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SECP_160_R1 = "secp160r1"
pattern $mBOTAN_ECGROUP_SECP_160_R2 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SECP_160_R2 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SECP_160_R2 = "secp160r2"
pattern $mBOTAN_ECGROUP_SECP_192_K1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SECP_192_K1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SECP_192_K1 = "secp192k1"
pattern $mBOTAN_ECGROUP_SECP_192_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SECP_192_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SECP_192_R1 = "secp192r1"
pattern $mBOTAN_ECGROUP_SECP_224_K1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SECP_224_K1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SECP_224_K1 = "secp224k1"
pattern $mBOTAN_ECGROUP_SECP_224_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SECP_224_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SECP_224_R1 = "secp224r1"
pattern $mBOTAN_ECGROUP_SECP_256_K1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SECP_256_K1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SECP_256_K1 = "secp256k1"
pattern $mBOTAN_ECGROUP_SECP_256_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SECP_256_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SECP_256_R1 = "secp256r1"
pattern $mBOTAN_ECGROUP_SECP_384_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SECP_384_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SECP_384_R1 = "secp384r1"
pattern $mBOTAN_ECGROUP_SECP_521_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SECP_521_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SECP_521_R1 = "secp521r1"
pattern $mBOTAN_ECGROUP_BRAINPOOL_160_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_BRAINPOOL_160_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_BRAINPOOL_160_R1 = "brainpool160r1"
pattern $mBOTAN_ECGROUP_BRAINPOOL_192_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_BRAINPOOL_192_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_BRAINPOOL_192_R1 = "brainpool192r1"
pattern $mBOTAN_ECGROUP_BRAINPOOL_224_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_BRAINPOOL_224_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_BRAINPOOL_224_R1 = "brainpool224r1"
pattern $mBOTAN_ECGROUP_BRAINPOOL_256_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_BRAINPOOL_256_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_BRAINPOOL_256_R1 = "brainpool256r1"
pattern $mBOTAN_ECGROUP_BRAINPOOL_320_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_BRAINPOOL_320_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_BRAINPOOL_320_R1 = "brainpool320r1"
pattern $mBOTAN_ECGROUP_BRAINPOOL_384_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_BRAINPOOL_384_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_BRAINPOOL_384_R1 = "brainpool384r1"
pattern $mBOTAN_ECGROUP_BRAINPOOL_512_R1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_BRAINPOOL_512_R1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_BRAINPOOL_512_R1 = "brainpool512r1"
pattern $mBOTAN_ECGROUP_X962_P192_V2 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_X962_P192_V2 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_X962_P192_V2 = "x962_p192v2"
pattern $mBOTAN_ECGROUP_X962_P192_V3 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_X962_P192_V3 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_X962_P192_V3 = "x962_p192v3"
pattern $mBOTAN_ECGROUP_X962_P239_V1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_X962_P239_V1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_X962_P239_V1 = "x962_p239v1"
pattern $mBOTAN_ECGROUP_X962_P239_V2 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_X962_P239_V2 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_X962_P239_V2 = "x962_p239v2"
pattern $mBOTAN_ECGROUP_X962_P239_V3 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_X962_P239_V3 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_X962_P239_V3 = "x962_p239v3"
pattern $mBOTAN_ECGROUP_GOST_256A :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_GOST_256A :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_GOST_256A = "gost_256A"
pattern $mBOTAN_ECGROUP_GOST_512A :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_GOST_512A :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_GOST_512A = "gost_512A"
pattern $mBOTAN_ECGROUP_FRP_256_V1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_FRP_256_V1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_FRP_256_V1 = "frp256v1"
pattern $mBOTAN_ECGROUP_SM2_P256_V1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_ECGROUP_SM2_P256_V1 :: forall a. (Eq a, IsString a) => a
BOTAN_ECGROUP_SM2_P256_V1 = "sm2p256v1"

pattern BOTAN_DLGROUP_FFDHE_IETF_2048
    ,   BOTAN_DLGROUP_FFDHE_IETF_3072
    ,   BOTAN_DLGROUP_FFDHE_IETF_4096
    ,   BOTAN_DLGROUP_FFDHE_IETF_6144
    ,   BOTAN_DLGROUP_FFDHE_IETF_8192
    ,   BOTAN_DLGROUP_MODP_IETF_1024
    ,   BOTAN_DLGROUP_MODP_IETF_1536
    ,   BOTAN_DLGROUP_MODP_IETF_2048
    ,   BOTAN_DLGROUP_MODP_IETF_3072
    ,   BOTAN_DLGROUP_MODP_IETF_4096
    ,   BOTAN_DLGROUP_MODP_IETF_6144
    ,   BOTAN_DLGROUP_MODP_IETF_8192
    ,   BOTAN_DLGROUP_MODP_SRP_1024
    ,   BOTAN_DLGROUP_MODP_SRP_1536
    ,   BOTAN_DLGROUP_MODP_SRP_2048
    ,   BOTAN_DLGROUP_MODP_SRP_3072
    ,   BOTAN_DLGROUP_MODP_SRP_4096
    ,   BOTAN_DLGROUP_MODP_SRP_6144
    ,   BOTAN_DLGROUP_MODP_SRP_8192
    ,   BOTAN_DLGROUP_DSA_JCE_1024
    ,   BOTAN_DLGROUP_DSA_BOTAN_2048
    ,   BOTAN_DLGROUP_DSA_BOTAN_3072
    ::  (Eq a, IsString a) => a

pattern $mBOTAN_DLGROUP_FFDHE_IETF_2048 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_FFDHE_IETF_2048 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_FFDHE_IETF_2048   = "ffdhe/ietf/2048"
pattern $mBOTAN_DLGROUP_FFDHE_IETF_3072 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_FFDHE_IETF_3072 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_FFDHE_IETF_3072   = "ffdhe/ietf/3072"
pattern $mBOTAN_DLGROUP_FFDHE_IETF_4096 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_FFDHE_IETF_4096 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_FFDHE_IETF_4096   = "ffdhe/ietf/4096"
pattern $mBOTAN_DLGROUP_FFDHE_IETF_6144 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_FFDHE_IETF_6144 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_FFDHE_IETF_6144   = "ffdhe/ietf/6144"
pattern $mBOTAN_DLGROUP_FFDHE_IETF_8192 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_FFDHE_IETF_8192 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_FFDHE_IETF_8192   = "ffdhe/ietf/8192"
pattern $mBOTAN_DLGROUP_MODP_IETF_1024 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_IETF_1024 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_IETF_1024    = "modp/ietf/1024"
pattern $mBOTAN_DLGROUP_MODP_IETF_1536 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_IETF_1536 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_IETF_1536    = "modp/ietf/1536"
pattern $mBOTAN_DLGROUP_MODP_IETF_2048 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_IETF_2048 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_IETF_2048    = "modp/ietf/2048"
pattern $mBOTAN_DLGROUP_MODP_IETF_3072 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_IETF_3072 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_IETF_3072    = "modp/ietf/3072"
pattern $mBOTAN_DLGROUP_MODP_IETF_4096 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_IETF_4096 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_IETF_4096    = "modp/ietf/4096"
pattern $mBOTAN_DLGROUP_MODP_IETF_6144 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_IETF_6144 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_IETF_6144    = "modp/ietf/6144"
pattern $mBOTAN_DLGROUP_MODP_IETF_8192 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_IETF_8192 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_IETF_8192    = "modp/ietf/8192"
pattern $mBOTAN_DLGROUP_MODP_SRP_1024 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_SRP_1024 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_SRP_1024     = "modp/srp/1024"
pattern $mBOTAN_DLGROUP_MODP_SRP_1536 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_SRP_1536 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_SRP_1536     = "modp/srp/1536"
pattern $mBOTAN_DLGROUP_MODP_SRP_2048 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_SRP_2048 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_SRP_2048     = "modp/srp/2048"
pattern $mBOTAN_DLGROUP_MODP_SRP_3072 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_SRP_3072 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_SRP_3072     = "modp/srp/3072"
pattern $mBOTAN_DLGROUP_MODP_SRP_4096 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_SRP_4096 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_SRP_4096     = "modp/srp/4096"
pattern $mBOTAN_DLGROUP_MODP_SRP_6144 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_SRP_6144 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_SRP_6144     = "modp/srp/6144"
pattern $mBOTAN_DLGROUP_MODP_SRP_8192 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_MODP_SRP_8192 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_MODP_SRP_8192     = "modp/srp/8192"
pattern $mBOTAN_DLGROUP_DSA_JCE_1024 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_DSA_JCE_1024 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_DSA_JCE_1024      = "dsa/jce/1024"
pattern $mBOTAN_DLGROUP_DSA_BOTAN_2048 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_DSA_BOTAN_2048 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_DSA_BOTAN_2048    = "dsa/botan/2048"
pattern $mBOTAN_DLGROUP_DSA_BOTAN_3072 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_DLGROUP_DSA_BOTAN_3072 :: forall a. (Eq a, IsString a) => a
BOTAN_DLGROUP_DSA_BOTAN_3072    = "dsa/botan/3072"

pattern BOTAN_EME_RAW
    ,   BOTAN_EME_PKCS1_v1_5
    ,   BOTAN_EME_OAEP
    :: (Eq a, IsString a) => a

pattern $mBOTAN_EME_RAW :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_EME_RAW :: forall a. (Eq a, IsString a) => a
BOTAN_EME_RAW        = "Raw"
pattern $mBOTAN_EME_PKCS1_v1_5 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_EME_PKCS1_v1_5 :: forall a. (Eq a, IsString a) => a
BOTAN_EME_PKCS1_v1_5 = "PKCS1v15"
pattern $mBOTAN_EME_OAEP :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_EME_OAEP :: forall a. (Eq a, IsString a) => a
BOTAN_EME_OAEP       = "OAEP"

pattern BOTAN_MGF_MGF1
    :: (Eq a, IsString a) => a

pattern $mBOTAN_MGF_MGF1 :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_MGF_MGF1 :: forall a. (Eq a, IsString a) => a
BOTAN_MGF_MGF1 = "MGF1"

-- | Create a new private key
foreign import capi safe "botan/ffi.h botan_privkey_create"
    botan_privkey_create
        :: Ptr BotanPrivKey    -- ^ __key__: the new object will be placed here
        -> ConstPtr CChar      -- ^ __algo_name__: something like "RSA" or "ECDSA"
        -> ConstPtr CChar      -- ^ __algo_params__: is specific to the algorithm. For RSA, specifies
                               --   the modulus bit length. For ECC is the name of the curve.
        -> BotanRNG            -- ^ __rng__: a random number generator
        -> IO CInt

pattern BOTAN_CHECK_KEY_NORMAL_TESTS
    ,   BOTAN_CHECK_KEY_EXPENSIVE_TESTS
    ::  (Eq a, Num a) => a
pattern $mBOTAN_CHECK_KEY_NORMAL_TESTS :: forall {r} {a}.
(Eq a, Num a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_CHECK_KEY_NORMAL_TESTS :: forall a. (Eq a, Num a) => a
BOTAN_CHECK_KEY_NORMAL_TESTS    = 0
pattern $mBOTAN_CHECK_KEY_EXPENSIVE_TESTS :: forall {r} {a}.
(Eq a, Num a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_CHECK_KEY_EXPENSIVE_TESTS :: forall a. (Eq a, Num a) => a
BOTAN_CHECK_KEY_EXPENSIVE_TESTS = 1
{-# LINE 235 "src/Botan/Bindings/PubKey.hsc" #-}

-- | Check the validity of a private key
foreign import capi safe "botan/ffi.h botan_privkey_check_key"
    botan_privkey_check_key
        :: BotanPrivKey    -- ^ __key__
        -> BotanRNG        -- ^ __rng__
        -> Word32          -- ^ __flags__
        -> IO CInt

{- |
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
-}
foreign import capi safe "botan/ffi.h botan_privkey_load"
    botan_privkey_load
        :: Ptr BotanPrivKey    -- ^ __key__
        -> BotanRNG            -- ^ __rng__
        -> ConstPtr Word8      -- ^ __bits[]__
        -> CSize               -- ^ __len__
        -> ConstPtr CChar      -- ^ __password__
        -> IO CInt

pattern BOTAN_PRIVKEY_EXPORT_FLAG_DER
    ,   BOTAN_PRIVKEY_EXPORT_FLAG_PEM
    ::  (Eq a, Num a) => a
pattern $mBOTAN_PRIVKEY_EXPORT_FLAG_DER :: forall {r} {a}.
(Eq a, Num a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PRIVKEY_EXPORT_FLAG_DER :: forall a. (Eq a, Num a) => a
BOTAN_PRIVKEY_EXPORT_FLAG_DER = 0
{-# LINE 262 "src/Botan/Bindings/PubKey.hsc" #-}
pattern BOTAN_PRIVKEY_EXPORT_FLAG_PEM = 1
{-# LINE 263 "src/Botan/Bindings/PubKey.hsc" #-}

{- |
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.
-}
foreign import capi safe "botan/ffi.h botan_privkey_export"
    botan_privkey_export
        :: BotanPrivKey    -- ^ __key__
        -> Ptr Word8       -- ^ __out[]__
        -> Ptr CSize       -- ^ __out_len__
        -> Word32          -- ^ __flags__
        -> IO CInt

-- | View the private key's DER encoding
foreign import capi safe "botan/ffi.h botan_privkey_view_der"
    botan_privkey_view_der
        :: BotanPrivKey                         -- ^ __key__
        -> BotanViewContext ctx                 -- ^ __ctx__
        -> FunPtr (BotanViewBinCallback ctx)    -- ^ __view__
        -> IO CInt

-- | View the private key's PEM encoding
foreign import capi safe "botan/ffi.h botan_privkey_view_pem"
    botan_privkey_view_pem
        :: BotanPrivKey                         -- ^ __key__
        -> BotanViewContext ctx                 -- ^ __ctx__
        -> FunPtr (BotanViewStrCallback ctx)    -- ^ __view__
        -> IO CInt

foreign import capi safe "botan/ffi.h botan_privkey_algo_name"
    botan_privkey_algo_name
        :: BotanPrivKey    -- ^ __key__
        -> Ptr CChar       -- ^ __out[]__
        -> Ptr CSize       -- ^ __out_len__
        -> IO CInt

{- |
Export a private key, running PBKDF for specified amount of time

Note: starting in 3.0, the output iterations count is not provided
-}
foreign import capi safe "botan/ffi.h botan_privkey_export_encrypted_pbkdf_msec"
    botan_privkey_export_encrypted_pbkdf_msec
        :: BotanPrivKey    -- ^ __key__
        -> Ptr Word8       -- ^ __out[]__
        -> Ptr CSize       -- ^ __out_len__
        -> BotanRNG        -- ^ __rng__
        -> ConstPtr CChar  -- ^ __passphrase__
        -> Word32          -- ^ __pbkdf_msec_runtime__
        -> Ptr CSize       -- ^ __pbkdf_iterations_out__
        -> ConstPtr CChar  -- ^ __cipher_algo__
        -> ConstPtr CChar  -- ^ __pbkdf_algo__
        -> Word32          -- ^ __flags__
        -> IO CInt

-- | Export a private key using the specified number of iterations.
foreign import capi safe "botan/ffi.h botan_privkey_export_encrypted_pbkdf_iter"
    botan_privkey_export_encrypted_pbkdf_iter
        :: BotanPrivKey    -- ^ __key__
        -> Ptr Word8       -- ^ __out[]__
        -> Ptr CSize       -- ^ __out_len__
        -> BotanRNG        -- ^ __rng__
        -> ConstPtr CChar  -- ^ __passphrase__
        -> CSize           -- ^ __pbkdf_iterations__
        -> ConstPtr CChar  -- ^ __cipher_algo__
        -> ConstPtr CChar  -- ^ __pbkdf_algo__
        -> Word32          -- ^ __flags__
        -> IO CInt

{- |
View the encryption of a private key (binary DER encoding)

Set cipher_algo, pbkdf_algo to NULL to use defaults
Set pbkdf_iterations to 0 to use defaults
-}
foreign import capi safe "botan/ffi.h botan_privkey_view_encrypted_der"
    botan_privkey_view_encrypted_der
        :: BotanPrivKey                         -- ^ __key__
        -> BotanRNG                             -- ^ __rng__
        -> ConstPtr CChar                       -- ^ __passphrase__
        -> ConstPtr CChar                       -- ^ __cipher_algo__
        -> ConstPtr CChar                       -- ^ __pbkdf_algo__
        -> CSize                                -- ^ __pbkdf_iterations__
        -> BotanViewContext ctx                 -- ^ __ctx__
        -> FunPtr (BotanViewBinCallback ctx)    -- ^ __view__
        -> IO CInt

{- |
View the encryption of a private key (binary DER encoding)

Set cipher_algo, pbkdf_algo to NULL to use defaults
-}
foreign import capi safe "botan/ffi.h botan_privkey_view_encrypted_der_timed"
    botan_privkey_view_encrypted_der_timed
        :: BotanPrivKey                         -- ^ __key__
        -> BotanRNG                             -- ^ __rng__
        -> ConstPtr CChar                       -- ^ __passphrase__
        -> ConstPtr CChar                       -- ^ __cipher_algo__
        -> ConstPtr CChar                       -- ^ __pbkdf_algo__
        -> CSize                                -- ^ __pbkdf_runtime_msec__
        -> BotanViewContext ctx                 -- ^ __ctx__
        -> FunPtr (BotanViewBinCallback ctx)    -- ^ __view__
        -> IO CInt

{- |
View the encryption of a private key (PEM encoding)

Set cipher_algo, pbkdf_algo to NULL to use defaults
Set pbkdf_iterations to 0 to use defaults
-}
foreign import capi safe "botan/ffi.h botan_privkey_view_encrypted_pem"
    botan_privkey_view_encrypted_pem
        :: BotanPrivKey                         -- ^ __key__
        -> BotanRNG                             -- ^ __rng__
        -> ConstPtr CChar                       -- ^ __passphrase__
        -> ConstPtr CChar                       -- ^ __cipher_algo__
        -> ConstPtr CChar                       -- ^ __pbkdf_algo__
        -> CSize                                -- ^ __pbkdf_iterations__
        -> BotanViewContext ctx                 -- ^ __ctx__
        -> FunPtr (BotanViewStrCallback ctx)    -- ^ __view__
        -> IO CInt

{- |
View the encryption of a private key (PEM encoding)

Set cipher_algo, pbkdf_algo to NULL to use defaults
-}
foreign import capi safe "botan/ffi.h botan_privkey_view_encrypted_pem_timed"
    botan_privkey_view_encrypted_pem_timed
        :: BotanPrivKey                         -- ^ __key__
        -> BotanRNG                             -- ^ __rng__
        -> ConstPtr CChar                       -- ^ __passphrase__
        -> ConstPtr CChar                       -- ^ __cipher_algo__
        -> ConstPtr CChar                       -- ^ __pbkdf_algo__
        -> CSize                                -- ^ __pbkdf_runtime_msec__
        -> BotanViewContext ctx                 -- ^ __ctx__
        -> FunPtr (BotanViewStrCallback ctx)    -- ^ __view__
        -> IO CInt

foreign import capi safe "botan/ffi.h botan_privkey_get_field"
    botan_privkey_get_field
        :: BotanMP         -- ^ __output__
        -> BotanPrivKey    -- ^ __key__
        -> ConstPtr CChar  -- ^ __field_name__
        -> IO CInt


-- | Opaque PubKey struct
data {-# CTYPE "botan/ffi.h" "struct botan_pubkey_struct" #-} BotanPubKeyStruct

-- | Botan PubKey object
newtype {-# CTYPE "botan/ffi.h" "botan_pubkey_t" #-} BotanPubKey
    = MkBotanPubKey { BotanPubKey -> Ptr BotanPubKeyStruct
runBotanPubKey :: Ptr BotanPubKeyStruct }
        deriving newtype (BotanPubKey -> BotanPubKey -> Bool
(BotanPubKey -> BotanPubKey -> Bool)
-> (BotanPubKey -> BotanPubKey -> Bool) -> Eq BotanPubKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BotanPubKey -> BotanPubKey -> Bool
== :: BotanPubKey -> BotanPubKey -> Bool
$c/= :: BotanPubKey -> BotanPubKey -> Bool
/= :: BotanPubKey -> BotanPubKey -> Bool
Eq, Eq BotanPubKey
Eq BotanPubKey
-> (BotanPubKey -> BotanPubKey -> Ordering)
-> (BotanPubKey -> BotanPubKey -> Bool)
-> (BotanPubKey -> BotanPubKey -> Bool)
-> (BotanPubKey -> BotanPubKey -> Bool)
-> (BotanPubKey -> BotanPubKey -> Bool)
-> (BotanPubKey -> BotanPubKey -> BotanPubKey)
-> (BotanPubKey -> BotanPubKey -> BotanPubKey)
-> Ord BotanPubKey
BotanPubKey -> BotanPubKey -> Bool
BotanPubKey -> BotanPubKey -> Ordering
BotanPubKey -> BotanPubKey -> BotanPubKey
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 :: BotanPubKey -> BotanPubKey -> Ordering
compare :: BotanPubKey -> BotanPubKey -> Ordering
$c< :: BotanPubKey -> BotanPubKey -> Bool
< :: BotanPubKey -> BotanPubKey -> Bool
$c<= :: BotanPubKey -> BotanPubKey -> Bool
<= :: BotanPubKey -> BotanPubKey -> Bool
$c> :: BotanPubKey -> BotanPubKey -> Bool
> :: BotanPubKey -> BotanPubKey -> Bool
$c>= :: BotanPubKey -> BotanPubKey -> Bool
>= :: BotanPubKey -> BotanPubKey -> Bool
$cmax :: BotanPubKey -> BotanPubKey -> BotanPubKey
max :: BotanPubKey -> BotanPubKey -> BotanPubKey
$cmin :: BotanPubKey -> BotanPubKey -> BotanPubKey
min :: BotanPubKey -> BotanPubKey -> BotanPubKey
Ord, Ptr BotanPubKey -> IO BotanPubKey
Ptr BotanPubKey -> Int -> IO BotanPubKey
Ptr BotanPubKey -> Int -> BotanPubKey -> IO ()
Ptr BotanPubKey -> BotanPubKey -> IO ()
BotanPubKey -> Int
(BotanPubKey -> Int)
-> (BotanPubKey -> Int)
-> (Ptr BotanPubKey -> Int -> IO BotanPubKey)
-> (Ptr BotanPubKey -> Int -> BotanPubKey -> IO ())
-> (forall b. Ptr b -> Int -> IO BotanPubKey)
-> (forall b. Ptr b -> Int -> BotanPubKey -> IO ())
-> (Ptr BotanPubKey -> IO BotanPubKey)
-> (Ptr BotanPubKey -> BotanPubKey -> IO ())
-> Storable BotanPubKey
forall b. Ptr b -> Int -> IO BotanPubKey
forall b. Ptr b -> Int -> BotanPubKey -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: BotanPubKey -> Int
sizeOf :: BotanPubKey -> Int
$calignment :: BotanPubKey -> Int
alignment :: BotanPubKey -> Int
$cpeekElemOff :: Ptr BotanPubKey -> Int -> IO BotanPubKey
peekElemOff :: Ptr BotanPubKey -> Int -> IO BotanPubKey
$cpokeElemOff :: Ptr BotanPubKey -> Int -> BotanPubKey -> IO ()
pokeElemOff :: Ptr BotanPubKey -> Int -> BotanPubKey -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO BotanPubKey
peekByteOff :: forall b. Ptr b -> Int -> IO BotanPubKey
$cpokeByteOff :: forall b. Ptr b -> Int -> BotanPubKey -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> BotanPubKey -> IO ()
$cpeek :: Ptr BotanPubKey -> IO BotanPubKey
peek :: Ptr BotanPubKey -> IO BotanPubKey
$cpoke :: Ptr BotanPubKey -> BotanPubKey -> IO ()
poke :: Ptr BotanPubKey -> BotanPubKey -> IO ()
Storable)

-- | Frees all resources of the PubKey object
foreign import capi safe "botan/ffi.h &botan_pubkey_destroy"
    botan_pubkey_destroy
        :: FinalizerPtr BotanPubKeyStruct

foreign import capi safe "botan/ffi.h botan_privkey_export_pubkey"
    botan_privkey_export_pubkey
        :: Ptr BotanPubKey    -- ^ __out__
        -> BotanPrivKey       -- ^ __in__
        -> IO CInt

foreign import capi safe "botan/ffi.h botan_pubkey_load"
    botan_pubkey_load
        :: Ptr BotanPubKey     -- ^ __key__
        -> ConstPtr Word8      -- ^ __bits[]__
        -> CSize               -- ^ __len__
        -> IO CInt

pattern BOTAN_PUBKEY_EXPORT_FLAG_DER    -- ^ __BOTAN_PRIVKEY_EXPORT_FLAG_DER__ in disguise
    ,   BOTAN_PUBKEY_EXPORT_FLAG_PEM    -- ^ __BOTAN_PRIVKEY_EXPORT_FLAG_PEM__ in disguise
    ::  (Eq a, Num a) => a
pattern $mBOTAN_PUBKEY_EXPORT_FLAG_DER :: forall {r} {a}.
(Eq a, Num a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PUBKEY_EXPORT_FLAG_DER :: forall a. (Eq a, Num a) => a
BOTAN_PUBKEY_EXPORT_FLAG_DER = BOTAN_PRIVKEY_EXPORT_FLAG_DER
pattern $mBOTAN_PUBKEY_EXPORT_FLAG_PEM :: forall {r} {a}.
(Eq a, Num a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PUBKEY_EXPORT_FLAG_PEM :: forall a. (Eq a, Num a) => a
BOTAN_PUBKEY_EXPORT_FLAG_PEM = BOTAN_PRIVKEY_EXPORT_FLAG_PEM

foreign import capi safe "botan/ffi.h botan_pubkey_export"
    botan_pubkey_export
        :: BotanPubKey    -- ^ __key__
        -> Ptr Word8      -- ^ __out[]__
        -> Ptr CSize      -- ^ __out_len__
        -> Word32         -- ^ __flags__
        -> IO CInt

-- | View the public key's DER encoding
foreign import capi safe "botan/ffi.h botan_pubkey_view_der"
    botan_pubkey_view_der
        :: BotanPubKey                       -- ^ __key__
        -> BotanViewContext ctx              -- ^ __ctx__
        -> FunPtr (BotanViewBinCallback ctx) -- ^ __view__
        -> IO CInt
    
    -- | View the public key's PEM encoding
foreign import capi safe "botan/ffi.h botan_pubkey_view_pem"
    botan_pubkey_view_pem
        :: BotanPubKey                       -- ^ __key__
        -> BotanViewContext ctx              -- ^ __ctx__
        -> FunPtr (BotanViewStrCallback ctx) -- ^ __view__
        -> IO CInt

foreign import capi safe "botan/ffi.h botan_pubkey_algo_name"
    botan_pubkey_algo_name
        :: BotanPubKey    -- ^ __key__
        -> Ptr CChar      -- ^ __out[]__
        -> Ptr CSize      -- ^ __out_len__
        -> IO CInt

-- | Returns 0 if key is valid, negative if invalid key or some other error
foreign import capi safe "botan/ffi.h botan_pubkey_check_key"
    botan_pubkey_check_key
        :: BotanPubKey    -- ^ __key__
        -> BotanRNG       -- ^ __rng__
        -> Word32         -- ^ __flags__
        -> IO CInt

foreign import capi safe "botan/ffi.h botan_pubkey_estimated_strength"
    botan_pubkey_estimated_strength
        :: BotanPubKey    -- ^ __key__
        -> Ptr CSize      -- ^ __estimate__
        -> IO CInt

foreign import capi safe "botan/ffi.h botan_pubkey_fingerprint"
    botan_pubkey_fingerprint
        :: BotanPubKey    -- ^ __key__
        -> ConstPtr CChar -- ^ __hash__
        -> Ptr Word8      -- ^ __out[]__
        -> Ptr CSize      -- ^ __out_len__
        -> IO CInt

-- | Get arbitrary named fields from public or private keys
foreign import capi safe "botan/ffi.h botan_pubkey_get_field"
    botan_pubkey_get_field
        :: BotanMP        -- ^ __output__
        -> BotanPubKey    -- ^ __key__
        -> ConstPtr CChar -- ^ __field_name__
        -> IO CInt

-- | View the uncompressed public point associated with the key
foreign import capi safe "botan/ffi.h botan_pubkey_view_ec_public_point"
    botan_pubkey_view_ec_public_point
        :: BotanPubKey                       -- ^ __key__
        -> BotanViewContext ctx              -- ^ __ctx__
        -> FunPtr (BotanViewBinCallback ctx) -- ^ __view__
        -> IO CInt