expose functions to utils
This commit is contained in:
1 parent
c890ad0c33
commit
b28c3c2c1d
6 files changed
+31
-46
No files matched your search
@@ -1,4 +1,4 @@
|
||||
# RED_CRYPTO ver 0.5.0
|
||||
# RED_CRYPTO ver 0.6.0
|
||||
|
||||
## Description
|
||||
|
||||
|
||||
@@ -264,6 +264,13 @@ void print_w128(w128_t *x)
|
||||
printf("\n");
|
||||
};
|
||||
|
||||
void print_chars_w128(w128_t *x) {
|
||||
for (uint8_t i = 0; i < 16; i++) {
|
||||
if (x->b[i] == 0x00) break;
|
||||
printf("%c", x->b[i]);
|
||||
}
|
||||
printf("\n");
|
||||
};
|
||||
|
||||
/*********************** TEST FUNCTION DEFINITIONS ***********************/
|
||||
#ifdef TEST_FUNCTIONS_ENABLED
|
||||
|
||||
@@ -32,6 +32,7 @@ void kuz_decrypt_block(kuz_key_t *subkeys, void *x);
|
||||
|
||||
// utils
|
||||
void print_w128(w128_t *x);
|
||||
void print_chars_w128(w128_t *x);
|
||||
|
||||
// tests
|
||||
#ifdef TEST_FUNCTIONS_ENABLED
|
||||
|
||||
@@ -24,42 +24,6 @@ uint8_t count_char_key = 0;
|
||||
|
||||
uint8_t crypto_mode = 0;
|
||||
|
||||
void print_chars_w128(w128_t *x) {
|
||||
for (uint8_t i = 0; i < 16; i++) {
|
||||
if (x->b[i] == 0x00) break;
|
||||
dprintf("%c", x->b[i]);
|
||||
}
|
||||
dprintf("\n");
|
||||
};
|
||||
|
||||
void print_chars(uint8_t *c) {
|
||||
for (uint8_t i = 0; i < 32; i++) {
|
||||
if (c[i] == 0x00) break;
|
||||
dprintf("%c", c[i]);
|
||||
}
|
||||
dprintf("\n");
|
||||
};
|
||||
|
||||
void print_int(uint8_t *c) {
|
||||
for (uint8_t i = 0; i < 32; i++) {
|
||||
dprintf("%d", c[i]);
|
||||
}
|
||||
dprintf("\n");
|
||||
};
|
||||
|
||||
void print_hex(uint8_t *h) {
|
||||
for (uint8_t i = 0; i < 32; i++) {
|
||||
dprintf("%x ", h[i]);
|
||||
}
|
||||
dprintf("\n");
|
||||
};
|
||||
|
||||
size_t min_len(size_t a, size_t b) {
|
||||
if (a < b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
}
|
||||
|
||||
void decrypt_pass_kuzn(const uint8_t encrypted_passwords[STORAGE_SIZE][STORAGE_PASS_LEN]) {
|
||||
kuz_key_t key;
|
||||
|
||||
+21
-9
@@ -6,7 +6,9 @@
|
||||
#ifndef RED_CRYPTO_H
|
||||
# define RED_CRYPTO_H
|
||||
|
||||
// includes of red_crypto
|
||||
# include "kc_to_ascii.h"
|
||||
# include "utils.h"
|
||||
|
||||
// #ifdef USE_RED_KUZNECHIK_128
|
||||
// #include "kuznechik_128bit.h"
|
||||
@@ -39,20 +41,30 @@
|
||||
# define STORAGE_PASS_LEN 64
|
||||
# endif
|
||||
|
||||
|
||||
//example for encrypted 64 byte password
|
||||
// const uint8_t red_enc_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},
|
||||
// };
|
||||
// example for encrypted 64 byte password
|
||||
// const uint8_t red_enc_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},
|
||||
// };
|
||||
|
||||
enum red_crypto_keys {
|
||||
RED_CRY_M = SAFE_RANGE + 0x80, // added safe range offset
|
||||
RED_RNG,
|
||||
RED_TEST,
|
||||
RED_PASS1, RED_PASS2, RED_PASS3, RED_PASS4, RED_PASS5, RED_PASS6, RED_PASS7, RED_PASS8, RED_PASS9, RED_PASS10, RED_PASS11, RED_PASS12
|
||||
RED_PASS1,
|
||||
RED_PASS2,
|
||||
RED_PASS3,
|
||||
RED_PASS4,
|
||||
RED_PASS5,
|
||||
RED_PASS6,
|
||||
RED_PASS7,
|
||||
RED_PASS8,
|
||||
RED_PASS9,
|
||||
RED_PASS10,
|
||||
RED_PASS11,
|
||||
RED_PASS12
|
||||
};
|
||||
|
||||
uint8_t crypto_process_record_user(uint16_t keycode, keyrecord_t *record, const uint8_t encrypted_passwords[STORAGE_SIZE][STORAGE_PASS_LEN]);
|
||||
|
||||
@@ -5,6 +5,7 @@ SRC += red_crypto/sha256.c
|
||||
SRC += red_crypto/aes.c
|
||||
SRC += red_crypto/kuznechik_8bit.c
|
||||
SRC += red_crypto/kc_to_ascii.c
|
||||
SRC += red_crypto/utils.c
|
||||
|
||||
# SRC += red_crypto/kuznechik_128bit.c # you can't include this, because you may not have ARMv8 and upper, check this
|
||||
# TODO: do something like this:
|
||||
|
||||
Reference in new issue
Block a user