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