0

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 */
  • 3
    What have you tried? What problem do you have with your attempt? And if you haven't tried anything, why? What doubts, thoughts or problems do you have? And please take some time to read about [how to ask good questions](http://stackoverflow.com/help/how-to-ask), as well as [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). – Some programmer dude Oct 04 '19 at 07:24
  • What's wrong with `static std::shared_ptr cryptoFactory()`? – Scheff's Cat Oct 04 '19 at 07:41

0 Answers0