Crypto update
This commit is contained in:
parent
0fbff778c2
commit
707ae813e9
@ -3,7 +3,7 @@
|
|||||||
#include <tomcrypt.h>
|
#include <tomcrypt.h>
|
||||||
|
|
||||||
#define DECLARE_DIGEST(name, _unused_, digestLength) \
|
#define DECLARE_DIGEST(name, _unused_, digestLength) \
|
||||||
void digest::tomcrypt::name(const char* input, size_t length, uint8_t(& result)[digestLength]) { \
|
void digest::tomcrypt::name(const char* input, size_t length, uint8_t* result) { \
|
||||||
hash_state hash{}; \
|
hash_state hash{}; \
|
||||||
\
|
\
|
||||||
name ##_init(&hash); \
|
name ##_init(&hash); \
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#define DECLARE_DIGEST(name, _unused_, digestLength) \
|
#define DECLARE_DIGEST(name, _unused_, digestLength) \
|
||||||
namespace tomcrypt { \
|
namespace tomcrypt { \
|
||||||
extern void name(const char* input, size_t length, uint8_t(& result)[digestLength]); \
|
extern void name(const char* input, size_t length, uint8_t* result); \
|
||||||
} \
|
} \
|
||||||
inline std::string name(const std::string& input) { \
|
inline std::string name(const std::string& input) { \
|
||||||
uint8_t result[digestLength]; \
|
uint8_t result[digestLength]; \
|
||||||
@ -28,6 +28,10 @@
|
|||||||
\
|
\
|
||||||
inline void name(const char* input, size_t length, uint8_t(& result)[digestLength]) { \
|
inline void name(const char* input, size_t length, uint8_t(& result)[digestLength]) { \
|
||||||
tomcrypt::name(input, length, result); \
|
tomcrypt::name(input, length, result); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
inline void name(const char* input, size_t length, uint8_t* result) { \
|
||||||
|
tomcrypt::name(input, length, result); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -47,6 +51,10 @@
|
|||||||
\
|
\
|
||||||
inline void name(const char* input, size_t length, uint8_t(& result)[digestLength]) { \
|
inline void name(const char* input, size_t length, uint8_t(& result)[digestLength]) { \
|
||||||
method((u_char*) input, length, result); \
|
method((u_char*) input, length, result); \
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
inline void name(const char* input, size_t length, uint8_t* result) { \
|
||||||
|
method((u_char*) input, length, result); \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ bool CryptionHandler::setupSharedSecretNew(const std::string &alpha, const std::
|
|||||||
sharedIv.resize(64, '\0');
|
sharedIv.resize(64, '\0');
|
||||||
keyMul((uint8_t*) shared.data(), reinterpret_cast<const uint8_t *>(publicKey), reinterpret_cast<const uint8_t *>(privateKey), true); //Remote key get negated
|
keyMul((uint8_t*) shared.data(), reinterpret_cast<const uint8_t *>(publicKey), reinterpret_cast<const uint8_t *>(privateKey), true); //Remote key get negated
|
||||||
sharedIv = digest::sha512(shared);
|
sharedIv = digest::sha512(shared);
|
||||||
|
digest::sha512(shared.data(), 32, sharedIv.data());
|
||||||
auto xor_key = alpha + beta;
|
auto xor_key = alpha + beta;
|
||||||
for(int i = 0; i < 64; i++)
|
for(int i = 0; i < 64; i++)
|
||||||
sharedIv[i] ^= xor_key[i];
|
sharedIv[i] ^= xor_key[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user