.
This commit is contained in:
parent
d668bf59ec
commit
4ff62a305c
@ -1,3 +0,0 @@
|
|||||||
-----BEGIN EC PARAMETERS-----
|
|
||||||
BggqhkjOPQMBBw==
|
|
||||||
-----END EC PARAMETERS-----
|
|
@ -1,16 +1,18 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
-----BEGIN CERTIFICATE-----
|
||||||
MIICcTCCAdqgAwIBAgIQCOhPCtiT+OzqOZ9/zm15UDANBgkqhkiG9w0BAQsFADBz
|
MIIC9TCCAl6gAwIBAgIQC2pwGj3EsKY5/Wt5EhoJ/DANBgkqhkiG9w0BAQsFADBz
|
||||||
MQswCQYDVQQGEwJTSzEKMAgGA1UECAwBLTEPMA0GA1UEBwwGS29zaWNlMREwDwYD
|
MQswCQYDVQQGEwJTSzEKMAgGA1UECAwBLTEPMA0GA1UEBwwGS29zaWNlMREwDwYD
|
||||||
VQQKDAhBdXRvcml0YTESMBAGA1UEAwwJbG9jYWwuZGV2MSAwHgYJKoZIhvcNAQkB
|
VQQKDAhBdXRvcml0YTESMBAGA1UEAwwJbG9jYWwuZGV2MSAwHgYJKoZIhvcNAQkB
|
||||||
FhFhdXRvcml0YUB0dWtlLmNvbTAiGA8yMDIwMDMxMTE0NTY0MloYDzIwMjUwMzEx
|
FhFhdXRvcml0YUB0dWtlLmNvbTAiGA8yMDIwMDMxMjA5MTY1MloYDzIwMjUwMzEy
|
||||||
MTQ1NjQyWjB3MQswCQYDVQQGEwJTUjEKMAgGA1UECAwBLTEPMA0GA1UEBwwGS29z
|
MDkxNjUyWjB3MQswCQYDVQQGEwJTUjEKMAgGA1UECAwBLTEPMA0GA1UEBwwGS29z
|
||||||
aWNlMQowCAYDVQQKDAEtMQowCAYDVQQLDAEtMRIwEAYDVQQDDAlTZXJ2ZXIuc2sx
|
aWNlMQowCAYDVQQKDAEtMQowCAYDVQQLDAEtMRIwEAYDVQQDDAlsb2NhbC5kZXYx
|
||||||
HzAdBgkqhkiG9w0BCQEWEHNlcnZlckBzZ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|
||||||
|
NrmYgRCqDQkMWxXQO1rjufAYXlYnH0xH8Ro43t90zc9j8GQhd0jd49o=
|
||||||
-----END CERTIFICATE-----
|
-----END CERTIFICATE-----
|
||||||
|
@ -1,15 +1,27 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
MIICXgIBAAKBgQDfYAqFlpuQw0qP+3Ek284X21rCJwtZKo/uSSlMtuuIhWwp7pXJ
|
MIIEowIBAAKCAQEA8A8dSI5ieyM1PnIL82gSSaRMoM2una5UF4gq9oR2xvj2OCMf
|
||||||
g+MOhHwpR+UWJ6oPnR8bn7dshKNErwDEchaT7Pid9Jt5uk8i0gLU5KKmAERQN1HD
|
segaKzK6Y4yD8cmzBvB9ZIsUUsokulERZSV/h3RIIpR+o26oZnabfJgM+DIGg+i9
|
||||||
JtZhhTx33iSFpyV0hTFRIsa2PMctj6B4wYgfdDKnLBCQTUYHhoiw7CRZlQIDAQAB
|
vkIpoigENZedLKshPW6RFrLV6b41Iu5G4ed6jHStYRqx9X6OylIbFwGHDp9NBtw1
|
||||||
AoGAEal1zjAapFS2D6eSv8FBLN87Wvh8hqQdeyVIm/LRsaV/vYVfzW4oH6TSRBmr
|
2DgMLipR3XRZOMaXZaK71op0YyevDJ5+/pxzvIJOYXXxvED5FRjvjxLMPr6xc0fd
|
||||||
GjhFfim5r4o5K14wd6o7uLde+VTy/eJhS0xNtHDyfrAsg0Eb3EleS/D6SrX81err
|
le2EPnAduDH8St4WS27NCtBckViQUNvNnJDPJ5EnMOm5p3pCoWDFQMlN4VlKHtk9
|
||||||
vCXxC9DScOsCxuI0KIzzWdy9pB4yAfpN1S7SZ/BcOJwm3mECQQD79TbvsVO3buce
|
QQgykolVGlO5t2BD5KboJE7hz53SQR48Z1GdZQIDAQABAoIBAGfjCpevMrQ6WNzk
|
||||||
I5V31SkvYA7ZhGj9e5hHosoENzxW/DLK2rJTkfJ5gA19Toiyy3Y+aEFOeJ/EZuje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K9fVrOWaNNkzw23rlXtm69Kw
|
||||||
|
1//DJjE+GApW/3t8ihxtnpKTvjwISrxdmVB4UhMCgYBrGbRcbwKpycbfCKwYvkE2
|
||||||
|
OnFpf3dIaO2A72kvfCwXRWsBjiMXrlhvTN8FwVl0eAPcBolHP0VvjAPgnHaInbe7
|
||||||
|
Eg1QfnO7Aw6BBfEMi4MOiRbHFriaVJIcBStYGQx3Yfu7m1tKq462OWLxAtBmeCNU
|
||||||
|
D1m4LXO0WQ1rfGEapZC1lQKBgQCpbZOVxYaqhfQ6KCpl1ENZbgACpuCv5UEruGTA
|
||||||
|
Y+wl79mTdIWNZHweuuox4U2yJFsEhnLLdCuIwV3pjHcAl3KviXZqiQcZGQY3SDCx
|
||||||
|
ooqOBN25jUidSA09m0MJeEyk7vc2yfAINKUgZYzVjIJ995dWvCI8+ygvTqa9yKCU
|
||||||
|
vPDxEwKBgA1H9HjatmUaXvCUqB79jevWIfWvupOocjp8yF5ygA0pSfzmrIrf/TWQ
|
||||||
|
kxvxdWT2N3veIddr8jULX8e/i9hqJnKEqh2zGXL2M53ZFDdsZOeaBSk8RKAiJhVV
|
||||||
|
a1ddeAkVJ/m4D4unA0hEM4st55fPVdmb3hGi3eM/HG723XxjL/nF
|
||||||
-----END RSA PRIVATE KEY-----
|
-----END RSA PRIVATE KEY-----
|
||||||
|
@ -52,6 +52,7 @@ int poslat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, char* cesta)
|
|||||||
//generovanie a poslanie kontrolneho suctu serveru pre kontrolu
|
//generovanie a poslanie kontrolneho suctu serveru pre kontrolu
|
||||||
byte* hash;
|
byte* hash;
|
||||||
hash = generovat_hash(cesta);
|
hash = generovat_hash(cesta);
|
||||||
|
for(int i = 0; i < VELKOST_HASHU; i++) hash[i] = (char)hash[i];
|
||||||
wolfSSL_write(ssl, hash, VELKOST_HASHU);
|
wolfSSL_write(ssl, hash, VELKOST_HASHU);
|
||||||
if(uspech <= 0)
|
if(uspech <= 0)
|
||||||
{
|
{
|
||||||
@ -62,7 +63,7 @@ int poslat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx, char* cesta)
|
|||||||
//posielanie jednotlivych bajtov
|
//posielanie jednotlivych bajtov
|
||||||
for(int i = 0; i < velkost + 1; ++i)
|
for(int i = 0; i < velkost + 1; ++i)
|
||||||
{
|
{
|
||||||
wolfSSL_write(ssl, pole_uk, velkost);
|
uspech = wolfSSL_write(ssl, pole_uk, velkost);
|
||||||
if(uspech <= 0)
|
if(uspech <= 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Nastala chyba pri posielani suboru.\n");
|
fprintf(stderr, "Nastala chyba pri posielani suboru.\n");
|
||||||
@ -84,14 +85,19 @@ int prijat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
|
|||||||
uspech = wolfSSL_read(ssl, cesta, VELKOST_CESTY);
|
uspech = wolfSSL_read(ssl, cesta, VELKOST_CESTY);
|
||||||
if(uspech <= 0)
|
if(uspech <= 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Nastala chyba pri prijati velkosti suboru\n");
|
fprintf(stderr, "Nastala chyba pri prijati dat o subore\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
printf("Prebieha prijimanie suboru %s\n", cesta);
|
printf("Prebieha prijimanie suboru %s\n", cesta);
|
||||||
|
|
||||||
//ziskanie informacie od klienta o velkosti odoslaneho suboru
|
//ziskanie informacie od klienta o velkosti odoslaneho suboru
|
||||||
char velkost_suboru[32];
|
char velkost_suboru[32];
|
||||||
wolfSSL_read(ssl, velkost_suboru, VELKOST_SUBOR);
|
uspech = wolfSSL_read(ssl, velkost_suboru, VELKOST_SUBOR);
|
||||||
|
if(uspech <= 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Nastala chyba pri prijati velkosti suboru\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
long velkost = atol(velkost_suboru);
|
long velkost = atol(velkost_suboru);
|
||||||
if(velkost < 1)
|
if(velkost < 1)
|
||||||
{
|
{
|
||||||
@ -120,7 +126,7 @@ int prijat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
|
|||||||
uspech = wolfSSL_read(ssl, pole_uk, velkost);
|
uspech = wolfSSL_read(ssl, pole_uk, velkost);
|
||||||
if(uspech <= 0)
|
if(uspech <= 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Nastala chyba pri prijimani suboru\n");
|
fprintf(stderr, "Nastala chyba pri prijati suboru\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pole_uk += 1;
|
pole_uk += 1;
|
||||||
@ -130,7 +136,8 @@ int prijat_subor(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
|
|||||||
//kontrola ci sa prijaty a vypocitany kontrolny sucet suboru zhoduju
|
//kontrola ci sa prijaty a vypocitany kontrolny sucet suboru zhoduju
|
||||||
byte* vypocitany_hash;
|
byte* vypocitany_hash;
|
||||||
vypocitany_hash = generovat_hash(cesta);
|
vypocitany_hash = generovat_hash(cesta);
|
||||||
if(!strcmp(prijaty_hash, (char*)vypocitany_hash))
|
for(int i = 0; i < VELKOST_HASHU; i++) vypocitany_hash[i] = (char)vypocitany_hash[i];
|
||||||
|
if(!strcmp(prijaty_hash, vypocitany_hash))
|
||||||
{
|
{
|
||||||
printf("Subor prisiel v poriadku.\n");
|
printf("Subor prisiel v poriadku.\n");
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ WOLFSSL_CTX* nastavit_ctx_klient()
|
|||||||
wolfSSL_Init();
|
wolfSSL_Init();
|
||||||
method = wolfTLSv1_2_client_method();
|
method = wolfTLSv1_2_client_method();
|
||||||
WOLFSSL_CTX *ctx = wolfSSL_CTX_new(method);
|
WOLFSSL_CTX *ctx = wolfSSL_CTX_new(method);
|
||||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
|
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
{
|
{
|
||||||
printf("Nepodarilo sa inicializovat WOLFSSL_CTX\n");
|
printf("Nepodarilo sa inicializovat WOLFSSL_CTX\n");
|
||||||
@ -29,7 +28,6 @@ WOLFSSL_CTX* nastavit_ctx_server()
|
|||||||
wolfSSL_Init();
|
wolfSSL_Init();
|
||||||
method = wolfTLSv1_2_server_method();
|
method = wolfTLSv1_2_server_method();
|
||||||
WOLFSSL_CTX *ctx = wolfSSL_CTX_new(method);
|
WOLFSSL_CTX *ctx = wolfSSL_CTX_new(method);
|
||||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
|
|
||||||
|
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
{
|
{
|
||||||
@ -268,7 +266,6 @@ int generovat_ecc_certifikat(int pocet_bitov, ecc_curve_id kluc_krivka, int algo
|
|||||||
certifikat.isCA = 0;
|
certifikat.isCA = 0;
|
||||||
certifikat.sigType = algoritmus;
|
certifikat.sigType = algoritmus;
|
||||||
certifikat.daysValid = 1825;
|
certifikat.daysValid = 1825;
|
||||||
|
|
||||||
uspech = wc_SetIssuer(&certifikat, "../certifikaty/autorita_ecc.pem");
|
uspech = wc_SetIssuer(&certifikat, "../certifikaty/autorita_ecc.pem");
|
||||||
if(uspech != 0)
|
if(uspech != 0)
|
||||||
{
|
{
|
||||||
|
@ -10,32 +10,32 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
#prepinace pre prekladac
|
#prepinace pre prekladac
|
||||||
CFLAGS = -Wall -Wcpp -fPIC -DREPLICATION_ENABLED -DJOURNALING_ENABLED -I./../wolfssl_hlavickove_subory/
|
CFLAGS = -Wcpp -I./../wolfssl_hlavickove_subory/
|
||||||
LIB32 = -L. -lwolfssl -lws2_32 -Os
|
LIB32 = -L. -lwolfssl -lws2_32 -Os
|
||||||
LIB64 = -L. -lwolfssl -lws2_32 -m64
|
LIB64 = -L. -lwolfssl -lws2_32 -m64
|
||||||
|
|
||||||
all: klient server
|
all: klient server
|
||||||
|
|
||||||
klient: klient.o kryptografia.o komunikacia.o rs232.o
|
klient: klient.o kryptografia.o komunikacia.o rs232.o
|
||||||
$(CC) $(CFLAGS) -o klient klient.o kryptografia.o komunikacia.o rs232.o $(LIB64)
|
$(CC) $(CFLAGS) -o klient klient.o kryptografia.o komunikacia.o rs232.o $(LIB32)
|
||||||
|
|
||||||
server: server.o kryptografia.o komunikacia.o rs232.o
|
server: server.o kryptografia.o komunikacia.o rs232.o
|
||||||
$(CC) $(CFLAGS) -o server server.o kryptografia.o komunikacia.o rs232.o $(LIB64)
|
$(CC) $(CFLAGS) -o server server.o kryptografia.o komunikacia.o rs232.o $(LIB32)
|
||||||
|
|
||||||
klient.o: klient.c
|
klient.o: klient.c
|
||||||
$(CC) -c klient.c $(LIB64)
|
$(CC) -c klient.c $(LIB32)
|
||||||
|
|
||||||
server.o: server.c
|
server.o: server.c
|
||||||
$(CC) -c server.c $(LIB64)
|
$(CC) -c server.c $(LIB32)
|
||||||
|
|
||||||
kryptografia.o: ../kniznica/kryptografia.c ../kniznica/kryptografia.h
|
kryptografia.o: ../kniznica/kryptografia.c ../kniznica/kryptografia.h
|
||||||
$(CC) -c ../kniznica/kryptografia.c $(LIB64)
|
$(CC) -c ../kniznica/kryptografia.c $(LIB32)
|
||||||
|
|
||||||
komunikacia.o: ../kniznica/komunikacia.c ../kniznica/komunikacia.h
|
komunikacia.o: ../kniznica/komunikacia.c ../kniznica/komunikacia.h
|
||||||
$(CC) -c ../kniznica/komunikacia.c $(LIB64)
|
$(CC) -c ../kniznica/komunikacia.c $(LIB32)
|
||||||
|
|
||||||
rs232.o: ../kniznica/rs232.c ../kniznica/rs232.h
|
rs232.o: ../kniznica/rs232.c ../kniznica/rs232.h
|
||||||
$(CC) -c ../kniznica/rs232.c $(LIB64)
|
$(CC) -c ../kniznica/rs232.c $(LIB32)
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -9,7 +9,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wolfssl/options.h>
|
|
||||||
#include <wolfssl/wolfcrypt/settings.h>
|
#include <wolfssl/wolfcrypt/settings.h>
|
||||||
#include <wolfssl/ssl.h>
|
#include <wolfssl/ssl.h>
|
||||||
#include <wolfssl/certs_test.h>
|
#include <wolfssl/certs_test.h>
|
||||||
@ -63,7 +62,7 @@ int main(int argc, char const *argv[])
|
|||||||
int uspech = 0;
|
int uspech = 0;
|
||||||
if(wolfSSL_connect(ssl) != SSL_SUCCESS)
|
if(wolfSSL_connect(ssl) != SSL_SUCCESS)
|
||||||
{
|
{
|
||||||
printf("Nepodarilo sa pripojit\n");
|
printf("Nepodarilo sa pripojit%d\n", uspech);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,22 +17,22 @@ LIB64 = -L. -lwolfssl -lws2_32 -m64
|
|||||||
all: klient server
|
all: klient server
|
||||||
|
|
||||||
klient: klient.o kryptografia.o komunikacia.o
|
klient: klient.o kryptografia.o komunikacia.o
|
||||||
$(CC) $(CFLAGS) -o klient klient.o kryptografia.o komunikacia.o $(LIB32)
|
$(CC) $(CFLAGS) -o klient klient.o kryptografia.o komunikacia.o $(LIB64)
|
||||||
|
|
||||||
server: server.o kryptografia.o komunikacia.o
|
server: server.o kryptografia.o komunikacia.o
|
||||||
$(CC) $(CFLAGS) -o server server.o kryptografia.o komunikacia.o $(LIB32)
|
$(CC) $(CFLAGS) -o server server.o kryptografia.o komunikacia.o $(LIB64)
|
||||||
|
|
||||||
klient.o: klient.c
|
klient.o: klient.c
|
||||||
$(CC) $(CFLAGS) -c klient.c $(LIB32)
|
$(CC) $(CFLAGS) -c klient.c $(LIB64)
|
||||||
|
|
||||||
server.o: server.c
|
server.o: server.c
|
||||||
$(CC) $(CFLAGS) -c server.c $(LIB32)
|
$(CC) $(CFLAGS) -c server.c $(LIB64)
|
||||||
|
|
||||||
kryptografia.o: ../kniznica/kryptografia.c ../kniznica/kryptografia.h
|
kryptografia.o: ../kniznica/kryptografia.c ../kniznica/kryptografia.h
|
||||||
$(CC) $(CFLAGS) -c ../kniznica/kryptografia.c $(LIB32)
|
$(CC) $(CFLAGS) -c ../kniznica/kryptografia.c $(LIB64)
|
||||||
|
|
||||||
komunikacia.o: ../kniznica/komunikacia.c ../kniznica/komunikacia.h
|
komunikacia.o: ../kniznica/komunikacia.c ../kniznica/komunikacia.h
|
||||||
$(CC) $(CFLAGS) -c ../kniznica/komunikacia.c $(LIB32)
|
$(CC) $(CFLAGS) -c ../kniznica/komunikacia.c $(LIB64)
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include <wolfssl/ssl.h>
|
#include <wolfssl/ssl.h>
|
||||||
|
|
||||||
#define RSA_VELKOST 1024
|
#define RSA_VELKOST 2048
|
||||||
#define ECC_VELKOST 32
|
#define ECC_VELKOST 32
|
||||||
#define RSA_EXPONENT 65537
|
#define RSA_EXPONENT 65537
|
||||||
|
|
||||||
@ -105,16 +105,18 @@ int main(int argc, char** argv)
|
|||||||
else if(!strcmp(argv[i+1], "rsa"))
|
else if(!strcmp(argv[i+1], "rsa"))
|
||||||
{
|
{
|
||||||
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_rsa.pem", NULL);
|
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_rsa.pem", NULL);
|
||||||
subor_certifikat = "../certifikaty/server_rsa.pem";
|
subor_certifikat = "../certifikaty/klient_rsa.pem";
|
||||||
subor_kluc = "../certifikaty/server_rsa.key";
|
subor_kluc = "../certifikaty/klient_rsa.key";
|
||||||
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
||||||
|
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0);
|
||||||
}
|
}
|
||||||
else if(!strcmp(argv[i+1], "ecc"))
|
else if(!strcmp(argv[i+1], "ecc"))
|
||||||
{
|
{
|
||||||
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_ecc.pem", NULL);
|
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_ecc.pem", NULL);
|
||||||
subor_certifikat = "../certifikaty/server_ecc.pem";
|
subor_certifikat = "../certifikaty/klient_ecc.pem";
|
||||||
subor_kluc = "../certifikaty/server_ecc.key";
|
subor_kluc = "../certifikaty/klient_ecc.key";
|
||||||
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
||||||
|
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -133,18 +135,21 @@ int main(int argc, char** argv)
|
|||||||
else if(!strcmp(argv[i+1], "rsa"))
|
else if(!strcmp(argv[i+1], "rsa"))
|
||||||
{
|
{
|
||||||
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_rsa.pem", NULL);
|
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_rsa.pem", NULL);
|
||||||
if(generovat_rsa_certifikat(RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "Klient.sk", "klient@klient.sk") == -1) return -1;
|
if(generovat_rsa_certifikat(RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "local.dev", "klient@klient.sk") == -1) return -1;
|
||||||
subor_certifikat = "../certifikaty/vygenerovany_certifikat.pem";
|
subor_certifikat = "../certifikaty/vygenerovany_certifikat.pem";
|
||||||
subor_kluc = "../certifikaty/vygenerovany_kluc.key";
|
subor_kluc = "../certifikaty/vygenerovany_kluc.key";
|
||||||
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
||||||
|
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0);
|
||||||
}
|
}
|
||||||
else if(!strcmp(argv[i+1], "ecc"))
|
else if(!strcmp(argv[i+1], "ecc"))
|
||||||
{
|
{
|
||||||
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_ecc.pem", NULL);
|
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_ecc.pem", NULL);
|
||||||
if(generovat_ecc_certifikat(ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "Klient.sk", "klient@klient.sk") == -1) return -1;
|
if(generovat_ecc_certifikat(ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "local.dev", "klient@klient.sk") == -1) return -1;
|
||||||
subor_certifikat = "../certifikaty/vygenerovany_certifikat.pem";
|
subor_certifikat = "../certifikaty/vygenerovany_certifikat.pem";
|
||||||
subor_kluc = "../certifikaty/vygenerovany_kluc.key";
|
subor_kluc = "../certifikaty/vygenerovany_kluc.key";
|
||||||
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
||||||
|
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -181,12 +186,17 @@ int main(int argc, char** argv)
|
|||||||
cislo_soketu = pripojit_na_server(ip_adresa, cislo_portu, 10);
|
cislo_soketu = pripojit_na_server(ip_adresa, cislo_portu, 10);
|
||||||
|
|
||||||
if(!cislo_soketu) return -1;
|
if(!cislo_soketu) return -1;
|
||||||
|
|
||||||
ssl = wolfSSL_new(ctx);
|
ssl = wolfSSL_new(ctx);
|
||||||
wolfSSL_set_fd(ssl, cislo_soketu);
|
wolfSSL_set_fd(ssl, cislo_soketu);
|
||||||
int uspech = wolfSSL_connect(ssl);
|
int uspech = wolfSSL_connect(ssl);
|
||||||
|
|
||||||
if(uspech != SSL_SUCCESS)
|
if(uspech != SSL_SUCCESS)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Nastala chyba v spojeni.\n");
|
char* popis_chyby = calloc(100, sizeof(char));
|
||||||
|
int chyba = wolfSSL_get_error(ssl, 0);
|
||||||
|
wolfSSL_ERR_error_string(chyba, popis_chyby);
|
||||||
|
fprintf(stderr, "Nastala chyba v spojeni.\nCislo chyby: %d\nDovod chyby: %s\n", chyba, popis_chyby);
|
||||||
printf("Skontrolujte certifikaty.\n");
|
printf("Skontrolujte certifikaty.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include <wolfssl/ssl.h>
|
#include <wolfssl/ssl.h>
|
||||||
|
|
||||||
#define RSA_VELKOST 1024
|
#define RSA_VELKOST 2048
|
||||||
#define ECC_VELKOST 32
|
#define ECC_VELKOST 32
|
||||||
#define RSA_EXPONENT 65537
|
#define RSA_EXPONENT 65537
|
||||||
|
|
||||||
@ -77,18 +77,21 @@ int main(int argc, char **argv)
|
|||||||
else if(!strcmp(argv[i+1], "rsa"))
|
else if(!strcmp(argv[i+1], "rsa"))
|
||||||
{
|
{
|
||||||
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_rsa.pem", NULL);
|
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_rsa.pem", NULL);
|
||||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0);
|
|
||||||
subor_certifikat = "../certifikaty/server_rsa.pem";
|
subor_certifikat = "../certifikaty/server_rsa.pem";
|
||||||
subor_kluc = "../certifikaty/server_rsa.key";
|
subor_kluc = "../certifikaty/server_rsa.key";
|
||||||
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
if(nacitat_certifikaty(ctx, subor_certifikat, subor_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"))
|
else if(!strcmp(argv[i+1], "ecc"))
|
||||||
{
|
{
|
||||||
|
printf("jo\n");
|
||||||
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_ecc.pem", NULL);
|
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_ecc.pem", NULL);
|
||||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0);
|
|
||||||
subor_certifikat = "../certifikaty/server_ecc.pem";
|
subor_certifikat = "../certifikaty/server_ecc.pem";
|
||||||
subor_kluc = "../certifikaty/server_ecc.key";
|
subor_kluc = "../certifikaty/server_ecc.key";
|
||||||
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
||||||
|
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -112,18 +115,23 @@ int main(int argc, char **argv)
|
|||||||
else if(!strcmp(argv[i+1], "rsa"))
|
else if(!strcmp(argv[i+1], "rsa"))
|
||||||
{
|
{
|
||||||
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_rsa.pem", NULL);
|
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_rsa.pem", NULL);
|
||||||
if(generovat_rsa_certifikat(RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "Server.sk", "server@server.sk") == -1) return -1;
|
if(generovat_rsa_certifikat(RSA_VELKOST, RSA_EXPONENT, CTC_SHA256wRSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||||
subor_certifikat = "../certifikaty/vygenerovany_certifikat.pem";
|
subor_certifikat = "../certifikaty/vygenerovany_certifikat.pem";
|
||||||
subor_kluc = "../certifikaty/vygenerovany_kluc.key";
|
subor_kluc = "../certifikaty/vygenerovany_kluc.key";
|
||||||
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
if(nacitat_certifikaty(ctx, subor_certifikat, subor_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"))
|
else if(!strcmp(argv[i+1], "ecc"))
|
||||||
{
|
{
|
||||||
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_ecc.pem", NULL);
|
wolfSSL_CTX_load_verify_locations(ctx, "../certifikaty/autorita_ecc.pem", NULL);
|
||||||
if(generovat_ecc_certifikat(ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "Server.sk", "server@server.sk") == -1) return -1;
|
if(generovat_ecc_certifikat(ECC_VELKOST, ECC_SECP256R1, CTC_SHAwECDSA, "SR", "Kosice", "local.dev", "server@server.sk") == -1) return -1;
|
||||||
subor_certifikat = "../certifikaty/vygenerovany_certifikat.pem";
|
subor_certifikat = "../certifikaty/vygenerovany_certifikat.pem";
|
||||||
subor_kluc = "../certifikaty/vygenerovany_kluc.key";
|
subor_kluc = "../certifikaty/vygenerovany_kluc.key";
|
||||||
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
if(nacitat_certifikaty(ctx, subor_certifikat, subor_kluc) == -1) return -1;
|
||||||
|
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, 0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -161,17 +169,21 @@ int main(int argc, char **argv)
|
|||||||
ssl = wolfSSL_new(ctx);
|
ssl = wolfSSL_new(ctx);
|
||||||
wolfSSL_set_fd(ssl, cislo_soketu_klienta);
|
wolfSSL_set_fd(ssl, cislo_soketu_klienta);
|
||||||
int uspech;
|
int uspech;
|
||||||
zobraz_sifru(ssl);
|
|
||||||
zobraz_certifikat(ssl);
|
|
||||||
if(wolfSSL_accept(ssl) != SSL_SUCCESS)
|
if(wolfSSL_accept(ssl) != SSL_SUCCESS)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Nastala chyba v spojeni.\n");
|
char* popis_chyby = calloc(100, sizeof(char));
|
||||||
|
int chyba = wolfSSL_get_error(ssl, 0);
|
||||||
|
wolfSSL_ERR_error_string(chyba, popis_chyby);
|
||||||
|
fprintf(stderr, "Nastala chyba v spojeni.\nCislo chyby: %d\nDovod chyby: %s\n", chyba, popis_chyby);
|
||||||
printf("Skontrolujte certifikaty.\n");
|
printf("Skontrolujte certifikaty.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
zobraz_sifru(ssl);
|
||||||
|
zobraz_certifikat(ssl);
|
||||||
prijat_subor(ssl, ctx);
|
prijat_subor(ssl, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ukoncit_soket(cislo_soketu);
|
ukoncit_soket(cislo_soketu);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
BIN
tcpip_kanal/wolfssl_32.dll
Normal file
BIN
tcpip_kanal/wolfssl_32.dll
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user