..
This commit is contained in:
parent
e82eace59d
commit
a5a06d2255
@ -1,18 +1,18 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC9TCCAl6gAwIBAgIQbFsMsUpL4cQYvdnPsNfEozANBgkqhkiG9w0BAQsFADBz
|
||||
MIIC9TCCAl6gAwIBAgIQD7QN9LZVR1zGQgnk5Ibj8jANBgkqhkiG9w0BAQsFADBz
|
||||
MQswCQYDVQQGEwJTSzEKMAgGA1UECAwBLTEPMA0GA1UEBwwGS29zaWNlMREwDwYD
|
||||
VQQKDAhBdXRvcml0YTESMBAGA1UEAwwJbG9jYWwuZGV2MSAwHgYJKoZIhvcNAQkB
|
||||
FhFhdXRvcml0YUB0dWtlLmNvbTAiGA8yMDIwMDMxODEwMzUwOFoYDzIwMjUwMzE4
|
||||
MTAzNTA4WjB3MQswCQYDVQQGEwJTUjEKMAgGA1UECAwBLTEPMA0GA1UEBwwGS29z
|
||||
FhFhdXRvcml0YUB0dWtlLmNvbTAiGA8yMDIwMDUxNjEwNDY1NFoYDzIwMjUwNTE2
|
||||
MTA0NjU0WjB3MQswCQYDVQQGEwJTUjEKMAgGA1UECAwBLTEPMA0GA1UEBwwGS29z
|
||||
aWNlMQowCAYDVQQKDAEtMQowCAYDVQQLDAEtMRIwEAYDVQQDDAlsb2NhbC5kZXYx
|
||||
HzAdBgkqhkiG9w0BCQEWEGtsaWVudEBrbGllbnQuc2swggEiMA0GCSqGSIb3DQEB
|
||||
AQUAA4IBDwAwggEKAoIBAQDwvJLGxRiSsplAIeOWOeMa4xeh8mVwTVZgJjuOK2xv
|
||||
Gze6NZ/or9OGHqBMat3rfW9xZazAg+UoL4TzqokVyjo1KQxGwbHuZQdqQ3/MgWnm
|
||||
1h2cdLicF8hMQtawYhqp1me9+Xh89y+tiBBAAilzGzPRQayYoMoEd9Ics8XPbSX/
|
||||
qEzSdVeuqb7AIQIDZ7v4DTnQIarJDFtzE4Rd37Dq+ThMiipe292FKbRqfyhU5974
|
||||
QtAfTQ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QADgYEAiQRgEyTvSfRdTFm4UKijgk5xMJGBCF7pj9H8CWmCl+Y3F2ztoyxw
|
||||
iJ+qtNTA1jlQiCVKWO4OfysihqVT2jeba9UO7WMSU3+k5B+O/XRJldDKDbiefye8
|
||||
1V/qo/2i00vbf1PV8wHfGHdav96fWm9Gla1BYvxHe8xiUFp/3IGqRIE=
|
||||
-----END CERTIFICATE-----
|
||||
|
@ -1,27 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEAtmpxNIHes7hUMNk/jy2YPSh5Zvfk465B13N88RcOILjYBscI
|
||||
uEzBqFDFclLBFrQR2JBf2ceX1g9vdkSLV3eRrK78lIzoDhfQTHwIfDJB2h6kIhTs
|
||||
8OywMG8wojVPNmSFgG0L4r5y105soBT2wfi5Q3Ai0t1O9/MeOq60Gh7hnsDY+AQQ
|
||||
0jFagHjd8/eumH9WCFyHuKz0Ir0UxoLSWFH4y+G/bAenYDZgVM5iOQ0YpaJRMJB5
|
||||
vQLmdpsHx3AVLwnNuIjfavJWOn4wKiEKNPjRWIb4to4m71E8unTsRFGyoEdeJsnv
|
||||
7xfnzWk9jRzFQR6mMQNHZz8N50EDDrkd1grfcwIDAQABAoIBAAja3JPymfTvcGbO
|
||||
pPSLqhA4nsFjgeDrh0FbgdJ85AVX87n11Mky21O9rVgCBw2AaugFr3bK5ualPoE8
|
||||
jTxkZCtAc1JiugEKduS/lfSGxrDn5op2VD99vdpxYKhUc3vtypfpXeJWjGHslKlQ
|
||||
sInJ9nRSRTPR5RDJjyDEyklaURQmWLHAs3JcZ6pRkpLvPo8MJP5iVfoXze0QZg+4
|
||||
Zvs+xAtpoy9I06MSi+J4e6EzLTRFXXkmkVHxMK1wKw9yNl0tl1+eQ3i5lzJmiTev
|
||||
noRVkmBRhATcdEnlSJVdiUOrZAmGS1As+IQiLrPyO7AKG7Ukr2lJHhLm/C6YblzR
|
||||
QeHefIECgYEA5hiY4uJZxAidSzBpq/1Osan66u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uxladJO+uqydSOjWnIbRLLQh3Q5tcvaRrnyOJS61ltpHZFh8
|
||||
OzoS2tT4YQoAzigICnA58e+PQfmsgI4asv60pb4fgF9M8Q/u59UbV2XtWZnNGreU
|
||||
p/FOk/86tQSLgwHaLsXX31ECgYAaJ0J23T7pofaagRQdjYHOinzEXtfebLV6Pxee
|
||||
KUmmTvfF4kMCQe9XrNmCSV+Q5zaWx3anDDpjF+RSagzh2nW2/wurrBlZSs0gFIxx
|
||||
dU4K7rowviVKVcjx8RdNk6P0uVxKu3TY10/hNuPjhhwm5jAPOinpoyESNF33gpBg
|
||||
fxbsYQKBgEkaKa8yXV2MibBRA97jaP8QFpE/j66ZTHrvCTA5YcDy4jlfMiWaEUAo
|
||||
eIGGYUBpe5iwjWTTJa2HNvBzlHqbrb580Vj0sCEUcUzf0vHRPIEJp5pnVDRJCFmQ
|
||||
nvs5EgJIXpaW6DZ8hgfGQecoNGjYGjo2yl4mHhT5KiCcCZw9NKEZ
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
@ -9,20 +9,15 @@
|
||||
#include "komunikacia.h"
|
||||
#include "kryptografia.h"
|
||||
|
||||
int poslat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, const char* cesta, nastavenia_aplikacie *nastavenia)
|
||||
int poslat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, const char* cesta, nastavenia_aplikacie *nastavenia, int velkost_bloku_dat)
|
||||
{
|
||||
int uspech;
|
||||
|
||||
//odoslanie nazvu (resp. cesty) suboru
|
||||
uspech = 0;
|
||||
while(uspech < VELKOST_CESTY)
|
||||
|
||||
while(wolfSSL_write(ssl, cesta, SPRAVA_VELKOST_BUFFERA) != SPRAVA_VELKOST_BUFFERA)
|
||||
{
|
||||
uspech = wolfSSL_write(ssl, cesta, VELKOST_CESTY);
|
||||
if(uspech <= 0)
|
||||
{
|
||||
fprintf(stderr, "Nastala chyba pri posielani dat o subore.\n");
|
||||
return -1;
|
||||
}
|
||||
if(wolfSSL_want_write(ssl)) continue;
|
||||
fprintf(stderr, "Nastala chyba pri posielani nazvu suboru\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//otvorenie suboru na citanie
|
||||
@ -40,123 +35,143 @@ int poslat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, const char* cesta, nastavenia_a
|
||||
//nastavi ukazovatel na koniec suboru
|
||||
//a zisti velkost suboru
|
||||
fseek(subor, 0, SEEK_END);
|
||||
int velkost = (int)ftell(subor);
|
||||
char velkost_suboru[VELKOST_SUBOR];
|
||||
sprintf(velkost_suboru, "%ld", velkost);
|
||||
printf("Velkost suboru: %s bajtov\n", velkost_suboru);
|
||||
uspech = 0;
|
||||
while(uspech < VELKOST_SUBOR)
|
||||
int velkost_suboru = (int)ftell(subor);
|
||||
char velkost_suboru_retazec[SPRAVA_VELKOST_BUFFERA];
|
||||
sprintf(velkost_suboru_retazec, "%d", velkost_suboru);
|
||||
printf("Velkost suboru: %s bajtov\n", velkost_suboru_retazec);
|
||||
|
||||
while(wolfSSL_write(ssl, velkost_suboru_retazec, SPRAVA_VELKOST_BUFFERA) != SPRAVA_VELKOST_BUFFERA)
|
||||
{
|
||||
uspech = wolfSSL_write(ssl, velkost_suboru, VELKOST_SUBOR);
|
||||
if(uspech <= 0)
|
||||
{
|
||||
fprintf(stderr, "Nastala chyba pri posielani dat o velkosti suboru.\n");
|
||||
return -1;
|
||||
}
|
||||
if(wolfSSL_want_write(ssl)) continue;
|
||||
fprintf(stderr, "Nastala chyba pri posielani velkosti suboru\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//nastavi ukazovatel na zaciatok suboru
|
||||
//a nacita data zo suboru do pola
|
||||
unsigned char* pole = calloc(velkost, sizeof(unsigned char));
|
||||
if(pole == NULL)
|
||||
unsigned char* data = calloc(velkost_suboru, sizeof(unsigned char));
|
||||
if(data == NULL)
|
||||
{
|
||||
fprintf(stderr, "Nepodarilo sa dynamicky alokovat pamat pre pole\n");
|
||||
fprintf(stderr, "Nepodarilo sa dynamicky alokovat pamat pre pole data,\ndo ktoreho sa nacita obsah suboru\n");
|
||||
return -1;
|
||||
}
|
||||
fseek(subor, 0, SEEK_SET);
|
||||
fread((unsigned char*)pole, 1, velkost, subor);
|
||||
fread((unsigned char*)data, 1, velkost_suboru, subor);
|
||||
|
||||
//posielanie jednotlivych bajtov
|
||||
unsigned char* data_ukazovatel = data;
|
||||
uspech = 0;
|
||||
while(uspech < velkost)
|
||||
int ostava_poslat = velkost_suboru;
|
||||
for(int i = 0; i < (velkost_suboru/velkost_bloku_dat) + 1; ++i)
|
||||
{
|
||||
uspech = wolfSSL_write(ssl, pole, velkost);
|
||||
if(uspech <= 0)
|
||||
if(ostava_poslat > velkost_bloku_dat)
|
||||
{
|
||||
fprintf(stderr, "Nastala chyba pri posielani suboru.\n");
|
||||
return -1;
|
||||
while(wolfSSL_write(ssl, data_ukazovatel, velkost_bloku_dat) != velkost_bloku_dat)
|
||||
{
|
||||
if(wolfSSL_want_write(ssl)) continue;
|
||||
fprintf(stderr, "Nastala chyba pri posielani suboru\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uspech = 0;
|
||||
while(wolfSSL_write(ssl, data_ukazovatel, ostava_poslat) != ostava_poslat)
|
||||
{
|
||||
if(wolfSSL_want_write(ssl)) continue;
|
||||
fprintf(stderr, "Nastala chyba pri posielani suboru\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
data_ukazovatel += velkost_bloku_dat;
|
||||
ostava_poslat -= velkost_bloku_dat;
|
||||
}
|
||||
printf("Subor bol uspesne odoslany.\n");
|
||||
|
||||
//generovanie a poslanie kontrolneho suctu serveru pre kontrolu
|
||||
unsigned char* kontrolny_sucet;
|
||||
int velkost_kontrolneho_suctu;
|
||||
kontrolny_sucet = generovat_kontrolny_sucet_suboru(nastavenia, cesta, velkost, &velkost_kontrolneho_suctu);
|
||||
|
||||
uspech = 0;
|
||||
while(uspech < velkost_kontrolneho_suctu)
|
||||
kontrolny_sucet = generovat_kontrolny_sucet_suboru(nastavenia, cesta, velkost_suboru, &velkost_kontrolneho_suctu);
|
||||
|
||||
while(wolfSSL_write(ssl, kontrolny_sucet, velkost_kontrolneho_suctu) != velkost_kontrolneho_suctu)
|
||||
{
|
||||
uspech = wolfSSL_write(ssl, kontrolny_sucet, velkost_kontrolneho_suctu);
|
||||
if(wolfSSL_want_write(ssl)) continue;
|
||||
fprintf(stderr, "Nastala chyba pri posielani kontrolneho suctu\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(kontrolny_sucet);
|
||||
fclose(subor);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int prijat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, nastavenia_aplikacie* nastavenia)
|
||||
int prijat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, nastavenia_aplikacie* nastavenia, int velkost_bloku_dat)
|
||||
{
|
||||
int uspech;
|
||||
|
||||
//prijem dat o subore
|
||||
char* cesta = calloc(VELKOST_CESTY, sizeof(char));
|
||||
char* velkost_suboru = calloc(VELKOST_SUBOR, sizeof(char));
|
||||
char* cesta = calloc(SPRAVA_VELKOST_BUFFERA, sizeof(char));
|
||||
char* velkost_suboru_retazec = calloc(SPRAVA_VELKOST_BUFFERA, sizeof(char));
|
||||
|
||||
uspech = 0;
|
||||
while(uspech < VELKOST_CESTY)
|
||||
while(wolfSSL_read(ssl, cesta, SPRAVA_VELKOST_BUFFERA) != SPRAVA_VELKOST_BUFFERA)
|
||||
{
|
||||
uspech = wolfSSL_read(ssl, cesta, VELKOST_CESTY);
|
||||
if(uspech <= 0)
|
||||
{
|
||||
fprintf(stderr, "Nastala chyba pri prijati dat o subore\n");
|
||||
return -1;
|
||||
}
|
||||
if(wolfSSL_want_read(ssl)) continue;
|
||||
fprintf(stderr, "Nastala chyba pri prijati nazvu suboru\n");
|
||||
return -1;
|
||||
}
|
||||
printf("Prebieha prijimanie suboru %s\n", cesta);
|
||||
|
||||
//ziskanie informacie od klienta o velkosti odoslaneho suboru
|
||||
uspech = 0;
|
||||
while(uspech < VELKOST_SUBOR)
|
||||
while(wolfSSL_read(ssl, velkost_suboru_retazec, SPRAVA_VELKOST_BUFFERA) != SPRAVA_VELKOST_BUFFERA)
|
||||
{
|
||||
uspech = wolfSSL_read(ssl, velkost_suboru, VELKOST_SUBOR);
|
||||
if(uspech <= 0)
|
||||
{
|
||||
fprintf(stderr, "Nastala chyba pri prijati velkosti suboru\n");
|
||||
return -1;
|
||||
}
|
||||
if(wolfSSL_want_read(ssl)) continue;
|
||||
fprintf(stderr, "Nastala chyba pri prijati velkosti suboru\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int velkost = (int)atol(velkost_suboru);
|
||||
if(velkost < 1)
|
||||
int velkost_suboru = (int)atol(velkost_suboru_retazec);
|
||||
if(velkost_suboru <= 0)
|
||||
{
|
||||
printf("Nastala chyba pri prijati suboru\n");
|
||||
printf("Bola prijata informacia o velkosti suboru s hodnotu mensou nez 0\nPravdepodobne nastala chyba pri prenose\n");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Velkost suboru: %s bajtov\n", velkost_suboru);
|
||||
printf("Velkost suboru: %s bajtov\n", velkost_suboru_retazec);
|
||||
}
|
||||
|
||||
//prijem jednotlivych bajtov
|
||||
unsigned char* pole = calloc(velkost, sizeof(unsigned char));
|
||||
if(pole == NULL)
|
||||
unsigned char* data = calloc(velkost_suboru, sizeof(unsigned char));
|
||||
if(data == NULL)
|
||||
{
|
||||
fprintf(stderr, "Nepodarilo sa dynamicky alokovat pamat pre pole\n");
|
||||
fprintf(stderr, "Nepodarilo sa dynamicky alokovat pamat pre pole data\ndo ktoreho sa zapisu prijate data\n");
|
||||
return -1;
|
||||
}
|
||||
unsigned char* pole_uk = pole;
|
||||
|
||||
uspech = 0;
|
||||
for(int i = 0; i < (velkost/16384) + 1; ++i)
|
||||
|
||||
unsigned char* data_ukazovatel = data;
|
||||
int ostava_prijat = velkost_suboru;
|
||||
for(int i = 0; i < (velkost_suboru/velkost_bloku_dat) + 1; ++i)
|
||||
{
|
||||
uspech = wolfSSL_read(ssl, pole_uk, velkost);
|
||||
pole_uk += 16384;
|
||||
if(uspech <= 0)
|
||||
if(ostava_prijat > velkost_bloku_dat)
|
||||
{
|
||||
while(wolfSSL_read(ssl, data_ukazovatel, velkost_bloku_dat) != velkost_bloku_dat)
|
||||
{
|
||||
fprintf(stderr, "Nastala chyba pri posielani suboru.\n");
|
||||
if(wolfSSL_want_read(ssl)) continue;
|
||||
fprintf(stderr, "Nastala chyba pri prijimani suboru\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(wolfSSL_read(ssl, data_ukazovatel, ostava_prijat) != ostava_prijat)
|
||||
{
|
||||
if(wolfSSL_want_read(ssl)) continue;
|
||||
fprintf(stderr, "Nastala chyba pri prijimani suboru\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
data_ukazovatel += velkost_bloku_dat;
|
||||
ostava_prijat -= velkost_bloku_dat;
|
||||
}
|
||||
printf("Subor bol uspesne prijaty.\n");
|
||||
|
||||
@ -165,25 +180,34 @@ int prijat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, nastavenia_aplikacie* nastaveni
|
||||
int velkost_kontrolneho_suctu;
|
||||
|
||||
FILE *subor = fopen(cesta, "wb+");
|
||||
int n = fwrite((unsigned char*)pole, 1, velkost, subor);
|
||||
int pocet_zapisanych_bajtov = fwrite((unsigned char*)data, 1, velkost_suboru, subor);
|
||||
if(pocet_zapisanych_bajtov <= 0)
|
||||
{
|
||||
fprintf(stderr, "Nepodarilo sa zapisat do suboru obsah prijateho suboru\n");
|
||||
return -1;
|
||||
}
|
||||
else if(pocet_zapisanych_bajtov < velkost_suboru)
|
||||
{
|
||||
fprintf(stderr, "Nepodarilo sa zapisat do suboru cely obsah prijateho suboru\n");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Do suboru %s bolo zapisanych %d bajtov\n", cesta, pocet_zapisanych_bajtov);
|
||||
}
|
||||
fclose(subor);
|
||||
|
||||
|
||||
kontrolny_sucet = generovat_kontrolny_sucet_suboru(nastavenia, cesta, velkost, &velkost_kontrolneho_suctu);
|
||||
kontrolny_sucet = generovat_kontrolny_sucet_suboru(nastavenia, cesta, velkost_suboru, &velkost_kontrolneho_suctu);
|
||||
|
||||
//prijem hashu, ktory vypocital server
|
||||
//prijem kontrolneho suctu, ktory vypocital server
|
||||
char* prijaty_kontrolny_sucet = calloc(velkost_kontrolneho_suctu, sizeof(char));
|
||||
|
||||
uspech = 0;
|
||||
while(uspech != velkost_kontrolneho_suctu)
|
||||
|
||||
while(wolfSSL_read(ssl, (char*)prijaty_kontrolny_sucet, velkost_kontrolneho_suctu) != velkost_kontrolneho_suctu)
|
||||
{
|
||||
uspech = wolfSSL_read(ssl, (char*)prijaty_kontrolny_sucet, velkost_kontrolneho_suctu);
|
||||
if(uspech <= 0)
|
||||
{
|
||||
fprintf(stderr, "Nastala chyba pri prijati kontrolneho suctu.\n");
|
||||
free(prijaty_kontrolny_sucet);
|
||||
return -1;
|
||||
}
|
||||
if(wolfSSL_want_read(ssl)) continue;
|
||||
fprintf(stderr, "Nastala chyba pri prijati kontrolneho suctu\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//kontrola ci sa prijaty a vypocitany kontrolny sucet suboru zhoduju
|
||||
@ -199,7 +223,7 @@ int prijat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, nastavenia_aplikacie* nastaveni
|
||||
}
|
||||
|
||||
free(cesta);
|
||||
free(velkost_suboru);
|
||||
free(velkost_suboru_retazec);
|
||||
free(kontrolny_sucet);
|
||||
free(prijaty_kontrolny_sucet);
|
||||
return 0;
|
||||
@ -420,14 +444,19 @@ int rs232_prijat_spravu(int cislo_rozhrania, const char* komunikacny_subor)
|
||||
FILE* subor = fopen(komunikacny_subor, "ab+");
|
||||
|
||||
int uspech = 0;
|
||||
int prebieha_nacitanie_velkosti_spravy = 0;
|
||||
int prebieha_nacitanie_kontrolneho_suctu = 0;
|
||||
int prebieha_nacitanie_dat = 0;
|
||||
stav_nacitania stav;
|
||||
stav = NEPREBIEHA_NACITANIE;
|
||||
unsigned char znak;
|
||||
|
||||
//mnozstvo nacitanych dat
|
||||
int nacitane_data = 0;
|
||||
|
||||
//kontrolny vzor ktory jednoznacne identifikuje zaciatok spravy
|
||||
unsigned char kontrolny_vzor[] = {0xAA, 0xAA, 0xAA, 0xAA};
|
||||
//urcuje kolko bajtov z kontrolneho vzoru
|
||||
//uz bolo prijatych z celkoveho poctu (4)
|
||||
int kontrolny_vzor_pozicia = 0;
|
||||
|
||||
//velkost spravy, ktora sa bude prijmat
|
||||
int velkost_spravy = 0;
|
||||
unsigned char velkost_spravy_hex[4];
|
||||
@ -443,70 +472,68 @@ int rs232_prijat_spravu(int cislo_rozhrania, const char* komunikacny_subor)
|
||||
int kontrolny_sucet_pozicia = 0;
|
||||
|
||||
unsigned char* prijate_data;
|
||||
|
||||
//kontrolny vzor ktory jednoznacne identifikuje zaciatok spravy
|
||||
unsigned char kontrolny_vzor[] = {0xAA, 0xAA, 0xAA, 0xAA};
|
||||
int kontrolny_vzor_pozicia = 0; //aktualna pozicia v kontrolnom vzore
|
||||
int velkost_kontrolneho_vzoru = sizeof(kontrolny_vzor)/sizeof(kontrolny_vzor[0]);
|
||||
|
||||
while(1)
|
||||
while(stav != NACITANIE_UKONCENE)
|
||||
{
|
||||
uspech = RS232_PollComport(cislo_rozhrania, &znak, 1);
|
||||
if(uspech > 0)
|
||||
{
|
||||
//nacitanie kontrolneho vzoru
|
||||
if(!prebieha_nacitanie_velkosti_spravy && !prebieha_nacitanie_dat && !prebieha_nacitanie_kontrolneho_suctu &&
|
||||
znak == kontrolny_vzor[kontrolny_vzor_pozicia])
|
||||
switch(stav)
|
||||
{
|
||||
kontrolny_vzor_pozicia++;
|
||||
if(kontrolny_vzor_pozicia == 4)
|
||||
{
|
||||
prebieha_nacitanie_velkosti_spravy = 1;
|
||||
kontrolny_vzor_pozicia = 0;
|
||||
}
|
||||
}
|
||||
//nacitanie velkosti spravy
|
||||
else if(!prebieha_nacitanie_dat && prebieha_nacitanie_velkosti_spravy)
|
||||
{
|
||||
velkost_spravy_hex[velkost_spravy_pozicia] = znak;
|
||||
velkost_spravy_pozicia++;
|
||||
if(velkost_spravy_pozicia == 4)
|
||||
{
|
||||
velkost_spravy = (uint32_t)velkost_spravy_hex[0] << 24 | (uint32_t)velkost_spravy_hex[1] << 16 |
|
||||
(uint32_t)velkost_spravy_hex[2] << 8 | (uint32_t)velkost_spravy_hex[3];
|
||||
prebieha_nacitanie_kontrolneho_suctu = 1;
|
||||
prebieha_nacitanie_velkosti_spravy = 0;
|
||||
|
||||
prijate_data = calloc(velkost_spravy, sizeof(unsigned char));
|
||||
if(prijate_data == NULL)
|
||||
case NEPREBIEHA_NACITANIE:
|
||||
if(znak == kontrolny_vzor[kontrolny_vzor_pozicia])
|
||||
{
|
||||
fprintf(stderr, "Nepodarilo sa dynamicky alokovat pamat pre prijate_data\n");
|
||||
return -1;
|
||||
kontrolny_vzor_pozicia++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//nacitanie kontrolneho vzoru
|
||||
else if(!prebieha_nacitanie_dat && prebieha_nacitanie_kontrolneho_suctu)
|
||||
{
|
||||
kontrolny_sucet_hex[kontrolny_sucet_pozicia] = znak;
|
||||
kontrolny_sucet_pozicia++;
|
||||
if(kontrolny_sucet_pozicia == 4)
|
||||
{
|
||||
kontrolny_sucet = (uint32_t)kontrolny_sucet_hex[0] << 24 | (uint32_t)kontrolny_sucet_hex[1] << 16 |
|
||||
(uint32_t)kontrolny_sucet_hex[2] << 8 | (uint32_t)kontrolny_sucet_hex[3];
|
||||
prebieha_nacitanie_dat = 1;
|
||||
prebieha_nacitanie_velkosti_spravy = 0;
|
||||
}
|
||||
}
|
||||
//nacitanie dat
|
||||
else
|
||||
{
|
||||
if(prebieha_nacitanie_dat)
|
||||
{
|
||||
if(kontrolny_vzor_pozicia == 4)
|
||||
{
|
||||
kontrolny_vzor_pozicia = 0;
|
||||
stav = PREBIEHA_NACITANIE_VELKOSTI_SPRAVY;
|
||||
}
|
||||
break;
|
||||
case PREBIEHA_NACITANIE_VELKOSTI_SPRAVY:
|
||||
velkost_spravy_hex[velkost_spravy_pozicia] = znak;
|
||||
velkost_spravy_pozicia++;
|
||||
if(velkost_spravy_pozicia == 4)
|
||||
{
|
||||
velkost_spravy = (uint32_t)velkost_spravy_hex[0] << 24 | (uint32_t)velkost_spravy_hex[1] << 16 |
|
||||
(uint32_t)velkost_spravy_hex[2] << 8 | (uint32_t)velkost_spravy_hex[3];
|
||||
velkost_spravy_pozicia = 0;
|
||||
stav = PREBIEHA_NACITANIE_KONTROLNEHO_SUCTU;
|
||||
|
||||
//dynamicka alokacia pola s velkostou, ktora bola prijata
|
||||
//do neho bude zapisana prijata sprava
|
||||
prijate_data = calloc(velkost_spravy, sizeof(unsigned char));
|
||||
if(prijate_data == NULL)
|
||||
{
|
||||
fprintf(stderr, "Nepodarilo sa dynamicky alokovat pamat pre prijate_data\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PREBIEHA_NACITANIE_KONTROLNEHO_SUCTU:
|
||||
kontrolny_sucet_hex[kontrolny_sucet_pozicia] = znak;
|
||||
kontrolny_sucet_pozicia++;
|
||||
if(kontrolny_sucet_pozicia == 4)
|
||||
{
|
||||
kontrolny_sucet = (uint32_t)kontrolny_sucet_hex[0] << 24 | (uint32_t)kontrolny_sucet_hex[1] << 16 |
|
||||
(uint32_t)kontrolny_sucet_hex[2] << 8 | (uint32_t)kontrolny_sucet_hex[3];
|
||||
kontrolny_sucet_pozicia = 0;
|
||||
stav = PREBIEHA_NACITANIE_DAT;
|
||||
}
|
||||
break;
|
||||
case PREBIEHA_NACITANIE_DAT:
|
||||
prijate_data[nacitane_data] = znak;
|
||||
nacitane_data += uspech;
|
||||
if(nacitane_data == velkost_spravy) break;
|
||||
}
|
||||
if(nacitane_data == velkost_spravy)
|
||||
{
|
||||
stav = NACITANIE_UKONCENE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//tento stav by nemal nikdy nastat
|
||||
fprintf(stderr, "Nepodarilo sa urcit stav nacitania spravy pomocou RS232\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -531,7 +558,7 @@ int rs232_prijat_spravu(int cislo_rozhrania, const char* komunikacny_subor)
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Sprava neprisla v poriadku");
|
||||
fprintf(stderr, "Sprava neprisla v poriadku");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,9 @@
|
||||
#include "kryptografia.h"
|
||||
#include "../externe_kniznice/teuniz_rs232/rs232.h"
|
||||
|
||||
#define VELKOST_CESTY 64 //velkost retazca, kt. uklada lokaciu suboru
|
||||
#define VELKOST_SUBOR 32 //velkost retazca, kt. uklada velkost prenasaneho suboru
|
||||
//velkost buffrov ktore ukladaju doplnujuce data pri komunikacii
|
||||
//napr. velkost suboru, cestu ku suboru a ine
|
||||
#define SPRAVA_VELKOST_BUFFERA 64
|
||||
|
||||
#if defined(_WIN32)
|
||||
//makro ktore urcuje win distribuciu ak nieje detekovana
|
||||
@ -76,6 +77,12 @@ int cakat_na_komunikaciu(int cislo_portu);
|
||||
// RS232 KOMUNIKACNY KANAL //
|
||||
/////////////////////////////
|
||||
|
||||
typedef enum stav_nacitania {
|
||||
NEPREBIEHA_NACITANIE, PREBIEHA_NACITANIE_VELKOSTI_SPRAVY, PREBIEHA_NACITANIE_KONTROLNEHO_SUCTU,
|
||||
PREBIEHA_NACITANIE_DAT, NACITANIE_UKONCENE
|
||||
} stav_nacitania;
|
||||
|
||||
|
||||
/**
|
||||
* rs232_otvorit_rozhranie: realizuje otvorenie RS232 serioveho rozhrania
|
||||
* @parameter int cislo_rozhrania: cislo RS232 serioveho rozhrania
|
||||
@ -119,17 +126,19 @@ int rs232_prijat_spravu(int cislo_rozhrania, const char* komunikacny_subor);
|
||||
* @parameter WOLFSSL_CTX* ctx : ukazuje na WOLFSSL_CTX strukturu
|
||||
* @parameter char* cesta: ukazuje na retazec, ktory reprezentuje cestu k suboru
|
||||
* @parameter nastavenia_aplikacie* nastavenia: reprezentuje nastavenia aplikacie: server alebo klient
|
||||
* @parameter int velkost_bloku_dat: velkost dat po ktorych sa budu data posielat
|
||||
* @vrati int : operacia bola uspesna(0), neuspesna(-1)
|
||||
*/
|
||||
int poslat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, const char* cesta, nastavenia_aplikacie* nastavenia);
|
||||
int poslat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, const char* cesta, nastavenia_aplikacie* nastavenia, int velkost_bloku_dat);
|
||||
|
||||
/**
|
||||
* prijat_subor: realizuje prijem suboru
|
||||
* @parameter WOLFSSL* ssl : ukazuje na aktualnu relaciu
|
||||
* @parameter WOLFSSL_CTX* ctx : ukazuje na WOLFSSL_CTX strukturu
|
||||
* @parameter nastavenia_aplikacie* nastavenia: reprezentuje nastavenia aplikacie: server alebo klient
|
||||
* @parameter int velkost_bloku_dat: velkost dat po ktorych sa budu data prijimat
|
||||
* @vrati int : operacia bola uspesna(0), neuspesna(-1)
|
||||
*/
|
||||
int prijat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, nastavenia_aplikacie* nastavenia);
|
||||
int prijat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, nastavenia_aplikacie* nastavenia, int velkost_bloku_dat);
|
||||
|
||||
#endif
|
@ -71,7 +71,7 @@ void zobraz_sifru(WOLFSSL* ssl)
|
||||
printf ("Pouzita sifra: %s\n", wolfSSL_get_cipher(ssl));
|
||||
}
|
||||
|
||||
int generovat_rsa_certifikat(int pocet_bitov, int exponent, int algoritmus, char* krajina, char* mesto, char* domena, char* email)
|
||||
int generovat_rsa_certifikat(const char* subor_certifikat, const char* subor_kluc, int pocet_bitov, int exponent, int algoritmus, char* krajina, char* mesto, char* domena, char* email)
|
||||
{
|
||||
int uspech = 0;
|
||||
|
||||
@ -151,7 +151,7 @@ int generovat_rsa_certifikat(int pocet_bitov, int exponent, int algoritmus, char
|
||||
pem_kluc_velkost = uspech;
|
||||
|
||||
//zapis vygenerovaneho klucu do suboru
|
||||
subor = fopen("../../certifikaty/vygenerovany_kluc.key", "wb");
|
||||
subor = fopen(subor_kluc, "wb+");
|
||||
fwrite(pem_kluc, 1, pem_kluc_velkost, subor);
|
||||
fclose(subor);
|
||||
|
||||
@ -204,8 +204,8 @@ int generovat_rsa_certifikat(int pocet_bitov, int exponent, int algoritmus, char
|
||||
}
|
||||
pem_certifikat_velkost = uspech;
|
||||
|
||||
//zapis vygenerovaneho klucu do suboru
|
||||
subor = fopen("../../certifikaty/vygenerovany_certifikat.pem", "wb");
|
||||
//zapis vygenerovaneho certifikatu do suboru
|
||||
subor = fopen(subor_certifikat, "wb+");
|
||||
fwrite(pem_certifikat, 1, pem_certifikat_velkost, subor);
|
||||
fclose(subor);
|
||||
|
||||
@ -214,7 +214,7 @@ int generovat_rsa_certifikat(int pocet_bitov, int exponent, int algoritmus, char
|
||||
return 0;
|
||||
}
|
||||
|
||||
int generovat_ecc_certifikat(int pocet_bitov, ecc_curve_id kluc_krivka, int algoritmus, char* krajina, char* mesto, char* domena, char* email)
|
||||
int generovat_ecc_certifikat(const char* subor_certifikat, const char* subor_kluc, int pocet_bitov, ecc_curve_id kluc_krivka, int algoritmus, char* krajina, char* mesto, char* domena, char* email)
|
||||
{
|
||||
int uspech = 0 ;
|
||||
|
||||
@ -293,7 +293,7 @@ int generovat_ecc_certifikat(int pocet_bitov, ecc_curve_id kluc_krivka, int algo
|
||||
pem_kluc_velkost = uspech;
|
||||
|
||||
//zapis vygenerovaneho kluca do suboru
|
||||
subor = fopen("../certifikaty/vygenerovany_kluc.key", "wb");
|
||||
subor = fopen(subor_kluc, "wb+");
|
||||
fwrite(pem_kluc, 1, pem_kluc_velkost, subor);
|
||||
fclose(subor);
|
||||
|
||||
@ -347,14 +347,14 @@ int generovat_ecc_certifikat(int pocet_bitov, ecc_curve_id kluc_krivka, int algo
|
||||
pem_certifikat_velkost = uspech;
|
||||
|
||||
//zapis vygenerovaneho klucu do suboru
|
||||
subor = fopen("../certifikaty/vygenerovany_certifikat.pem", "wb");
|
||||
subor = fopen(subor_certifikat, "wb+");
|
||||
fwrite(pem_certifikat, 1, pem_certifikat_velkost, subor);
|
||||
fclose(subor);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vygenerovat_rsa_ziadost(int pocet_bitov, int exponent, int algoritmus, char* krajina, char* mesto, char* domena, char* email)
|
||||
int vygenerovat_rsa_ziadost(const char* subor_ziadost, const char* subor_kluc, int pocet_bitov, int exponent, int algoritmus, char* krajina, char* mesto, char* domena, char* email)
|
||||
{
|
||||
int uspech = 0;
|
||||
|
||||
@ -392,6 +392,11 @@ int vygenerovat_rsa_ziadost(int pocet_bitov, int exponent, int algoritmus, char*
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE* subor = fopen(subor_kluc, "wb+");
|
||||
fwrite(pem_kluc, 1, pem_kluc_velkost, subor);
|
||||
fclose(subor);
|
||||
printf("RSA kluc bol uspesne vygenerovany\n");
|
||||
|
||||
//premenne pre ukladanie dat ziadosti
|
||||
Cert ziadost;
|
||||
unsigned char der_ziadost[VELKOST_BUFFERA];
|
||||
@ -429,9 +434,13 @@ int vygenerovat_rsa_ziadost(int pocet_bitov, int exponent, int algoritmus, char*
|
||||
fprintf(stderr, "Nastala chyba pri vytvoreni suboru PEM so ziadostou.\nCislo chyby: %d\nDovod chyby: %s\n", uspech, wc_GetErrorString(uspech));
|
||||
return -1;
|
||||
}
|
||||
pem_ziadost_velkost = uspech;
|
||||
subor = fopen(subor_ziadost, "wb+");
|
||||
fwrite(pem_ziadost, 1, pem_ziadost_velkost, subor);
|
||||
fclose(subor);
|
||||
}
|
||||
|
||||
int vygenerovat_ecc_ziadost(int pocet_bitov, ecc_curve_id kluc_krivka, int algoritmus, char* krajina, char* mesto, char* domena, char* email)
|
||||
int vygenerovat_ecc_ziadost(const char* subor_ziadost, const char* subor_kluc, int pocet_bitov, ecc_curve_id kluc_krivka, int algoritmus, char* krajina, char* mesto, char* domena, char* email)
|
||||
{
|
||||
int uspech = 0;
|
||||
|
||||
@ -469,6 +478,11 @@ int vygenerovat_ecc_ziadost(int pocet_bitov, ecc_curve_id kluc_krivka, int algor
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE* subor = fopen(subor_kluc, "wb+");
|
||||
fwrite(pem_kluc, 1, pem_kluc_velkost, subor);
|
||||
fclose(subor);
|
||||
printf("ECC kluc bol uspesne vygenerovany\n");
|
||||
|
||||
//premenne pre ukladanie dat ziadosti
|
||||
Cert ziadost;
|
||||
unsigned char der_ziadost[VELKOST_BUFFERA];
|
||||
@ -506,6 +520,10 @@ int vygenerovat_ecc_ziadost(int pocet_bitov, ecc_curve_id kluc_krivka, int algor
|
||||
fprintf(stderr, "Nastala chyba pri vytvoreni suboru PEM so ziadostou.\nCislo chyby: %d\nDovod chyby: %s\n", uspech, wc_GetErrorString(uspech));
|
||||
return -1;
|
||||
}
|
||||
pem_ziadost_velkost = uspech;
|
||||
subor = fopen(subor_ziadost, "wb+");
|
||||
fwrite(pem_ziadost, 1, pem_ziadost_velkost, subor);
|
||||
fclose(subor);
|
||||
}
|
||||
|
||||
int nacitat_certifikaty(WOLFSSL_CTX* ctx, const char* subor_certifikat, const char* subor_kluc)
|
||||
@ -541,7 +559,6 @@ int nacitat_certifikaty(WOLFSSL_CTX* ctx, const char* subor_certifikat, const ch
|
||||
|
||||
void zobraz_certifikat(WOLFSSL* ssl)
|
||||
{
|
||||
printf("Informacie o certifikate:\n");
|
||||
WOLFSSL_X509 *certifikat = wolfSSL_get_peer_certificate(ssl);
|
||||
char* pole;
|
||||
if (!certifikat)
|
||||
|
@ -26,8 +26,13 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
//velkost bufferov do ktorych sa ukladaju data certifikatov, klucov, ziadosti
|
||||
#define VELKOST_BUFFERA 4096
|
||||
|
||||
//pocet bajtov ktore vstupuju do crc funkcie
|
||||
#define CRC32_VELKOST 10
|
||||
|
||||
//velkost vystupu blake2d hashu v bitoch
|
||||
#define BLAKE2B_VELKOST 64
|
||||
|
||||
/**
|
||||
@ -82,41 +87,49 @@ unsigned char* generovat_kontrolny_sucet_suboru(nastavenia_aplikacie* nastavenia
|
||||
/**
|
||||
* generovat_ecc_certifikat: realizuje vygenerovania sukromneho kluca, nacitanie sukromneho kluca autority,
|
||||
* vygenerovanie a podpis ecc certifikatu pomocou sukromneho kluca a certifikatu autority
|
||||
* @parameter const char* subor_kluc : absolutna cesta ku suboru so sukromnym klucom vo formate PEM
|
||||
* @parameter const char* subor_certifikat : absolutna cesta ku suboru s certifikatom vo formate PEM
|
||||
* @parameter int pocet_bitov : velkost kluca
|
||||
* @parameter ecc-curve_id kluc_krivka: kod krivky pre generovanie sukromneho kluca
|
||||
* @parameter int algoritmus: kod algoritmu, sluziaceho na vymenu klucov
|
||||
* @vrati int: operacia bola uspesna(0), neuspesna(-1)
|
||||
*/
|
||||
int generovat_ecc_certifikat(int pocet_bitov, ecc_curve_id kluc_krivka, int algoritmus, char* krajina, char* mesto, char* domena, char* email);
|
||||
int generovat_ecc_certifikat(const char* subor_kluc, const char* subor_certifikat, int pocet_bitov, ecc_curve_id kluc_krivka, int algoritmus, char* krajina, char* mesto, char* domena, char* email);
|
||||
|
||||
/**
|
||||
* generovat_rsa_certifikat: realizuje vygenerovania sukromneho kluca, nacitanie sukromneho kluca autority,
|
||||
* vygenerovanie a podpis rsa certifikatu pomocou sukromneho kluca a certifikatu autority
|
||||
* @parameter const char* subor_kluc : absolutna cesta ku suboru so sukromnym klucom vo formate PEM
|
||||
* @parameter const char* subor_certifikat : absolutna cesta ku suboru s certifikatom vo formate PEM
|
||||
* @parameter int pocet_bitov : velkost kluca
|
||||
* @parameter int exponent : hodnota exponentu
|
||||
* @parameter int algoritmus : kod algoritmu, sluziaceho na vymenu klucov
|
||||
* @vrati int : operacia bola uspesna(0), neuspesna(-1)
|
||||
*/
|
||||
int generovat_rsa_certifikat(int pocet_bitov, int exponent, int algoritmus, char* krajina, char* mesto, char* domena, char* email);
|
||||
int generovat_rsa_certifikat(const char* subor_kluc, const char* subor_certifikat, int pocet_bitov, int exponent, int algoritmus, char* krajina, char* mesto, char* domena, char* email);
|
||||
|
||||
/**
|
||||
* generovat_rsa_ziadost: realizuje vygenerovania sukromneho kluca, vygenerovanie a podpis ziadosti
|
||||
* @parameter const char* subor_kluc : absolutna cesta ku suboru so sukromnym klucom vo formate PEM
|
||||
* @parameter const char* subor_ziadost : absolutna cesta ku suboru so ziadostou vo formate PEM
|
||||
* @parameter int pocet_bitov : velkost kluca
|
||||
* @parameter int exponent : hodnota exponentu
|
||||
* @parameter int algoritmus: kod algoritmu, sluziaceho na vymenu klucov
|
||||
* @vrati int: operacia bola uspesna(0), neuspesna(-1)
|
||||
*/
|
||||
int generovat_rsa_ziadost(int pocet_bitov, int exponent, int algoritmus, char* krajina, char* mesto, char* domena, char* email);
|
||||
int generovat_rsa_ziadost(const char* subor_kluc, const char* subor_ziadost, int pocet_bitov, int exponent, int algoritmus, char* krajina, char* mesto, char* domena, char* email);
|
||||
|
||||
/**
|
||||
* generovat_ecc_ziadost: realizuje vygenerovania sukromneho kluca, vygenerovanie a podpis ziadosti
|
||||
* @parameter const char* subor_kluc : absolutna cesta ku suboru so sukromnym klucom vo formate PEM
|
||||
* @parameter const char* subor_ziadost : absolutna cesta ku suboru so ziadostou vo formate PEM
|
||||
* @parameter int pocet_bitov : velkost kluca
|
||||
* @parameter ecc-curve_id kluc_krivka: kod krivky pre generovanie sukromneho kluca
|
||||
* @parameter int algoritmus: kod algoritmu, sluziaceho na vymenu klucov
|
||||
* @vrati int: operacia bola uspesna(0), neuspesna(-1)
|
||||
*/
|
||||
|
||||
int generovat_ecc_ziadost(int pocet_bitov, ecc_curve_id kluc_krivka, int algoritmus, char* krajina, char* mesto, char* domena, char* email);
|
||||
int generovat_ecc_ziadost(const char* subor_kluc, const char* subor_ziadost, int pocet_bitov, ecc_curve_id kluc_krivka, int algoritmus, char* krajina, char* mesto, char* domena, char* email);
|
||||
|
||||
/**
|
||||
* nastav_ctx_klient : realizuje vytvorenie a inicializaciu CTX struktury
|
||||
|
@ -103,6 +103,7 @@ int main(int argc, char const *argv[])
|
||||
WOLFSSL *ssl;
|
||||
WOLFSSL_CTX *ctx = NULL;
|
||||
const char* subor = NULL;
|
||||
int autentizacia = 0;
|
||||
int zadane_rozhranie = 0;
|
||||
int uvedeny_subor = 0;
|
||||
int nacitanie_zo_suboru = 0;
|
||||
@ -118,9 +119,10 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("---------------\n| Certifikaty |\n---------------\n");
|
||||
for(int i = 0; i < argc; i++)
|
||||
{
|
||||
if( (!strcmp(argv[i], "-s")) )
|
||||
if( (!strcmp(argv[i], "-subor")) )
|
||||
{
|
||||
uvedeny_subor = 1;
|
||||
if((argv[i+1] == NULL) )
|
||||
@ -133,7 +135,7 @@ int main(int argc, char const *argv[])
|
||||
subor = argv[i+1];
|
||||
}
|
||||
}
|
||||
if( (!strcmp(argv[i], "-port")) )
|
||||
else if( (!strcmp(argv[i], "-port")) )
|
||||
{
|
||||
zadane_rozhranie = 1;
|
||||
if((argv[i+1] == NULL))
|
||||
@ -150,7 +152,32 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-n")) )
|
||||
else if( (!strcmp(argv[i], "-cert-aut")) )
|
||||
{
|
||||
if((argv[i+1] == NULL) || (i == argc-1))
|
||||
{
|
||||
printf("Nezadali ste typ certifikatu autority ktory chcete nacitat\n");
|
||||
return -1;
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_rsa.pem", NULL);
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
autentizacia = 1;
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
autentizacia = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Zadali ste nespravny typ certifikatu\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-cert")) )
|
||||
{
|
||||
nacitanie_zo_suboru = 1;
|
||||
if(generovanie_certifikatu)
|
||||
@ -165,17 +192,11 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_rsa.pem", NULL);
|
||||
if(nacitat_certifikaty(ctx, RSA_CERTIFIKAT, RSA_KLUC) == -1) return -1;
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
if(nacitat_certifikaty(ctx, ECC_CERTIFIKAT, ECC_KLUC) == -1) return -1;
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -183,7 +204,7 @@ int main(int argc, char const *argv[])
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-g")) )
|
||||
else if( (!strcmp(argv[i], "-cert-gen")) )
|
||||
{
|
||||
generovanie_certifikatu = 1;
|
||||
if(nacitanie_zo_suboru)
|
||||
@ -198,18 +219,14 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_rsa.pem", NULL);
|
||||
if(generovat_rsa_certifikat(RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(generovat_rsa_certifikat(VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC, RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(nacitat_certifikaty(ctx, VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC) == -1) return -1;
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
|
||||
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
if(generovat_ecc_certifikat(ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(generovat_ecc_certifikat(VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC, ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(nacitat_certifikaty(ctx, VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC) == -1) return -1;
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -219,23 +236,29 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//vypis upozornenia o autentizacii
|
||||
if(!autentizacia)
|
||||
{
|
||||
printf("Nebol nacitany certifikat autority, takze nebude vykonana autentizacia druhej strany\n");
|
||||
}
|
||||
|
||||
if(!zadane_rozhranie)
|
||||
{
|
||||
fprintf(stderr, "Nebol urcene seriove rozhranie\n");
|
||||
return -1;
|
||||
}
|
||||
else if(!generovanie_certifikatu && !nacitanie_zo_suboru)
|
||||
{
|
||||
fprintf(stderr, "Nebola zvolena metoda nacitania certifikatov\n");
|
||||
printf("Zadajde prepinac -g (generovanie), alebo -n (nacitanie_zo_suboru) s parametrom rsa alebo ecc\n");
|
||||
return -1;
|
||||
}
|
||||
else if(!uvedeny_subor)
|
||||
{
|
||||
fprintf(stderr, "Nebola uvedena cesta ku suboru na odoslanie\n");
|
||||
return -1;
|
||||
}
|
||||
{
|
||||
fprintf(stderr, "Nebol urcene seriove rozhranie\n");
|
||||
return -1;
|
||||
}
|
||||
else if(!generovanie_certifikatu && !nacitanie_zo_suboru)
|
||||
{
|
||||
fprintf(stderr, "Nebola zvolena metoda nacitania certifikatov\n");
|
||||
printf("Zadajde prepinac -gen-cert (generovanie), alebo -cert (nacitanie zo suboru) s parametrom rsa alebo ecc\n");
|
||||
return -1;
|
||||
}
|
||||
else if(!uvedeny_subor)
|
||||
{
|
||||
fprintf(stderr, "Nebola uvedena cesta ku suboru na odoslanie\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//nastav_sifry(ctx, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256");
|
||||
|
||||
@ -256,6 +279,8 @@ int main(int argc, char const *argv[])
|
||||
wolfSSL_set_using_nonblock(ssl, k_subor);
|
||||
|
||||
//pokus o inizicalizaciu TLS handshaku so serverom
|
||||
printf("-----------------\n| TLS Handshake |\n-----------------\n");
|
||||
printf("Inicializacia TLS spojenia\n");
|
||||
uspech = wolfSSL_connect(ssl);
|
||||
if(uspech != SSL_SUCCESS)
|
||||
{
|
||||
@ -268,19 +293,20 @@ int main(int argc, char const *argv[])
|
||||
free(popis_chyby);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Podarilo sa vytvorit TLS spojenie\n");
|
||||
zobraz_sifru(ssl);
|
||||
printf("----------------------------\n| Informacie o certifikate |\n----------------------------\n");
|
||||
zobraz_certifikat(ssl);
|
||||
|
||||
//nastavenie funkcie pre vypocet kontrolneho suctu
|
||||
//nastavime typ "crc" alebo "hash" a nazov funkcie, nazov druhej funkcie nastavime na NULL
|
||||
nastav_funkciu(&nastavenia, "crc", (hashovacia_funkcia)NULL, funkcia_CRC32);
|
||||
|
||||
if(poslat_subor(ssl, ctx, subor, &nastavenia) == -1)
|
||||
{
|
||||
fclose(fopen(KOMUNIKACNY_SUBOR, "wb"));
|
||||
return -1;
|
||||
}
|
||||
printf("-------------------\n| Poslanie suboru |\n-------------------\n");
|
||||
|
||||
if(poslat_subor(ssl, ctx, subor, &nastavenia, 4096) == -1) return -1;
|
||||
|
||||
printf("----------------------\n| Ukoncenie spojenia |\n----------------------\n");
|
||||
|
||||
//ukoncenie spojenia, vymazanie komunikacneho suboru
|
||||
//a vycistenie serioveho buffera
|
||||
|
BIN
rs232_kanal/klient/obr.jpg
Normal file
BIN
rs232_kanal/klient/obr.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
@ -13,4 +13,4 @@
|
||||
:: -s cesta-ku-suboru sluzi na nacitanie cesty k suboru, ktory chceme odoslat
|
||||
|
||||
::Priklady spustenia:
|
||||
klient -port 4 -n rsa -s document.pdf
|
||||
klient -port 4 -cert rsa -cert-aut rsa -subor obr.jpg
|
||||
|
BIN
rs232_kanal/server/obr.jpg
Normal file
BIN
rs232_kanal/server/obr.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
@ -100,6 +100,7 @@ int main(int argc, char const *argv[])
|
||||
|
||||
WOLFSSL *ssl;
|
||||
WOLFSSL_CTX *ctx = NULL;
|
||||
int autentizacia = 0;
|
||||
int zadane_rozhranie = 0;
|
||||
int generovanie_certifikatu = 0;
|
||||
int nacitanie_zo_suboru = 0;
|
||||
@ -115,9 +116,10 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("---------------\n| Certifikaty |\n---------------\n");
|
||||
for(int i = 0; i < argc; i++)
|
||||
{
|
||||
if( (!strcmp(argv[i], "-port")) )
|
||||
if( (!strcmp(argv[i], "-port")) )
|
||||
{
|
||||
zadane_rozhranie = 1;
|
||||
if((argv[i+1] == NULL))
|
||||
@ -134,7 +136,32 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-n")) )
|
||||
else if( (!strcmp(argv[i], "-cert-aut")) )
|
||||
{
|
||||
if((argv[i+1] == NULL) || (i == argc-1))
|
||||
{
|
||||
printf("Nezadali ste typ certifikatu autority ktory chcete nacitat\n");
|
||||
return -1;
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_rsa.pem", NULL);
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
autentizacia = 1;
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
autentizacia = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Zadali ste nespravny typ certifikatu\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-cert")) )
|
||||
{
|
||||
nacitanie_zo_suboru = 1;
|
||||
if(generovanie_certifikatu)
|
||||
@ -149,17 +176,11 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_rsa.pem", NULL);
|
||||
if(nacitat_certifikaty(ctx, RSA_CERTIFIKAT, RSA_KLUC) == -1) return -1;
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
if(nacitat_certifikaty(ctx, ECC_CERTIFIKAT, ECC_KLUC) == -1) return -1;
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -167,7 +188,7 @@ int main(int argc, char const *argv[])
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-g")) )
|
||||
else if( (!strcmp(argv[i], "-cert-gen")) )
|
||||
{
|
||||
generovanie_certifikatu = 1;
|
||||
if(nacitanie_zo_suboru)
|
||||
@ -182,15 +203,13 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_rsa.pem", NULL);
|
||||
if(generovat_rsa_certifikat(RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(generovat_rsa_certifikat(VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC, RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(nacitat_certifikaty(ctx, VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC) == -1) return -1;
|
||||
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
if(generovat_ecc_certifikat(ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(generovat_ecc_certifikat(VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC, ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(nacitat_certifikaty(ctx, VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC) == -1) return -1;
|
||||
}
|
||||
else
|
||||
@ -201,6 +220,12 @@ int main(int argc, char const *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//vypis upozornenia o autentizacii
|
||||
if(!autentizacia)
|
||||
{
|
||||
printf("Nebol nacitany certifikat autority, takze nebude vykonana autentizacia druhej strany\n");
|
||||
}
|
||||
|
||||
if(!zadane_rozhranie)
|
||||
{
|
||||
@ -233,6 +258,8 @@ int main(int argc, char const *argv[])
|
||||
wolfSSL_set_using_nonblock(ssl, k_subor);
|
||||
|
||||
//cakanie na inicializaciu TLS handshaku klientom
|
||||
printf("-----------------\n| TLS Handshake |\n-----------------\n");
|
||||
printf("Inicializacia TLS spojenia\n");
|
||||
uspech = wolfSSL_accept(ssl);
|
||||
if(uspech != SSL_SUCCESS)
|
||||
{
|
||||
@ -245,24 +272,24 @@ int main(int argc, char const *argv[])
|
||||
free(popis_chyby);
|
||||
return -1;
|
||||
}
|
||||
printf("Podarilo sa vytvorit TLS spojenie\n");
|
||||
zobraz_sifru(ssl);
|
||||
printf("----------------------------\n| Informacie o certifikate |\n----------------------------\n");
|
||||
zobraz_certifikat(ssl);
|
||||
|
||||
|
||||
//nastavenie funkcie pre vypocet kontrolneho suctu
|
||||
//nastavime typ "crc" alebo "hash" a nazov funkcie, nazov druhej funkcie nastavime na NULL
|
||||
nastav_funkciu(&nastavenia, "crc", (hashovacia_funkcia)NULL, funkcia_CRC32);
|
||||
|
||||
|
||||
//vypocet casu prenosu suboru
|
||||
printf("-------------------\n| Prijatie suboru |\n-------------------\n");
|
||||
clock_t cas;
|
||||
cas = clock();
|
||||
if(prijat_subor(ssl, ctx, &nastavenia) == -1)
|
||||
{
|
||||
fclose(fopen(KOMUNIKACNY_SUBOR, "wb"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(prijat_subor(ssl, ctx, &nastavenia, 4096) == -1) return -1;
|
||||
cas = clock() - cas;
|
||||
printf("Cas prenosu suboru: %f sekund\n", (double)cas/CLOCKS_PER_SEC);
|
||||
|
||||
printf("----------------------\n| Ukoncenie spojenia |\n----------------------\n");
|
||||
|
||||
//ukoncenie spojenia, vymazanie komunikacneho suboru
|
||||
//a vycistenie serioveho buffera
|
||||
|
@ -11,4 +11,4 @@
|
||||
:: -g rsa|ecc sluzi na generovanie certifikatu
|
||||
:: -n rsa|ecc sluzi na nacitanie uz vygenerovanych certifikatov z adresara /certifikaty
|
||||
|
||||
server -port 5 -n rsa
|
||||
server -port 5 -cert rsa -cert-aut rsa
|
@ -22,9 +22,12 @@
|
||||
#define ECC_CERTIFIKAT "../../certifikaty/klient/klient_ecc.pem"
|
||||
#define VYGENEROVANY_KLUC "../../certifikaty/klient/vygenerovany_kluc.key"
|
||||
#define VYGENEROVANY_CERTIFIKAT "../../certifikaty/klient/vygenerovany_certifikat.pem"
|
||||
#define VYGENEROVANA_ZIADOST "../../certifikaty/klient/vygenerovana_ziadost.pem"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int autentizacia = 0;
|
||||
clock_t cas;
|
||||
int uspech;
|
||||
int generovanie_certifikatu = 0;
|
||||
int nacitanie_zo_suboru = 0;
|
||||
@ -56,9 +59,10 @@ int main(int argc, char** argv)
|
||||
{
|
||||
//skontroluje ci nebol zadany prepinac "-g" pre moznost generovanie certifikatu,
|
||||
//ak ano pozrie aky typ certifikatu (v CLI argument hned za nim) bol zvoleny
|
||||
printf("---------------\n| Certifikaty |\n---------------\n");
|
||||
for(int i = 0; i < argc; i++)
|
||||
{
|
||||
if( (!strcmp(argv[i], "-s")) )
|
||||
if( (!strcmp(argv[i], "-subor")) )
|
||||
{
|
||||
uvedeny_subor = 1;
|
||||
if((argv[i+1] == NULL) )
|
||||
@ -71,9 +75,9 @@ int main(int argc, char** argv)
|
||||
subor = argv[i+1];
|
||||
}
|
||||
}
|
||||
if( (!strcmp(argv[i], "-ip")) )
|
||||
if( (!strcmp(argv[i], "-ip-adr")) )
|
||||
{
|
||||
port = 1;
|
||||
ip = 1;
|
||||
if((argv[i+1] == NULL) )
|
||||
{
|
||||
printf("Nezadali ste ip adresu\n");
|
||||
@ -86,7 +90,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-port")) )
|
||||
{
|
||||
ip = 1;
|
||||
port = 1;
|
||||
if((argv[i+1] == NULL) )
|
||||
{
|
||||
printf("Nezadali ste cislo portu\n");
|
||||
@ -97,7 +101,32 @@ int main(int argc, char** argv)
|
||||
cislo_portu = atoi(argv[i+1]);
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-n")) )
|
||||
else if( (!strcmp(argv[i], "-cert-aut")) )
|
||||
{
|
||||
if((argv[i+1] == NULL) || (i == argc-1))
|
||||
{
|
||||
printf("Nezadali ste typ certifikatu autority ktory chcete nacitat\n");
|
||||
return -1;
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_rsa.pem", NULL);
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
autentizacia = 1;
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
autentizacia = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Zadali ste nespravny typ certifikatu\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-cert")) )
|
||||
{
|
||||
nacitanie_zo_suboru = 1;
|
||||
if(generovanie_certifikatu)
|
||||
@ -112,12 +141,10 @@ int main(int argc, char** argv)
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_rsa.pem", NULL);
|
||||
if(nacitat_certifikaty(ctx, RSA_CERTIFIKAT, RSA_KLUC) == -1) return -1;
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
if(nacitat_certifikaty(ctx, ECC_CERTIFIKAT, ECC_KLUC) == -1) return -1;
|
||||
}
|
||||
else
|
||||
@ -126,9 +153,14 @@ int main(int argc, char** argv)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-g")) )
|
||||
else if( (!strcmp(argv[i], "-cert-gen")) )
|
||||
{
|
||||
generovanie_certifikatu = 1;
|
||||
if(nacitanie_zo_suboru)
|
||||
{
|
||||
fprintf(stderr, "Nie je mozne zvolit obidve metody nacitania certifikatov naraz\n");
|
||||
return -1;
|
||||
}
|
||||
if((argv[i+1] == NULL) || (i == argc-1))
|
||||
{
|
||||
printf("Nezadali ste typ certifikatu ktory chcete vygenerovat\n");
|
||||
@ -136,17 +168,14 @@ int main(int argc, char** argv)
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita_rsa.pem", NULL);
|
||||
if(generovat_rsa_certifikat(RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "local.dev", "klient@klient.sk") == -1) return -1;
|
||||
if(generovat_rsa_certifikat(VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC, RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(nacitat_certifikaty(ctx, VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC) == -1) return -1;
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
|
||||
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
if(generovat_ecc_certifikat(ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "local.dev", "klient@klient.sk") == -1) return -1;
|
||||
if(generovat_ecc_certifikat(VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC, ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(nacitat_certifikaty(ctx, VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC) == -1) return -1;
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -155,6 +184,12 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//vypis upozornenia o autentizacii
|
||||
if(!autentizacia)
|
||||
{
|
||||
printf("Nebol nacitany certifikat autority, takze nebude vykonana autentizacia druhej strany\n");
|
||||
}
|
||||
|
||||
if(!ip)
|
||||
{
|
||||
@ -181,18 +216,23 @@ int main(int argc, char** argv)
|
||||
//nastav_sifry(ctx, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256");
|
||||
|
||||
//pokus o inicializaciu TCP/IP prenosoveho kanala
|
||||
printf("----------------\n| TCP/IP kanal |\n----------------\n");
|
||||
printf("Pokus o inicializaciu TCP/IP prenosoveho kanala\n");
|
||||
cislo_soketu = pripojit_na_server(ip_adresa, cislo_portu, 5);
|
||||
|
||||
if(!cislo_soketu) return -1;
|
||||
printf("TCP/IP kanal bol uspesne vytvoreny\n");
|
||||
|
||||
//pokus o vytvorenie novej wolfSSL relacie
|
||||
ssl = wolfSSL_new(ctx);
|
||||
|
||||
//priradenie file descriptora soketu ako I/O pre TLS spojenie
|
||||
wolfSSL_set_fd(ssl, cislo_soketu);
|
||||
wolfSSL_set_using_nonblock(ssl, 1);
|
||||
|
||||
//pokus o inizicalizaciu TLS handshaku so serverom
|
||||
uspech = wolfSSL_connect(ssl);
|
||||
printf("-----------------\n| TLS Handshake |\n-----------------\n");
|
||||
printf("Inicializacia TLS spojenia\n");
|
||||
if(uspech != SSL_SUCCESS)
|
||||
{
|
||||
char* popis_chyby = calloc(100, sizeof(char));
|
||||
@ -202,18 +242,21 @@ int main(int argc, char** argv)
|
||||
printf("Skontrolujte certifikaty.\n");
|
||||
free(popis_chyby);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
printf("Podarilo sa vytvorit TLS spojenie\n");
|
||||
zobraz_sifru(ssl);
|
||||
printf("----------------------------\n| Informacie o certifikate |\n----------------------------\n");
|
||||
zobraz_certifikat(ssl);
|
||||
|
||||
//nastavenie funkcie pre vypocet kontrolneho suctu
|
||||
//nastavime typ "crc" alebo "hash" a nazov funkcie, nazov druhej funkcie nastavime na NULL
|
||||
nastav_funkciu(&nastavenia, "crc", (hashovacia_funkcia)NULL, funkcia_CRC32);
|
||||
|
||||
printf("-------------------\n| Poslanie suboru |\n-------------------\n");
|
||||
|
||||
if(poslat_subor(ssl, ctx, subor, &nastavenia, 16384) == -1) return -1;
|
||||
|
||||
if(poslat_subor(ssl, ctx, subor, &nastavenia) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
printf("----------------------\n| Ukoncenie spojenia |\n----------------------\n");
|
||||
ukoncit_spojenie(ssl, ctx);
|
||||
}
|
||||
ukoncit_soket(cislo_soketu);
|
||||
|
BIN
tcpip_kanal/klient/obr.jpg
Normal file
BIN
tcpip_kanal/klient/obr.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
@ -12,4 +12,4 @@
|
||||
:: -s cesta-ku-suboru sluzi na nacitanie cesty k suboru, ktory chceme odoslat
|
||||
|
||||
::Priklady spustenia:
|
||||
klient -ip 127.0.0.1 -port 8080 -n rsa -s document.pdf
|
||||
klient -ip-adr 127.0.0.1 -port 8080 -cert rsa -cert-aut rsa -subor obr.jpg
|
||||
|
BIN
tcpip_kanal/server/obr.jpg
Normal file
BIN
tcpip_kanal/server/obr.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
@ -22,9 +22,12 @@
|
||||
#define ECC_CERTIFIKAT "../../certifikaty/server/server_ecc.pem"
|
||||
#define VYGENEROVANY_KLUC "../../certifikaty/server/vygenerovany_kluc.key"
|
||||
#define VYGENEROVANY_CERTIFIKAT "../../certifikaty/server/vygenerovany_certifikat.pem"
|
||||
#define VYGENEROVANA_ZIADOST "../../certifikaty/server/vygenerovana_ziadost.pem"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int autentizacia = 0;
|
||||
int uspech;
|
||||
int autentizacia_klienta = 0;
|
||||
int generovanie_certifikatu = 0;
|
||||
int nacitanie_zo_suboru = 0;
|
||||
@ -52,6 +55,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
//skontroluje ci nebol zadany prepinac "-g" pre moznost generovanie certifikatu,
|
||||
//ak ano pozrie aky typ certifikatu (v CLI argument hned za nim) bol zvoleny
|
||||
printf("---------------\n| Certifikaty |\n---------------\n");
|
||||
for(int i = 0; i < argc; i++)
|
||||
{
|
||||
if( (!strcmp(argv[i], "-port")) )
|
||||
@ -67,7 +71,32 @@ int main(int argc, char **argv)
|
||||
cislo_portu = atoi(argv[i+1]);
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-n")) )
|
||||
else if( (!strcmp(argv[i], "-cert-aut")) )
|
||||
{
|
||||
if((argv[i+1] == NULL) || (i == argc-1))
|
||||
{
|
||||
printf("Nezadali ste typ certifikatu autority ktory chcete nacitat\n");
|
||||
return -1;
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_rsa.pem", NULL);
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
autentizacia = 1;
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
autentizacia = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Zadali ste nespravny typ certifikatu\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-cert")) )
|
||||
{
|
||||
nacitanie_zo_suboru = 1;
|
||||
if(generovanie_certifikatu)
|
||||
@ -82,18 +111,11 @@ int main(int argc, char **argv)
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_rsa.pem", NULL);
|
||||
if(nacitat_certifikaty(ctx, RSA_CERTIFIKAT, RSA_KLUC) == -1) return -1;
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
printf("jo\n");
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
if(nacitat_certifikaty(ctx, ECC_CERTIFIKAT, ECC_KLUC) == -1) return -1;
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -101,7 +123,7 @@ int main(int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if( (!strcmp(argv[i], "-g")) )
|
||||
else if( (!strcmp(argv[i], "-cert-gen")) )
|
||||
{
|
||||
generovanie_certifikatu = 1;
|
||||
if(nacitanie_zo_suboru)
|
||||
@ -116,15 +138,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "rsa"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_rsa.pem", NULL);
|
||||
if(generovat_rsa_certifikat(RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(generovat_rsa_certifikat(VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC, RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(nacitat_certifikaty(ctx, VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC) == -1) return -1;
|
||||
|
||||
}
|
||||
else if(!strcmp(argv[i+1], "ecc"))
|
||||
{
|
||||
wolfSSL_CTX_load_verify_locations(ctx, "../../certifikaty/autorita/autorita_ecc.pem", NULL);
|
||||
if(generovat_ecc_certifikat(ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(generovat_ecc_certifikat(VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC, ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||
if(nacitat_certifikaty(ctx, VYGENEROVANY_CERTIFIKAT, VYGENEROVANY_KLUC) == -1) return -1;
|
||||
}
|
||||
else
|
||||
@ -135,6 +155,12 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
//vypis upozornenia o autentizacii
|
||||
if(!autentizacia)
|
||||
{
|
||||
printf("Nebol nacitany certifikat autority, takze nebude vykonana autentizacia druhej strany\n");
|
||||
}
|
||||
|
||||
if(!port)
|
||||
{
|
||||
fprintf(stderr, "Nebol urceny port\n");
|
||||
@ -151,6 +177,8 @@ int main(int argc, char **argv)
|
||||
//nastav_sifry(ctx, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256");
|
||||
|
||||
//pokus vytvorenie TCP/IP prenosoveho kanala
|
||||
printf("----------------\n| TCP/IP kanal |\n----------------\n");
|
||||
printf("Pokus o inicializaciu TCP/IP prenosoveho kanala\n");
|
||||
cislo_soketu = cakat_na_komunikaciu(cislo_portu);
|
||||
|
||||
struct sockaddr_in adresa;
|
||||
@ -158,15 +186,18 @@ int main(int argc, char **argv)
|
||||
int velkost = sizeof(adresa);
|
||||
int cislo_soketu_klienta = accept(cislo_soketu, (struct sockaddr*)&adresa, &velkost);
|
||||
printf("Spojenie [%s:%d]\n", inet_ntoa(adresa.sin_addr), ntohs(adresa.sin_port));
|
||||
printf("TCP/IP kanal bol uspesne vytvoreny\n");
|
||||
|
||||
//pokus o vytvorenie novej wolfSSL relacie
|
||||
ssl = wolfSSL_new(ctx);
|
||||
|
||||
//priradenie file descriptora soketu ako I/O pre TLS spojenie
|
||||
wolfSSL_set_fd(ssl, cislo_soketu_klienta);
|
||||
wolfSSL_set_using_nonblock(ssl, 1);
|
||||
|
||||
//cakanie na inicializaciu TLS handshaku klientom
|
||||
int uspech;
|
||||
printf("-----------------\n| TLS Handshake |\n-----------------\n");
|
||||
printf("Inicializacia TLS spojenia\n");
|
||||
if(wolfSSL_accept(ssl) != SSL_SUCCESS)
|
||||
{
|
||||
char* popis_chyby = calloc(100, sizeof(char));
|
||||
@ -177,7 +208,9 @@ int main(int argc, char **argv)
|
||||
free(popis_chyby);
|
||||
return -1;
|
||||
}
|
||||
printf("Podarilo sa vytvorit TLS spojenie\n");
|
||||
zobraz_sifru(ssl);
|
||||
printf("----------------------------\n| Informacie o certifikate |\n----------------------------\n");
|
||||
zobraz_certifikat(ssl);
|
||||
|
||||
//nastavenie funkcie pre vypocet kontrolneho suctu
|
||||
@ -185,15 +218,14 @@ int main(int argc, char **argv)
|
||||
nastav_funkciu(&nastavenia, "crc", (hashovacia_funkcia)NULL, funkcia_CRC32);
|
||||
|
||||
//vypocet casu prenosu suboru
|
||||
printf("-------------------\n| Prijatie suboru |\n-------------------\n");
|
||||
clock_t cas;
|
||||
cas = clock();
|
||||
if(prijat_subor(ssl, ctx, &nastavenia) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(prijat_subor(ssl, ctx, &nastavenia, 16384) == -1) return -1;
|
||||
cas = clock() - cas;
|
||||
printf("Cas prenosu suboru: %f sekund\n", (double)cas/CLOCKS_PER_SEC);
|
||||
|
||||
|
||||
printf("----------------------\n| Ukoncenie spojenia |\n----------------------\n");
|
||||
ukoncit_spojenie(ssl, ctx);
|
||||
}
|
||||
ukoncit_soket(cislo_soketu);
|
||||
|
@ -11,5 +11,5 @@
|
||||
:: -n rsa|ecc sluzi na nacitanie uz vygenerovanych certifikatov z adresara /certifikaty
|
||||
|
||||
::Priklady spustenia:
|
||||
server -port 8080 -n rsa
|
||||
server -port 8080 -cert rsa -cert-aut rsa
|
||||
::server -port 8080 -g ecc
|
Loading…
Reference in New Issue
Block a user