changed struct of storing, adding proccess of encrypting features
This commit is contained in:
1 parent
847923b74b
commit
a12f7243c9
2 files changed
+43
-3
No files matched your search
@@ -31,6 +31,29 @@ uint8_t decrypted_mode = 0;
|
|||||||
|
|
||||||
uint8_t red_menu_mode = 0;
|
uint8_t red_menu_mode = 0;
|
||||||
|
|
||||||
|
void encrypt_pass_kuzn() {
|
||||||
|
kuz_key_t key;
|
||||||
|
w128_t x;
|
||||||
|
|
||||||
|
init_dec_pass();
|
||||||
|
|
||||||
|
// for hashing key, like a KDF algorithm
|
||||||
|
#ifdef USE_SHA256_KEY
|
||||||
|
SHA256_CTX ctx;
|
||||||
|
sha256_init(&ctx);
|
||||||
|
sha256_update(&ctx, readed_key, min_len(u_strlen(readed_key), MAX_KEY_LEN));
|
||||||
|
BYTE result_key[SHA256_BLOCK_SIZE];
|
||||||
|
sha256_final(&ctx, result_key);
|
||||||
|
print_hex(result_key);
|
||||||
|
kuz_set_encrypt_key(&key, result_key);
|
||||||
|
#endif
|
||||||
|
// if you don't have enough FLASH in MCU
|
||||||
|
#ifndef USE_SHA256_KEY
|
||||||
|
kuz_set_encrypt_key(&key, readed_key);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// decrypting passwords
|
// decrypting passwords
|
||||||
void decrypt_pass_kuzn() {
|
void decrypt_pass_kuzn() {
|
||||||
kuz_key_t key;
|
kuz_key_t key;
|
||||||
|
|||||||
+20
-3
@@ -29,6 +29,19 @@
|
|||||||
# define MAX_KEY_LEN 128
|
# define MAX_KEY_LEN 128
|
||||||
# define BLOCK_SIZE 16
|
# define BLOCK_SIZE 16
|
||||||
|
|
||||||
|
# ifndef INIT_STORAGE_SIZE
|
||||||
|
# define INIT_STORAGE_SIZE 4
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef INIT_STORAGE_PASS_LEN
|
||||||
|
# define INIT_STORAGE_PASS_LEN 128
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef INIT_STORAGE_PASS_LEN
|
||||||
|
# if (INIT_STORAGE_PASS_LEN % 16 != 0)
|
||||||
|
# error "Password length must be multiply of 16 (16,32,64...)"
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
// example for encrypted 64 byte password
|
// example for encrypted 64 byte password
|
||||||
// const uint8_t red_enc_pass[STORAGE_SIZE][STORAGE_PASS_LEN] = {
|
// const uint8_t red_enc_pass[STORAGE_SIZE][STORAGE_PASS_LEN] = {
|
||||||
@@ -56,15 +69,18 @@ enum red_crypto_keys {
|
|||||||
RED_PASS10
|
RED_PASS10
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t storage_size = 4;
|
uint8_t storage_size = INIT_STORAGE_SIZE;
|
||||||
uint8_t storage_pass_len = 64;
|
uint8_t storage_pass_len = INIT_STORAGE_PASS_LEN;
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
uint8_t raw[1+1+4+(uint32_t)storage_size*(uint32_t)storage_pass_len];
|
uint8_t raw[3 + 3 + 1 + 1 + 4 + 1 + (uint32_t)storage_size * (uint32_t)storage_pass_len];
|
||||||
struct {
|
struct {
|
||||||
|
uint8_t init_var[3]; // if in eeprom is bytes "RED", then it's not first flash or first power-on, or in eeprom is old red_crypto
|
||||||
|
uint8_t version[3]; // red_crypto library version
|
||||||
uint8_t storage_size;
|
uint8_t storage_size;
|
||||||
uint8_t storage_pass_len;
|
uint8_t storage_pass_len;
|
||||||
uint32_t memory_usage;
|
uint32_t memory_usage;
|
||||||
|
uint8_t password_count;
|
||||||
uint8_t passwords[(uint32_t)storage_size * (uint32_t)storage_pass_len];
|
uint8_t passwords[(uint32_t)storage_size * (uint32_t)storage_pass_len];
|
||||||
};
|
};
|
||||||
} red_crypto_storage;
|
} red_crypto_storage;
|
||||||
@@ -72,5 +88,6 @@ typedef union {
|
|||||||
red_crypto_storage enc_pass;
|
red_crypto_storage enc_pass;
|
||||||
|
|
||||||
uint8_t crypto_process_record_user(uint16_t keycode, keyrecord_t *record);
|
uint8_t crypto_process_record_user(uint16_t keycode, keyrecord_t *record);
|
||||||
|
void encrypt_pass_kuzn(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in new issue
Block a user