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

{-# LANGUAGE CApiFFI #-}

module Botan.Bindings.PubKey.KeyAgreement where

import Botan.Bindings.Prelude
import Botan.Bindings.PubKey
import Botan.Bindings.View



-- NOTE: Asymmetry in naming of struct vs functions

-- | Opaque key agreement struct
data {-# CTYPE "botan/ffi.h" "struct botan_pk_op_ka_struct" #-} BotanPKOpKeyAgreementStruct

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

-- | Destroy a key agreement object
foreign import capi safe "botan/ffi.h &botan_pk_op_key_agreement_destroy"
    botan_pk_op_key_agreement_destroy
        :: FinalizerPtr BotanPKOpKeyAgreementStruct

pattern BOTAN_PUBKEY_KEY_AGREEMENT_FLAGS_NONE -- ^ Not actual flag
    ::  (Eq a, Num a) => a
pattern $mBOTAN_PUBKEY_KEY_AGREEMENT_FLAGS_NONE :: forall {r} {a}.
(Eq a, Num a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bBOTAN_PUBKEY_KEY_AGREEMENT_FLAGS_NONE :: forall a. (Eq a, Num a) => a
BOTAN_PUBKEY_KEY_AGREEMENT_FLAGS_NONE = 0

foreign import capi safe "botan/ffi.h botan_pk_op_key_agreement_create"
    botan_pk_op_key_agreement_create
        :: Ptr BotanPKOpKeyAgreement -- ^ __op__
        -> BotanPrivKey              -- ^ __key__
        -> ConstPtr CChar            -- ^ __kdf__
        -> Word32                    -- ^ __flags__
        -> IO CInt

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

foreign import capi safe "botan/ffi.h botan_pk_op_key_agreement_view_public"
    botan_pk_op_key_agreement_view_public
        :: BotanPrivKey                         -- ^ __key__
        -> BotanViewContext ctx                 -- ^ __ctx__
        -> FunPtr (BotanViewBinCallback ctx)    -- ^ __view__
        -> IO CInt

foreign import capi safe "botan/ffi.h botan_pk_op_key_agreement_size"
    botan_pk_op_key_agreement_size
        :: BotanPKOpKeyAgreement -- ^ __op__
        -> Ptr CSize             -- ^ __out_len__
        -> IO CInt

foreign import capi safe "botan/ffi.h botan_pk_op_key_agreement"
    botan_pk_op_key_agreement
        :: BotanPKOpKeyAgreement -- ^ __op__
        -> Ptr Word8             -- ^ __out[]__
        -> Ptr CSize             -- ^ __out_len__,
        -> ConstPtr Word8        -- ^ __other_key[]__
        -> CSize                 -- ^ __other_key_len__
        -> ConstPtr Word8        -- ^ __salt[]__
        -> CSize                 -- ^ __salt_len__
        -> IO CInt