Classes | Public Member Functions | Static Public Attributes | Protected Member Functions

ibrcommon::AES128Stream Class Reference

#include <AES128Stream.h>

Inherits ibrcommon::CipherStream.

Collaboration diagram for ibrcommon::AES128Stream:
Collaboration graph
[legend]

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:
mode tell the constructor wether this will be used for en- or decryption
output the stream in which will the cipher- or plaintext be serialized into
key the AES128 key to use. Its size is key_size_in_bytes.
salt the salt, which shall be the same for all data which belongs together
iv if used for decryption, this is the initialisation vector, which was created at encryption. The size of this array is iv_len.
tag if used for decryption, this is the authentication tag, which was created at encryption. The size of this array is tag_len.

Definition at line 9 of file AES128Stream.cpp.

References gcm_init_and_key(), gcm_init_message(), IBRCOMMON_LOGGER, 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 31 of file AES128Stream.cpp.

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

Here is the call graph for this function:

ibrcommon::AES128Stream::~AES128Stream (  )  [virtual]

cleans the output buffer and the context

Definition at line 52 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 90 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 85 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_iv the array in which the vector will be written into

Definition at line 58 of file AES128Stream.cpp.

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_tag the array in which the tag will be written into

Definition at line 64 of file AES128Stream.cpp.

References gcm_compute_tag(), and RETURN_OK.

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 72 of file AES128Stream.cpp.

References getTag().

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::iv_len = 8 [static]
const size_t ibrcommon::AES128Stream::key_size_in_bytes = 16 [static]
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.

const size_t ibrcommon::AES128Stream::tag_len = 16 [static]

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