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

#include <Cipher.h>

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

Public Member Functions

 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
 
virtual CryptoBuffer EncryptBuffer (const CryptoBuffer &unEncryptedData)=0
 
virtual CryptoBuffer FinalizeEncryption ()=0
 
virtual CryptoBuffer DecryptBuffer (const CryptoBuffer &encryptedData)=0
 
virtual CryptoBuffer FinalizeDecryption ()=0
 
virtual void Reset ()=0
 
const CryptoBufferGetIV () const
 
const CryptoBufferGetTag () const
 
bool Fail () const
 
bool Good () const
 

Static Public Member Functions

static CryptoBuffer GenerateIV (size_t ivLengthBytes, bool ctrMode=false)
 
static CryptoBuffer GenerateKey (size_t keyLengthBytes=SYMMETRIC_KEY_LENGTH)
 

Protected Member Functions

 SymmetricCipher ()
 

Protected Attributes

CryptoBuffer m_key
 
CryptoBuffer m_initializationVector
 
CryptoBuffer m_tag
 
bool m_failure
 

Detailed Description

Interface for symmetric encryption and decryption providers. An instance of this class is good for exactly one encryption or decryption run. It should not be used to encrypt or decrypt multiple messages.

Definition at line 27 of file Cipher.h.

Constructor & Destructor Documentation

◆ SymmetricCipher() [1/6]

Aws::Utils::Crypto::SymmetricCipher::SymmetricCipher ( const CryptoBuffer key,
size_t  ivSize,
bool  ivGenerationInCtrMode = false 
)
inline

Initialize with key and an auto-generated initializationVector. Copies key. ivGenerationInCtrMode, if true, initializes the iv with a 4 byte counter at the end.

Definition at line 34 of file Cipher.h.

◆ SymmetricCipher() [2/6]

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

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

Definition at line 44 of file Cipher.h.

◆ SymmetricCipher() [3/6]

Aws::Utils::Crypto::SymmetricCipher::SymmetricCipher ( CryptoBuffer &&  key,
CryptoBuffer &&  initializationVector,
CryptoBuffer &&  tag = CryptoBuffer(0) 
)
inline

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

Definition at line 55 of file Cipher.h.

◆ SymmetricCipher() [4/6]

Aws::Utils::Crypto::SymmetricCipher::SymmetricCipher ( const SymmetricCipher other)
delete

◆ SymmetricCipher() [5/6]

Aws::Utils::Crypto::SymmetricCipher::SymmetricCipher ( SymmetricCipher &&  toMove)
inline

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.

Definition at line 71 of file Cipher.h.

◆ ~SymmetricCipher()

virtual Aws::Utils::Crypto::SymmetricCipher::~SymmetricCipher ( )
virtualdefault

◆ SymmetricCipher() [6/6]

Aws::Utils::Crypto::SymmetricCipher::SymmetricCipher ( )
inlineprotected

Definition at line 156 of file Cipher.h.

Member Function Documentation

◆ DecryptBuffer()

virtual CryptoBuffer Aws::Utils::Crypto::SymmetricCipher::DecryptBuffer ( const CryptoBuffer encryptedData)
pure virtual

Decrypt a buffer of data. Part of the contract for this interface is that intention that a user call this function multiple times for a large stream. As such, multiple calls to this function on the same instance should produce valid sequential output from an encrypted stream.

Implemented in Aws::Utils::Crypto::OpenSSLCipher, Aws::Utils::Crypto::AES_KeyWrap_Cipher_CommonCrypto, Aws::Utils::Crypto::CommonCryptoCipher, Aws::Utils::Crypto::AES_KeyWrap_Cipher_BCrypt, Aws::Utils::Crypto::AES_CTR_Cipher_BCrypt, Aws::Utils::Crypto::AES_CBC_Cipher_BCrypt, Aws::Utils::Crypto::BCryptSymmetricCipher, Aws::Utils::Crypto::AES_KeyWrap_Cipher_OpenSSL, Aws::Utils::Crypto::AES_GCM_Cipher_BCrypt, and Aws::S3Encryption::Modules::AES_GCM_AppendedTag.

◆ EncryptBuffer()

virtual CryptoBuffer Aws::Utils::Crypto::SymmetricCipher::EncryptBuffer ( const CryptoBuffer unEncryptedData)
pure virtual

Encrypt a buffer of data. Part of the contract for this interface is that intention that a user call this function multiple times for a large stream. As such, multiple calls to this function on the same instance should produce valid sequential output for an encrypted stream.

Implemented in Aws::Utils::Crypto::OpenSSLCipher, Aws::Utils::Crypto::AES_KeyWrap_Cipher_CommonCrypto, Aws::Utils::Crypto::CommonCryptoCipher, Aws::Utils::Crypto::AES_KeyWrap_Cipher_BCrypt, Aws::Utils::Crypto::AES_CTR_Cipher_BCrypt, Aws::Utils::Crypto::AES_CBC_Cipher_BCrypt, Aws::Utils::Crypto::BCryptSymmetricCipher, Aws::Utils::Crypto::AES_KeyWrap_Cipher_OpenSSL, Aws::Utils::Crypto::AES_GCM_Cipher_BCrypt, and Aws::S3Encryption::Modules::AES_GCM_AppendedTag.

◆ Fail()

bool Aws::Utils::Crypto::SymmetricCipher::Fail ( ) const
inline

Definition at line 139 of file Cipher.h.

◆ FinalizeDecryption()

virtual CryptoBuffer Aws::Utils::Crypto::SymmetricCipher::FinalizeDecryption ( )
pure virtual

◆ FinalizeEncryption()

virtual CryptoBuffer Aws::Utils::Crypto::SymmetricCipher::FinalizeEncryption ( )
pure virtual

◆ GenerateIV()

static CryptoBuffer Aws::Utils::Crypto::SymmetricCipher::GenerateIV ( size_t  ivLengthBytes,
bool  ctrMode = false 
)
static

Generates a non-deterministic random IV. The first call is somewhat expensive but subsequent calls should be fast. If ctrMode is true, it will pad nonce in the first 1/4 of the iv and initialize the back 1/4 to 1.

◆ GenerateKey()

static CryptoBuffer Aws::Utils::Crypto::SymmetricCipher::GenerateKey ( size_t  keyLengthBytes = SYMMETRIC_KEY_LENGTH)
static

Generates a non-deterministic random symmetric key. Default (and minimum bar for security) is 256 bits.

◆ GetIV()

const CryptoBuffer& Aws::Utils::Crypto::SymmetricCipher::GetIV ( ) const
inline

IV used for encryption/decryption

Definition at line 131 of file Cipher.h.

◆ GetTag()

const CryptoBuffer& Aws::Utils::Crypto::SymmetricCipher::GetTag ( ) const
inline

Tag generated by encryption and used for the decryption. This will be set in an authenticated mode, otherwise empty

Definition at line 137 of file Cipher.h.

◆ Good()

bool Aws::Utils::Crypto::SymmetricCipher::Good ( ) const
inline

Definition at line 140 of file Cipher.h.

◆ operator bool()

virtual Aws::Utils::Crypto::SymmetricCipher::operator bool ( ) const
inlinevirtual

Whether or not the cipher is in a good state. If this ever returns false, throw away all buffers it has vended.

Reimplemented in Aws::S3Encryption::Modules::AES_GCM_AppendedTag.

Definition at line 100 of file Cipher.h.

◆ operator=() [1/2]

SymmetricCipher& Aws::Utils::Crypto::SymmetricCipher::operator= ( const SymmetricCipher other)
delete

◆ operator=() [2/2]

SymmetricCipher& Aws::Utils::Crypto::SymmetricCipher::operator= ( SymmetricCipher &&  toMove)
inline

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.

Definition at line 84 of file Cipher.h.

◆ Reset()

virtual void Aws::Utils::Crypto::SymmetricCipher::Reset ( )
pure virtual

Member Data Documentation

◆ m_failure

bool Aws::Utils::Crypto::SymmetricCipher::m_failure
protected

Definition at line 161 of file Cipher.h.

◆ m_initializationVector

CryptoBuffer Aws::Utils::Crypto::SymmetricCipher::m_initializationVector
protected

Definition at line 159 of file Cipher.h.

◆ m_key

CryptoBuffer Aws::Utils::Crypto::SymmetricCipher::m_key
protected

Definition at line 158 of file Cipher.h.

◆ m_tag

CryptoBuffer Aws::Utils::Crypto::SymmetricCipher::m_tag
protected

Definition at line 160 of file Cipher.h.


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