Reversed stuff

This commit is contained in:
WolverinDEV 2019-07-07 14:32:17 +02:00
parent 8447b1d7eb
commit 6259ebd531

View File

@ -305,9 +305,18 @@ bool CryptionHandler::encryptPacket(protocol::BasicPacket *packet, std::string &
return false;
}
size_t length = packet->data().length();
size_t tag_length = 8;
char tag_buffer[8];
size_t target_length = 2048;
uint8_t target_buffer[2048];
if(target_length < length) {
error = "buffer too large";
return false;
}
int err;
if((err = eax_encrypt_authenticate_memory(find_cipher("rijndael"),
(uint8_t *) key, /* the key */
@ -318,7 +327,8 @@ 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 *) packet->data().data_ptr(), /* The result buffer */
(uint8_t *) target_buffer, /* The result buffer */
(uint8_t *) tag_buffer,
(unsigned long *) &tag_length
)) != CRYPT_OK){
@ -326,7 +336,9 @@ bool CryptionHandler::encryptPacket(protocol::BasicPacket *packet, std::string &
return false;
}
assert(tag_length == 8);
packet->mac().write(tag_buffer, tag_length);
packet->data(pipes::buffer_view{target_buffer, length});
packet->mac().write(tag_buffer, tag_length);
packet->setEncrypted(true);
return true;
}