6 #ifndef _INC_cCipherBase_H
7 #define _INC_cCipherBase_H
12 #include "../GrayLibBase.h"
120 virtual size_t get_BlockAlignSize()
const = 0;
121 virtual HRESULT Cipher(BYTE* pOutput,
const BYTE* pInput,
size_t nSizeBytes) = 0;
140 : m_bEncodeMode(bEncodeMode)
141 , m_eBlockMode(eBlockMode)
152 m_bEncodeMode = bEncodeMode;
156 return m_bEncodeMode;
161 m_eBlockMode = eBlockMode;
210 virtual HRESULT CipherModeCTR(BYTE* pOutput,
const BYTE* pInput,
size_t nSize, BYTE* pNonceCounter,
size_t* pNCOffset, BYTE* pStreamBlock)
222 virtual HRESULT Cipher(BYTE* pOutput,
const BYTE* pInput,
size_t nSize)
override
226 ::memcpy(pOutput, pInput, nSize);
230 static size_t GRAYCALL CopyFillX(
void* pOutput,
size_t nOutSize,
const void* pInput,
size_t nInputSize);
245 , m_eCipherAlgorithm(eCipherAlgorithm)
250 const BYTE* pIV,
size_t nSizeIV,
251 const BYTE* pAdd,
size_t nSizeAdd,
252 BYTE* pTag,
size_t nSizeTag) = 0;
255 const BYTE* pIV,
size_t nSizeIV,
256 const BYTE* pAdd,
size_t nSizeAdd,
257 const BYTE* pTag,
size_t nSizeTag) = 0;
269 cCipherNone(
bool bEncodeMode =
true,
size_t nBlockAlignSize = 1) noexcept
271 , m_nBlockAlignSize(nBlockAlignSize)
288 return m_nBlockAlignSize;
291 virtual HRESULT Cipher(BYTE* pOutput,
const BYTE* pInput,
size_t nSizeBytes)
override
295 if (m_nBlockAlignSize > 1)
297 nSizeBytes -= nSizeBytes % m_nBlockAlignSize;
299 ::memcpy(pOutput, pInput, nSizeBytes);
#define IGNORE_WARN_INTERFACE(c)
Definition: GrayCore.h:79
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define UNREFERENCED_PARAMETER(P)
< _WIN32 type thing. get rid of stupid warning.
Definition: SysTypes.h:299
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cCipherBase.h:125
virtual HRESULT CipherModeCTR(BYTE *pOutput, const BYTE *pInput, size_t nSize, BYTE *pNonceCounter, size_t *pNCOffset, BYTE *pStreamBlock)
Definition: cCipherBase.h:210
virtual size_t get_BlockAlignSize() const override
Definition: cCipherBase.h:164
void put_EncodeMode(bool bEncodeMode) noexcept
Definition: cCipherBase.h:148
void put_BlockMode(CIPHER_BLOCK_TYPE eBlockMode) noexcept
Definition: cCipherBase.h:159
bool get_EncodeMode() const noexcept
Definition: cCipherBase.h:154
virtual HRESULT SetCipherKey(const void *pKeyData=nullptr, size_t nKeySize=0)
Definition: cCipherBase.h:172
virtual HRESULT CipherModeECB(BYTE *pOutput, const BYTE *pInput)
Definition: cCipherBase.h:182
cCipherBase(bool bEncodeMode=true, CIPHER_BLOCK_TYPE eBlockMode=CIPHER_BLOCK_UNK) noexcept
Definition: cCipherBase.h:139
virtual HRESULT CipherModeCBC(BYTE *pOutput, const BYTE *pInput, size_t nSize, BYTE *pIV)
Definition: cCipherBase.h:190
CIPHER_BLOCK_TYPE m_eBlockMode
Cipher block mode. How are sequences of blocks treated?
Definition: cCipherBase.h:136
virtual HRESULT Cipher(BYTE *pOutput, const BYTE *pInput, size_t nSize) override
Definition: cCipherBase.h:222
bool m_bEncodeMode
We are in encode/encrypt mode vs decode/decrypt mode.
Definition: cCipherBase.h:135
virtual HRESULT CipherModeCFB(BYTE *pOutput, const BYTE *pInput, size_t nSize, BYTE *pIV, size_t *pIVOffset)
Definition: cCipherBase.h:199
virtual ~cCipherBase()
Definition: cCipherBase.h:144
Definition: cCipherBase.h:234
cCipherBlockBase(bool bEncodeMode, CipherAlgorithm_TYPE eCipherAlgorithm) noexcept
Definition: cCipherBase.h:243
CipherAlgorithm_TYPE m_eCipherAlgorithm
cCipherAES or cCipherCamellia
Definition: cCipherBase.h:239
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)=0
cNewPtr< cCipherBase > m_pCipherBase
cipher base used. cCipherAES or cCipherCamellia
Definition: cCipherBase.h:240
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)=0
Definition: cCipherBase.h:261
virtual size_t get_BlockAlignSize() const override
Definition: cCipherBase.h:283
virtual HRESULT SetCipherKey(const void *pKeyData=nullptr, size_t nKeySize=0) override
Definition: cCipherBase.h:275
cCipherNone(bool bEncodeMode=true, size_t nBlockAlignSize=1) noexcept
Definition: cCipherBase.h:269
size_t m_nBlockAlignSize
for testing. 1 = no block size.
Definition: cCipherBase.h:266
virtual HRESULT Cipher(BYTE *pOutput, const BYTE *pInput, size_t nSizeBytes) override
Definition: cCipherBase.h:291
Definition: cCipherBase.h:111
CipherVariable_TYPE
Definition: cCipherBase.h:43
@ CipherVariable_IV_LEN
Cipher accepts IVs of variable length.
Definition: cCipherBase.h:46
@ CipherVariable_KEY_LEN
Cipher accepts keys of variable length.
Definition: cCipherBase.h:47
@ CipherVariable_NULL
Definition: cCipherBase.h:45
CIPHER_BLOCK_TYPE
Definition: cCipherBase.h:73
@ CIPHER_BLOCK_CFB
Definition: cCipherBase.h:101
@ CIPHER_BLOCK_CCM
Definition: cCipherBase.h:108
@ CIPHER_BLOCK_CBC
Definition: cCipherBase.h:86
@ CIPHER_BLOCK_OFB
Output feedback. NOT USED.
Definition: cCipherBase.h:95
@ CIPHER_BLOCK_GCM
Definition: cCipherBase.h:107
@ CIPHER_BLOCK_ECB
Definition: cCipherBase.h:92
@ CIPHER_BLOCK_UNK
Also defined also in "WinCrypt.h" as "#define CRYPT_MODE_*" (same values).
Definition: cCipherBase.h:80
@ CIPHER_BLOCK_CTR
Counter.
Definition: cCipherBase.h:104
CipherAlgorithm_TYPE
Definition: cCipherBase.h:22
@ CipherAlgorithm_NULL
Definition: cCipherBase.h:28
@ CipherAlgorithm_CCM_Camellia
Definition: cCipherBase.h:37
@ CipherAlgorithm_DES
Definition: cCipherBase.h:32
@ CipherAlgorithm_AES
Definition: cCipherBase.h:29
@ CipherAlgorithm_GCM_AES
Definition: cCipherBase.h:34
@ CipherAlgorithm_QTY
Definition: cCipherBase.h:39
@ CipherAlgorithm_Blowfish
Definition: cCipherBase.h:33
@ CipherAlgorithm_Camellia
Definition: cCipherBase.h:30
@ CipherAlgorithm_RC4
Definition: cCipherBase.h:31
@ CipherAlgorithm_CCM_AES
Definition: cCipherBase.h:36
@ CipherAlgorithm_GCM_Camellia
Definition: cCipherBase.h:35
CipherKeySize_TYPE
Definition: cCipherBase.h:51
@ CipherKeySize_128
Definition: cCipherBase.h:62
@ CipherKeySize_DES_EDE
Definition: cCipherBase.h:61
@ CipherKeySize_DES
Definition: cCipherBase.h:57
@ CipherKeySize_64
Definition: cCipherBase.h:58
@ CipherKeySize_DES_EDE3
Definition: cCipherBase.h:65
@ CipherKeySize_192
Definition: cCipherBase.h:66
@ CipherKeySize_NONE
Definition: cCipherBase.h:54
@ CipherKeySize_256
Definition: cCipherBase.h:67
MIDL_INTERFACE("0C3E2E71-B93C-11d2-AAD0-006007654304") IScriptableObj