68 lines
1.6 KiB
C
68 lines
1.6 KiB
C
//////////////////////////////////////////////////
|
|
// Bakalarska praca //
|
|
// Meno studenta: Tomas Lukac //
|
|
// Veduci BP: prof. Ing. Milos Drutarovsky CSc. //
|
|
// Skola: KEMT FEI TUKE //
|
|
// Datum poslednej upravy: 12.3.2020 //
|
|
//////////////////////////////////////////////////
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <wolfssl/wolfcrypt/settings.h>
|
|
#include <wolfssl/ssl.h>
|
|
#include <wolfssl/certs_test.h>
|
|
#include <wolfssl/wolfcrypt/types.h>
|
|
|
|
#ifdef _WIN32
|
|
#include <Windows.h>
|
|
#else
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include "../kniznica/kryptografia.h"
|
|
#include "../kniznica/rs232.h"
|
|
|
|
int cislo_portu = 3;
|
|
int baud_frekvencia = 9600;
|
|
char rezim[]={'8','N','1', 0};
|
|
|
|
int main(int argc, char const *argv[])
|
|
{
|
|
WOLFSSL *ssl;
|
|
WOLFSSL_CTX *ctx = NULL;
|
|
|
|
//otvorenie portu pre citanie
|
|
if(RS232_OpenComport(cislo_portu, baud_frekvencia, rezim, 1))
|
|
{
|
|
printf("Nebolo mozne otvorit serialovy port\n");
|
|
}
|
|
|
|
if((ctx = nastavit_ctx_server()) == NULL)
|
|
{
|
|
return -1;
|
|
}
|
|
const char* subor_certifikat = "../certifikaty/klient.pem";
|
|
const char* subor_kluc = "../certifikaty/klient.key";
|
|
if(!nacitat_certifikaty(ctx, subor_certifikat, subor_kluc)) return -1;
|
|
|
|
wolfSSL_SetIOSend(ctx, rs232_zapis);
|
|
wolfSSL_SetIORecv(ctx, rs232_citanie);
|
|
|
|
if ((ssl = wolfSSL_new(ctx)) == NULL)
|
|
{
|
|
printf("Nepodarilo sa vytvorit ssl relaciu\n");
|
|
wolfSSL_CTX_free(ctx);
|
|
return -1;
|
|
}
|
|
|
|
int ret;
|
|
if(wolfSSL_accept(ssl) == -1)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
RS232_CloseComport(cislo_portu);
|
|
|
|
return 0;
|
|
}
|