Cuberite
A lightweight, fast and extensible game server for Minecraft
CtrDrbgContext.h
Go to the documentation of this file.
1 
2 // CtrDrbgContext.h
3 
4 // Declares the cCtrDrbgContext class representing a wrapper over CTR-DRBG implementation in mbedTLS
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "mbedtls/ctr_drbg.h"
13 
14 
15 
16 
17 
18 // fwd: EntropyContext.h
19 class cEntropyContext;
20 
21 
22 
23 
24 
26 {
27  friend class cSslConfig;
28  friend class cRsaPrivateKey;
29  friend class cCryptoKey;
30 
31 public:
33  cCtrDrbgContext(void);
34 
36  cCtrDrbgContext(const std::shared_ptr<cEntropyContext> & a_EntropyContext);
37 
41  int Initialize(const void * a_Custom, size_t a_CustomSize);
42 
44  bool IsValid(void) const { return m_IsValid; }
45 
46 protected:
48  std::shared_ptr<cEntropyContext> m_EntropyContext;
49 
51  mbedtls_ctr_drbg_context m_CtrDrbg;
52 
54  bool m_IsValid;
55 
56 
58  mbedtls_ctr_drbg_context * GetInternal(void) { return &m_CtrDrbg; }
59 } ;
60 
61 
62 
63 
bool IsValid(void) const
Returns true if the object is valid (has been initialized properly)
bool m_IsValid
Set to true if the object is valid (has been initialized properly)
cCtrDrbgContext(void)
Constructs the context with a new entropy context.
mbedtls_ctr_drbg_context * GetInternal(void)
Returns the internal context ptr.
int Initialize(const void *a_Custom, size_t a_CustomSize)
Initializes the context.
mbedtls_ctr_drbg_context m_CtrDrbg
The random generator context.
std::shared_ptr< cEntropyContext > m_EntropyContext
The entropy source used for generating the random.
Encapsulates an RSA private key used in PKI cryptography.
Definition: RsaPrivateKey.h:21