Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cCipherTypeDef.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cCipherTypeDef_H
7 #define _INC_cCipherTypeDef_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 #include "cCipherBase.h"
15 
16 
17 namespace GrayLib
18 {
19  class cCipherPadding;
20 
22  {
26 
28 #define CIPHERTYPEDEF(a,b,c,d,e,f,g) SSL_Cipher_##a,
29 #include "cCipherTypeDef.tbl"
30 #undef CIPHERTYPEDEF
32  };
33 
35  {
39 
40  public:
41  // SSL_Cipher_TYPE m_eCipherType;
42  // const char* const m_pszName;
43 
45 
49 
50  size_t m_nSizeIV;
51 
54 
56 
59 
60  public:
61  static const cCipherTypeDef* GRAYCALL GetCipherTypeDef(SSL_Cipher_TYPE eCipherType);
62 
64  };
65 
66  class GRAYLIB_LINK cCipherAlgDef // : public cObjectFactory
67  {
70  public:
72 
73  protected:
74  cCipherAlgDef(CipherAlgorithm_TYPE eCipherAlgorithm) noexcept
75  : m_eCipherAlgorithm(eCipherAlgorithm)
76  {
77  }
78  virtual ~cCipherAlgDef()
79  {
80  }
81 
82  public:
84  {
86  return this->m_eCipherAlgorithm;
87  }
88  virtual cCipherBase* AllocCipherAlg(bool bEncodeMode) const = 0;
89  };
90 
91  class GRAYLIB_LINK cCipherAlgMgr : public cSingleton<cCipherAlgMgr>
92  {
94  private:
96  public:
97  cCipherAlgMgr();
98  void AddCipherAlg(const cCipherAlgDef* pDef)
99  {
100  m_a.Add(pDef);
101  }
103  {
104  return m_a.FindArgForKey(e);
105  }
106  const cCipherAlgDef* GetCipherAlg(SSL_Cipher_TYPE eCipherType) const
107  {
108  const cCipherTypeDef* p = cCipherTypeDef::GetCipherTypeDef(eCipherType);
109  if (p == nullptr)
110  return nullptr;
111  return GetCipherAlg(p->m_eCipherAlgorithm);
112  }
113 
114  void LoadAllCipherAlgs();
115  };
116 
118  {
121  public:
123  {
124  }
125  virtual cCipherBase* AllocCipherAlg(bool bEncodeMode) const
126  {
127  return new cCipherNone(bEncodeMode);
128  }
129  };
130 }
131 
132 #endif
133 
#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
Definition: cCipherTypeDef.h:67
virtual cCipherBase * AllocCipherAlg(bool bEncodeMode) const =0
CipherAlgorithm_TYPE get_HashCode() const noexcept
Definition: cCipherTypeDef.h:83
cCipherAlgDef(CipherAlgorithm_TYPE eCipherAlgorithm) noexcept
Definition: cCipherTypeDef.h:74
const CipherAlgorithm_TYPE m_eCipherAlgorithm
Definition: cCipherTypeDef.h:71
virtual ~cCipherAlgDef()
Definition: cCipherTypeDef.h:78
Definition: cCipherTypeDef.h:92
void AddCipherAlg(const cCipherAlgDef *pDef)
Definition: cCipherTypeDef.h:98
const cCipherAlgDef * GetCipherAlg(SSL_Cipher_TYPE eCipherType) const
Definition: cCipherTypeDef.h:106
const cCipherAlgDef * GetCipherAlg(CipherAlgorithm_TYPE e) const
Definition: cCipherTypeDef.h:102
Definition: cCipherTypeDef.h:118
virtual cCipherBase * AllocCipherAlg(bool bEncodeMode) const
Definition: cCipherTypeDef.h:125
cCipherAlgNone()
Definition: cCipherTypeDef.h:122
Definition: cCipherBase.h:125
Definition: cCipherBase.h:261
Definition: cCipherTypeDef.h:35
CIPHER_BLOCK_TYPE m_eBlockMode
Cipher mode (e.g. CIPHER_BLOCK_CBC)
Definition: cCipherTypeDef.h:44
UNITTEST_FRIEND(cCipherTypeDef)
CipherAlgorithm_TYPE m_eCipherAlgorithm
Base cipher algorithm implementation for SSL_Cipher_TYPE. Indicates what cCipherBase to use.
Definition: cCipherTypeDef.h:58
size_t m_nBlockAlignSize
block size, in bytes, size_t
Definition: cCipherTypeDef.h:55
static const cCipherTypeDef *GRAYCALL GetCipherTypeDef(SSL_Cipher_TYPE eCipherType)
Definition: cCipherTypeDef.cpp:68
CipherKeySize_TYPE m_nSizeKey
Definition: cCipherTypeDef.h:48
size_t m_nSizeIV
IV/NONCE size, in bytes. For cipher that accept many sizes: recommended size.
Definition: cCipherTypeDef.h:50
CipherVariable_TYPE m_nVarFlags
Flags for variable IV size, variable key size, etc.
Definition: cCipherTypeDef.h:53
TYPE_PTR FindArgForKey(TYPE_KEY key1) const noexcept
Definition: cArraySort.h:455
Definition: cArraySort.h:613
ITERATE_t Add(TYPE_ARG pNew)
Definition: cArraySort.h:186
Definition: cSingleton.h:127
Definition: cMesh.h:22
CipherVariable_TYPE
Definition: cCipherBase.h:43
CIPHER_BLOCK_TYPE
Definition: cCipherBase.h:73
CipherAlgorithm_TYPE
Definition: cCipherBase.h:22
@ CipherAlgorithm_NULL
Definition: cCipherBase.h:28
SSL_Cipher_TYPE
Definition: cCipherTypeDef.h:22
@ SSL_Cipher_NONE
Definition: cCipherTypeDef.h:27
@ SSL_Cipher_QTY
Definition: cCipherTypeDef.h:31
CipherKeySize_TYPE
Definition: cCipherBase.h:51