mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
profile complete sha512 generation
This commit is contained in:
parent
e5c3b3978a
commit
d8c9c91d0c
@ -88,14 +88,17 @@ bool KeyPair::generateFromPassphrase(const char* passphrase, const Mnemonic* wor
|
||||
//crypto_auth_hmacsha512_state state;
|
||||
size_t word_index_size = sizeof(word_indices);
|
||||
//crypto_auth_hmacsha512_init(&state, (unsigned char*)word_indices, sizeof(word_indices));
|
||||
Profiler timeSum;
|
||||
sha512_init(&state);
|
||||
|
||||
Profiler timeUsed;
|
||||
sha512_update(&state, *word_indices, word_indices->size());
|
||||
printf("time used in one step: %s\n", timeUsed.string().data());
|
||||
auto timeUsedString = timeUsed.string();
|
||||
|
||||
sha512_update(&state, (unsigned char*)clearPassphrase.data(), clearPassphrase.size());
|
||||
//crypto_auth_hmacsha512_update(&state, (unsigned char*)passphrase, pass_phrase_size);
|
||||
sha512_final(&state, hash);
|
||||
printf("timeSum: %s\n", timeSum.string().data());
|
||||
printf("time used in one step: %s\n", timeUsedString.data());
|
||||
//crypto_auth_hmacsha512_final(&state, hash);
|
||||
|
||||
/*
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
#include "KeyPairEd25519.h"
|
||||
#include <assert.h>
|
||||
// using sha512 from iroha-ed because it need half the time as sodium
|
||||
#include "ed25519/ed25519.h"
|
||||
|
||||
#include "../SingletonManager/ErrorManager.h"
|
||||
|
||||
@ -51,12 +53,15 @@ KeyPairEd25519* KeyPairEd25519::create(const Passphrase* passphrase)
|
||||
std::string clear_passphrase = passphrase->createClearPassphrase();
|
||||
|
||||
crypto_hash_sha512_state state;
|
||||
//sha_context state;
|
||||
|
||||
unsigned char hash[crypto_hash_sha512_BYTES];
|
||||
//crypto_auth_hmacsha512_state state;
|
||||
size_t word_index_size = sizeof(word_indices);
|
||||
//crypto_auth_hmacsha512_init(&state, (unsigned char*)word_indices, sizeof(word_indices));
|
||||
Profiler timeSum;
|
||||
crypto_hash_sha512_init(&state);
|
||||
//sha512_init(&state);
|
||||
Profiler timeUsed;
|
||||
//Poco::UInt64 valueBuffer[PHRASE_WORD_COUNT];
|
||||
auto value_buffer = mm->getFreeMemory(PHRASE_WORD_COUNT * sizeof(Poco::UInt64));
|
||||
@ -65,12 +70,22 @@ KeyPairEd25519* KeyPairEd25519::create(const Passphrase* passphrase)
|
||||
value_buffer_p[i] = word_indices[i];
|
||||
}
|
||||
auto betweenTime = timeUsed.string();
|
||||
crypto_hash_sha512_update(&state, *value_buffer, sizeof(Poco::UInt64) * PHRASE_WORD_COUNT);
|
||||
printf("time used in for loop: %s (between: %s)\n", timeUsed.string().data(), betweenTime.data());
|
||||
//crypto_hash_sha512_update(&state, *value_buffer, sizeof(Poco::UInt64) * PHRASE_WORD_COUNT);
|
||||
//sha512_update(&state, *value_buffer, sizeof(Poco::UInt64) * PHRASE_WORD_COUNT);
|
||||
Profiler timeUsed2;
|
||||
//sha512_update(&state, (const unsigned char*)value_buffer_p, value_buffer->size());
|
||||
crypto_hash_sha512_update(&state, (const unsigned char*)value_buffer_p, value_buffer->size());
|
||||
//sha512_update(&state, *value_buffer, value_buffer->size());
|
||||
auto timeUsed2String = timeUsed2.string();
|
||||
//crypto_hash_sha512_update(&state, (const unsigned char*)word_indices, PHRASE_WORD_COUNT * sizeof(Poco::UInt16));
|
||||
crypto_hash_sha512_update(&state, (unsigned char*)clear_passphrase.data(), clear_passphrase.size());
|
||||
//sha512_update(&state, (unsigned char*)clear_passphrase.data(), clear_passphrase.size());
|
||||
//crypto_auth_hmacsha512_update(&state, (unsigned char*)passphrase, pass_phrase_size);
|
||||
//crypto_hash_sha512_final(&state, hash);
|
||||
//sha512_final(&state, hash);
|
||||
crypto_hash_sha512_final(&state, hash);
|
||||
printf("timeSum: %s\n", timeSum.string().data());
|
||||
printf("time used in for loop: %s (between: %s)\n", timeUsed2String.data(), betweenTime.data());
|
||||
//crypto_auth_hmacsha512_final(&state, hash);
|
||||
|
||||
/*
|
||||
|
||||
@ -165,7 +165,7 @@ namespace DataTypeConverter
|
||||
|
||||
sodium_bin2hex(*hex, hexSize, pubkey, binSize);
|
||||
|
||||
std::string hexString((const char*)*hex, hexSize);
|
||||
std::string hexString((const char*)*hex, hexSize-1);
|
||||
mm->releaseMemory(hex);
|
||||
return hexString;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user