This commit is contained in:
WolverinDEV 2019-07-07 14:05:44 +02:00
commit 1c293e4f2e
2 changed files with 13 additions and 6 deletions

View File

@ -275,10 +275,18 @@ std::string LicenseChain::exportChain() {
return stream.str();
}
inline void _ed25519_create_keypair(uint8_t(&public_key)[32], uint8_t(&private_key)[32]) {
uint8_t seed[32];
ed25519_create_seed(seed);
uint8_t buffer_private[64]; /* Because we word with SHA512 we required 64 bytes! */
ed25519_create_keypair(public_key, buffer_private, seed);
memcpy(private_key, buffer_private, 32);
}
void LicenseChain::addIntermediateEntry() {
auto entry = make_shared<IntermediateLicenseEntry>();
uint8_t seed[32 * 2]; //FIXME more secure
ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData, seed);
_ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData);
entry->key.privateKey = true;
entry->_begin = system_clock::now() - hours(16);
entry->_end = system_clock::now() + hours(16);
@ -289,8 +297,7 @@ void LicenseChain::addIntermediateEntry() {
std::shared_ptr<LicenseEntry> LicenseChain::addServerEntry(ServerLicenseType type, const std::string &issuer, uint32_t slots) {
auto entry = make_shared<ServerLicenseEntry>();
uint8_t seed[32 * 2]; //FIXME more secure
ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData, seed);
_ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData);
entry->key.privateKey = true;
entry->issuer = issuer;
entry->licenseType = type;
@ -303,8 +310,7 @@ std::shared_ptr<LicenseEntry> LicenseChain::addServerEntry(ServerLicenseType typ
void LicenseChain::addEphemeralEntry() {
auto entry = make_shared<EphemeralLicenseEntry>();
uint8_t seed[32 * 2]; //FIXME more secure
ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData, seed);
_ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData);
entry->key.privateKey = true;
entry->_begin = system_clock::now() - hours(6);
entry->_end = system_clock::now() + hours(6);

View File

@ -20,6 +20,7 @@
} \
\
inline std::string name(const char* input, int64_t length = -1) { \
if(length == -1) length = strlen(input); \
uint8_t result[digestLength]; \
tomcrypt::name(input, length, result); \
return std::string((const char*) result, digestLength); \