GateKeeper.h
author Thomas
Wed, 02 May 2018 09:46:48 +0200
branchCOM-87
changeset 287 99abd7d70c1e
parent 284 83ad8d765099
child 360 57c7ace37425
permissions -rw-r--r--
Rename flags
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
vb@107
     8
    typedef wstring tstring;
vb@96
     9
#else
vb@107
    10
    typedef string tstring;
vb@96
    11
#endif
vb@88
    12
vb@96
    13
    class GateKeeper {
vb@96
    14
    public:
vb@107
    15
        typedef pair<tstring, tstring> product;
vb@107
    16
        typedef vector< product > product_list;
vb@112
    17
        union aeskey_t {
vb@129
    18
            uint8_t c_key[32];
vb@123
    19
            uint16_t w_key[16];
vb@123
    20
            uint32_t dw_key[8];
vb@123
    21
            uint64_t qw_key[4];
vb@112
    22
        };
vb@89
    23
vb@117
    24
        GateKeeper(CpEpCOMServerAdapterModule * self);
vb@96
    25
        ~GateKeeper();
vb@88
    26
vb@96
    27
        CpEpCOMServerAdapterModule * const module() const
vb@96
    28
        {
vb@96
    29
            return _self;
vb@96
    30
        }
vb@88
    31
vb@96
    32
        void keep();
vb@88
    33
markus@284
    34
        static void update_now();
markus@284
    35
vb@96
    36
    protected:
vb@96
    37
        static const LPCTSTR plugin_reg_path;
vb@96
    38
        static const LPCTSTR plugin_reg_value_name;
vb@96
    39
        static const LPCTSTR updater_reg_path;
vb@88
    40
vb@96
    41
        static const time_t cycle;
vb@137
    42
        static const time_t fraction;
markus@284
    43
        static const std::chrono::seconds waiting;
vb@96
    44
vb@96
    45
        static time_t time_diff();
vb@96
    46
vb@96
    47
        void keep_plugin();
vb@96
    48
vb@126
    49
        void install_msi(tstring filename);
vb@111
    50
        string update_key();
vb@116
    51
        BCRYPT_KEY_HANDLE delivery_key();
vb@121
    52
        string wrapped_delivery_key(BCRYPT_KEY_HANDLE hDeliveryKey);
vb@112
    53
vb@97
    54
        void update_product(product p, DWORD context);
vb@214
    55
        product_list registered_products();
vb@96
    56
        void keep_updated();
markus@269
    57
        static tstring get_lockFile();
vb@96
    58
vb@96
    59
    private:
vb@96
    60
        time_t now;
vb@96
    61
        time_t next;
vb@96
    62
        bool cu_open;
vb@96
    63
        HKEY cu;
vb@96
    64
        HKEY hkUpdater;
vb@97
    65
        HINTERNET internet;
vb@116
    66
        BCRYPT_ALG_HANDLE hAES;
vb@116
    67
        BCRYPT_ALG_HANDLE hRSA;
vb@96
    68
vb@110
    69
        CpEpCOMServerAdapterModule * _self;
markus@284
    70
markus@284
    71
        static std::mutex update_wait_mtx;
markus@284
    72
        static std::condition_variable update_wait_var;
markus@284
    73
        static bool update_wait_forced;
vb@96
    74
    };
vb@96
    75
}