Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cPEM.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cPEM_H
7 #define _INC_cPEM_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
13 #include "GrayCore/include/cHeap.h"
15 
16 namespace GrayLib
17 {
18  class GRAYLIB_LINK cPEM : public cHeapBlock
19  {
27 
28  protected:
29  static bool GRAYCALL ReadIV(const char* s, BYTE* pIV, size_t nIVSize);
30  static void GRAYCALL DecryptPrep(BYTE* pKey, size_t nKeySize, BYTE* pIV, const BYTE* pPassword, size_t nPassSize);
31 
32  static void GRAYCALL DecryptDES(BYTE pIV[8], BYTE* pBuffer, size_t nSizeBuf, const BYTE* pPassword, size_t nPassSize);
33  static void GRAYCALL DecryptDES3(BYTE pIV[8], BYTE* pBuffer, size_t nSizeBuf, const BYTE* pPassword, size_t nPassSize);
34  static void GRAYCALL DecryptAES(BYTE pIV[16], UINT nKeySize, BYTE* pBuffer, size_t nSizeBuf, const BYTE* pPassword, size_t nPassSize);
35 
36  public:
37  static const char k_BEGINf[19]; // "-----BEGIN %s-----";
38  static const char k_ENDf[17]; // "-----END %s-----";
39 
40  size_t m_nSizeRead;
41 
42  public:
43  cPEM() noexcept
44  {
45  }
46  ~cPEM() noexcept
47  {
48  }
49 
50  static const char* FindHeader(const char* pData, const char* pszType);
51 
52  HRESULT ReadPEM(const char* pszType, const BYTE* pData, const BYTE* pPassword = nullptr, size_t nPassSize = 0);
53 
54  static HRESULT GRAYCALL WriteToPEM(char* pOut, StrLen_t nOutLen, const char* pszType, const BYTE* pDerData, size_t nSizeDer);
55 
57  };
58 };
59 #endif
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cPEM.h:19
~cPEM() noexcept
Definition: cPEM.h:46
size_t m_nSizeRead
The uncompressed read size.
Definition: cPEM.h:40
cPEM() noexcept
Definition: cPEM.h:43
UNITTEST_FRIEND(cPEM)
Definition: cHeap.h:156
Definition: cMesh.h:22
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32