not working changing passwords in storage

This commit is contained in:
redlineo committed 2025-04-01 14:59:39 +00:00
1 parent 14fb36819f
commit be92c14ee6
3 files changed
+40 -14

No files matched your search

+10 -4
View File
@@ -40,7 +40,7 @@ void crypto_eeprom_init() {
enc_pass.init_var[2] = 'D';
enc_pass.version[0] = '0';
enc_pass.version[1] = '7';
enc_pass.version[2] = '1';
enc_pass.version[2] = '2';
enc_pass.memory_usage = 0;
enc_pass.password_count = 0;
enc_pass.storage_size = INIT_STORAGE_SIZE;
@@ -56,13 +56,19 @@ void crypto_eeprom_init() {
}
// encrypt new password
uint8_t *encrypt_pass_kuzn(const uint8_t *new_pass, const uint8_t new_pass_length) {
uint8_t *encrypt_pass_kuzn(const uint8_t *new_pass, const uint8_t new_pass_length, const uint8_t password_index) {
kuz_key_t key;
w128_t x;
new_pass_enc = red_init_array(enc_pass.storage_pass_len, 0x00); // assign zeros to encrypted new password var
// copy new password in decrypted_passwords
for (uint8_t byte_index = 0; byte_index < new_pass_length; byte_index++) {
decrypted_passwords[enc_pass.password_count][byte_index] = new_pass[byte_index];
if (password_index == -1) {
for (uint8_t byte_index = 0; byte_index < new_pass_length; byte_index++) {
decrypted_passwords[enc_pass.password_count][byte_index] = new_pass[byte_index];
}
} else {
for (uint8_t byte_index = 0; byte_index < new_pass_length; byte_index++) {
decrypted_passwords[password_index][byte_index] = new_pass[byte_index];
}
}
kuz_init();
+1 -1
View File
@@ -108,7 +108,7 @@ typedef union {
red_crypto_storage_eeprom enc_pass;
uint8_t crypto_process_record_user(uint16_t keycode, keyrecord_t *record);
uint8_t *encrypt_pass_kuzn(const uint8_t *new_pass, const uint8_t new_pass_length);
uint8_t *encrypt_pass_kuzn(const uint8_t *new_pass, const uint8_t new_pass_length, const uint8_t password_index);
void crypto_eeprom_init(void);
#endif
+29 -9
View File
@@ -19,6 +19,7 @@ enum menu_options {
uint8_t readed_option[1] = {255};
uint8_t count_readed = 0;
uint8_t return_key = 0;
uint8_t password_index = -1;
uint8_t *enc_pass_new;
uint8_t *readed_key_new;
@@ -76,34 +77,53 @@ uint8_t draw_red_menu(uint16_t keycode, keyrecord_t *record) {
readed_option[0] = CHANGE_PASS_NAME;
}
if (readed_option[0] == ASCII_LOW_6) {
readed_option[0] = ADD_NEW_PASS;
readed_key_new = red_init_array(MAX_KEY_LEN, 0x00);
count_char_key_new = 0;
readed_option[0] = ADD_NEW_PASS;
}
if (return_key == 1) {
send_string(SS_DOWN(X_LCTL) SS_DOWN(X_A) SS_UP(X_LCTL) SS_UP(X_A) SS_TAP(X_BACKSPACE));
return 1;
}
readed_key_new = red_init_array(MAX_KEY_LEN, 0x00); // init or reinit readed keys
count_char_key_new = 0; // init or reinit counted keys
break;
}
case SHOW_PASS_NAMES:
case SHOW_MEMORY_USAGE:
case CHANGE_MASTER_KEY:
case CHANGE_PASS_IN_STORAGE:
send_string("Which one? [0-");
send_byte(enc_pass.password_count);
send_string("]: ");
password_index = kc_to_ascii(keycode, record, readed_option, &count_readed);
count_readed = 0;
readed_option[0] = READING_PASS;
send_string("\nWrite new password. Tap `Enter` for confirm\n");
break;
case CHANGE_PASS_NAME:
case SAVE_NEW_PASS:
enc_pass_new = (uint8_t *)malloc(sizeof(uint8_t) * enc_pass.storage_pass_len);
enc_pass_new = encrypt_pass_kuzn(readed_key_new, count_char_key_new);
for (uint8_t new_pass_index = 0; new_pass_index < enc_pass.storage_pass_len; new_pass_index++) {
enc_pass.passwords[enc_pass.password_count * enc_pass.storage_pass_len + new_pass_index] = enc_pass_new[new_pass_index];
enc_pass_new = encrypt_pass_kuzn(readed_key_new, count_char_key_new, password_index);
if (password_index == -1) {
for (uint8_t new_pass_index = 0; new_pass_index < enc_pass.storage_pass_len; new_pass_index++) {
enc_pass.passwords[enc_pass.password_count * enc_pass.storage_pass_len + new_pass_index] = enc_pass_new[new_pass_index];
}
enc_pass.password_count++;
} else {
for (uint8_t new_pass_index = password_index; new_pass_index < enc_pass.storage_pass_len; new_pass_index++) {
enc_pass.passwords[enc_pass.password_count * enc_pass.storage_pass_len + new_pass_index] = enc_pass_new[new_pass_index];
}
}
enc_pass.password_count++;
// eeconfig_update_user_datablock(enc_pass.raw);
red_write_to_storage();
send_string("Successful adding new key on keycode RED_PASS");
send_byte(enc_pass.password_count);
if (password_index == -1) {
send_byte(enc_pass.password_count);
} else {
send_byte(password_index);
}
send_string("\n");
send_string(SS_DELAY(1000));
send_string(SS_DELAY(300));
password_index = -1;
readed_option[0] = 255;
break;
case READING_PASS: