feat(net): add SRP6_Client

This commit is contained in:
fallenoak 2023-01-05 22:49:20 -06:00 committed by GitHub
parent 5d1a800076
commit cb62e2dcfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 2 deletions

View 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;
}