Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cSSLConfig.h
Go to the documentation of this file.
1 //
3 //
4 #ifndef _INC_cSSLConfig_H
5 #define _INC_cSSLConfig_H
6 #ifndef NO_PRAGMA_ONCE
7 #pragma once
8 #endif
9 
10 #include "GraySSLInt.h"
17 
18 namespace GraySSL
19 {
21  {
29 
33  };
34 
36  {
39 
43  };
44 
46  {
49 
50  public:
51 
53 
55 
57 
58  bool m_bAllowRC4;
59  const SSL_CipherSuite_t* m_pCipherSuiteList[SSL_VERSION_QTY];
60 
62 
63  // extension RFC 7301 Application Layer Protocol Negotiation.
64  const char** m_ppAlpnList;
65 
67 
69 
70 #if defined(USE_SSL_RENEGOTIATION)
71  bool m_bRenegotiationEnable;
72  int m_nRenegotiationMaxRecords;
73  cSSLCtr m_renego_period;
74 #endif
75 
76 #if defined(USE_SSL_SESSION_TICKETS)
79 #endif
80 
82 
83  // TODO Replace Cert validation scheme!
85 
86 #if defined(USE_SSL_X509_CRT_PARSE)
89 #endif
90 
91 #if defined(USE_SSL_DHM)
94 #endif
95 
96  public:
97  cSSLConfig();
98  ~cSSLConfig();
99 
100  bool CheckOpts();
101 
102  void SetCipherSuiteList(const SSL_CipherSuite_t* ciphersuites, SSL_VERSION_TYPE v);
103  void put_AllowRC4(bool bAllowRC4);
104 
105  bool IsECPGroupAllowed(const cECPGroup& grp) const;
106 
108  {
110  this->m_eAuthMode = eAuthMode;
111  }
112 
113  void put_VerifyCert(IX509VerifyCert* pVerifyCert)
114  {
117  m_pVerifyCert = pVerifyCert;
118  }
119 
120  HRESULT VerifyCrt(cX509Crt* pCrt, const char* pszPeerCN, OUT X509_Verify_t& eVerifyResults) const;
121 
123  {
125  this->m_pRandom = pRandom;
126  }
127 
128  void put_EncryptThenMac(bool etm);
129 
130  void put_UseExtendedMasterSecret(bool ems);
131 
132  void put_VersionMin(SSL_VERSION_TYPE v);
133  void put_VersionMax(SSL_VERSION_TYPE v);
134 
135  HRESULT put_MaxFragLenCode(SSL_MAX_FRAG_TYPE eMaxFragLenCode);
136 
137  void put_UseTruncatedHMAC(bool bTruncatedHMAC)
138  {
141  m_bTruncatedHMAC = bTruncatedHMAC;
142  }
143 
145  {
147  //
153  //
159  //
165 
166  this->m_eRenoLegacyType = allow_legacy;
167  }
168 
169  void put_FallbackSCSV(bool fallback)
170  {
180  this->m_bFallbackSCSV = fallback;
181  }
182 
183  HRESULT put_AlpnProtocols(const char** ppAlpnList);
184 
185  const char* FindAlpn(const BYTE* pFind, StrLen_t nLenFind) const;
186 
187 #if defined(USE_SSL_RENEGOTIATION)
188  void put_RenegotiationEnable(bool enable_renegotiation)
189  {
195  this->m_bRenegotiationEnable = enable_renegotiation;
196  }
197 
198  void put_RenegotiationMaxRecords(int max_records)
199  {
216  //
217  this->m_nRenegotiationMaxRecords = max_records;
218  }
219 
220  void put_RenegotiationPeriod(cSSLCtr c)
221  {
229 
230  this->m_renego_period = c;
231  }
232 #endif // USE_SSL_RENEGOTIATION
233 
234 #if defined(USE_SSL_SESSION_TICKETS)
235  void put_UseSessionTickets(bool bUseTickets)
236  {
243  //
244  this->m_bUseSessionTickets = bUseTickets;
245  }
246 
248  {
251  this->m_nTicketLifeSeconds = lifetime; // Seconds
252  }
253 #endif // USE_SSL_SESSION_TICKETS
254 
255 #if defined(USE_SSL_X509_CRT_PARSE)
256  void SetCAChain(cX509Crt* pCaChain, cX509Crl* pCaCrl)
257  {
261  this->m_pCaChain = pCaChain;
262  this->m_pCaCrl = pCaCrl;
263  }
264 #endif // USE_SSL_X509_CRT_PARSE
265 
266 #if defined(USE_SSL_DHM)
267  HRESULT SetKeyExDHMParams(const char* dhm_P, const char* dhm_G);
269 #endif // USE_SSL_DHM
270 
271  };
272 }
273 
274 #endif
#define GRAYSSL_LINK
Definition: GraySSLInt.h:25
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cBigInteger.h:18
Definition: cBigUnsigned.h:22
Definition: cECPGroupPrefs.h:16
Definition: cECPGroup.h:34
Definition: cKeyExDHM.h:15
Definition: cSSLMsg.h:305
Definition: cSSLSession.h:135
Definition: cX509Crl.h:59
Definition: cX509Crt.h:20
Definition: cSSLConfig.h:46
cRefPtr< cX509Crt > m_pCaChain
own trusted CA chain
Definition: cSSLConfig.h:87
void put_UseTruncatedHMAC(bool bTruncatedHMAC)
Definition: cSSLConfig.h:137
const char ** m_ppAlpnList
ordered list of supported protocols. nullptr terminated.
Definition: cSSLConfig.h:64
bool m_bAllowRC4
flag for enable/disabling SSL_Cipher_RC4_128. default = false. GET RID OF THIS using m_pCipherSuiteLi...
Definition: cSSLConfig.h:58
cBigInteger m_dhm_G
generator for DHM. cKeyExDHM
Definition: cSSLConfig.h:93
cBigUnsigned m_dhm_P
prime modulus for DHM. cKeyExDHM
Definition: cSSLConfig.h:92
IRandomNoise * m_pRandom
random number generator. g_Rand.
Definition: cSSLConfig.h:56
SSL_RENO_LEGACY_TYPE m_eRenoLegacyType
Allow legacy renegotiation.
Definition: cSSLConfig.h:68
void put_VerifyCert(IX509VerifyCert *pVerifyCert)
Definition: cSSLConfig.h:113
SSL_AUTHMODE_TYPE m_eAuthMode
Verification mode for cert failures.
Definition: cSSLConfig.h:81
void put_FallbackSCSV(bool fallback)
Definition: cSSLConfig.h:169
HRESULT SetKeyExDHMParams(const char *dhm_P, const char *dhm_G)
void put_UseSessionTickets(bool bUseTickets)
Definition: cSSLConfig.h:235
bool m_bExtendedMasterSecret
flag for extended master secret. Extended Master Secret, aka Session Hash (draft-ietf-tls-session-has...
Definition: cSSLConfig.h:54
bool m_bUseSessionTickets
use session tickets? (default true for client)
Definition: cSSLConfig.h:77
void put_AuthMode(SSL_AUTHMODE_TYPE eAuthMode)
Definition: cSSLConfig.h:107
TIMESECD_t m_nTicketLifeSeconds
session ticket lifetime
Definition: cSSLConfig.h:78
IX509VerifyCert * m_pVerifyCert
Alternate mechanism to check certs.
Definition: cSSLConfig.h:84
HRESULT SetKeyExDHMParams(cKeyExDHM *dhm_ctx)
cRangeT< SSL_VERSION_TYPE > m_VerRange
What range of versions do we support?
Definition: cSSLConfig.h:52
cRefPtr< cX509Crl > m_pCaCrl
trusted CA CRLs
Definition: cSSLConfig.h:88
cECPGroupPrefs m_ECPGroupsAllowed
Allow only these ECPGroup_TYPE curves. 0 terminated array of ECPGroup_TYPE.
Definition: cSSLConfig.h:61
void SetCAChain(cX509Crt *pCaChain, cX509Crl *pCaCrl)
Definition: cSSLConfig.h:256
bool m_bFallbackSCSV
flag for allowing fallback connections SSL_FALLBACK_SCSV cipher suite ? (Client only)
Definition: cSSLConfig.h:66
void put_RenoLegacyType(SSL_RENO_LEGACY_TYPE allow_legacy)
Definition: cSSLConfig.h:144
void put_RandomNoise(IRandomNoise *pRandom)
Definition: cSSLConfig.h:122
void put_SessionTicketLifetime(TIMESECD_t lifetime)
Definition: cSSLConfig.h:247
Definition: cRefPtr.h:225
Definition: cX509.h:119
X509_Verify_t
Definition: cX509.h:41
SSL_MAX_FRAG_TYPE
Definition: SSLTypes.h:170
SSL_VERSION_TYPE
Definition: SSLTypes.h:66
@ SSL_VERSION_QTY
Definition: SSLTypes.h:75
WORD SSL_CipherSuite_t
SSL_CipherSuite_TYPE stored as 2 bytes.
Definition: SSLTypes.h:110
Definition: GraySSL.cpp:11
SSL_RENO_LEGACY_TYPE
Definition: cSSLConfig.h:36
@ SSL_RENO_LEGACY_BREAK_HANDSHAKE
Definition: cSSLConfig.h:42
@ SSL_RENO_LEGACY_ALLOW_RENEGOTIATION
Definition: cSSLConfig.h:41
@ SSL_RENO_LEGACY_NO_RENEGOTIATION
Definition: cSSLConfig.h:40
SSL_AUTHMODE_TYPE
Definition: cSSLConfig.h:21
@ SSL_AUTHMODE_REQUIRED
peer must present a valid certificate, handshake is aborted if verification failed.
Definition: cSSLConfig.h:32
@ SSL_AUTHMODE_OPTIONAL
peer certificate is checked, Allow to continue even if CA doesn't validate. Just warn.
Definition: cSSLConfig.h:31
@ SSL_AUTHMODE_NONE
Don't bother checking at all. peer certificate is not checked. this is insecure and SHOULD be avoided...
Definition: cSSLConfig.h:30
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
int TIMESECD_t
signed delta seconds. like TIMESEC_t. redefined in TimeUnits.h.
Definition: cTimeSys.h:19
Definition: SSLTypes.h:270
Definition: cRandom.h:19