|
//
// (w)ritten by andreas saurwein 2002, mailto:saurwein@uniwares.com
//
#pragma once
#include <wincrypt.h>
#pragma comment(lib, "Crypt32.lib")
#include <afxtempl.h>
class CProtectedData
{
public:
CProtectedData(BOOL bSilent=TRUE, BOOL bLocal=FALSE, BOOL bAudit=FALSE);
virtual ~CProtectedData(void);
void SetUI(HWND hWnd, LPCTSTR pPrompt);
void SetAudit(BOOL bAudit=TRUE);
void SetLocal(BOOL bLocal=TRUE);
void SetData(LPBYTE pData, DWORD dwSize);
const DATA_BLOB* ProtectData(); // no description, no entropy
const DATA_BLOB* ProtectData(LPCTSTR pDesc); // no entropy
const DATA_BLOB* ProtectData(LPCTSTR pDesc, const CString& rString);// entropy is a CString
const DATA_BLOB* ProtectData(LPCTSTR pDesc, LPCTSTR pString); // entropy is a LPCTSTR
const DATA_BLOB* ProtectData(LPCTSTR pDesc, LPBYTE pEntropy, DWORD dwEntropySize); // returns encrypted data and the size
void FreeProtectedData(); // free the associated datablock
DATA_BLOB* UnprotectData(); // no description, no entropy
DATA_BLOB* UnprotectData(LPTSTR* pDesc); // no entropy
DATA_BLOB* UnprotectData(LPTSTR* pDesc, const CString& rString); // entropy is a CString
DATA_BLOB* UnprotectData(LPTSTR* pDesc, LPCTSTR pString); // entropy is a LPCTSTR
DATA_BLOB* UnprotectData(LPTSTR* pDesc, LPBYTE pEntropy, DWORD dwEntropySize); // returns decrypted data and the size
void FreeUnprotectedData(); // free the associated datablock
private:
DATA_BLOB m_ProtectedData; // points to the protected data
CRYPTPROTECT_PROMPTSTRUCT m_Prompt; // prompt data
BOOL m_bSilent; // dont prompt
BOOL m_bLocal; // use machine local encryption
BOOL m_bAudit; // audit any encrypt/decrypt operation
LPBYTE m_pData; // actual data
DWORD m_dwSize; // actual size of data
};
class CUserProtectedData : public CProtectedData
{
public:
CUserProtectedData(BOOL bSilent=TRUE, BOOL bAudit=FALSE) : CProtectedData(bSilent, FALSE, bAudit) {}
virtual ~CUserProtectedData(void) {};
};
class CMachineProtectedData : public CProtectedData
{
public:
CMachineProtectedData(BOOL bSilent=TRUE, BOOL bAudit=FALSE) : CProtectedData(bSilent, TRUE, bAudit) {}
virtual ~CMachineProtectedData(void) {};
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Software Smith, Blacksmith, Repeat Founder, Austrian, Asgardian.