#pragma once /*! * \file */ #ifdef __cplusplus extern "C" { #endif #include #include "keypair.h" #include "sharedkey.h" /*! * \brief Defines how a KeyPair create function should look like. * Used to store a pointer to function to a implementation. */ typedef struct KeyPair (*KeyPairCreator)(); /*! * \brief Defines how a KeyPair deleter function should look like. * Used to store a pointer to function to a implementation. */ typedef void (*KeyPairDeleter)(struct KeyPair); /*! * \brief Defines how a Derived Shared Key function should look like. * Used to store a pointer to function to a implementation. */ typedef struct SharedKey (*SharedKeyDeriver)(struct KeyPair, unsigned char const*, bool); /*! * \brief Defines how a Derived Shared Key deleter function should look like. * Used to store a pointer to function to a implementation. */ typedef void (*SharedKeyDeleter)(struct SharedKey); /*! * \brief The Api struct stores pointers to functions of a specific implementation. Like a Curve25519 specific one. */ struct Api { KeyPairCreator create_key_pair; ///< Pointer to keypair creation function KeyPairDeleter free_key_pair; ///< Pointer to keypair deletor function SharedKeyDeriver derive_shared_key; ///< Pointer to shared key derivation function SharedKeyDeleter free_shared_key; ///< Pointer to shared key deleter function }; /*! * A Pointer to function typedef to facilitate multiple implementations. */ typedef struct Api(*ImplementationGetter)(); /*! * \brief get_implementation The pointer to member function variable to implement when * defining a an implementation */ extern ImplementationGetter get_implementation; #ifdef __cplusplus } #endif