[Crypto] Implement CryptoCore::RandomGenerator.
As a cryptographically secure random generator. Internally it uses mbedTLS CTR-DRBG implementation which gets re-seeded with entropy from OS::get_entropy when needed. CryptoCore now additionally depends on `ctr_drbg.c` and `entropy.c` thirdparty mbedtls files.
This commit is contained in:
@ -35,9 +35,24 @@
|
||||
|
||||
class CryptoCore {
|
||||
public:
|
||||
class RandomGenerator {
|
||||
private:
|
||||
void *entropy = nullptr;
|
||||
void *ctx = nullptr;
|
||||
|
||||
static int _entropy_poll(void *p_data, unsigned char *r_buffer, size_t p_len, size_t *r_len);
|
||||
|
||||
public:
|
||||
RandomGenerator();
|
||||
~RandomGenerator();
|
||||
|
||||
Error init();
|
||||
Error get_random_bytes(uint8_t *r_buffer, size_t p_bytes);
|
||||
};
|
||||
|
||||
class MD5Context {
|
||||
private:
|
||||
void *ctx = nullptr; // To include, or not to include...
|
||||
void *ctx = nullptr;
|
||||
|
||||
public:
|
||||
MD5Context();
|
||||
@ -50,7 +65,7 @@ public:
|
||||
|
||||
class SHA1Context {
|
||||
private:
|
||||
void *ctx = nullptr; // To include, or not to include...
|
||||
void *ctx = nullptr;
|
||||
|
||||
public:
|
||||
SHA1Context();
|
||||
@ -63,7 +78,7 @@ public:
|
||||
|
||||
class SHA256Context {
|
||||
private:
|
||||
void *ctx = nullptr; // To include, or not to include...
|
||||
void *ctx = nullptr;
|
||||
|
||||
public:
|
||||
SHA256Context();
|
||||
@ -76,7 +91,7 @@ public:
|
||||
|
||||
class AESContext {
|
||||
private:
|
||||
void *ctx = nullptr; // To include, or not to include...
|
||||
void *ctx = nullptr;
|
||||
|
||||
public:
|
||||
AESContext();
|
||||
|
||||
Reference in New Issue
Block a user