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