Skip to content
Snippets Groups Projects
rsa.hh 931 B
Newer Older
  • Learn to ignore specific revisions
  • #ifndef __VEREIGN_NCRYPT_RSA_HH
    #define __VEREIGN_NCRYPT_RSA_HH
    
    #include <vereign/ncrypt/unique_ptr.hh>
    #include <vereign/bytes/buffer.hh>
    
    #include <windows.h>
    #include <ncrypt.h>
    #include <string>
    
    #include <optional>
    
    
    namespace vereign::ncrypt::rsa {
    
    
    struct KeyUIPolicy {
    
      std::string_view CreationTitle;
      std::string_view Description;
      std::string_view FriendlyName;
    
    auto OpenStorageProvider() -> UniquePtr;
    auto LoadKey(NCRYPT_PROV_HANDLE provider, const std::string& key_name) -> UniquePtr;
    
    auto CreateKey(
      NCRYPT_PROV_HANDLE provider,
      int bits,
      const std::string& key_name,
      std::optional<KeyUIPolicy> ui_policy
    ) -> UniquePtr;
    
    void DeleteKey(NCRYPT_KEY_HANDLE key);
    
    void PublicKeyEncrypt(NCRYPT_KEY_HANDLE key, bytes::View src, bytes::Buffer& encrypted);
    void PrivateKeyDecrypt(NCRYPT_KEY_HANDLE key, bytes::View src, bytes::Buffer& decrypted);
    
    } // vereign::ncrypt::rsa
    
    #endif // __VEREIGN_NCRYPT_RSA_HH