elftosb::Keyblob Class Reference

Keyblob specification. More...

`#include <Keyblob.h>`

Collaboration diagram for elftosb::Keyblob:
[legend]

## Public Types

enum | _encryption_constants { k_encryptBlockSize = 16, k_qspiAlignlength }
| Constants for encryption. More...
typedef std::vector< OptionContext * > | option_vector_t
| List of options entries.

## Public Member Functions

| Keyblob (uint32_t identifier)
void | setIdentifier (uint32_t identifier)
uint32_t | getIdentifier () const
void | addOptions (OptionContext *context)
| Add options.
option_vector_t * | getOptions ()
| Return options vector.
uint8_t * | createWrappedKeyblobData (uint8_t *kek, uint32_t *byteCount)
| Create and wrap keyblob data based on options. More...
bool | encryptMatchingRange (uint32_t start, uint32_t len, uint8_t *data)
| Encrypt for OTFAD if range is within a keyblob entry range. More...

## Static Public Member Functions

static uint32_t | getKekSizeBytes ()

## Protected Types

enum | _keywrap_constants { kKeySizeBits = 128, kExpandedKekSizeInts = 64, kNumKeyBlobs = 4, kKeyBlobSizeBytes = 64, kOutputLineSize = 16, kRegionAddrMask = (0x400 - 1), kFlagMask = 0x07, kKeyFlags = 0x03, kAesKeySizeBytes = 16, kCtrSizeBytes = 8, kKekSizeBytes = 16, kNumKeyChars = 32, kNumCtrChars = 16, kCrc32SizeBytes = 32 }
| Keywrap constants. More...

## Protected Member Functions

void | populateKeyBlob (keyblob_t *blob, uint32_t start, uint32_t end, const char *keyHex, const char *counterHex)
void | encrypt (uint32_t length, uint8_t *data, AESKey< 128 > *key, AESCounter< 128 > *counter)
bool | getOptionValues (OptionContext &opt, const char **key, const char **ctr, uint32_t *start, uint32_t *end)

## Protected Attributes

uint32_t | m_id
| Unique identifier.
option_vector_t | m_options
| List of option entries.

## Detailed Description

Keyblob specification.

## Member Enumeration Documentation

enum elftosb::Keyblob::_encryption_constants

Constants for encryption.

Enumerator
k_encryptBlockSize | Block size for AES-128 encryption.
k_qspiAlignlength | QSPI image alignment length, 512 is supposed to be the safe alignment level for any QSPI device this means that all QSPI images generated by this tool will be sizes of multiple 512

enum elftosb::Keyblob::_keywrap_constants

protected

Keywrap constants.

Enumerator
kKeySizeBits | AES-128.
kExpandedKekSizeInts | Expanded KeK size.
kNumKeyBlobs | Number of key blobs.
kKeyBlobSizeBytes | Key blob size in bytes.
kOutputLineSize | Number of bytes per output line.
kRegionAddrMask | Region addresses are modulo 1024.
kFlagMask | Key flags mask.
kKeyFlags | Default flags: RO=0, ADE=1, VLD=1.
kAesKeySizeBytes | Number of bytes in AES-128 key.
kCtrSizeBytes | Number of bytes in Ctr.
kKekSizeBytes | Number of bytes in KeK.
kNumKeyChars | Number of characters in key string.
kNumCtrChars | Number of characters in ctr string.
kCrc32SizeBytes | Number of bytes covered by CRC32.

## Member Function Documentation

uint8_t * Keyblob::createWrappedKeyblobData | ( | uint8_t * | kek,
|  | uint32_t * | byteCount
| ) |  |

Create and wrap keyblob data based on options.

Return values

  Pointer | to new wrapped data (caller must delete)
  Number | of bytes in wrapped data

bool Keyblob::encryptMatchingRange | ( | uint32_t | start,
|  | uint32_t | len,
|  | uint8_t * | data
| ) |  |

Encrypt for OTFAD if range is within a keyblob entry range.

len must be a multiple of k_qspiAlignlength, which is also a multiple of k_encryptBlockSize.

Return values

  True | if data was encrypted (range matched)

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

- Keyblob.h
- Keyblob.cpp