Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cCipherCCM Class Reference

#include <cCipherCCM.h>

Inheritance diagram for GrayLib::cCipherCCM:
GrayLib::cCipherBlockBase GrayLib::cCipherBase Gray::CObject ICipherBase

Public Member Functions

 cCipherCCM (bool bEncodeMode, CipherAlgorithm_TYPE eCipherAlgorithm)
 
virtual ~cCipherCCM ()
 
virtual HRESULT SetCipherKey (const void *pKeyData, size_t nKeySize) override
 
virtual HRESULT AuthEncrypt (BYTE *pOutput, const BYTE *pInput, size_t nSize, const BYTE *pIV, size_t nSizeIV, const BYTE *pAdd, size_t nSizeAdd, BYTE *pTag, size_t nSizeTag) override
 
virtual HRESULT AuthDecrypt (BYTE *pOutput, const BYTE *pInput, size_t nSize, const BYTE *pIV, size_t nSizeIV, const BYTE *pAdd, size_t nSizeAdd, const BYTE *pTag, size_t nSizeTag) override
 
 UNITTEST_FRIEND (cCipherCCM)
 
- Public Member Functions inherited from GrayLib::cCipherBlockBase
 cCipherBlockBase (bool bEncodeMode, CipherAlgorithm_TYPE eCipherAlgorithm) noexcept
 
- Public Member Functions inherited from GrayLib::cCipherBase
 cCipherBase (bool bEncodeMode=true, CIPHER_BLOCK_TYPE eBlockMode=CIPHER_BLOCK_UNK) noexcept
 
virtual ~cCipherBase ()
 
void put_EncodeMode (bool bEncodeMode) noexcept
 
bool get_EncodeMode () const noexcept
 
void put_BlockMode (CIPHER_BLOCK_TYPE eBlockMode) noexcept
 
virtual size_t get_BlockAlignSize () const override
 
virtual HRESULT CipherModeECB (BYTE *pOutput, const BYTE *pInput)
 
virtual HRESULT CipherModeCBC (BYTE *pOutput, const BYTE *pInput, size_t nSize, BYTE *pIV)
 
virtual HRESULT CipherModeCFB (BYTE *pOutput, const BYTE *pInput, size_t nSize, BYTE *pIV, size_t *pIVOffset)
 
virtual HRESULT CipherModeCTR (BYTE *pOutput, const BYTE *pInput, size_t nSize, BYTE *pNonceCounter, size_t *pNCOffset, BYTE *pStreamBlock)
 
virtual HRESULT Cipher (BYTE *pOutput, const BYTE *pInput, size_t nSize) override
 
- Public Member Functions inherited from Gray::CObject
virtual ~CObject ()
 
virtual bool isValidCheck () const noexcept
 < memory allocation and structure definitions are valid. More...
 
virtual void AssertValid () const
 < memory allocation and structure definitions are valid. More...
 
virtual void Serialize (cArchive &a)
 

Additional Inherited Members

- Static Public Member Functions inherited from GrayLib::cCipherBase
static size_t GRAYCALL CopyFillX (void *pOutput, size_t nOutSize, const void *pInput, size_t nInputSize)
 
- Public Attributes inherited from GrayLib::cCipherBlockBase
CipherAlgorithm_TYPE m_eCipherAlgorithm
 cCipherAES or cCipherCamellia More...
 
cNewPtr< cCipherBasem_pCipherBase
 cipher base used. cCipherAES or cCipherCamellia More...
 
- Protected Attributes inherited from GrayLib::cCipherBase
bool m_bEncodeMode
 We are in encode/encrypt mode vs decode/decrypt mode. More...
 
CIPHER_BLOCK_TYPE m_eBlockMode
 Cipher block mode. How are sequences of blocks treated? More...
 

Detailed Description

can use cCipherAES, cCipherCamellia CCM context structure

Constructor & Destructor Documentation

◆ cCipherCCM()

GrayLib::cCipherCCM::cCipherCCM ( bool  bEncodeMode,
CipherAlgorithm_TYPE  eCipherAlgorithm 
)
inline

◆ ~cCipherCCM()

virtual GrayLib::cCipherCCM::~cCipherCCM ( )
inlinevirtual

Member Function Documentation

◆ AuthDecrypt()

HRESULT GrayLib::cCipherCCM::AuthDecrypt ( BYTE *  pOutput,
const BYTE *  pInput,
size_t  nSize,
const BYTE *  pIV,
size_t  nSizeIV,
const BYTE *  pAdd,
size_t  nSizeAdd,
const BYTE *  pTag,
size_t  nSizeTag 
)
overridevirtual

CCM buffer Authenticated decryption

  • pOutput = n buffer for holding the output data
  • pInput = buffer holding the input data
  • nSize = length of the input data
  • pIV = initialization vector
  • nSizeIV = length of IV
  • pAdd = additional data
  • nSizeAdd = length of additional data
  • pTag = buffer holding the tag
  • nSizeTag = length of the tag
    Returns
    0 if successful and authenticated, HRESULT_WIN32_C(ERROR_NOT_AUTHENTICATED) if tag does not match

Implements GrayLib::cCipherBlockBase.

◆ AuthEncrypt()

HRESULT GrayLib::cCipherCCM::AuthEncrypt ( BYTE *  pOutput,
const BYTE *  pInput,
size_t  nSize,
const BYTE *  pIV,
size_t  nSizeIV,
const BYTE *  pAdd,
size_t  nSizeAdd,
BYTE *  pTag,
size_t  nSizeTag 
)
overridevirtual

CCM buffer Authenticated encryption

  • pOutput = buffer holding the output data
  • pInput = buffer holding the input data
  • nSize = length of the input data
  • pIV = nonce (initialization vector)
  • nSizeIV = length of IV in bytes must be 2, 3, 4, 5, 6, 7 or 8
  • pAdd = additional data
  • nSizeAdd = length of additional data in bytes must be less than 2^16 - 2^8
  • pTag = buffer for holding the tag
  • nSizeTag = length of the tag to generate in bytes must be 4, 6, 8, 10, 14 or 16
    Note
    The tag is written to a separate buffer. To get the tag concatenated with the output as in the CCM spec, use pTag = output + length and make sure the output buffer is at least length + nSizeTag wide.
    Returns
    0 if successful

Implements GrayLib::cCipherBlockBase.

◆ SetCipherKey()

HRESULT GrayLib::cCipherCCM::SetCipherKey ( const void *  pKeyData,
size_t  nKeySize 
)
overridevirtual

CCM initialization (encryption and decryption)

  • pKeyData = set cipher key. Fix it if unaligned.
  • nKeySize = key size in bytes (must be acceptable by the cipher)
    Returns
    0 if successful, or a cipher specific error code

Reimplemented from GrayLib::cCipherBase.

◆ UNITTEST_FRIEND()

GrayLib::cCipherCCM::UNITTEST_FRIEND ( cCipherCCM  )

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