summaryrefslogtreecommitdiffstats
path: root/src/PolarSSL++/CtrDrbgContext.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-04-30 17:05:13 +0200
committerMattes D <github@xoft.cz>2014-04-30 17:05:13 +0200
commit014fab58e6eafce87a092aa859c5008dbdaa5c7b (patch)
treeac4ea8515e0461483714e18cef7bbb961f0fbec3 /src/PolarSSL++/CtrDrbgContext.h
parentDelayed sending the KeepAlive packet for 3 seconds after login. (diff)
parentRemoved unneeded #includes. (diff)
downloadcuberite-014fab58e6eafce87a092aa859c5008dbdaa5c7b.tar
cuberite-014fab58e6eafce87a092aa859c5008dbdaa5c7b.tar.gz
cuberite-014fab58e6eafce87a092aa859c5008dbdaa5c7b.tar.bz2
cuberite-014fab58e6eafce87a092aa859c5008dbdaa5c7b.tar.lz
cuberite-014fab58e6eafce87a092aa859c5008dbdaa5c7b.tar.xz
cuberite-014fab58e6eafce87a092aa859c5008dbdaa5c7b.tar.zst
cuberite-014fab58e6eafce87a092aa859c5008dbdaa5c7b.zip
Diffstat (limited to '')
-rw-r--r--src/PolarSSL++/CtrDrbgContext.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/PolarSSL++/CtrDrbgContext.h b/src/PolarSSL++/CtrDrbgContext.h
new file mode 100644
index 000000000..65e9a2374
--- /dev/null
+++ b/src/PolarSSL++/CtrDrbgContext.h
@@ -0,0 +1,63 @@
+
+// CtrDrbgContext.h
+
+// Declares the cCtrDrbgContext class representing a wrapper over CTR-DRBG implementation in PolarSSL
+
+
+
+
+
+#pragma once
+
+#include "polarssl/ctr_drbg.h"
+
+
+
+
+
+// fwd: EntropyContext.h
+class cEntropyContext;
+
+
+
+
+
+class cCtrDrbgContext
+{
+ friend class cSslContext;
+ friend class cRsaPrivateKey;
+ friend class cPublicKey;
+
+public:
+ /** Constructs the context with a new entropy context. */
+ cCtrDrbgContext(void);
+
+ /** Constructs the context with the specified entropy context. */
+ cCtrDrbgContext(const SharedPtr<cEntropyContext> & a_EntropyContext);
+
+ /** Initializes the context.
+ a_Custom is optional additional data to use for entropy, nullptr is accepted.
+ Returns 0 if successful, PolarSSL error code on failure. */
+ int Initialize(const void * a_Custom, size_t a_CustomSize);
+
+ /** Returns true if the object is valid (has been initialized properly) */
+ bool IsValid(void) const { return m_IsValid; }
+
+protected:
+ /** The entropy source used for generating the random */
+ SharedPtr<cEntropyContext> m_EntropyContext;
+
+ /** The random generator context */
+ ctr_drbg_context m_CtrDrbg;
+
+ /** Set to true if the object is valid (has been initialized properly) */
+ bool m_IsValid;
+
+
+ /** Returns the internal context ptr. Only use in PolarSSL API calls. */
+ ctr_drbg_context * GetInternal(void) { return &m_CtrDrbg; }
+} ;
+
+
+
+