<commit_before>#include <string>
#include <sstream>
#include <rapidjson/document.h>
#include <rapidjson/writer.h>
#include <rapidjson/ostreamwrapper.h>
#include <openssl/bn.h>
#include <openssl/bio.h>
#include <openssl/pem.h>
#include <openssl/evp.h>
#include <openssl/asn1.h>
#include <openssl/objects.h>
#include "status.h"
#include "protocols.h"
#include "chat.h"
#include "types.h"

using std::string;
using std::stringstream;

Status status;

Status::Status()
{
	srand(time(NULL));
	rsa = 0;
	_online = 0;
	_difficulty = Difficulty::Peaceful;
	_level = "default";
	_debug = true;
}

Status::~Status()
{
	RSA_free(rsa);
}

int Status::keygen()
{
#if OPENSSL_VERSION_NUMBER >= 0x010100000
	BIGNUM *e = BN_new();
	BN_set_word(e, 65537);
	rsa = RSA_new();
	RSA_generate_key_ex(rsa, 1024, e, NULL);
	BN_free(e);
#else
	rsa = RSA_generate_key(1024, 65537, NULL, NULL);
#endif
	if (rsa == NULL)
		return -1;
	return 0;
}

int Status::pubkey(BIO *bio)
{
	// TODO: Error checking<commit_msg>Check for RSA generation success<commit_after>#include <string>
#include <sstream>
#include <rapidjson/document.h>
#include <rapidjson/writer.h>
#include <rapidjson/ostreamwrapper.h>
#include <openssl/bn.h>
#include <openssl/bio.h>
#include <openssl/pem.h>
#include <openssl/evp.h>
#include <openssl/asn1.h>
#include <openssl/objects.h>
#include "status.h"
#include "protocols.h"
#include "chat.h"
#include "types.h"

using std::string;
using std::stringstream;

Status status;

Status::Status()
{
	srand(time(NULL));
	rsa = 0;
	_online = 0;
	_difficulty = Difficulty::Peaceful;
	_level = "default";
	_debug = true;
}

Status::~Status()
{
	RSA_free(rsa);
}

int Status::keygen()
{
#if OPENSSL_VERSION_NUMBER >= 0x010100000
	BIGNUM *e = BN_new();
	BN_set_word(e, 65537);
	rsa = RSA_new();
	int ret = RSA_generate_key_ex(rsa, 1024, e, NULL);
	BN_free(e);
	if (!ret)
		return -1;
#else
	rsa = RSA_generate_key(1024, 65537, NULL, NULL);
	if (rsa == NULL)
		return -1;
#endif
	return 0;
}

int Status::pubkey(BIO *bio)
{
	// TODO: Error checking
{'fraction_non_alphanumeric': 0.16872224962999507, 'fraction_numerical': 0.03305377405032067, 'mean_word_length': 5.298136645962733, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1393593', 'n_tokens_mistral': 920, 'n_tokens_neox': 837, 'n_words': 183}