From 4d63d1ea8b6bbcc236ac2ad915a43d9f3a702f99 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sun, 8 Jan 2023 22:21:42 -0600 Subject: [PATCH] feat(net): add SRP6_Random --- src/net/srp/SRP6_Random.cpp | 16 ++++++++++++++++ src/net/srp/SRP6_Random.hpp | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/net/srp/SRP6_Random.cpp create mode 100644 src/net/srp/SRP6_Random.hpp diff --git a/src/net/srp/SRP6_Random.cpp b/src/net/srp/SRP6_Random.cpp new file mode 100644 index 0000000..7522797 --- /dev/null +++ b/src/net/srp/SRP6_Random.cpp @@ -0,0 +1,16 @@ +#include "net/srp/SRP6_Random.hpp" +#include +#include + +SRP6_Random::SRP6_Random(const void* seed, uint32_t seedLen) { + SHA1_CONTEXT ctx; + SHA1_Init(&ctx); + SHA1_Update(&ctx, static_cast(seed), seedLen); + SHA1_Final(reinterpret_cast(this->m_randkey1), &ctx); + + memcpy(this->m_randkey2, this->m_randkey1, sizeof(this->m_randkey2)); + + memset(this->m_randpool, 0, sizeof(this->m_randpool)); + + this->m_inpool = 0; +} diff --git a/src/net/srp/SRP6_Random.hpp b/src/net/srp/SRP6_Random.hpp new file mode 100644 index 0000000..e799f3b --- /dev/null +++ b/src/net/srp/SRP6_Random.hpp @@ -0,0 +1,18 @@ +#ifndef NET_SRP_SRP6_RANDOM_HPP +#define NET_SRP_SRP6_RANDOM_HPP + +#include + +class SRP6_Random { + public: + // Member variables + char m_randkey1[20]; + char m_randkey2[20]; + char m_randpool[20]; + uint32_t m_inpool; + + // Member functions + SRP6_Random(const void* seed, uint32_t seedLen); +}; + +#endif