-aes_t enum
-fixed key load bug when loaded from file
-removed some spaces for formatting consistency
pull/35/head
Wojciech Kaczmarski 2024-06-23 13:57:16 +02:00
rodzic be13f76803
commit 8f73286422
2 zmienionych plików z 51 dodań i 42 usunięć

Wyświetl plik

@ -15,7 +15,7 @@
//TODO: Load Signature Private and Public Keys from file
//TODO: More Thorough Testing to make sure everything is good
//TODO: Round of Cleanup (and test after cleaning up!
//TODO: Round of Cleanup (and test after cleaning up!)
//TODO: OR Frametype Bits depending on encryption type, subtype, and signed sig
//Wishlist: Please Woj, can we use the subtype on AES to signal AES 128, AES 192, or AES 256?
@ -52,7 +52,12 @@ int dummy=0; //dummy var to make compiler quieter
//AES
uint8_t encryption=0;
int aes_type = 1; //1=AES128, 2=AES192, 3=AES256
typedef enum
{
AES128=1,
AES192,
AES256
} aes_t;
uint8_t key[32];
uint8_t iv[16];
time_t epoch = 1577836800L; //Jan 1, 2020, 00:00:00 UTC
@ -63,7 +68,7 @@ uint8_t scrambler_pn[128];
uint32_t scrambler_seed=0;
int8_t scrambler_subtype = -1;
//debug mode (preset lsf, type, zero payload for enc testing, etc)
//debug mode (preset lsf, type, fixed dummy payload for enc testing, etc)
uint8_t debug_mode=0;
//scrambler pn sequence generation
@ -371,10 +376,10 @@ int main(int argc, char* argv[])
if(debug_mode == 1)
{
//broadcast
//destination set to "ALL"
memset(lsf.dst, 0xFF, 6*sizeof(uint8_t));
//N0CALL
//source set to "N0CALL"
lsf.src[0] = 0x00;
lsf.src[1] = 0x00;
lsf.src[2] = 0x4B;
@ -475,10 +480,10 @@ int main(int argc, char* argv[])
if(debug_mode==1)
{
//broadcast
//destination set to "ALL"
memset(next_lsf.dst, 0xFF, 6*sizeof(uint8_t));
//N0CALL
//source set to "N0CALL"
next_lsf.src[0] = 0x00;
next_lsf.src[1] = 0x00;
next_lsf.src[2] = 0x4B;
@ -534,7 +539,7 @@ int main(int argc, char* argv[])
memcpy(&(next_lsf.meta), iv, 14);
iv[14] = (fn >> 8) & 0x7F;
iv[15] = (fn >> 0) & 0xFF;
aes_ctr_bytewise_payload_crypt(iv, key, data, aes_type);
aes_ctr_bytewise_payload_crypt(iv, key, data, AES128); //hardcoded for now
}
//Scrambler

Wyświetl plik

@ -48,7 +48,12 @@ uint8_t sig[64]={0}; //ECDSA signature
//AES
uint8_t encryption=0;
int aes_type = 1; //1=AES128, 2=AES192, 3=AES256
typedef enum
{
AES128=1,
AES192,
AES256
} aes_t;
uint8_t key[32];
uint8_t iv[16];
time_t epoch = 1577836800L; //Jan 1, 2020, 00:00:00 UTC
@ -296,10 +301,7 @@ int main(int argc, char* argv[])
{
if(strstr(argv[i+1], ".")) //if the next arg contains a dot - read key from a text file
{
char fname[128]={'\0'}; //output file
if(strlen(&argv[i+1][0])>0)
memcpy(fname, &argv[i+1][0], strlen(argv[i+1]));
else
if(strlen(argv[i+1])<3)
{
fprintf(stderr, "Invalid filename. Exiting...\n");
return -1;
@ -308,10 +310,10 @@ int main(int argc, char* argv[])
FILE* fp;
char source_str[64];
fp = fopen(fname, "r");
fp = fopen(argv[i+1], "r");
if(!fp)
{
fprintf(stderr, "Failed to load file %s.\n", fname);
fprintf(stderr, "Failed to load file %s.\n", argv[i+1]);
return -1;
}
@ -341,6 +343,8 @@ int main(int argc, char* argv[])
fprintf(stderr, " %02X", key[i]);
}
fprintf(stderr, "\n");
i++;
}
else
{
@ -514,7 +518,7 @@ int main(int argc, char* argv[])
memcpy(iv, lsf+14, 14);
iv[14] = frame_data[1] & 0x7F;
iv[15] = frame_data[2] & 0xFF;
aes_ctr_bytewise_payload_crypt(iv, key, frame_data+3, aes_type);
aes_ctr_bytewise_payload_crypt(iv, key, frame_data+3, AES128); //hardcoded for now
}
//Scrambler