24#ifndef STREAM_CIPHER_INCLUDED 
   25#define STREAM_CIPHER_INCLUDED 
   27#include <openssl/evp.h>   
   44    std::basic_string<unsigned char, my_char_traits<unsigned char>>;
 
  113  virtual bool encrypt(
unsigned char *dest, 
const unsigned char *src,
 
  127  virtual bool decrypt(
unsigned char *dest, 
const unsigned char *src,
 
  196template <Cipher_type TYPE>
 
  206  void close() 
override;
 
  207  bool encrypt(
unsigned char *dest, 
const unsigned char *src,
 
  209  bool decrypt(
unsigned char *dest, 
const unsigned char *src,
 
The class implements AES-CTR encryption/decryption.
Definition: stream_cipher.h:197
 
static const int PASSWORD_LENGTH
Definition: stream_cipher.h:199
 
bool open(const Key_string &password, int header_size) override
Open the cipher with given password.
Definition: stream_cipher.cc:46
 
static const int FILE_KEY_LENGTH
Definition: stream_cipher.h:201
 
unsigned char m_file_key[FILE_KEY_LENGTH]
Definition: stream_cipher.h:217
 
bool encrypt(unsigned char *dest, const unsigned char *src, int length) override
Encrypt data.
Definition: stream_cipher.cc:143
 
void deinit_cipher()
Destroy OpenSSL cipher related context.
Definition: stream_cipher.cc:137
 
unsigned char m_iv[AES_BLOCK_SIZE]
Definition: stream_cipher.h:219
 
static const int AES_BLOCK_SIZE
Definition: stream_cipher.h:200
 
~Aes_ctr_cipher() override
Definition: stream_cipher.cc:73
 
bool decrypt(unsigned char *dest, const unsigned char *src, int length) override
Decrypt data.
Definition: stream_cipher.cc:163
 
bool set_stream_offset(uint64_t offset) override
Support encrypting/decrypting data at random position of a stream.
Definition: stream_cipher.cc:83
 
bool init_cipher(uint64_t offset)
Initialize OpenSSL cipher related context and IV.
Definition: stream_cipher.cc:105
 
EVP_CIPHER_CTX * m_ctx
Definition: stream_cipher.h:215
 
void close() override
Close the cipher.
Definition: stream_cipher.cc:78
 
The class provides standards to be used by the Aes_ctr ciphers.
Definition: stream_cipher.h:157
 
static const int AES_BLOCK_SIZE
Definition: stream_cipher.h:160
 
static std::unique_ptr< Stream_cipher > get_encryptor()
Returns a new unique Stream_cipher encryptor.
Definition: stream_cipher.cc:35
 
static std::unique_ptr< Stream_cipher > get_decryptor()
Returns a new unique Stream_cipher decryptor.
Definition: stream_cipher.cc:40
 
static const int PASSWORD_LENGTH
Definition: stream_cipher.h:159
 
static const EVP_MD * get_evp_md()
Returns the message digest function to be uses when opening the cipher.
Definition: stream_cipher.h:167
 
static const int FILE_KEY_LENGTH
Definition: stream_cipher.h:161
 
static const EVP_CIPHER * get_evp_cipher()
Returns the cipher to be uses when using the cipher.
Definition: stream_cipher.h:173
 
This abstract class represents the interface of a replication logs encryption cipher that can be used...
Definition: stream_cipher.h:84
 
virtual bool decrypt(unsigned char *dest, const unsigned char *src, int length)=0
Decrypt data.
 
int get_header_size()
Returns the size of the header of the stream being encrypted/decrypted.
Definition: stream_cipher.cc:33
 
virtual bool set_stream_offset(uint64_t offset)=0
Support encrypting/decrypting data at random position of a stream.
 
virtual bool open(const Key_string &password, int header_size)=0
Open the cipher with given password.
 
int m_header_size
Definition: stream_cipher.h:149
 
virtual void close()=0
Close the cipher.
 
virtual bool encrypt(unsigned char *dest, const unsigned char *src, int length)=0
Encrypt data.
 
virtual ~Stream_cipher()=default
 
const EVP_MD * my_EVP_sha512()
Definition: my_ssl_algo_cache.cc:105
 
const EVP_CIPHER * my_EVP_aes_256_ctr()
Definition: my_ssl_algo_cache.cc:273
 
static char * password
Definition: mysql_secure_installation.cc:58
 
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
 
class Aes_ctr_cipher< Cipher_type::ENCRYPT > Aes_ctr_encryptor
Definition: stream_cipher.h:236
 
std::basic_string< unsigned char, my_char_traits< unsigned char > > Key_string
Definition: stream_cipher.h:44
 
Cipher_type
Definition: stream_cipher.h:188
 
class Aes_ctr_cipher< Cipher_type::DECRYPT > Aes_ctr_decryptor
Definition: stream_cipher.h:237