diff --git a/include/flags.h b/include/flags.h index b474231..24eb164 100644 --- a/include/flags.h +++ b/include/flags.h @@ -39,7 +39,8 @@ enum WHY2_TEXT_KEY_CHAIN_VERSIONS { WHY2_v1, //FIRST VERSION. Replaced on May 28th 17:45:26 2022 UTC in commit 0d64f4fa7c37f0b57914db902258e279a71c7f9a. WHY2_v2, //SECOND VERSION. Replaced on July 11th 17:12:41 2022 UTC in commit 0f01cde0f1e1a9210f4eef7b949e6d247072d3a6. - WHY2_v3 //THIRD VERSION. THE LATEST ONE + WHY2_v3, //THIRD VERSION. + WHY2_v4 }; enum WHY2_OUTPUT_FORMAT diff --git a/src/core/app/main.c b/src/core/app/main.c index 3a61398..d0de1c9 100644 --- a/src/core/app/main.c +++ b/src/core/app/main.c @@ -23,7 +23,7 @@ along with this program. If not, see . int main(void) { //SET FLAGS - why2_set_flags((why2_input_flags) { 1, 1, 0, WHY2_v3, WHY2_OUTPUT_TEXT }); + why2_set_flags((why2_input_flags) { 1, 1, 0, WHY2_v4, WHY2_OUTPUT_TEXT }); //RUN ENCRYPTION WITH WHY2_TEXT_TO_ENCRYPT, GENERATE NEW KEY AND DO NOT CHECK FOR ACTIVE WHY2_VERSION & PREVENT ANY OUTPUT why2_output_flags encryptedText = why2_encrypt_text(WHY2_TEXT_TO_ENCRYPT, NULL); diff --git a/src/core/lib/flags.c b/src/core/lib/flags.c index 0e93c9c..beb7a1c 100644 --- a/src/core/lib/flags.c +++ b/src/core/lib/flags.c @@ -25,7 +25,7 @@ along with this program. If not, see . #include //CONSTS (this is just local) -#define DEFAULT_FLAGS (why2_input_flags) { 0, 0, 0, WHY2_v3, WHY2_OUTPUT_TEXT } +#define DEFAULT_FLAGS (why2_input_flags) { 0, 0, 0, WHY2_v4, WHY2_OUTPUT_TEXT } #define DEFAULT_MEMORY_IDENTIFIER "" int encryptionOperation(int text, int encryptedText); diff --git a/src/core/lib/test/main.c b/src/core/lib/test/main.c index 5ef72f8..a74eb39 100644 --- a/src/core/lib/test/main.c +++ b/src/core/lib/test/main.c @@ -44,7 +44,7 @@ int main(void) 0, //SKIP CHECK 0, //NO OUTPUT 0, //UPDATE - WHY2_v3, //LATEST VERSION + WHY2_v4, //LATEST VERSION WHY2_OUTPUT_TEXT //READABLE TEXT OUTPUT }; diff --git a/src/core/lib/utils/misc.c b/src/core/lib/utils/misc.c index 51ddd21..ba085a6 100644 --- a/src/core/lib/utils/misc.c +++ b/src/core/lib/utils/misc.c @@ -34,6 +34,7 @@ along with this program. If not, see . #include #include +int mod_cb(int a, int b) { return a % b; } int multiply_cb(int a, int b) { return a * b; } int subtract_cb(int a, int b) { return a - b; } int sum_cb(int a, int b) { return a + b; } @@ -302,18 +303,24 @@ void why2_generate_text_key_chain(char *key, int *text_key_chain, int text_key_c number_buffer_2 = text_key_chain_size - (i + 1); number_buffer_3 = why2_get_key_length() - (number_buffer + (i < text_key_chain_size)); break; + + case WHY2_v4: + number_buffer_2 = text_key_chain_size - (i + 1); + number_buffer_3 = (why2_get_key_length() ^ text_key_chain_size) >> (number_buffer & (i < text_key_chain_size)); //gl fucker + break; } //FILL textKeyChain - if ((number_buffer + 1) % 3 == 0) + if (why2_get_flags().version == WHY2_v4 && (number_buffer + 1) % 4 == 0) + { + cb = mod_cb; + } else if ((number_buffer + 1) % 3 == 0) { cb = multiply_cb; - } - else if ((number_buffer + 1) % 2 == 0) + } else if ((number_buffer + 1) % 2 == 0) { cb = subtract_cb; - } - else + } else { cb = sum_cb; } diff --git a/src/logger/app/main.c b/src/logger/app/main.c index a5abcd9..d0247e2 100644 --- a/src/logger/app/main.c +++ b/src/logger/app/main.c @@ -16,7 +16,7 @@ int main(void) 1, 1, 0, - WHY2_v3, + WHY2_v4, WHY2_OUTPUT_TEXT } ); diff --git a/src/logger/lib/logger.c b/src/logger/lib/logger.c index eb230bb..ece85d7 100644 --- a/src/logger/lib/logger.c +++ b/src/logger/lib/logger.c @@ -132,7 +132,7 @@ void why2_write_log(int loggerFile, char *logMessage) 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_v3, WHY2_OUTPUT_TEXT }); + if (!why2_get_flags_changed()) why2_set_flags((why2_input_flags) { 0, 1, 0, WHY2_v4, WHY2_OUTPUT_TEXT }); if (flags.key != NULL) //ENCRYPT TEXT IF KEY WAS CHANGED {