#ifndef GDCMCAPICRYPTOGRAPHICMESSAGESYNTAX_H
#define GDCMCAPICRYPTOGRAPHICMESSAGESYNTAX_H
#include "gdcmCryptographicMessageSyntax.h"
#include <windows.h>
#include <wincrypt.h>
#include <vector>
namespace gdcm
{
class GDCM_EXPORT CAPICryptographicMessageSyntax : public CryptographicMessageSyntax
{
public:
CAPICryptographicMessageSyntax();
~CAPICryptographicMessageSyntax();
bool ParseCertificateFile( const char *filename );
bool ParseKeyFile( const char *filename );
bool SetPassword(const char * pass, size_t passLen);
void SetCipherType(CipherTypes type);
CipherTypes GetCipherType() const;
bool Encrypt(char *output, size_t &outlen, const char *array, size_t len) const;
bool Decrypt(char *output, size_t &outlen, const char *array, size_t len) const;
bool GetInitialized() const
{
return initialized;
}
private:
bool Initialize();
static ALG_ID GetAlgIdByObjId(const char * pszObjId);
const char *GetCipherObjId() const;
static void ReverseBytes(unsigned char* data, DWORD len);
static bool LoadFile(const char * filename, unsigned char* & buffer, DWORD & bufLen);
private:
bool initialized;
HCRYPTPROV hProv;
std::vector<PCCERT_CONTEXT> certifList;
HCRYPTKEY hRsaPrivK;
CipherTypes cipherType;
};
}
#endif