keycodes. boost stil can't handle dates

This commit is contained in:
Kevin Darby committed 2019-05-30 18:24:24 -04:00
1 parent 7d75d87e6b
commit 8a965d41ff
24 files changed
+747 -132

No files matched your search

+17 -14
View File
@@ -1,7 +1,10 @@
#include "PublicKey.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/helper_macros.h"
#include "lib/logging/logging.h"
#include "lib/utils/crypto/iostreambio.h"
#include <sstream>
namespace openssl
{
@@ -25,14 +28,14 @@ PublicKey::PublicKey(const PrivateKey& key) : PrivateKey()
{
//I don't know how to do this another way
openssl::BIO* bio = openssl::BIO_new(openssl::BIO_s_mem());
// int i = openssl::PEM_write_bio_PUBKEY(bio, key._key);
//int err = BIO_flush(bio);
//UNUSED(i);
//UNUSED(err);
int i = openssl::PEM_write_bio_PUBKEY(bio, key._key);
int err = BIO_flush(bio);
UNUSED(i);
UNUSED(err);
openssl::EVP_PKEY* k = openssl::PEM_read_bio_PUBKEY(bio, 0, 0, 0);
BIO_free(bio);
//bts_assert(k);
bts_assert(k);
this->_key = k;
}
@@ -45,7 +48,7 @@ const PublicKeyPtr PublicKey::create(const PrivateKey& private_key)
PublicKeyPtr ret(new PublicKey(private_key));
return ret;
}
const PublicKeyPtr PublicKey::read_file(const std::string& filename)
{
PublicKeyPtr ret;
@@ -53,13 +56,13 @@ const PublicKeyPtr PublicKey::read_file(const std::string& filename)
bts_assert_msg(bio, "can't load keyfile");
openssl::EVP_PKEY* key = openssl::PEM_read_bio_PUBKEY(bio, 0, 0, 0);
if(!key)
//LOG(Error, Config) << "Invalid public key read";
LOG(Gen, Error, "Invalid public key read");
else
ret.reset(new PublicKey(key));
ret.reset(new PublicKey(key));
return ret;
}
const PublicKeyPtr PublicKey::read_string(const std::string& public_key)
{
PublicKeyPtr ret;
@@ -68,9 +71,9 @@ const PublicKeyPtr PublicKey::read_string(const std::string& public_key)
bts::crypto::iostreambio biostream(&oss);
openssl::EVP_PKEY* key = openssl::PEM_read_bio_PUBKEY(biostream.getBIO(), 0, 0, 0);
if(!key)
//LOG(Error, Config) << "Invalid public key read";
LOG(Gen, Error, "Invalid public key read");
else
ret.reset(new PublicKey(key));
ret.reset(new PublicKey(key));
return ret;
}
@@ -89,7 +92,7 @@ const PublicKeyPtr PublicKey::read_stream(std::istream& stream)
openssl::EVP_PKEY* key = openssl::PEM_read_bio_PUBKEY(bio, 0, 0, 0);
if(!key)
// LOG(Error, Config) << "Invalid public key read";
LOG(Gen, Error, "Invalid public key read");
else
ret.reset(new PublicKey(key));
return ret;
@@ -109,7 +112,7 @@ bool PublicKey::encrypt(const std::iostream& in_data, std::iostream& out_data) c
{
return public_encrypt(in_data, out_data);
}
bool PublicKey::decrypt(const std::iostream& in_data, std::iostream& out_data) const
{
return public_decrypt(in_data, out_data);