IBR-DTNSuite  0.8
ibrcommon::AES128Stream Class Reference

#include <AES128Stream.h>

Inheritance diagram for ibrcommon::AES128Stream:
Collaboration diagram for ibrcommon::AES128Stream:

List of all members.

Classes

struct  gcm_iv

Public Member Functions

 AES128Stream (const CipherMode mode, std::ostream &output, const unsigned char key[key_size_in_bytes], const u_int32_t salt)
 AES128Stream (const CipherMode mode, std::ostream &output, const unsigned char key[key_size_in_bytes], const u_int32_t salt, const unsigned char iv[iv_len])
virtual ~AES128Stream ()
void getIV (unsigned char(&to_iv)[iv_len]) const
void getTag (unsigned char(&to_tag)[tag_len])
bool verify (const unsigned char(&verify_tag)[tag_len])

Static Public Attributes

static const size_t key_size_in_bytes = 16
static const size_t salt_len = sizeof(u_int32_t)
static const size_t iv_len = 8
static const size_t tag_len = 16
static const size_t BUFF_SIZE = 2048

Protected Member Functions

virtual void encrypt (char *buf, const size_t size)
virtual void decrypt (char *buf, const size_t size)

Detailed Description

Encrypts or decrypts an input stream using AES with a 128bit key using galois counter mode. In encryption mode initialisation vector and tag will be created and can be read with getIV() and getTag(). In decryption mode initialisation vector and tag have to be set at construction or via the decrypt()-Method. TODO test the gcm_iv structure on be and le systems

Definition at line 20 of file AES128Stream.h.


Constructor & Destructor Documentation

ibrcommon::AES128Stream::AES128Stream ( const CipherMode  mode,
std::ostream &  output,
const unsigned char  key[key_size_in_bytes],
const u_int32_t  salt 
)

Creates a AES128Stream object, either for encrypting or decrypting, which is controlled by mode. If this object is used for decryption iv and tag have to be set.

Parameters:
modetell the constructor wether this will be used for en- or decryption
outputthe stream in which will the cipher- or plaintext be serialized into
keythe AES128 key to use. Its size is key_size_in_bytes.
saltthe salt, which shall be the same for all data which belongs together
ivif used for decryption, this is the initialisation vector, which was created at encryption. The size of this array is iv_len.
tagif used for decryption, this is the authentication tag, which was created at encryption. The size of this array is tag_len.

Definition at line 8 of file AES128Stream.cpp.

References gcm_init_and_key(), gcm_init_message(), IBRCOMMON_LOGGER, IBRCOMMON_LOGGER_ENDL, and iv_len.

Here is the call graph for this function:

ibrcommon::AES128Stream::AES128Stream ( const CipherMode  mode,
std::ostream &  output,
const unsigned char  key[key_size_in_bytes],
const u_int32_t  salt,
const unsigned char  iv[iv_len] 
)

Definition at line 30 of file AES128Stream.cpp.

References gcm_init_and_key(), gcm_init_message(), IBRCOMMON_LOGGER, IBRCOMMON_LOGGER_ENDL, and iv_len.

Here is the call graph for this function:

cleans the output buffer and the context

Definition at line 51 of file AES128Stream.cpp.

References gcm_end().

Here is the call graph for this function:


Member Function Documentation

void ibrcommon::AES128Stream::decrypt ( char *  buf,
const size_t  size 
) [protected, virtual]

Implements ibrcommon::CipherStream.

Definition at line 89 of file AES128Stream.cpp.

References gcm_decrypt().

Here is the call graph for this function:

void ibrcommon::AES128Stream::encrypt ( char *  buf,
const size_t  size 
) [protected, virtual]

Implements ibrcommon::CipherStream.

Definition at line 84 of file AES128Stream.cpp.

References gcm_encrypt().

Here is the call graph for this function:

void ibrcommon::AES128Stream::getIV ( unsigned char(&)  to_iv[iv_len]) const

Write the initialisation vector into an array, with length iv_len.

Parameters:
to_ivthe array in which the vector will be written into

Definition at line 57 of file AES128Stream.cpp.

References iv_len.

Referenced by dtn::security::PayloadConfidentialBlock::encrypt(), and dtn::security::SecurityBlock::encryptBlock().

void ibrcommon::AES128Stream::getTag ( unsigned char(&)  to_tag[tag_len])

Write the authentication tag into an array, with length tag_len.

Parameters:
to_tagthe array in which the tag will be written into

Definition at line 63 of file AES128Stream.cpp.

References gcm_compute_tag().

Referenced by dtn::security::PayloadConfidentialBlock::encrypt(), dtn::security::SecurityBlock::encryptBlock(), and verify().

Here is the call graph for this function:

bool ibrcommon::AES128Stream::verify ( const unsigned char(&)  verify_tag[tag_len])

compares the given tag with the tag of the last en-/decryption

Definition at line 71 of file AES128Stream.cpp.

References getTag(), and tag_len.

Referenced by dtn::security::SecurityBlock::decryptBlock(), and dtn::security::PayloadConfidentialBlock::decryptPayload().

Here is the call graph for this function:


Member Data Documentation

const size_t ibrcommon::AES128Stream::BUFF_SIZE = 2048 [static]

the size of the buffer in which the data will be streamed

Definition at line 32 of file AES128Stream.h.

const size_t ibrcommon::AES128Stream::salt_len = sizeof(u_int32_t) [static]

the number of bytes of the salt

Definition at line 26 of file AES128Stream.h.


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