GateKeeper.h
author Volker Birk <vb@pep-project.org>
Thu, 23 Jun 2016 21:08:02 +0200
changeset 123 6d311985ee41
parent 121 6ee2155ec27a
child 126 8cf20db557f1
permissions -rw-r--r--
Micro$oft Crypto Nonsense
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@123
    18
            uint8_t c_key[132];
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@96
    40
        static const DWORD waiting;
vb@96
    41
vb@96
    42
        static time_t time_diff();
vb@96
    43
vb@96
    44
        void keep_plugin();
vb@96
    45
vb@111
    46
        string update_key();
vb@116
    47
        BCRYPT_KEY_HANDLE delivery_key();
vb@121
    48
        string wrapped_delivery_key(BCRYPT_KEY_HANDLE hDeliveryKey);
vb@112
    49
vb@97
    50
        void update_product(product p, DWORD context);
vb@96
    51
        product_list& registered_products();
vb@96
    52
        void keep_updated();
vb@96
    53
vb@96
    54
    private:
vb@96
    55
        time_t now;
vb@96
    56
        time_t next;
vb@96
    57
        bool cu_open;
vb@96
    58
        HKEY cu;
vb@96
    59
        HKEY hkUpdater;
vb@97
    60
        HINTERNET internet;
vb@116
    61
        BCRYPT_ALG_HANDLE hAES;
vb@116
    62
        BCRYPT_ALG_HANDLE hRSA;
vb@96
    63
vb@110
    64
        CpEpCOMServerAdapterModule * _self;
vb@96
    65
    };
vb@96
    66
}