two phase init of aes encoder/decoder

This commit is contained in:
Daniel Larimer 2013-09-05 19:02:10 -04:00
parent be836e3e47
commit 8c95d62c9e
2 changed files with 11 additions and 7 deletions

View file

@ -11,9 +11,10 @@ namespace fc {
class aes_encoder
{
public:
aes_encoder( const fc::sha256& key, const fc::uint128& init_value );
aes_encoder();
~aes_encoder();
void init( const fc::sha256& key, const fc::uint128& init_value );
uint32_t encode( const char* plaintxt, uint32_t len, const char* ciphertxt );
uint32_t final_encode( const char* ciphertxt );
@ -24,9 +25,10 @@ namespace fc {
class aes_decoder
{
public:
aes_decoder( const fc::sha256& key, const fc::uint128& init_value );
aes_decoder();
~aes_decoder();
void init( const fc::sha256& key, const fc::uint128& init_value );
uint32_t encode( const char* plaintxt, uint32_t len, const char* ciphertxt );
uint32_t final_encode( const char* ciphertxt );

View file

@ -15,7 +15,11 @@ struct aes_encoder::impl
evp_cipher_ctx ctx;
};
aes_encoder::aes_encoder( const fc::sha256& key, const fc::uint128& init_value )
aes_encoder::aes_encoder(){}
aes_encoder::~aes_encoder()
{
}
void aes_encoder::init( const fc::sha256& key, const fc::uint128& init_value )
{
my->ctx.obj = EVP_CIPHER_CTX_new();
/* Create and initialise the context */
@ -36,9 +40,6 @@ aes_encoder::aes_encoder( const fc::sha256& key, const fc::uint128& init_value )
("s", ERR_error_string( ERR_get_error(), nullptr) ) );
}
}
aes_encoder::~aes_encoder()
{
}
uint32_t aes_encoder::encode( const char* plaintxt, uint32_t plaintext_len, const char* ciphertxt )
{
@ -73,7 +74,8 @@ struct aes_decoder::impl
evp_cipher_ctx ctx;
};
aes_decoder::aes_decoder( const fc::sha256& key, const fc::uint128& init_value )
aes_decoder::aes_decoder(){}
void aes_decoder::init( const fc::sha256& key, const fc::uint128& init_value )
{
my->ctx.obj = EVP_CIPHER_CTX_new();
/* Create and initialise the context */