open-license-manager
2014-10-13 62258ba3b4737432a95c3af8d0e03ed3fb7953e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * CryptoHelperWindows.h
 *
 *  Created on: Sep 14, 2014
 *
 */
 
#ifndef CRYPTOHELPERWINDOWS_H_
#define CRYPTOHELPERWINDOWS_H_
 
//#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <wincrypt.h>
#include <tchar.h>
#include <string>
#include "../CryptoHelper.h"
 
 
 
namespace license {
using namespace std;
 
class CryptoHelperWindows: public CryptoHelper {
private :
    void acquireContext();
    //    Handle to the cryptography provider.
    HCRYPTPROV m_hCryptProv;
    //    Handle to the cryptography key.
    HCRYPTKEY m_hCryptKey;
    void printHash(HCRYPTHASH* hHash) const;
public:
    CryptoHelperWindows();
 
    virtual void generateKeyPair();
    virtual const string exportPrivateKey() const;
    virtual const string exportPublicKey() const;
 
    virtual const string signString(const void* privateKey, size_t pklen,
            const string& license) const;
 
    virtual ~CryptoHelperWindows();
};
 
} /* namespace license */
 
#endif /* CRYPTOHELPERWINDOWS_H_ */