clan::AES256_Encrypt Class Reference - ClanLib SDK
Description: clan::AES256_Encrypt Class Reference

Public Member Functions | Static Public Attributes | List of all members
clan::AES256_Encrypt Class Reference
clanCore Crypto

AES-256 encryption class (running in Cipher Block Chaining mode). More...

`#include <aes256_encrypt.h>`

## Public Member Functions
| AES256_Encrypt ()
| Constructs a AES-256 generator (running in Cipher Block Chaining mode).
void | add (const DataBuffer &data)
| Add data to be encrypted.
void | add (const void *data, int size)
| Adds data to be encrypted.
void | calculate ()
| Finalize encryption.
DataBuffer | get_data () const
| Get encrypted data.
void | reset ()
| Resets the encryption.
void | set_iv (const unsigned char iv[iv_size])
| Sets the initialisation vector.
void | set_key (const unsigned char key[key_size])
| Sets the cipher key.
void | set_padding (bool value=true, bool use_pkcs7=true, unsigned int num_additional_padded_blocks=0)
| Enable AES Padding.

## Static Public Attributes
static const int | block_size = 16
static const int | iv_size = 16
static const int | key_size = 32

## Detailed Description

AES-256 encryption class (running in Cipher Block Chaining mode).

## Constructor & Destructor Documentation

## ◆ AES256_Encrypt()

clan::AES256_Encrypt::AES256_Encrypt | ( |  | ) |

Constructs a AES-256 generator (running in Cipher Block Chaining mode).

## Member Function Documentation

## ◆ add() [1/2]

void clan::AES256_Encrypt::add | ( | const DataBuffer & | data | ) |

Add data to be encrypted.

Parameters

  data | = Data Buffer

## ◆ add() [2/2]

void clan::AES256_Encrypt::add | ( | const void * | data,
|  | int | size )

Adds data to be encrypted.

## ◆ calculate()

void clan::AES256_Encrypt::calculate | ( |  | ) |

Finalize encryption.

## ◆ get_data()

DataBuffer clan::AES256_Encrypt::get_data | ( |  | ) | const

Get encrypted data.

This is the databuffer used internally to store the encrypted data. You may call "set_size()" to clear the buffer, inbetween calls to "add()" You may call "set_capacity()" to optimise storage requirements before the add() call

## ◆ reset()

void clan::AES256_Encrypt::reset | ( |  | ) |

Resets the encryption.

## ◆ set_iv()

void clan::AES256_Encrypt::set_iv | ( | const unsigned char | iv[iv_size] | ) |

Sets the initialisation vector.

This should be a random number
This must be called before the initial add()

References iv_size.

## ◆ set_key()

void clan::AES256_Encrypt::set_key | ( | const unsigned char | key[key_size] | ) |

Sets the cipher key.

This must be called before the initial add()

References key_size.

## ◆ set_padding()

void clan::AES256_Encrypt::set_padding | ( | bool | value = true,
|  | bool | use_pkcs7 = true,
|  | unsigned int | num_additional_padded_blocks = 0 )

Enable AES Padding.

Example (use_pkcs7==true) : ... 0x03 0x03 0x03 (3 octets of padding) Example (use_pkcs7==false) : ... 0x02 0x02 0x02 (3 octets of padding, the last octet is the length)

Parameters

  value | = true = Enable padding (default)
  use_pkcs7 | = true = This uses the PKCS#7/RFC3369 method (Enabled by default). false = use the TLS method (rfc2246)
  num_additional_padded_blocks | = (Only valid when use_pkcs7==false). Set to "frustrate attacks on a protocol based on analysis of the lengths of exchanged messages". (Range 0 to 15)

## Member Data Documentation

## ◆ block_size

const int clan::AES256_Encrypt::block_size = 16
| static

## ◆ iv_size

const int clan::AES256_Encrypt::iv_size = 16
| static

Referenced by set_iv().

## ◆ key_size

const int clan::AES256_Encrypt::key_size = 32
| static

Referenced by set_key().

The documentation for this class was generated from the following file:

- aes256_encrypt.h