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

{-# LANGUAGE CApiFFI #-}

module Botan.Bindings.PubKey.Encrypt where

import Botan.Bindings.Prelude
import Botan.Bindings.PubKey
import Botan.Bindings.RNG



-- | Opaque encrypt struct
data {-# CTYPE "botan/ffi.h" "struct botan_pk_op_encrypt_struct" #-} BotanPKOpEncryptStruct

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

-- | Destroy a encrypt object
foreign import capi safe "botan/ffi.h &botan_pk_op_encrypt_destroy"
    botan_pk_op_encrypt_destroy
        :: FinalizerPtr BotanPKOpEncryptStruct

pattern BOTAN_PUBKEY_ENCRYPT_FLAGS_NONE -- ^ Not actual flag
    ::  (Eq a, Num a) => a
pattern $mBOTAN_PUBKEY_ENCRYPT_FLAGS_NONE :: forall {r} {a}.
(Eq a, Num a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PUBKEY_ENCRYPT_FLAGS_NONE :: forall a. (Eq a, Num a) => a
BOTAN_PUBKEY_ENCRYPT_FLAGS_NONE = 0

foreign import capi safe "botan/ffi.h botan_pk_op_encrypt_create"
    botan_pk_op_encrypt_create
        :: Ptr BotanPKOpEncrypt      -- ^ __op__
        -> BotanPubKey               -- ^ __key__
        -> ConstPtr CChar            -- ^ __padding__
        -> Word32                    -- ^ __flags__
        -> IO CInt

foreign import capi safe "botan/ffi.h botan_pk_op_encrypt_output_length"
    botan_pk_op_encrypt_output_length
        :: BotanPKOpEncrypt      -- ^ __op__
        -> CSize                 -- ^ __ptext_len__
        -> Ptr CSize             -- ^ __ctext_len__
        -> IO CInt

foreign import capi safe "botan/ffi.h botan_pk_op_encrypt"
    botan_pk_op_encrypt
        :: BotanPKOpEncrypt      -- ^ __op__
        -> BotanRNG              -- ^ __rng__
        -> Ptr Word8             -- ^ __out[]__
        -> Ptr CSize             -- ^ __out_len__
        -> Ptr Word8             -- ^ __plaintext[]__
        -> CSize                 -- ^ __plaintext_len__
        -> IO CInt