This abstract class represents the interface of a replication logs encryption cipher that can be used to encrypt/decrypt a given stream content in both sequential and random way.
More...
#include <stream_cipher.h>
This abstract class represents the interface of a replication logs encryption cipher that can be used to encrypt/decrypt a given stream content in both sequential and random way.
Sequential means encrypting/decrypting a stream from the begin to end in order. For sequential encrypting/decrypting, you just need to call it like:
open(); encrypt(); ... encrypt(); // call it again and again ... close();
Random means encrypting/decrypting a stream data without order. For example:
- It first encrypts the data of a stream at the offset from 100 to 200.
- And then encrypts the data of the stream at the offset from 0 to 99.
For random encrypting/decrypting, you need to call set_stream_offset() before calling encrypt(). Example:
open();
set_stream_offset(100); encrypt(...); ... set_stream_offset(0); encrypt(...)
close();
◆ ~Stream_cipher()
virtual Stream_cipher::~Stream_cipher |
( |
| ) |
|
|
virtualdefault |
◆ close()
virtual void Stream_cipher::close |
( |
| ) |
|
|
pure virtual |
◆ decrypt()
virtual bool Stream_cipher::decrypt |
( |
unsigned char * |
dest, |
|
|
const unsigned char * |
src, |
|
|
int |
length |
|
) |
| |
|
pure virtual |
Decrypt data.
- Parameters
-
[in] | dest | The buffer for storing decrypted data. It should be at least 'length' bytes. |
[in] | src | The data which will be decrypted. |
[in] | length | Length of the data. |
- Return values
-
Implemented in Aes_ctr_cipher< TYPE >.
◆ encrypt()
virtual bool Stream_cipher::encrypt |
( |
unsigned char * |
dest, |
|
|
const unsigned char * |
src, |
|
|
int |
length |
|
) |
| |
|
pure virtual |
Encrypt data.
- Parameters
-
[in] | dest | The buffer for storing encrypted data. It should be at least 'length' bytes. |
[in] | src | The data which will be encrypted. |
[in] | length | Length of the data. |
- Return values
-
Implemented in Aes_ctr_cipher< TYPE >.
◆ get_header_size()
int Stream_cipher::get_header_size |
( |
| ) |
|
Returns the size of the header of the stream being encrypted/decrypted.
- Returns
- the size of the header of the stream being encrypted/decrypted.
◆ open()
virtual bool Stream_cipher::open |
( |
const Key_string & |
password, |
|
|
int |
header_size |
|
) |
| |
|
pure virtual |
Open the cipher with given password.
- Parameters
-
[in] | password | The password which is used to initialize the cipher. |
[in] | header_size | The encrypted stream offset wrt the down stream. |
- Return values
-
Implemented in Aes_ctr_cipher< TYPE >.
◆ set_stream_offset()
virtual bool Stream_cipher::set_stream_offset |
( |
uint64_t |
offset | ) |
|
|
pure virtual |
Support encrypting/decrypting data at random position of a stream.
- Parameters
-
[in] | offset | The stream offset of the data which will be encrypted/ decrypted in next encrypt()/decrypt() call. |
- Return values
-
Implemented in Aes_ctr_cipher< TYPE >.
◆ m_header_size
int Stream_cipher::m_header_size = 0 |
|
protected |
The documentation for this class was generated from the following files: