#include <cCipherBlowfish.h>
|
| cCipherBlowfish (bool bEncodeMode=true, const void *pKeyData=nullptr, size_t nKeySize=0) |
|
virtual | ~cCipherBlowfish () |
|
virtual size_t | get_BlockAlignSize () const override |
|
virtual HRESULT | SetCipherKey (const void *pKeyData=nullptr, size_t nKeySize=0) override |
|
virtual HRESULT | CipherModeECB (BYTE pOutput[k_BlockAlign], const BYTE pInput[k_BlockAlign]) override |
|
virtual HRESULT | CipherModeCBC (BYTE *pOutput, const BYTE *pInput, size_t nSize, BYTE *pIV) override |
|
virtual HRESULT | CipherModeCFB (BYTE *pOutput, const BYTE *pInput, size_t nSize, BYTE pIV[k_BlockAlign], size_t *pnIVOffset) override |
|
virtual HRESULT | CipherModeCTR (BYTE *pOutput, const BYTE *pInput, size_t nSize, BYTE pNonceCounter[k_BlockAlign], size_t *pNCOffset, BYTE pStreamBlock[k_BlockAlign]) override |
|
virtual HRESULT | Cipher (BYTE *pOutput, const BYTE *pInput, size_t nSizeBytes) override |
|
| UNITTEST_FRIEND (cCipherBlowfish) |
|
| 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 HRESULT | CipherModeECB (BYTE *pOutput, const BYTE *pInput) |
|
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 | ~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) |
|
CipherAlgorithm_Blowfish crypt and decrypt using Blowfish http://en.wikipedia.org/wiki/Blowfish_%28cipher%29
- Note
- Can be used by .CAB files in _WIN32
-
watch out for get_BlockAlignSize()
◆ cCipherBlowfish()
GrayLib::cCipherBlowfish::cCipherBlowfish |
( |
bool |
bEncodeMode = true , |
|
|
const void * |
pKeyData = nullptr , |
|
|
size_t |
nKeySize = 0 |
|
) |
| |
◆ ~cCipherBlowfish()
GrayLib::cCipherBlowfish::~cCipherBlowfish |
( |
| ) |
|
|
virtual |
◆ Cipher()
HRESULT GrayLib::cCipherBlowfish::Cipher |
( |
BYTE * |
pOutput, |
|
|
const BYTE * |
pInput, |
|
|
size_t |
nSizeBytes |
|
) |
| |
|
overridevirtual |
Encrypt from Input Buffer to Output Buffer Check the buffer's length - should be > 0 and multiple of 8
- Returns
- <0 = error. Amount of data i could actually process (some may be dropped for alignment)
Reimplemented from GrayLib::cCipherBase.
◆ CipherModeCBC()
HRESULT GrayLib::cCipherBlowfish::CipherModeCBC |
( |
BYTE * |
pOutput, |
|
|
const BYTE * |
pInput, |
|
|
size_t |
nSize, |
|
|
BYTE * |
pIV |
|
) |
| |
|
overridevirtual |
Blowfish-CBC buffer encryption/decryption Length should be a multiple of the block size (8 bytes) [k_BlockAlign]
- Note
- Upon exit, the content of the IV is updated so that you can call the function same function again on the following block(s) of data and get the same result as if it was encrypted in one call. This allows a "streaming" usage. If on the other hand you need to retain the contents of the IV, you should either save it manually or use the cipher module instead.
- pOutput = buffer holding the output data
- pInput = buffer holding the input data
- nSize = length of the input data
- pIV = initialization vector (updated after use)
- Returns
- 0 if successful, or NTE_BAD_LEN
Reimplemented from GrayLib::cCipherBase.
◆ CipherModeCFB()
HRESULT GrayLib::cCipherBlowfish::CipherModeCFB |
( |
BYTE * |
pOutput, |
|
|
const BYTE * |
pInput, |
|
|
size_t |
nSize, |
|
|
BYTE |
pIV[k_BlockAlign], |
|
|
size_t * |
pnIVOffset |
|
) |
| |
|
overridevirtual |
Blowfish CFB buffer encryption/decryption. CIPHER_BLOCK_CFB
- Note
- Upon exit, the content of the IV is updated so that you can call the function same function again on the following block(s) of data and get the same result as if it was encrypted in one call. This allows a "streaming" usage. If on the other hand you need to retain the contents of the IV, you should either save it manually or use the cipher module instead.
- pOutput = buffer holding the output data
- pInput = buffer holding the input data
- nSize = length of the input data
- pIV = initialization vector (updated after use)
- pnIVOffset = offset in IV (updated after use)
- Returns
- 0 if successful
◆ CipherModeCTR()
HRESULT GrayLib::cCipherBlowfish::CipherModeCTR |
( |
BYTE * |
pOutput, |
|
|
const BYTE * |
pInput, |
|
|
size_t |
nSize, |
|
|
BYTE |
pNonceCounter[k_BlockAlign], |
|
|
size_t * |
pNCOffset, |
|
|
BYTE |
pStreamBlock[k_BlockAlign] |
|
) |
| |
|
overridevirtual |
Blowfish-CTR buffer encryption/decryption Warning: You have to keep the maximum use of your counter in mind!
- pOutput = buffer holding the output data
- pInput = buffer holding the input data
- nSize = length of the input data
- pNonceCounter = The 64-bit nonce and counter.
- pNCOffset = The offset in the current stream_block (for resuming within current cipher stream). The offset pointer to should be 0 at the start of a stream.
- pStreamBlock = The saved stream-block for resuming. Is overwritten by the function.
- Returns
- 0 if successful
◆ CipherModeECB()
HRESULT GrayLib::cCipherBlowfish::CipherModeECB |
( |
BYTE |
pOutput[k_BlockAlign], |
|
|
const BYTE |
pInput[k_BlockAlign] |
|
) |
| |
|
overridevirtual |
Blowfish-ECB CIPHER_BLOCK_ECB block encryption/decryption [k_BlockAlign]
- pInput = 8-byte input block
- pOutput = 8-byte output block
- Returns
- 0 if successful
◆ get_BlockAlignSize()
virtual size_t GrayLib::cCipherBlowfish::get_BlockAlignSize |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ SetCipherKey()
HRESULT GrayLib::cCipherBlowfish::SetCipherKey |
( |
const void * |
pKeyData = nullptr , |
|
|
size_t |
nKeySize = 0 |
|
) |
| |
|
overridevirtual |
Constructor - Initialize the P and S boxes for a given Key
- pKeyData = set cipher key. Fix it if unaligned.
- nKeySize = must be between 32 and 448 bits
Reimplemented from GrayLib::cCipherBase.
◆ UNITTEST_FRIEND()
◆ k_BlockAlign
const size_t GrayLib::cCipherBlowfish::k_BlockAlign = 8 |
|
static |
Blowfish uses 64 bit blocks = 8 bytes = sizeof(cCipherBlowfishBlock)
◆ k_KeySizeMax
const size_t GrayLib::cCipherBlowfish::k_KeySizeMax = 56 |
|
static |
The documentation for this class was generated from the following files: