unified dec_pass array, update readme
This commit is contained in:
1 parent
90399dc61b
commit
aaa6f71708
2 files changed
+24
-32
No files matched your search
+21
-27
@@ -2,27 +2,15 @@
|
||||
|
||||
#include "red_crypto.h"
|
||||
|
||||
uint8_t dec_pass[STORAGE_SIZE][STORAGE_PASS_LEN] = {
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
uint8_t dec_pass[STORAGE_SIZE][STORAGE_PASS_LEN];
|
||||
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
};
|
||||
void init_dec_pass() {
|
||||
for (uint8_t i = 0; i < STORAGE_SIZE; i++) {
|
||||
for (uint8_t j = 0; j < STORAGE_PASS_LEN; j++) {
|
||||
dec_pass[i][j] = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// you can use key any length with SHA256, kuznechik use only 32byte
|
||||
#ifdef USE_SHA256_KEY
|
||||
@@ -32,8 +20,6 @@ uint8_t readed_key[128] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
uint8_t readed_key[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
#endif
|
||||
|
||||
const uint8_t test_pass_block[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
uint8_t count_char_key = 0;
|
||||
|
||||
uint8_t crypto_mode = 0;
|
||||
@@ -79,6 +65,8 @@ void decrypt_pass_kuzn(const uint8_t encrypted_passwords[STORAGE_SIZE][STORAGE_P
|
||||
kuz_key_t key;
|
||||
w128_t x;
|
||||
|
||||
init_dec_pass();
|
||||
|
||||
#ifdef USE_SHA256_KEY
|
||||
SHA256_CTX ctx;
|
||||
sha256_init(&ctx);
|
||||
@@ -96,8 +84,8 @@ void decrypt_pass_kuzn(const uint8_t encrypted_passwords[STORAGE_SIZE][STORAGE_P
|
||||
dprintf("decrypted\t=");
|
||||
#endif
|
||||
for (uint8_t k = 0; k < STORAGE_PASS_LEN / 16; k++) {
|
||||
uint8_t cnt_zeros=0;
|
||||
for (uint8_t z = 0+k*16; z < 16+k*16; z++) {
|
||||
uint8_t cnt_zeros = 0;
|
||||
for (uint8_t z = 0 + k * 16; z < 16 + k * 16; z++) {
|
||||
if (encrypted_passwords[j][z] == 0x00) {
|
||||
cnt_zeros++;
|
||||
} else {
|
||||
@@ -105,16 +93,16 @@ void decrypt_pass_kuzn(const uint8_t encrypted_passwords[STORAGE_SIZE][STORAGE_P
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cnt_zeros!=0) break; // if there is zero 8 byte block in password, e.g. password length <32 or <64
|
||||
if (cnt_zeros != 0) break; // if there is zero 8 byte block in password, e.g. password length <32 or <64
|
||||
|
||||
for (uint8_t i = 0 + k * 16; i < 16 + k * 16; i++) {
|
||||
x.b[i%16] = encrypted_passwords[j][i];
|
||||
x.b[i % 16] = encrypted_passwords[j][i];
|
||||
}
|
||||
|
||||
kuz_decrypt_block(&key, &x);
|
||||
|
||||
for (uint8_t i = 0 + k * 16; i < 16 + k * 16; i++) {
|
||||
dec_pass[j][i] = x.b[i%16];
|
||||
dec_pass[j][i] = x.b[i % 16];
|
||||
}
|
||||
|
||||
#ifdef USE_RED_CRY_DEBUG
|
||||
@@ -182,6 +170,12 @@ uint8_t crypto_process_record_user(uint16_t keycode, keyrecord_t *record, const
|
||||
send_chars_pass(dec_pass[3]);
|
||||
}
|
||||
break;
|
||||
// if you want to add more keys for passwords, copy this `case`
|
||||
// case RED_PASSX: //change X here
|
||||
// if (record->event.pressed) {
|
||||
// send_chars_pass(dec_pass[X]); //change X here
|
||||
// }
|
||||
// break;
|
||||
case RED_RNG:
|
||||
if (record->event.pressed) {
|
||||
// TODO: change seed
|
||||
|
||||
Reference in new issue
Block a user