esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
ndnph::mbedtls::AesGcm< keyBits > Class Template Reference

AES-GCM secret key. More...

#include <mbed-common.hpp>

Public Types

using Key = std::array< uint8_t, keyBits/8 >
 
using IvLen = AesGcmIvHelper::IvLen
 
using TagLen = std::integral_constant< size_t, 16 >
 

Public Member Functions

 AesGcm ()
 
 ~AesGcm ()
 
 AesGcm (const AesGcm &)=delete
 
AesGcmoperator= (const AesGcm &)=delete
 
bool import (const Key &key)
 Import raw AES key.
 
template<typename Encrypted >
tlv::Value encrypt (Region &region, tlv::Value plaintext, const uint8_t *aad=nullptr, size_t aadLen=0)
 Encrypt to encrypted-message.
 
template<typename Encrypted >
tlv::Value decrypt (Region &region, const Encrypted &encrypted, const uint8_t *aad=nullptr, size_t aadLen=0)
 Decrypt from encrypted-message.
 
void clearDecryptIvChecker ()
 

Detailed Description

template<int keyBits>
class ndnph::mbedtls::AesGcm< keyBits >

AES-GCM secret key.

Template Parameters
keyBitsAES key size in bits, either 128 or 256.

InitializationVector requirements are enforced by AesGcmIvHelper . AuthenticationTag is 16 octets. Other sizes are not supported.

Member Typedef Documentation

◆ IvLen

template<int keyBits>
using ndnph::mbedtls::AesGcm< keyBits >::IvLen = AesGcmIvHelper::IvLen

◆ Key

template<int keyBits>
using ndnph::mbedtls::AesGcm< keyBits >::Key = std::array<uint8_t, keyBits / 8>

◆ TagLen

template<int keyBits>
using ndnph::mbedtls::AesGcm< keyBits >::TagLen = std::integral_constant<size_t, 16>

Constructor & Destructor Documentation

◆ AesGcm() [1/2]

template<int keyBits>
ndnph::mbedtls::AesGcm< keyBits >::AesGcm ( )
inlineexplicit

◆ ~AesGcm()

template<int keyBits>
ndnph::mbedtls::AesGcm< keyBits >::~AesGcm ( )
inline

◆ AesGcm() [2/2]

template<int keyBits>
ndnph::mbedtls::AesGcm< keyBits >::AesGcm ( const AesGcm< keyBits > &  )
delete

Member Function Documentation

◆ clearDecryptIvChecker()

template<int keyBits>
void ndnph::mbedtls::AesGcm< keyBits >::clearDecryptIvChecker ( )
inline

◆ decrypt()

template<int keyBits>
template<typename Encrypted >
tlv::Value ndnph::mbedtls::AesGcm< keyBits >::decrypt ( Region region,
const Encrypted &  encrypted,
const uint8_t *  aad = nullptr,
size_t  aadLen = 0 
)
inline

Decrypt from encrypted-message.

Template Parameters
Encrypteda specialization of EncryptedMessage .
Parameters
regionwhere to allocate memory.
encryptedencrypted-message.
aadadditional associated data.
aadLenlength of aad .
Returns
plaintext, or a falsy value upon failure.
Postcondition
internal IV is incremented by number of ciphertext blocks.

This function enforces IV uniqueness. It requires the random number portion to be consistent, and the counter portion to be monotonically increasing. Attempting to decrypt the same message for a second time would result in failure due to duplicate IV. Caller should deduplicate incoming messages, or disable this check by calling clearDecryptIvChecker() every time.

◆ encrypt()

template<int keyBits>
template<typename Encrypted >
tlv::Value ndnph::mbedtls::AesGcm< keyBits >::encrypt ( Region region,
tlv::Value  plaintext,
const uint8_t *  aad = nullptr,
size_t  aadLen = 0 
)
inline

Encrypt to encrypted-message.

Template Parameters
Encrypteda specialization of EncryptedMessage .
Parameters
regionwhere to allocate memory.
plaintextinput plaintext.
aadadditional associated data.
aadLenlength of aad .
Returns
encrypted-message, or a falsy value upon failure.
Postcondition
internal IV is incremented by number of encrypted blocks.

◆ import()

template<int keyBits>
bool ndnph::mbedtls::AesGcm< keyBits >::import ( const Key key)
inline

Import raw AES key.

Returns
whether success.

◆ operator=()

template<int keyBits>
AesGcm & ndnph::mbedtls::AesGcm< keyBits >::operator= ( const AesGcm< keyBits > &  )
delete

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