GateKeeper.h
author Thomas
Thu, 14 Nov 2019 16:18:44 +0100
branchsync
changeset 373 5b10b2200c91
parent 370 8be91c5f6570
child 382 bf5a83a0c9bc
permissions -rw-r--r--
Adjust HandshakeSignal enum to engine changes
     1 class CpEpCOMServerAdapterModule;
     2 
     3 using namespace std;
     4 
     5 namespace pEp {
     6 
     7 #ifdef UNICODE
     8 	typedef wstring tstring;
     9 	typedef wregex tregex;
    10 	typedef wsmatch tsmatch;
    11 #else
    12 	typedef string tstring;
    13 	typedef regex tregex;
    14 	typedef smatch tsmatch;
    15 #endif
    16 
    17     class GateKeeper {
    18     public:
    19         typedef pair<tstring, tstring> product;
    20         typedef vector< product > product_list;
    21         union aeskey_t {
    22             uint8_t c_key[32];
    23             uint16_t w_key[16];
    24             uint32_t dw_key[8];
    25             uint64_t qw_key[4];
    26         };
    27 
    28         GateKeeper(CpEpCOMServerAdapterModule * self);
    29         ~GateKeeper();
    30 
    31         CpEpCOMServerAdapterModule * const module() const
    32         {
    33             return _self;
    34         }
    35 
    36         void keep();
    37 		product_list registered_products();
    38 		bool update_product(product p, DWORD context = 0);
    39 
    40 		static GateKeeper *gatekeeper() { return the_gatekeeper; }
    41 
    42     protected:
    43         static const LPCTSTR plugin_reg_path;
    44         static const LPCTSTR plugin_reg_value_name;
    45         static const LPCTSTR updater_reg_path;
    46 
    47         static const time_t cycle;
    48         static const time_t fraction;
    49         static const DWORD waiting;
    50 
    51         static time_t time_diff();
    52 
    53         void keep_plugin();
    54 
    55         void execute_file(tstring filename);
    56         string update_key();
    57         BCRYPT_KEY_HANDLE delivery_key();
    58         string wrapped_delivery_key(BCRYPT_KEY_HANDLE hDeliveryKey);
    59 
    60         void keep_updated();
    61         static tstring get_lockFile();
    62 		static GateKeeper *the_gatekeeper;
    63 
    64     private:
    65         time_t now;
    66         time_t next;
    67         bool cu_open;
    68         HKEY cu;
    69         HKEY hkUpdater;
    70         HINTERNET internet;
    71         BCRYPT_ALG_HANDLE hAES;
    72         BCRYPT_ALG_HANDLE hRSA;
    73 
    74         CpEpCOMServerAdapterModule * _self;
    75     };
    76 }