GateKeeper.h
author Thomas
Thu, 05 Dec 2019 12:17:32 +0100
branchCOM-106
changeset 382 bf5a83a0c9bc
parent 370 8be91c5f6570
child 392 2fa7e72ed581
permissions -rw-r--r--
COM-106: Provide method to try to update product
     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         bool try_update(product *p);
    40 
    41 		static GateKeeper *gatekeeper() { return the_gatekeeper; }
    42 
    43     protected:
    44         static const LPCTSTR plugin_reg_path;
    45         static const LPCTSTR plugin_reg_value_name;
    46         static const LPCTSTR updater_reg_path;
    47 
    48         static const time_t cycle;
    49         static const time_t fraction;
    50         static const DWORD waiting;
    51 
    52         static time_t time_diff();
    53 
    54         void keep_plugin();
    55 
    56         void execute_file(tstring filename);
    57         string update_key();
    58         BCRYPT_KEY_HANDLE delivery_key();
    59         string wrapped_delivery_key(BCRYPT_KEY_HANDLE hDeliveryKey);
    60 
    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 }