two phase init of aes encoder/decoder
This commit is contained in:
parent
be836e3e47
commit
8c95d62c9e
2 changed files with 11 additions and 7 deletions
|
|
@ -11,9 +11,10 @@ namespace fc {
|
||||||
class aes_encoder
|
class aes_encoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
aes_encoder( const fc::sha256& key, const fc::uint128& init_value );
|
aes_encoder();
|
||||||
~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 encode( const char* plaintxt, uint32_t len, const char* ciphertxt );
|
||||||
uint32_t final_encode( const char* ciphertxt );
|
uint32_t final_encode( const char* ciphertxt );
|
||||||
|
|
||||||
|
|
@ -24,9 +25,10 @@ namespace fc {
|
||||||
class aes_decoder
|
class aes_decoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
aes_decoder( const fc::sha256& key, const fc::uint128& init_value );
|
aes_decoder();
|
||||||
~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 encode( const char* plaintxt, uint32_t len, const char* ciphertxt );
|
||||||
uint32_t final_encode( const char* ciphertxt );
|
uint32_t final_encode( const char* ciphertxt );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,11 @@ struct aes_encoder::impl
|
||||||
evp_cipher_ctx ctx;
|
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();
|
my->ctx.obj = EVP_CIPHER_CTX_new();
|
||||||
/* Create and initialise the context */
|
/* 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) ) );
|
("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 )
|
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;
|
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();
|
my->ctx.obj = EVP_CIPHER_CTX_new();
|
||||||
/* Create and initialise the context */
|
/* Create and initialise the context */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue