diff --git a/README.md b/README.md index 443229c..be5bf04 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# RED_CRYPTO ver 0.5.0 +# RED_CRYPTO ver 0.6.0 ## Description diff --git a/kuznechik_8bit.c b/kuznechik_8bit.c index 958dd55..9f8848a 100644 --- a/kuznechik_8bit.c +++ b/kuznechik_8bit.c @@ -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 diff --git a/kuznechik_8bit.h b/kuznechik_8bit.h index 686e63f..d3635d1 100644 --- a/kuznechik_8bit.h +++ b/kuznechik_8bit.h @@ -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 diff --git a/red_crypto.c b/red_crypto.c index 4ce6381..be2d334 100644 --- a/red_crypto.c +++ b/red_crypto.c @@ -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; diff --git a/red_crypto.h b/red_crypto.h index 741ef3c..8734b6a 100644 --- a/red_crypto.h +++ b/red_crypto.h @@ -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]); diff --git a/red_crypto.mk b/red_crypto.mk index 78e5997..6a7c0e7 100644 --- a/red_crypto.mk +++ b/red_crypto.mk @@ -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: