AWS SDK for C++  1.9.103
AWS SDK for C++
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Aws::Utils::Crypto::BCryptSymmetricCipher Class Referenceabstract

#include <CryptoImpl.h>

+ Inheritance diagram for Aws::Utils::Crypto::BCryptSymmetricCipher:

Public Member Functions

 BCryptSymmetricCipher (const CryptoBuffer &key, size_t ivSize, bool ctrMode=false)
 
 BCryptSymmetricCipher (const CryptoBuffer &key, const CryptoBuffer &initializationVector, const CryptoBuffer &tag=CryptoBuffer(0))
 
 BCryptSymmetricCipher (CryptoBuffer &&key, CryptoBuffer &&initializationVector, CryptoBuffer &&tag=std::move(CryptoBuffer(0)))
 
 BCryptSymmetricCipher (const BCryptSymmetricCipher &)=delete
 
BCryptSymmetricCipheroperator= (const BCryptSymmetricCipher &)=delete
 
 BCryptSymmetricCipher (BCryptSymmetricCipher &&toMove)
 
BCryptSymmetricCipheroperator= (BCryptSymmetricCipher &&toMove)
 
virtual ~BCryptSymmetricCipher ()
 
CryptoBuffer EncryptBuffer (const CryptoBuffer &unEncryptedData) override
 
CryptoBuffer FinalizeEncryption () override
 
CryptoBuffer DecryptBuffer (const CryptoBuffer &encryptedData) override
 
CryptoBuffer FinalizeDecryption () override
 
void Reset () override
 
- Public Member Functions inherited from Aws::Utils::Crypto::SymmetricCipher
 SymmetricCipher (const CryptoBuffer &key, size_t ivSize, bool ivGenerationInCtrMode=false)
 
 SymmetricCipher (const CryptoBuffer &key, const CryptoBuffer &initializationVector, const CryptoBuffer &tag=CryptoBuffer(0))
 
 SymmetricCipher (CryptoBuffer &&key, CryptoBuffer &&initializationVector, CryptoBuffer &&tag=CryptoBuffer(0))
 
 SymmetricCipher (const SymmetricCipher &other)=delete
 
SymmetricCipheroperator= (const SymmetricCipher &other)=delete
 
 SymmetricCipher (SymmetricCipher &&toMove)
 
SymmetricCipheroperator= (SymmetricCipher &&toMove)
 
virtual ~SymmetricCipher ()=default
 
virtual operator bool () const
 
const CryptoBufferGetIV () const
 
const CryptoBufferGetTag () const
 
bool Fail () const
 
bool Good () const
 

Protected Member Functions

void InitKey ()
 
virtual size_t GetBlockSizeBytes () const =0
 
virtual size_t GetKeyLengthBits () const =0
 
bool CheckKeyAndIVLength (size_t expectedKeyLength, size_t expectedIVLength)
 
- Protected Member Functions inherited from Aws::Utils::Crypto::SymmetricCipher
 SymmetricCipher ()
 

Static Protected Member Functions

static BCRYPT_KEY_HANDLE ImportKeyBlob (BCRYPT_ALG_HANDLE handle, CryptoBuffer &key)
 

Protected Attributes

BCRYPT_ALG_HANDLE m_algHandle
 
BCRYPT_KEY_HANDLE m_keyHandle
 
DWORD m_flags
 
CryptoBuffer m_workingIv
 
PBCRYPT_AUTHENTICATED_CIPHER_MODE_INFO m_authInfoPtr
 
bool m_encryptDecryptCalled
 
- Protected Attributes inherited from Aws::Utils::Crypto::SymmetricCipher
CryptoBuffer m_key
 
CryptoBuffer m_initializationVector
 
CryptoBuffer m_tag
 
bool m_failure
 

Additional Inherited Members

- Static Public Member Functions inherited from Aws::Utils::Crypto::SymmetricCipher
static CryptoBuffer GenerateIV (size_t ivLengthBytes, bool ctrMode=false)
 
static CryptoBuffer GenerateKey (size_t keyLengthBytes=SYMMETRIC_KEY_LENGTH)
 

Detailed Description

Encryptor/Decrypto for AES.

Definition at line 181 of file CryptoImpl.h.

Constructor & Destructor Documentation

◆ BCryptSymmetricCipher() [1/5]

Aws::Utils::Crypto::BCryptSymmetricCipher::BCryptSymmetricCipher ( const CryptoBuffer key,
size_t  ivSize,
bool  ctrMode = false 
)

◆ BCryptSymmetricCipher() [2/5]

Aws::Utils::Crypto::BCryptSymmetricCipher::BCryptSymmetricCipher ( const CryptoBuffer key,
const CryptoBuffer initializationVector,
const CryptoBuffer tag = CryptoBuffer(0) 
)

Initialize with key and initializationVector, set tag for decryption of authenticated modes (makes copies of the buffers)

◆ BCryptSymmetricCipher() [3/5]

Aws::Utils::Crypto::BCryptSymmetricCipher::BCryptSymmetricCipher ( CryptoBuffer &&  key,
CryptoBuffer &&  initializationVector,
CryptoBuffer &&  tag = std::move(CryptoBuffer(0)) 
)

Initialize with key and initializationVector, set tag for decryption of authenticated modes (move the buffers)

◆ BCryptSymmetricCipher() [4/5]

Aws::Utils::Crypto::BCryptSymmetricCipher::BCryptSymmetricCipher ( const BCryptSymmetricCipher )
delete

◆ BCryptSymmetricCipher() [5/5]

Aws::Utils::Crypto::BCryptSymmetricCipher::BCryptSymmetricCipher ( BCryptSymmetricCipher &&  toMove)

Normally we don't work around VS 2013 not auto-generating these, but they are kind of expensive, so let's go ahead and optimize by defining default move operations. Implementors of this class need to be sure to define the move operations and call the base class.

◆ ~BCryptSymmetricCipher()

virtual Aws::Utils::Crypto::BCryptSymmetricCipher::~BCryptSymmetricCipher ( )
virtual

Member Function Documentation

◆ CheckKeyAndIVLength()

bool Aws::Utils::Crypto::BCryptSymmetricCipher::CheckKeyAndIVLength ( size_t  expectedKeyLength,
size_t  expectedIVLength 
)
protected

◆ DecryptBuffer()

CryptoBuffer Aws::Utils::Crypto::BCryptSymmetricCipher::DecryptBuffer ( const CryptoBuffer encryptedData)
overridevirtual

You should call this multiple times until you run out of data. Call FinalizeDecryption() when finished to receive any remaining data. Once you call this method the first time, it can not ever be used with EncryptBuffer()

Implements Aws::Utils::Crypto::SymmetricCipher.

Reimplemented in Aws::Utils::Crypto::AES_KeyWrap_Cipher_BCrypt, Aws::Utils::Crypto::AES_CTR_Cipher_BCrypt, Aws::Utils::Crypto::AES_CBC_Cipher_BCrypt, and Aws::Utils::Crypto::AES_GCM_Cipher_BCrypt.

◆ EncryptBuffer()

CryptoBuffer Aws::Utils::Crypto::BCryptSymmetricCipher::EncryptBuffer ( const CryptoBuffer unEncryptedData)
overridevirtual

You should call this multiple times until you run out of data. Call FinalizeEncryption() when finished to receive any remaining data. Once you call this method the first time, it can not ever be used with DecryptBuffer()

Implements Aws::Utils::Crypto::SymmetricCipher.

Reimplemented in Aws::Utils::Crypto::AES_KeyWrap_Cipher_BCrypt, Aws::Utils::Crypto::AES_CTR_Cipher_BCrypt, Aws::Utils::Crypto::AES_CBC_Cipher_BCrypt, and Aws::Utils::Crypto::AES_GCM_Cipher_BCrypt.

◆ FinalizeDecryption()

CryptoBuffer Aws::Utils::Crypto::BCryptSymmetricCipher::FinalizeDecryption ( )
overridevirtual

Some ciphers have remaining blocks that need to be cleared, call this after calling DecryptBuffer one or more times. The potential data returned here is part of your decrypted message. Once you call this method, you can not use this instance any more.

Implements Aws::Utils::Crypto::SymmetricCipher.

Reimplemented in Aws::Utils::Crypto::AES_KeyWrap_Cipher_BCrypt, Aws::Utils::Crypto::AES_GCM_Cipher_BCrypt, Aws::Utils::Crypto::AES_CTR_Cipher_BCrypt, and Aws::Utils::Crypto::AES_CBC_Cipher_BCrypt.

◆ FinalizeEncryption()

CryptoBuffer Aws::Utils::Crypto::BCryptSymmetricCipher::FinalizeEncryption ( )
overridevirtual

Some ciphers have remaining blocks that need to be cleared, call this after calling EncryptBuffer one or more times. The potential data returned here is part of your encrypted message. Once you call this method, you can not use this instance any more.

Implements Aws::Utils::Crypto::SymmetricCipher.

Reimplemented in Aws::Utils::Crypto::AES_KeyWrap_Cipher_BCrypt, Aws::Utils::Crypto::AES_GCM_Cipher_BCrypt, Aws::Utils::Crypto::AES_CTR_Cipher_BCrypt, and Aws::Utils::Crypto::AES_CBC_Cipher_BCrypt.

◆ GetBlockSizeBytes()

virtual size_t Aws::Utils::Crypto::BCryptSymmetricCipher::GetBlockSizeBytes ( ) const
protectedpure virtual

◆ GetKeyLengthBits()

virtual size_t Aws::Utils::Crypto::BCryptSymmetricCipher::GetKeyLengthBits ( ) const
protectedpure virtual

◆ ImportKeyBlob()

static BCRYPT_KEY_HANDLE Aws::Utils::Crypto::BCryptSymmetricCipher::ImportKeyBlob ( BCRYPT_ALG_HANDLE  handle,
CryptoBuffer key 
)
staticprotected

◆ InitKey()

void Aws::Utils::Crypto::BCryptSymmetricCipher::InitKey ( )
protected

◆ operator=() [1/2]

BCryptSymmetricCipher& Aws::Utils::Crypto::BCryptSymmetricCipher::operator= ( BCryptSymmetricCipher &&  toMove)

Normally we don't work around VS 2013 not auto-generating these, but they are kind of expensive, so let's go ahead and optimize by defining default move operations. Implementors of this class need to be sure to define the move operations and call the base class.

◆ operator=() [2/2]

BCryptSymmetricCipher& Aws::Utils::Crypto::BCryptSymmetricCipher::operator= ( const BCryptSymmetricCipher )
delete

◆ Reset()

void Aws::Utils::Crypto::BCryptSymmetricCipher::Reset ( )
overridevirtual

Member Data Documentation

◆ m_algHandle

BCRYPT_ALG_HANDLE Aws::Utils::Crypto::BCryptSymmetricCipher::m_algHandle
protected

Definition at line 244 of file CryptoImpl.h.

◆ m_authInfoPtr

PBCRYPT_AUTHENTICATED_CIPHER_MODE_INFO Aws::Utils::Crypto::BCryptSymmetricCipher::m_authInfoPtr
protected

Definition at line 248 of file CryptoImpl.h.

◆ m_encryptDecryptCalled

bool Aws::Utils::Crypto::BCryptSymmetricCipher::m_encryptDecryptCalled
protected

We need to call BCryptEncrypt or BCryptEncrypt at least once. (corner case for empty string)

Definition at line 254 of file CryptoImpl.h.

◆ m_flags

DWORD Aws::Utils::Crypto::BCryptSymmetricCipher::m_flags
protected

Definition at line 246 of file CryptoImpl.h.

◆ m_keyHandle

BCRYPT_KEY_HANDLE Aws::Utils::Crypto::BCryptSymmetricCipher::m_keyHandle
protected

Definition at line 245 of file CryptoImpl.h.

◆ m_workingIv

CryptoBuffer Aws::Utils::Crypto::BCryptSymmetricCipher::m_workingIv
protected

Definition at line 247 of file CryptoImpl.h.


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