Finally fixed crypto library!

This commit is contained in:
WolverinDEV 2019-07-07 19:02:28 +02:00
parent 57ba1027c5
commit 79bb9b94cf
2 changed files with 8 additions and 9 deletions

View File

@ -16,14 +16,18 @@
inline std::string name(const std::string& input) { \
uint8_t result[digestLength]; \
tomcrypt::name(input.data(), input.length(), result); \
return std::string((const char*) result, (size_t) digestLength); \
auto _result = std::string((const char*) result, (size_t) digestLength); \
assert(_result.length() == digestLength) \
return _result; \
} \
\
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, (size_t) digestLength); \
auto _result = std::string((const char*) result, (size_t) digestLength); \
assert(_result.length() == digestLength) \
return _result; \
} \
\
\

View File

@ -208,10 +208,6 @@ bool CryptionHandler::generate_key_nonce(
memcpy(&buffer[6], this->iv_struct, this->iv_struct_length);
digest::sha256(buffer, buffer_length, key_cache.key_nonce);
/*
memcpy(key_cache.key, key_nonce.data(), 16);
memcpy(key_cache.nonce, key_nonce.data() + 16, 16);
*/
key_cache.generation = generation;
}
@ -294,7 +290,7 @@ bool CryptionHandler::decryptPacket(protocol::BasicPacket *packet, std::string &
(unsigned long) header.length(), /* header length */
(const unsigned char *) data.data_ptr(),
(unsigned long) data.length(),
(unsigned char *) data.data_ptr(),
(unsigned char *) target_buffer,
(unsigned char *) packet->mac().data_ptr(),
(unsigned long) packet->mac().length(),
&success
@ -309,7 +305,7 @@ bool CryptionHandler::decryptPacket(protocol::BasicPacket *packet, std::string &
return false;
}
//packet->data(pipes::buffer_view{target_buffer, length});
packet->data(pipes::buffer_view{target_buffer, length});
packet->setEncrypted(false);
return true;
}
@ -343,7 +339,6 @@ bool CryptionHandler::encryptPacket(protocol::BasicPacket *packet, std::string &
(unsigned long) packet->header().length(), /* header length */
(uint8_t *) packet->data().data_ptr(), /* The plain text */
(unsigned long) packet->data().length(), /* Plain text length */
// (uint8_t *) packet->data().data_ptr(), /* The result buffer */
(uint8_t *) target_buffer, /* The result buffer */
(uint8_t *) tag_buffer,
(unsigned long *) &tag_length