some more crypto additions
This commit is contained in:
parent
43aae0bb8e
commit
a45a57a862
@ -1 +1,7 @@
|
||||
namespace pupes_message_client_lib {}
|
||||
#ifndef PM_CRYPT_H
|
||||
#define PM_CRYPT_H
|
||||
#include <openssl/crypto.h>
|
||||
namespace pupes_message_client_lib {
|
||||
EVP_PKEY *generate_keypair();
|
||||
}
|
||||
#endif
|
@ -1,14 +1,13 @@
|
||||
#include "../common/color.h"
|
||||
#include "crypt.h"
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <string>
|
||||
#
|
||||
|
||||
namespace pupes_message_client_lib {
|
||||
void error(std::string msg) {
|
||||
@ -51,8 +50,7 @@ EVP_PKEY *SaveOrGetKeypair(EVP_PKEY *keypair = nullptr) {
|
||||
std::clog << BLUE
|
||||
"[LOG]" RESET
|
||||
" Private key file not found. Generating a new keypair.\n";
|
||||
|
||||
return nullptr;
|
||||
return generate_keypair();
|
||||
}
|
||||
error("Failed to open private key file for reading.\n");
|
||||
}
|
||||
|
@ -6,4 +6,5 @@ extern void (*receive_callback)(std::vector<user>, std::string);
|
||||
extern SSL_CTX *ctx_global;
|
||||
extern SSL *ssl_global;
|
||||
extern int sockfd_global;
|
||||
extern EVP_PKEY *keypair_global;
|
||||
#endif
|
@ -1,10 +1,14 @@
|
||||
#include "init.h"
|
||||
#include "crypt.h"
|
||||
#include "flow_help.h"
|
||||
#include "global_vars.h"
|
||||
#include "ssl.h"
|
||||
#include "tcp.h"
|
||||
#include "types.h"
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
EVP_PKEY *keypair_global;
|
||||
|
||||
void (*receive_callback)(std::vector<user>, std::string) = nullptr;
|
||||
SSL_CTX *ctx_global = nullptr;
|
||||
SSL *ssl_global = nullptr;
|
||||
@ -14,6 +18,7 @@ namespace pupes_message_client_lib {
|
||||
|
||||
void init(const char *hostname, const char *port) {
|
||||
OpenSSL_add_all_algorithms();
|
||||
keypair_global = pupes_message_client_lib::SaveOrGetKeypair();
|
||||
|
||||
ctx_global = pupes_message_client_lib::InitTLS();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user