2020-03-12 16:22:08 +00:00
|
|
|
Bakalarska praca
|
|
|
|
Meno studenta: Tomas Lukac
|
|
|
|
Veduci BP: prof. Ing. Milos Drutarovsky CSc.
|
|
|
|
Skola: KEMT FEI TUKE
|
2020-05-06 10:53:08 +00:00
|
|
|
Datum poslednej upravy: 6.5.2020
|
2020-05-06 10:46:52 +00:00
|
|
|
Verzia: 0.3
|
2020-03-11 21:01:54 +00:00
|
|
|
----------------------------
|
|
|
|
Zoznam zdrojovych suborov
|
|
|
|
certifikaty
|
2020-04-07 20:11:21 +00:00
|
|
|
autorita
|
|
|
|
|__autorita_ecc.pem
|
|
|
|
|__autorita_ecc.key
|
|
|
|
|__autorita_rsa.pem
|
|
|
|
|__autorita_rsa.key
|
|
|
|
server
|
|
|
|
|__server_ecc.pem
|
|
|
|
|__server_ecc.key
|
|
|
|
|__server_rsa.pem
|
|
|
|
|__server_rsa.key
|
|
|
|
klient
|
|
|
|
|__klient_ecc.pem
|
|
|
|
|__klient_ecc.key
|
|
|
|
|__klient_rsa.pem
|
|
|
|
|__klient_rsa.key
|
2020-03-11 21:01:54 +00:00
|
|
|
kniznica
|
|
|
|
|__komunikacia.h
|
|
|
|
|__komunikacia.c
|
|
|
|
|__kryptografia.h
|
|
|
|
|__kryptografia.c
|
2020-03-12 16:22:08 +00:00
|
|
|
tcpip_kanal
|
2020-04-16 09:25:05 +00:00
|
|
|
klient
|
|
|
|
|__klient.c
|
|
|
|
|__Makefile
|
|
|
|
server
|
|
|
|
|__server.c
|
|
|
|
|__Makefile
|
2020-03-12 16:22:08 +00:00
|
|
|
rs232_kanal
|
2020-04-16 09:25:05 +00:00
|
|
|
klient
|
|
|
|
|__klient.c
|
|
|
|
|__Makefile
|
|
|
|
|__klient.txt
|
|
|
|
server
|
|
|
|
|__server.c
|
|
|
|
|__Makefile
|
|
|
|
|__server.txt
|
2020-03-11 21:01:54 +00:00
|
|
|
|
2020-05-06 10:46:52 +00:00
|
|
|
Kniznica
|
|
|
|
1. Komunikacna cast
|
|
|
|
...
|
|
|
|
2. Kryptograficka cast
|
|
|
|
...
|
|
|
|
|
|
|
|
Externe kniznice
|
|
|
|
1.TEUNIZ/RS232
|
|
|
|
Kniznica napisana v jazyku C, ktora umoznuje pracu so seriovym rozhranim RS232
|
|
|
|
na platformach Linux a Windows.
|
|
|
|
Pouzita verzia: May 31, 2019
|
|
|
|
Viac informacii: https://www.teuniz.net/RS-232
|
|
|
|
2. WOLFSSL
|
|
|
|
Kniznica napisana v jazyku C, ktora umoznuje vytvorenie zabezpeceneho prenosoveho kanala
|
|
|
|
pomocou protokolu SSL/TLS. Podporuje embedded zariadenia, IoT, desktop, RTOS, cloudy, ...
|
|
|
|
Podporuje standardy do verzii TLS 1.3 a DTLS 1.2. Podla vyvojarov je 20x mensia ako OpenSSL.
|
|
|
|
Jej sucastou je krytograficka kniznica wolfCrypt, obsahujuca nastroje na sifrovanie,
|
|
|
|
vymenu klucov, vypocet kontrolnych suctov a ine.
|
|
|
|
Pouzita verzia: 4.4.0
|
|
|
|
Viac informacii: https://www.wolfssl.com
|
|
|
|
3. ZLIB
|
|
|
|
Kniznica napisana v jazyku C, umoznujuca kompresiu a dekompresiu dat. Je to volny software
|
|
|
|
s otvorenym zdrojovym kodom. V SSL/TLS knizniciach je casto vyuzivana na kompresiu TLS spojeni,
|
|
|
|
ale v mojej kniznici som ju pouzil na vypocet CRC32 kontrolneho suctu.
|
|
|
|
Pouzita verzia: 1.2.11
|
|
|
|
Viac informacii: https://www.zlib.net
|
|
|
|
|
2020-03-11 21:01:54 +00:00
|
|
|
Opis aplikacie
|
2020-03-12 16:22:08 +00:00
|
|
|
Realizuje zabezpecenu vymenu sprav medzi klientom a serverom a autentizaciu servera klientom vyuzitim kniznice WolfSSL. Ako prvu je
|
|
|
|
potrebne spustit aplikaciu na strane servera s prepinacom port s hodnotou, ktora urcuje ake bude cislo portu, na ktorom bude server
|
2020-04-07 20:11:21 +00:00
|
|
|
cakat na prichadzajucu komunikaciu, v pripade rs232 kanala je potrebne uviest cislo serioveho rozhrania (hodnoty: https://www.teuniz.net/RS-232/).
|
|
|
|
Dalsim potrebnym prepinacom je bud -n (nacitanie certifikatov z adresaru /certifikaty) alebo -g (vygenerovanie a podpis certifikatov
|
|
|
|
pomocou certifikatu a kluca autority, ktore sa nachadzaju taktiez v adresari /certifikaty).Sukromne kluce a certifikaty su ulozene vo formate DER.
|
|
|
|
Nasledne je potrebne spustit aplikaciu na strane klienta, ktora pri pouziti kanalu TCP_IP okrem predchadzajucich parametrov vyzaduje parameter
|
|
|
|
pre ip adresu: -ip adresa. Po vytvoreni zabezpeceneho prenosoveho kanalu sa klient pokusi odoslat subor, ktoreho lokacia mu bola predana pri
|
|
|
|
spusteni pomocou parametru -s subor. Pred samotnym poslanim klient najprv vyhotovi kontrolny sucet suboru, ktory odosle po zabezpecenom kanali
|
|
|
|
serveru. Ten po prijati suboru overi ci sa zhoduje prijaty kontrolny sucet s jeho, ktory vyhotovil po prijati suboru. Ak pri prijati suboru
|
2020-05-06 10:46:52 +00:00
|
|
|
nenastala chyba a kontrolne sucty sa zhoduju server oznami ze prijem bol uspesny a ukonci svoju cinnost.
|
2020-04-07 20:11:21 +00:00
|
|
|
Klientsky program po odoslani suboru ukonci svoju cinnost.
|
2020-03-12 16:22:08 +00:00
|
|
|
|
|
|
|
Generovanie certifikatov RSA (OpenSSL)
|
|
|
|
openssl genrsa -out autorita_rsa.key 2048
|
|
|
|
openssl req -x509 -new -nodes -key autorita_rsa.key -sha256 -days 1825 -out autorita_rsa.pem
|
|
|
|
openssl x509 -outform pem -in autorita_rsa.pem -out autorita_rsa.crt
|
|
|
|
openssl genrsa -out server_rsa.key 2048
|
|
|
|
openssl req -new -key server_rsa.key -out server_rsa.csr
|
|
|
|
openssl x509 -req -in server_rsa.csr -CA autorita_rsa.pem -CAkey autorita_rsa.key -CAcreateserial -out server_rsa.pem -days 1825 -sha256
|
|
|
|
openssl x509 -outform pem -in server_rsa.pem -out server_rsa.crt
|
|
|
|
openssl genrsa -out klient_rsa.key 2048
|
|
|
|
openssl req -new -key klient_rsa.key -out klient_rsa.csr
|
|
|
|
openssl x509 -req -in klient_rsa.csr -CA autorita_rsa.pem -CAkey autorita_rsa.key -CAcreateserial -out klient_rsa.pem -days 1825 -sha256
|
|
|
|
openssl pkcs12 -inkey klient_rsa.key -in klient_rsa.pem -export -out klient_rsa.pfx
|
|
|
|
|
|
|
|
Generovanie certifikatov ECC (OpenSSL)
|
|
|
|
openssl ecparam -genkey -name prime256v1 -out autorita_ecc.key
|
|
|
|
openssl req -x509 -new -nodes -key autorita_ecc.key -sha256 -days 1825 -out autorita_ecc.pem
|
|
|
|
openssl x509 -outform pem -in autorita_ecc.pem -out autorita_ecc.crt
|
|
|
|
openssl ecparam -genkey -name prime256v1 -out server_ecc.key
|
|
|
|
openssl req -new -key server_ecc.key -out server_ecc.csr
|
|
|
|
openssl x509 -req -in server_ecc.csr -CA autorita_ecc.pem -CAkey autorita_ecc.key -CAcreateserial -out server_ecc.pem -days 1825 -sha256
|
|
|
|
openssl x509 -outform pem -in server_ecc.pem -out server_ecc.crt
|
|
|
|
openssl ecparam -genkey -name prime256v1 -out klient_ecc.key
|
|
|
|
openssl req -new -key klient_ecc.key -out klient_ecc.csr
|
|
|
|
openssl x509 -req -in klient_ecc.csr -CA autorita_ecc.pem -CAkey autorita_ecc.key -CAcreateserial -out klient_ecc.pem -days 1825 -sha256
|
|
|
|
openssl pkcs12 -inkey klient_ecc.key -in klient_ecc.pem -export -out klient_ecc.pfx
|
|
|
|
|
|
|
|
|
2020-03-11 21:01:54 +00:00
|
|
|
Navod na prelozenie a spustenie (Linux)
|
|
|
|
1. prelozenie kniznice wolfssl s podporou OpenSSL (v adresari s kniznicou)
|
|
|
|
./configure --enable-opensslextra --enable-certgen --enable-keygen
|
|
|
|
make
|
|
|
|
sudo make install
|
2020-03-12 16:22:08 +00:00
|
|
|
2. prelozenie programov (v podadresari tcpip_kanal alebo rs232_kanal)
|
2020-03-11 21:01:54 +00:00
|
|
|
make all
|
2020-04-07 20:11:21 +00:00
|
|
|
3. spustenie (prenosovy kanal TCP/IP)
|
2020-03-12 16:22:08 +00:00
|
|
|
./server -port port -n rsa|ecc
|
|
|
|
./server -port port -g rsa|ecc
|
|
|
|
./klient -ip 127.0.0.1 -port port -n rsa|ecc -s subor
|
|
|
|
./klient -ip 127.0.0.1 -port port -g rsa|ecc -s subor
|
2020-04-07 20:11:21 +00:00
|
|
|
4. spustenie (prenosovy kanal RS232)
|
|
|
|
./server -port seriove_rozhranie -n rsa|ecc
|
|
|
|
./server -port seriove_rozhranie -g rsa|ecc
|
|
|
|
./klient -port seriove_rozhranie -n rsa|ecc -s subor
|
|
|
|
./klient -port seriove_rozhranie -g rsa|ecc -s subor
|
2020-03-11 21:01:54 +00:00
|
|
|
|
|
|
|
Navod na prelozenie a spustenie (Windows)
|
2020-04-07 20:11:21 +00:00
|
|
|
1. skopirovanie potrebnych dll z adresara /wolfssl/64bit_kniznice/ , resp. /wolfssl/32bit_kniznice/
|
2020-04-16 09:25:05 +00:00
|
|
|
do podadresara tcpip_kanal -> klient alebo server, resp. rs232_kanal -> klient alebo server
|
2020-04-07 20:11:21 +00:00
|
|
|
a) wolfssl.dll -> kniznica wolfssl
|
|
|
|
b) vcruntime140.dll -> visual c++ runtime
|
|
|
|
c) api-ms-win-crt-runtime-l1-1-0.dll
|
2020-05-06 10:46:52 +00:00
|
|
|
d) msvcr100.dll
|
|
|
|
e) zlib1.dll -> kniznica zlib
|
|
|
|
f) rs232.dll -> kniznica teuniz/rs232
|
2020-04-07 20:11:21 +00:00
|
|
|
2. prelozenie programov (v podadresari tcpip_kanal alebo rs232_kanal)
|
|
|
|
make all
|
|
|
|
3. spustenie (prenosovy kanal TCP/IP)
|
|
|
|
server -port port -n rsa|ecc
|
|
|
|
server -port port -g rsa|ecc
|
|
|
|
klient -ip 127.0.0.1 -port port -n rsa|ecc -s subor
|
|
|
|
klient -ip 127.0.0.1 -port port -g rsa|ecc -s subor
|
|
|
|
4. spustenie (prenosovy kanal RS232)
|
|
|
|
server -port seriove_rozhranie -n rsa|ecc
|
|
|
|
server -port seriove_rozhranie -g rsa|ecc
|
|
|
|
klient -port seriove_rozhranie -n rsa|ecc -s subor
|
|
|
|
klient -port seriove_rozhranie -g rsa|ecc -s subor
|
2020-03-12 16:22:08 +00:00
|
|
|
|
|
|
|
|