mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-16 04:32:29 +00:00
feat(net): add SRP6_Client
This commit is contained in:
parent
5d1a800076
commit
cb62e2dcfe
5 changed files with 45 additions and 2 deletions
24
src/net/srp/SRP6_Client.cpp
Normal file
24
src/net/srp/SRP6_Client.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "net/srp/SRP6_Client.hpp"
|
||||
#include <cstring>
|
||||
|
||||
int32_t SRP6_Client::BeginAuthentication(const char* accountName, const char* password) {
|
||||
if (!accountName || !password) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SHA1_Init(&this->ctx);
|
||||
|
||||
SHA1_CONTEXT ctx;
|
||||
|
||||
SHA1_Init(&ctx);
|
||||
SHA1_Update(&ctx, reinterpret_cast<const uint8_t*>(accountName), strlen(accountName));
|
||||
SHA1_Final(this->accountNameDigest, &ctx);
|
||||
|
||||
SHA1_Init(&ctx);
|
||||
SHA1_Update(&ctx, reinterpret_cast<const uint8_t*>(accountName), strlen(accountName));
|
||||
SHA1_Update(&ctx, reinterpret_cast<const uint8_t*>(":"), 1u);
|
||||
SHA1_Update(&ctx, reinterpret_cast<const uint8_t*>(password), strlen(password));
|
||||
SHA1_Final(this->interimDigest, &ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
17
src/net/srp/SRP6_Client.hpp
Normal file
17
src/net/srp/SRP6_Client.hpp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef NET_SRP_SRP6_CLIENT_HPP
|
||||
#define NET_SRP_SRP6_CLIENT_HPP
|
||||
|
||||
#include <common/SHA1.hpp>
|
||||
|
||||
class SRP6_Client {
|
||||
public:
|
||||
// Member variables
|
||||
uint8_t accountNameDigest[SHA1_DIGEST_SIZE];
|
||||
uint8_t interimDigest[SHA1_DIGEST_SIZE];
|
||||
SHA1_CONTEXT ctx;
|
||||
|
||||
// Member functions
|
||||
int32_t BeginAuthentication(const char* accountName, const char* password);
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue