I need the implementation of the following abstract class. So that it can successfully compile with another code that uses functions from the abstract class. I mostly need the part on the shared pointer.
Here is the code
#ifndef CRYPTO_HPP
#define CRYPTO_HPP
#include <functional>
#include <memory>
enum class Algorithm
{
eNONE,
eCAESAR,
eAES,
eRSA,
};
class Crypto
{
public:
Crypto(std::function<void(const uint8_t *data, uint32_t len)> encryptCallback,
std::function<void(const uint8_t *data, uint32_t len)> decryptCallback);
virtual void genKeys() = 0;
virtual bool getKeys(uint8_t **pubKey, uint32_t &pubLen,
uint8_t **priKey, uint32_t &priLen) = 0;
virtual void setKeys(const uint8_t *pubKey, uint32_t pubLen,
const uint8_t *priKey, uint32_t priLen) = 0;
virtual void destroyKeys() = 0;
virtual bool encrypt(const uint8_t *data, uint32_t len) = 0;
virtual bool decrypt(const uint8_t *data, uint32_t len) = 0;
static std::shared_ptr<Crypto> cryptoFactory(std::function<void(const uint8_t *data, uint32_t len)> encryptCallback,
std::function<void(const uint8_t *data, uint32_t len)> decryptCallback,
Algorithm algorithm);
protected:
/** @brief Encrypt callback function */
std::function<void(const uint8_t *data, uint32_t len)>m_encryptCallback;
/** @brief Decrypt callback function */
std::function<void(const uint8_t *data, uint32_t len)> m_decryptCallback;
};
#endif /* CRYPTO_HPP */