implemented anon flags in logger
All checks were successful
Codacy Scan / Codacy Security Scan (push) Successful in 1m45s
Build WHY2-chat / test-why2 (./out/why2-chat-client, ./configure.sh, ubuntu-latest, ./out/why2-chat-server) (push) Successful in 3m42s
Test Project / test-project (./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./test) (push) Successful in 3m41s
Test WHY2-core / test-why2 (why2, ./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./out/why2-core-test, valgrind --leak-check=full --show-leak-kinds=reachable --track-origins=yes -s) (push) Successful in 4m11s
Test WHY2-logger / test-why2 (why2-logger, ./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./out/why2-logger-test, valgrind --leak-check=full --show-leak-kinds=reachable --track-origins=yes -s) (push) Successful in 4m24s

This commit is contained in:
Václav Šmejkal 2025-01-13 19:55:54 +01:00
parent 520f8bce34
commit 17a73d9157
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
2 changed files with 17 additions and 2 deletions

View File

@ -29,7 +29,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <why2/logger/flags.h>
#include <why2/logger/utils.h>
#include <why2/crypto.h>
#include <why2/encrypter.h>
#include <why2/flags.h>
#include <why2/memory.h>
#include <why2/misc.h>
@ -94,6 +96,9 @@ why2_log_file why2_init_logger(char *directoryPath)
}
}
//SET ENCRYPTER FLAGS
if (!why2_get_flags_changed()) __why2_set_flags_anon((why2_input_flags) { 0, 1, 0, WHY2_v4, WHY2_OUTPUT_TEXT, 64 });
//DEALLOCATION
why2_deallocate(dateBuffer);
why2_deallocate(latestBuffer);
@ -131,8 +136,7 @@ void why2_write_log(int loggerFile, char *logMessage)
struct tm tm = *localtime(&timeL);
why2_log_flags flags = why2_get_log_flags();
//SET ENCRYPTER FLAGS
if (!why2_get_flags_changed()) why2_set_flags((why2_input_flags) { 0, 1, 0, WHY2_v4, WHY2_OUTPUT_TEXT, 63 });
if (!why2_get_padding_changed()) __why2_set_padding_anon(WHY2_RECOMMENDED_PADDING_RATE(strlen(logMessageUsed)));
if (flags.key != NULL) //ENCRYPT TEXT IF KEY WAS CHANGED
{

View File

@ -107,6 +107,17 @@ why2_decrypted_output why2_decrypt_logger(why2_log_file logger)
for (int i = 0; i < lines; i++) //DECRYPT content
{
if (!why2_get_padding_changed())
{
printf("A\n");
unsigned long length_buffer = 1;
for (unsigned long j = 0; j < strlen(content[i]); j++)
{
if (content[i][j] == why2_get_encryption_separator()) length_buffer++;
}
__why2_set_padding_anon(length_buffer / 4);
}
outputBuffer = why2_decrypt_text(content[i], why2_get_log_flags().key); //DECRYPT
contentDecrypted[i] = why2_strdup(outputBuffer.output_text); //COPY