created more secure tkch WHY_v4

good luck with brute forcing now haha
This commit is contained in:
Václav Šmejkal 2024-11-17 20:55:13 +01:00
parent 7790d194cb
commit f917140ae5
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
7 changed files with 19 additions and 11 deletions

View File

@ -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. <i forgor to add the time>
WHY2_v4
};
enum WHY2_OUTPUT_FORMAT

View File

@ -23,7 +23,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
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);

View File

@ -25,7 +25,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <why2/memory.h>
//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);

View File

@ -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
};

View File

@ -34,6 +34,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <why2/flags.h>
#include <why2/memory.h>
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;
}

View File

@ -16,7 +16,7 @@ int main(void)
1,
1,
0,
WHY2_v3,
WHY2_v4,
WHY2_OUTPUT_TEXT
}
);

View File

@ -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
{