#pragma once

#include <memory>
#include <vector>
#include <openssl/evp.h>


namespace drp::util::crypto {


/**
 * Represent an RSA private key.
 */
class RsaPrivateKey {
public:
    RsaPrivateKey();
    explicit RsaPrivateKey(const std::vector<std::uint8_t>& data, int padMode);

    [[nodiscard]] std::vector<std::uint8_t> decrypt(const std::vector<std::uint8_t>& encryptedData) const;

    [[nodiscard]] std::vector<std::uint8_t> serialize() const;
    static RsaPrivateKey deserialize(std::vector<std::uint8_t>& data);

private:
    [[nodiscard]] std::unique_ptr<EVP_PKEY, decltype(&EVP_PKEY_free)> getOpenSslKey() const;

    int padMode {};
    std::vector<std::uint8_t> _data;
};


}
