AWS IoT Device SDK C++ v2  1.34.0
AWS IoT Device SDK C++ v2
Public Member Functions | Static Public Member Functions | List of all members
Aws::Crt::Crypto::SymmetricCipher Class Referencefinal

#include <SymmetricCipher.h>

Public Member Functions

 SymmetricCipher (const SymmetricCipher &)=delete
 
SymmetricCipheroperator= (const SymmetricCipher &)=delete
 
 SymmetricCipher (SymmetricCipher &&) noexcept=default
 
SymmetricCipheroperator= (SymmetricCipher &&) noexcept=default
 
 operator bool () const noexcept
 
SymmetricCipherState GetState () const noexcept
 
int LastError () const noexcept
 
bool Encrypt (const ByteCursor &toEncrypt, ByteBuf &out) noexcept
 
bool FinalizeEncryption (ByteBuf &out) noexcept
 
bool Decrypt (const ByteCursor &toDecrypt, ByteBuf &out) noexcept
 
bool FinalizeDecryption (ByteBuf &out) noexcept
 
bool Reset () noexcept
 
ByteCursor GetKey () const noexcept
 
ByteCursor GetIV () const noexcept
 
ByteCursor GetTag () const noexcept
 
void SetTag (ByteCursor tag) const noexcept
 

Static Public Member Functions

static SymmetricCipher CreateAES_256_CBC_Cipher (const Optional< ByteCursor > &key=Optional< ByteCursor >(), const Optional< ByteCursor > &iv=Optional< ByteCursor >(), Allocator *allocator=ApiAllocator()) noexcept
 
static SymmetricCipher CreateAES_256_CTR_Cipher (const Optional< ByteCursor > &key=Optional< ByteCursor >(), const Optional< ByteCursor > &iv=Optional< ByteCursor >(), Allocator *allocator=ApiAllocator()) noexcept
 
static SymmetricCipher CreateAES_256_GCM_Cipher (const Optional< ByteCursor > &key=Optional< ByteCursor >(), const Optional< ByteCursor > &iv=Optional< ByteCursor >(), const Optional< ByteCursor > &aad=Optional< ByteCursor >(), Allocator *allocator=ApiAllocator()) noexcept
 
static SymmetricCipher CreateAES_256_KeyWrap_Cipher (const Optional< ByteCursor > &key=Optional< ByteCursor >(), Allocator *allocator=ApiAllocator()) noexcept
 

Constructor & Destructor Documentation

◆ SymmetricCipher() [1/2]

Aws::Crt::Crypto::SymmetricCipher::SymmetricCipher ( const SymmetricCipher )
delete

◆ SymmetricCipher() [2/2]

Aws::Crt::Crypto::SymmetricCipher::SymmetricCipher ( SymmetricCipher &&  )
defaultnoexcept

Member Function Documentation

◆ CreateAES_256_CBC_Cipher()

SymmetricCipher Aws::Crt::Crypto::SymmetricCipher::CreateAES_256_CBC_Cipher ( const Optional< ByteCursor > &  key = Optional<ByteCursor>(),
const Optional< ByteCursor > &  iv = Optional<ByteCursor>(),
Allocator allocator = ApiAllocator() 
)
staticnoexcept

Creates an AES 256 CBC mode cipher using a provided key and iv. Key must be 32 bytes. If key or iv are not provided, they will be generated.

◆ CreateAES_256_CTR_Cipher()

SymmetricCipher Aws::Crt::Crypto::SymmetricCipher::CreateAES_256_CTR_Cipher ( const Optional< ByteCursor > &  key = Optional<ByteCursor>(),
const Optional< ByteCursor > &  iv = Optional<ByteCursor>(),
Allocator allocator = ApiAllocator() 
)
staticnoexcept

Creates an AES 256 CTR mode cipher using a provided key and iv. If key and iv are not provided, they will be generated.

◆ CreateAES_256_GCM_Cipher()

SymmetricCipher Aws::Crt::Crypto::SymmetricCipher::CreateAES_256_GCM_Cipher ( const Optional< ByteCursor > &  key = Optional<ByteCursor>(),
const Optional< ByteCursor > &  iv = Optional<ByteCursor>(),
const Optional< ByteCursor > &  aad = Optional<ByteCursor>(),
Allocator allocator = ApiAllocator() 
)
staticnoexcept

Creates an AES 256 GCM mode cipher using a provided key, iv, tag, and aad if provided. Key and iv will be generated if not provided. AAD values are not generated. Provide AAD if you need to provide additional auth info.

◆ CreateAES_256_KeyWrap_Cipher()

SymmetricCipher Aws::Crt::Crypto::SymmetricCipher::CreateAES_256_KeyWrap_Cipher ( const Optional< ByteCursor > &  key = Optional<ByteCursor>(),
Allocator allocator = ApiAllocator() 
)
staticnoexcept

Creates an AES 256 Keywrap mode cipher using key if provided. If a key is not provided, one will be generated.

◆ Decrypt()

bool Aws::Crt::Crypto::SymmetricCipher::Decrypt ( const ByteCursor toDecrypt,
ByteBuf out 
)
noexcept

Decrypts the value in toEncrypt and stores any immediate results in out. Out can be dynamically re-sized if out is a dynamic byte buf. Otherwise, make sure the size of out is at least 1 block larger than the input to allow for padding. Returns true on success. Call LastError() for the reason this call failed.

◆ Encrypt()

bool Aws::Crt::Crypto::SymmetricCipher::Encrypt ( const ByteCursor toEncrypt,
ByteBuf out 
)
noexcept

Encrypts the value in toEncrypt and stores any immediate results in out. Out can be dynamically re-sized if out is a dynamic byte buf. Otherwise, make sure the size of out is at least 2 blocks larger than the input to allow for padding.

Returns true on success. Call LastError() for the reason this call failed.

◆ FinalizeDecryption()

bool Aws::Crt::Crypto::SymmetricCipher::FinalizeDecryption ( ByteBuf out)
noexcept

Decrypts any remaining data on the cipher and stores the output in out. Out can be dynamically re-sized if out is a dynamic byte buf. Otherwise, make sure the size of out is at least 2 blocks for CBC, CTR, GCM, and Keywrap modes.

Returns true on success. Call LastError() for the reason this call failed.

◆ FinalizeEncryption()

bool Aws::Crt::Crypto::SymmetricCipher::FinalizeEncryption ( ByteBuf out)
noexcept

Encrypts any remaining data on the cipher and stores the output in out. Out can be dynamically re-sized if out is a dynamic byte buf. Otherwise, make sure the size of out is at least 2 blocks for CBC, CTR, and GCM modes and 40 bytes for KeyWrap.

Returns true on success. Call LastError() for the reason this call failed.

◆ GetIV()

ByteCursor Aws::Crt::Crypto::SymmetricCipher::GetIV ( ) const
noexcept

Returns the initialization vector used for this cipher. This IV is not copied from the cipher so do not mutate this data. Copy if you need to pass it around anywhere.

◆ GetKey()

ByteCursor Aws::Crt::Crypto::SymmetricCipher::GetKey ( ) const
noexcept

Returns the key used for this cipher. This key is not copied from the cipher so do not mutate this data. Copy if you need to pass it around anywhere.

◆ GetState()

SymmetricCipherState Aws::Crt::Crypto::SymmetricCipher::GetState ( ) const
noexcept

Returns current state of the cipher instance. ready to be used, finalized, or in a error state. If the cipher is in a finalized or error state it may not be used anymore

◆ GetTag()

ByteCursor Aws::Crt::Crypto::SymmetricCipher::GetTag ( ) const
noexcept

Returns the encryption tag generated during encryption operations for this cipher in GCM mode. This tag is not copied from the cipher so do not mutate this data. Copy if you need to pass it around anywhere.

◆ LastError()

int Aws::Crt::Crypto::SymmetricCipher::LastError ( ) const
inlinenoexcept

Returns the value of the last aws error encountered by operations on this instance.

◆ operator bool()

Aws::Crt::Crypto::SymmetricCipher::operator bool ( ) const
noexcept

Returns true if the instance is in a valid state, false otherwise.

◆ operator=() [1/2]

SymmetricCipher& Aws::Crt::Crypto::SymmetricCipher::operator= ( const SymmetricCipher )
delete

◆ operator=() [2/2]

SymmetricCipher& Aws::Crt::Crypto::SymmetricCipher::operator= ( SymmetricCipher &&  )
defaultnoexcept

◆ Reset()

bool Aws::Crt::Crypto::SymmetricCipher::Reset ( )
noexcept

Reset to cipher to new state.

◆ SetTag()

void Aws::Crt::Crypto::SymmetricCipher::SetTag ( ByteCursor  tag) const
noexcept

Sets the tag used during decryption operations for this cipher in GCM mode. No-op outside of GCM mode. In GCM mode, encrypt operation overrides the value of the tag.


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