|
| Cipher () |
|
| Cipher (const key_t key, mode_t mode, uint8_t *address=NULL, size_t size=0) |
|
virtual | ~Cipher () |
|
void | set (uint8_t *address, size_t size=0) |
|
void | set (const key_t key, mode_t mode, uint8_t *address, size_t size=0) |
|
secure::keybytes | iv () |
|
secure::keybytes | key () |
|
size_t | flush (void) |
| Push a final cipher block. More...
|
|
size_t | put (const uint8_t *data, size_t size) |
| Process cipher data. More...
|
|
size_t | puts (const char *string) |
| This essentially encrypts a single string and pads with NULL bytes as needed. More...
|
|
size_t | pad (const uint8_t *address, size_t size) |
| This is used to process any data unaligned to the blocksize at the end of a cipher session. More...
|
|
size_t | process (uint8_t *address, size_t size, bool flag=false) |
| Process encrypted data in-place. More...
|
|
size_t | size (void) const |
|
size_t | pos (void) const |
|
size_t | align (void) const |
|
A generic data ciphering class.
This is used to construct cryptographic ciphers to encode and decode data as needed. The cipher type is specified by the key object. This class can be used to send output streaming to memory or in a fixed size buffer. If the latter is used, a push() method is called through a virtual when the buffer is full. Since block ciphers are used, buffers should be aligned to the block size.
- Author
- David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 289 of file secure.h.
size_t ucommon::Cipher::flush |
( |
void |
| ) |
|
size_t ucommon::Cipher::pad |
( |
const uint8_t * |
address, |
|
|
size_t |
size |
|
) |
| |
This is used to process any data unaligned to the blocksize at the end of a cipher session.
On an encryption, it will add padding or an entire padding block with the number of bytes to strip. On decryption it will remove padding at the end. The pkcs5 method of padding with removal count is used. This also sets the address buffer to NULL to prevent further puts until reset.
- Parameters
-
address | of data to add before final pad. |
size | of data to add before final pad. |
- Returns
- actual bytes encrypted or decrypted.
Definition at line 301 of file cipher.cpp.
References bufaddr, bufmode, bufpos, DECRYPT, ENCRYPT, flush(), ucommon::Cipher::Key::iosize(), keys, put(), size(), and zerofill().
Referenced by process(), and puts().
size_t ucommon::Cipher::process |
( |
uint8_t * |
address, |
|
|
size_t |
size, |
|
|
bool |
flag = false |
|
) |
| |
Process encrypted data in-place.
This assumes no need to set the address buffer.
- Parameters
-
address | of data to process. |
size | of data to process. |
flag | if to pad data. |
- Returns
- bytes processed and written back to buffer.
Definition at line 641 of file common.cpp.
References pad(), put(), and set().
size_t ucommon::Cipher::put |
( |
const uint8_t * |
data, |
|
|
size_t |
size |
|
) |
| |
Process cipher data.
This requires the size to be a multiple of the cipher block size. If an unaligned sized block of data is used, it will be ignored and the size returned will be 0.
- Parameters
-
data | to process. |
size | of data to process. |
- Returns
- size of processed output, should be same as size or 0 if error.
Definition at line 266 of file cipher.cpp.
References bufaddr, bufmode, bufpos, bufsize, context, DECRYPT, ENCRYPT, ucommon::Cipher::Key::iosize(), keys, push(), put(), release(), and size().
Referenced by encode(), encodefile(), final(), pad(), process(), process(), put(), and puts().