GateKeeper.h
author Markus Schaber <markus@pep-security.net>
Tue, 04 Oct 2016 23:07:42 +0200
branchkeysync
changeset 178 9f30e2a5f72c
parent 141 95ae11dfbc8f
child 208 35eb7b0492ac
permissions -rw-r--r--
COM-30 COM-24: Refactorings
Drop unused enum.
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
vb@96
    34
    protected:
vb@96
    35
        static const LPCTSTR plugin_reg_path;
vb@96
    36
        static const LPCTSTR plugin_reg_value_name;
vb@96
    37
        static const LPCTSTR updater_reg_path;
vb@88
    38
vb@96
    39
        static const time_t cycle;
vb@137
    40
        static const time_t fraction;
vb@96
    41
        static const DWORD waiting;
vb@96
    42
vb@96
    43
        static time_t time_diff();
vb@96
    44
vb@96
    45
        void keep_plugin();
vb@96
    46
vb@126
    47
        void install_msi(tstring filename);
vb@111
    48
        string update_key();
vb@116
    49
        BCRYPT_KEY_HANDLE delivery_key();
vb@121
    50
        string wrapped_delivery_key(BCRYPT_KEY_HANDLE hDeliveryKey);
vb@112
    51
vb@97
    52
        void update_product(product p, DWORD context);
vb@96
    53
        product_list& registered_products();
vb@96
    54
        void keep_updated();
vb@96
    55
vb@96
    56
    private:
vb@96
    57
        time_t now;
vb@96
    58
        time_t next;
vb@96
    59
        bool cu_open;
vb@96
    60
        HKEY cu;
vb@96
    61
        HKEY hkUpdater;
vb@141
    62
        HKEY hkPluginStart;
vb@97
    63
        HINTERNET internet;
vb@116
    64
        BCRYPT_ALG_HANDLE hAES;
vb@116
    65
        BCRYPT_ALG_HANDLE hRSA;
vb@96
    66
vb@110
    67
        CpEpCOMServerAdapterModule * _self;
vb@96
    68
    };
vb@96
    69
}