mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-10-26 13:56:05 +03:00
feat(net): add SRP6_Random
This commit is contained in:
parent
ae66f35543
commit
4d63d1ea8b
16
src/net/srp/SRP6_Random.cpp
Normal file
16
src/net/srp/SRP6_Random.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "net/srp/SRP6_Random.hpp"
|
||||
#include <cstring>
|
||||
#include <common/SHA1.hpp>
|
||||
|
||||
SRP6_Random::SRP6_Random(const void* seed, uint32_t seedLen) {
|
||||
SHA1_CONTEXT ctx;
|
||||
SHA1_Init(&ctx);
|
||||
SHA1_Update(&ctx, static_cast<const uint8_t*>(seed), seedLen);
|
||||
SHA1_Final(reinterpret_cast<uint8_t*>(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;
|
||||
}
|
||||
18
src/net/srp/SRP6_Random.hpp
Normal file
18
src/net/srp/SRP6_Random.hpp
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef NET_SRP_SRP6_RANDOM_HPP
|
||||
#define NET_SRP_SRP6_RANDOM_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
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
|
||||
Loading…
Reference in New Issue
Block a user