Teaspeak-Server/client/src/Identity.h

44 lines
1.2 KiB
C++

#pragma once
#include <tomcrypt.h>
#include <string>
namespace ts {
class Identity {
public:
static Identity* createNew();
explicit Identity(std::string data);
Identity(std::string asnStruct,int64_t keyOffset,int64_t lastCheckedOffset);
~Identity();
bool valid(){ return keyPair != nullptr; }
std::string publicKey();
std::string privateKey();
std::string exportIdentity();
ecc_key* getKeyPair(){
return keyPair;
}
ecc_key& getPrivateKey();
bool improveSecurityLevel(int target);
bool improveSecurityLevelMultithreaded(int target, int nthread = 4, size_t nblockSize = 1000, size_t baseOffset = 0, bool verbose = false);
int getSecurityLevel();
int64_t lastValidKeyOffset(){ return keyOffset; }
int64_t lastTestedKeyOffset(){ return lastCheckedOffset; }
private:
Identity();
int getSecurityLevel(char* hasBuffer, size_t keyLength, int64_t offset);
void importKey(std::string asn1);
ecc_key* keyPair = nullptr;
size_t keyOffset;
size_t lastCheckedOffset;
};
}