AESKeyBase Class Reference

Base class for AESKey<S>. More...

`#include <AESKey.h>`

Inheritance diagram for AESKeyBase:
[legend]

## Public Member Functions

void | _readFromStream (std::istream &stream, unsigned bytes, uint8_t *buffer)
| Reads hex encoded data from stream. More...
void | _writeToStream (std::ostream &stream, unsigned bytes, const uint8_t *buffer)
| Writes hex encoded data to stream. More...
void | _readFromStream (std::istream &stream, unsigned bytes, uint8_t *buffer) const
| Reads hex encoded data from stream. More...
void | _writeToStream (std::ostream &stream, unsigned bytes, const uint8_t *buffer) const
| Writes hex encoded data to stream. More...

## Detailed Description

Base class for AESKey<S>.

This class implements some bigger, non-template methods used in the AESKey<S> templated subclass.

## Member Function Documentation

void AESKeyBase::_readFromStream | ( | std::istream & | stream,
|  | unsigned | bytes,
|  | uint8_t * | buffer
| ) |  | const

Reads hex encoded data from stream.

The data from the stream is expected to be hex encoded. Each two characters from the stream encode a single result byte. All non-hexadecimal characters are ignored, including newlines. Every two hexadecimal characters form an encoded byte. This is true even if the two characters representing the upper and lower nibbles are separated by whitespace or other characters.

Postcondition
  The stream read head is left pointing just after the last encoded byte.

Parameters

  | stream | Input stream to read from.
  | bytes | Number of encoded bytes to read. This is the number of result bytes, not the count of bytes to read from the stream.
  [out] | buffer | Pointer to the buffer where decoded data is written.

Exceptions

  std::runtime_error | This exception will be thrown if less data than required is available from stream, or if some other error occurs while reading from stream.

void AESKeyBase::_readFromStream | ( | std::istream & | stream,
|  | unsigned | bytes,
|  | uint8_t * | buffer
| ) |  |

Reads hex encoded data from stream.

The data from the stream is expected to be hex encoded. Each two characters from the stream encode a single result byte. All non-hexadecimal characters are ignored, including newlines. Every two hexadecimal characters form an encoded byte. This is true even if the two characters representing the upper and lower nibbles are separated by whitespace or other characters.

Postcondition
  The stream read head is left pointing just after the last encoded byte.

Parameters

  | stream | Input stream to read from.
  | bytes | Number of encoded bytes to read. This is the number of result bytes, not the count of bytes to read from the stream.
  [out] | buffer | Pointer to the buffer where decoded data is written.

Exceptions

  std::runtime_error | This exception will be thrown if less data than required is available from stream, or if some other error occurs while reading from stream.

void AESKeyBase::_writeToStream | ( | std::ostream & | stream,
|  | unsigned | bytes,
|  | const uint8_t * | buffer
| ) |  | const

Writes hex encoded data to stream.

Key data is written to stream as a sequence of hex encoded octets, each two characters long. No spaces or newlines are inserted between the encoded octets or at the end of the sequence.

Exceptions

  std::runtime_error | Thrown if the stream reports an error while writing the key data.

void AESKeyBase::_writeToStream | ( | std::ostream & | stream,
|  | unsigned | bytes,
|  | const uint8_t * | buffer
| ) |  |

Writes hex encoded data to stream.

Key data is written to stream as a sequence of hex encoded octets, each two characters long. No spaces or newlines are inserted between the encoded octets or at the end of the sequence.

Exceptions

  std::runtime_error | Thrown if the stream reports an error while writing the key data.

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

- apps/elftosb/common/AESKey.h
- apps/elftosb/common/AESKey.cpp