Mixe for Privacy and Anonymity in the Internet
|
This class could be used for encryption/decryption of data (streams) with AES using 128bit OFB mode. More...
#include <CASymCipherOFB.hpp>
Public Member Functions | |
CASymCipherOFB () | |
~CASymCipherOFB () | |
bool | isKeyValid () |
SINT32 | setKey (const UINT8 *key) |
Sets the keys for crypt1() and crypt2() to the same key. More... | |
SINT32 | setKeys (const UINT8 *key, UINT32 keysize) |
Sets the keys for crypt1() and crypt2() either to the same key (if keysize==KEY_SIZE) or to different values, if keysize==2* KEY_SIZE. More... | |
SINT32 | setKey (const UINT8 *key, bool bEncrypt) |
Sets the key1 and key2 used for encryption/decryption to the same value of key. More... | |
SINT32 | setIVs (const UINT8 *p_iv) |
Sets iv1 and iv2 to p_iv. More... | |
SINT32 | setIV2 (const UINT8 *p_iv) |
Sets iv2 to p_iv. More... | |
SINT32 | crypt1 (const UINT8 *in, UINT8 *out, UINT32 len) |
Encryptes/Decrpytes in to out using iv1 and key1. More... | |
SINT32 | crypt2 (const UINT8 *in, UINT8 *out, UINT32 len) |
Decryptes in to out using iv2 and key2. More... | |
Public Member Functions inherited from CALockAble | |
CALockAble () | |
virtual | ~CALockAble () |
SINT32 | lock () |
Locks the lockable object by threadsafe incrementing a reference counter. More... | |
SINT32 | unlock () |
Unlocks the lockable object by threadsafe decrementing a reference counter. More... | |
Static Public Member Functions | |
static SINT32 | testSpeed () |
Static Public Member Functions inherited from CASymChannelCipher | |
static const UINT8 *const | getAlgorithmName (SYMCHANNELCIPHER_ALGORITHM alg) |
Protected Attributes | |
AES_KEY * | m_keyAES1 |
AES_KEY * | m_keyAES2 |
UINT8 * | m_iv1 |
UINT8 * | m_iv2 |
bool | m_bKeySet |
Private Attributes | |
CAMutex * | m_pcsEnc |
CAMutex * | m_pcsDec |
UINT32 * | m_pEncMsgIV |
UINT32 * | m_pDecMsgIV |
Additional Inherited Members | |
Protected Member Functions inherited from CALockAble | |
SINT32 | waitForDestroy () |
If called checks if the reference counter equals zero. More... | |
This class could be used for encryption/decryption of data (streams) with AES using 128bit OFB mode.
Because of the OFB mode technical encryption and decrpytion are the same (depending on the kind of input). Therefore there is only a general crypt() function. This class has a 2-in-1 feature: Two independent IVs are available. Therefore we have crypt1() and crypt2() depending on the used IV.
Definition at line 43 of file CASymCipherOFB.hpp.
|
inline |
Definition at line 47 of file CASymCipherOFB.hpp.
References m_bKeySet, m_iv1, m_iv2, m_keyAES1, m_keyAES2, m_pcsDec, and m_pcsEnc.
|
inline |
Definition at line 67 of file CASymCipherOFB.hpp.
References m_iv1, m_iv2, m_keyAES1, m_keyAES2, m_pcsDec, m_pcsEnc, and CALockAble::waitForDestroy().
Encryptes/Decrpytes in to out using iv1 and key1.
AES is used for encryption and the encryption is done with a special 128bit-OFB mode: In the case that (len mod 16 !=0) the unused cipher output bits are discarded and NOT used next time encryptAES() is called. That means that every time encrpytAES() is called at first new cipher output is created by calling AES-encrypt(iv).
in | input (plain text) bytes |
out | output (encrpyted) bytes |
len | len of input. because the cipher preserves the size, len of output=len of input |
E_SUCCESS |
Implements CASymChannelCipher.
Definition at line 136 of file CASymCipherOFB.cpp.
Decryptes in to out using iv2 and key2.
in | input (encrypted) bytes |
out | output (decrpyted) bytes |
len | len of input. because the cipher preserves the size, len of output=len of input |
E_SUCCESS |
Implements CASymChannelCipher.
Definition at line 225 of file CASymCipherOFB.cpp.
References E_SUCCESS, KEY_SIZE, len, m_iv1, m_iv2, and m_keyAES2.
|
inlinevirtual |
Implements CASymChannelCipher.
Definition at line 91 of file CASymCipherOFB.hpp.
References m_bKeySet.
Sets iv2 to p_iv.
p_iv | 16 random bytes used for new iv2. |
E_SUCCESS |
Implements CASymChannelCipher.
Definition at line 120 of file CASymCipherOFB.hpp.
Sets iv1 and iv2 to p_iv.
p_iv | 16 random bytes used for new iv1 and iv2. |
E_SUCCESS |
Implements CASymChannelCipher.
Definition at line 109 of file CASymCipherOFB.hpp.
Sets the keys for crypt1() and crypt2() to the same key.
Sets the key1 and key2 used for encryption/decryption.
Also resets the IVs to zero!
key | 16 random bytes used as key |
E_SUCCESS |
Implements CASymChannelCipher.
Definition at line 48 of file CASymCipherOFB.cpp.
Referenced by setKeys().
Sets the key1 and key2 used for encryption/decryption to the same value of key.
Also resets the IVs to zero!
key | 16 random bytes used as key |
bEncrypt | if true, the key should be used for encryption (otherwise it will be used for decryption) |
E_SUCCESS |
Definition at line 58 of file CASymCipherOFB.cpp.
References E_SUCCESS, m_bKeySet, m_iv1, m_iv2, m_keyAES1, and m_keyAES2.
Sets the keys for crypt1() and crypt2() either to the same key (if keysize==KEY_SIZE) or to different values, if keysize==2* KEY_SIZE.
Implements CASymChannelCipher.
Definition at line 93 of file CASymCipherOFB.cpp.
References E_SUCCESS, E_UNKNOWN, KEY_SIZE, m_bKeySet, m_iv1, m_iv2, m_keyAES1, m_keyAES2, CAMsg::printMsg(), and setKey().
|
static |
|
protected |
Definition at line 149 of file CASymCipherOFB.hpp.
Referenced by CASymCipherOFB(), isKeyValid(), setKey(), and setKeys().
|
protected |
Definition at line 147 of file CASymCipherOFB.hpp.
Referenced by CASymCipherOFB(), crypt1(), crypt2(), setIVs(), setKey(), setKeys(), and ~CASymCipherOFB().
|
protected |
Definition at line 148 of file CASymCipherOFB.hpp.
Referenced by CASymCipherOFB(), crypt2(), setIV2(), setIVs(), setKey(), setKeys(), and ~CASymCipherOFB().
|
protected |
Definition at line 143 of file CASymCipherOFB.hpp.
Referenced by CASymCipherOFB(), crypt1(), setKey(), setKeys(), and ~CASymCipherOFB().
|
protected |
Definition at line 144 of file CASymCipherOFB.hpp.
Referenced by CASymCipherOFB(), crypt2(), setKey(), setKeys(), and ~CASymCipherOFB().
|
private |
Definition at line 133 of file CASymCipherOFB.hpp.
Referenced by CASymCipherOFB(), and ~CASymCipherOFB().
|
private |
Definition at line 132 of file CASymCipherOFB.hpp.
Referenced by CASymCipherOFB(), and ~CASymCipherOFB().
|
private |
Definition at line 135 of file CASymCipherOFB.hpp.
|
private |
Definition at line 134 of file CASymCipherOFB.hpp.