GateKeeper.h
author Dean
Tue, 04 Oct 2016 12:31:52 +0200
branchkeysync
changeset 174 1fa1296363f9
parent 141 95ae11dfbc8f
child 208 35eb7b0492ac
permissions -rw-r--r--
Formatting and spelling fixes
     1 class CpEpCOMServerAdapterModule;
     2 
     3 using namespace std;
     4 
     5 namespace pEp {
     6 
     7 #ifdef UNICODE
     8     typedef wstring tstring;
     9 #else
    10     typedef string tstring;
    11 #endif
    12 
    13     class GateKeeper {
    14     public:
    15         typedef pair<tstring, tstring> product;
    16         typedef vector< product > product_list;
    17         union aeskey_t {
    18             uint8_t c_key[32];
    19             uint16_t w_key[16];
    20             uint32_t dw_key[8];
    21             uint64_t qw_key[4];
    22         };
    23 
    24         GateKeeper(CpEpCOMServerAdapterModule * self);
    25         ~GateKeeper();
    26 
    27         CpEpCOMServerAdapterModule * const module() const
    28         {
    29             return _self;
    30         }
    31 
    32         void keep();
    33 
    34     protected:
    35         static const LPCTSTR plugin_reg_path;
    36         static const LPCTSTR plugin_reg_value_name;
    37         static const LPCTSTR updater_reg_path;
    38 
    39         static const time_t cycle;
    40         static const time_t fraction;
    41         static const DWORD waiting;
    42 
    43         static time_t time_diff();
    44 
    45         void keep_plugin();
    46 
    47         void install_msi(tstring filename);
    48         string update_key();
    49         BCRYPT_KEY_HANDLE delivery_key();
    50         string wrapped_delivery_key(BCRYPT_KEY_HANDLE hDeliveryKey);
    51 
    52         void update_product(product p, DWORD context);
    53         product_list& registered_products();
    54         void keep_updated();
    55 
    56     private:
    57         time_t now;
    58         time_t next;
    59         bool cu_open;
    60         HKEY cu;
    61         HKEY hkUpdater;
    62         HKEY hkPluginStart;
    63         HINTERNET internet;
    64         BCRYPT_ALG_HANDLE hAES;
    65         BCRYPT_ALG_HANDLE hRSA;
    66 
    67         CpEpCOMServerAdapterModule * _self;
    68     };
    69 }