Fixed ED255 library
This commit is contained in:
		
							parent
							
								
									085d346122
								
							
						
					
					
						commit
						8447b1d7eb
					
				@ -275,10 +275,18 @@ std::string LicenseChain::exportChain() {
 | 
				
			|||||||
	return stream.str();
 | 
						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() {
 | 
					void LicenseChain::addIntermediateEntry() {
 | 
				
			||||||
	auto entry = make_shared<IntermediateLicenseEntry>();
 | 
						auto entry = make_shared<IntermediateLicenseEntry>();
 | 
				
			||||||
	uint8_t seed[32 * 2]; //FIXME more secure
 | 
						_ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData);
 | 
				
			||||||
	ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData, seed);
 | 
					 | 
				
			||||||
	entry->key.privateKey = true;
 | 
						entry->key.privateKey = true;
 | 
				
			||||||
	entry->_begin = system_clock::now() - hours(16);
 | 
						entry->_begin = system_clock::now() - hours(16);
 | 
				
			||||||
	entry->_end = 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) {
 | 
					std::shared_ptr<LicenseEntry> LicenseChain::addServerEntry(ServerLicenseType type, const std::string &issuer, uint32_t slots) {
 | 
				
			||||||
	auto entry = make_shared<ServerLicenseEntry>();
 | 
						auto entry = make_shared<ServerLicenseEntry>();
 | 
				
			||||||
	uint8_t seed[32 * 2]; //FIXME more secure
 | 
						_ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData);
 | 
				
			||||||
	ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData, seed);
 | 
					 | 
				
			||||||
	entry->key.privateKey = true;
 | 
						entry->key.privateKey = true;
 | 
				
			||||||
	entry->issuer = issuer;
 | 
						entry->issuer = issuer;
 | 
				
			||||||
	entry->licenseType = type;
 | 
						entry->licenseType = type;
 | 
				
			||||||
@ -303,8 +310,7 @@ std::shared_ptr<LicenseEntry> LicenseChain::addServerEntry(ServerLicenseType typ
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void LicenseChain::addEphemeralEntry() {
 | 
					void LicenseChain::addEphemeralEntry() {
 | 
				
			||||||
	auto entry = make_shared<EphemeralLicenseEntry>();
 | 
						auto entry = make_shared<EphemeralLicenseEntry>();
 | 
				
			||||||
	uint8_t seed[32 * 2]; //FIXME more secure
 | 
						_ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData);
 | 
				
			||||||
	ed25519_create_keypair(entry->key.publicKeyData, entry->key.privateKeyData, seed);
 | 
					 | 
				
			||||||
	entry->key.privateKey = true;
 | 
						entry->key.privateKey = true;
 | 
				
			||||||
	entry->_begin = system_clock::now() - hours(6);
 | 
						entry->_begin = system_clock::now() - hours(6);
 | 
				
			||||||
	entry->_end = system_clock::now() + hours(6);
 | 
						entry->_end = system_clock::now() + hours(6);
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,7 @@
 | 
				
			|||||||
	}                                                                                           \
 | 
						}                                                                                           \
 | 
				
			||||||
																								\
 | 
																													\
 | 
				
			||||||
	inline std::string name(const char* input, int64_t length = -1) {                           \
 | 
						inline std::string name(const char* input, int64_t length = -1) {                           \
 | 
				
			||||||
 | 
						    if(length == -1) length = strlen(input);                                                \
 | 
				
			||||||
		uint8_t result[digestLength];                                                           \
 | 
							uint8_t result[digestLength];                                                           \
 | 
				
			||||||
		tomcrypt::name(input, length, result);                                                  \
 | 
							tomcrypt::name(input, length, result);                                                  \
 | 
				
			||||||
		return std::string((const char*) result, digestLength);                                 \
 | 
							return std::string((const char*) result, digestLength);                                 \
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user