Provides methods to prepare data to be sent crypted over networks channels and to decrypt received data. ATTENTION - This class algorithms are not standardized!!! This class is designed especially for use with SP2P API as easy to use utility. It uses specific methods to guaranty cryped data transmission without delays. Padding is not optional, this class handles padding in a way so excess data transmission is avoided as much as it can be. Use of this class for stream communication (TCP). For UDP datagrams crypting simply use AES class
More...
#include <AESNetworkStream.h>
|
| AESNetworkStream (AES::KeySize AESKeySize, unsigned char *AESKeyBytes, AES::Mode AESChiperMode=AES::AESM_CBC, unsigned char *CBCInitialVector=0) |
| Initializes AESNetworkStream object
|
|
unsigned char * | CBCInitialVector () |
| Gets the AES CBC initial vector used for first crypted chunks when AES in CBC mode
|
|
int | WriteForCrypt (unsigned char *buff, int offset, int length) |
| Writes unencrypted data to crypt buffer to be extracted crypted using ReadCrypted method
|
|
int | ReadCrypted (unsigned char *buff, int offset, int desired_length) |
| Reads reads data from crypt buffer, crypts it and stores it in buffer
|
|
int | WriteForDeCrypt (unsigned char *buff, int offset, int length) |
| Writes encrypted data to de-crypt buffer to be extracted decrypted using ReadDeCrypted method
|
|
int | ReadDeCrypted (unsigned char *buff, int offset, int desired_length) |
| Reads reads data from de-crypt buffer, decrypts it and stores it in buffer
|
|
int | AvailableCrypted () |
| Gets total available size of crypted data to take
|
|
int | AvailableDeCrypted () |
| Gets total available size of decrypted data to take
|
|
void | ClearCrypted () |
| Clears all available crypted data that could be read form stream
|
|
void | ClearDeCrypted () |
| Clears all available decrypted data that could be read form stream
|
|
void | ClearAuxBuffers () |
| Clears all free buffer slots which result is heap memory deallocation, this operation can not cause data loss
|
|
void | Clear () |
| Clears both crypt, de-crypt buffer and free slot buffer, all presend data will be thrown away. You can use AESNetworkStream normaly after that. AESNetworkStream will ocupate heap memory so it can hold all crypted / decrypted data. Total occupied data will be equal to maximal length of crypted and decurypted data in some moment hold in inner data structures AESNetworkStream does not free this memory until you delete whole AESNetworkStream object or call Clear. So you can call Clear after intense use when you know you will not use it for some time (If you use AESNetworkStream so data is hold for some period of time and if memory consumption is important factor)
|
|
| ~AESNetworkStream () |
| Destructor
|
|
Provides methods to prepare data to be sent crypted over networks channels and to decrypt received data. ATTENTION - This class algorithms are not standardized!!! This class is designed especially for use with SP2P API as easy to use utility. It uses specific methods to guaranty cryped data transmission without delays. Padding is not optional, this class handles padding in a way so excess data transmission is avoided as much as it can be. Use of this class for stream communication (TCP). For UDP datagrams crypting simply use AES class
sp2plib::AESNetworkStream::AESNetworkStream |
( |
AES::KeySize |
AESKeySize, |
|
|
unsigned char * |
AESKeyBytes, |
|
|
AES::Mode |
AESChiperMode = AES::AESM_CBC , |
|
|
unsigned char * |
CBCInitialVector = 0 |
|
) |
| |
Initializes AESNetworkStream object
- Parameters
-
AESKeySize | Size of AES key |
AESKeyBytes | AES key bytes |
AESChiperMode | Specifies AES chiper mode. Note that padding is hanled by AESNetworkStream is special way, you dont need to worry about large data in CBC mode. CBC mode is recomended! |
CBCInitialVector | If CBC mode is used this argumenet specifies initial CBC vector used for first chunk XOR pair. If not or null provided and AES in CBC mode random sequence will be generated |
sp2plib::AESNetworkStream::~AESNetworkStream |
( |
| ) |
|
int sp2plib::AESNetworkStream::AvailableCrypted |
( |
| ) |
|
Gets total available size of crypted data to take
int sp2plib::AESNetworkStream::AvailableDeCrypted |
( |
| ) |
|
Gets total available size of decrypted data to take
unsigned char* sp2plib::AESNetworkStream::CBCInitialVector |
( |
| ) |
|
Gets the AES CBC initial vector used for first crypted chunks when AES in CBC mode
void sp2plib::AESNetworkStream::Clear |
( |
| ) |
|
Clears both crypt, de-crypt buffer and free slot buffer, all presend data will be thrown away. You can use AESNetworkStream normaly after that. AESNetworkStream will ocupate heap memory so it can hold all crypted / decrypted data. Total occupied data will be equal to maximal length of crypted and decurypted data in some moment hold in inner data structures AESNetworkStream does not free this memory until you delete whole AESNetworkStream object or call Clear. So you can call Clear after intense use when you know you will not use it for some time (If you use AESNetworkStream so data is hold for some period of time and if memory consumption is important factor)
void sp2plib::AESNetworkStream::ClearAuxBuffers |
( |
| ) |
|
Clears all free buffer slots which result is heap memory deallocation, this operation can not cause data loss
void sp2plib::AESNetworkStream::ClearCrypted |
( |
| ) |
|
Clears all available crypted data that could be read form stream
void sp2plib::AESNetworkStream::ClearDeCrypted |
( |
| ) |
|
Clears all available decrypted data that could be read form stream
int sp2plib::AESNetworkStream::ReadCrypted |
( |
unsigned char * |
buff, |
|
|
int |
offset, |
|
|
int |
desired_length |
|
) |
| |
Reads reads data from crypt buffer, crypts it and stores it in buffer
- Parameters
-
buff | Buffer to store crypted data to. Make sure buffer is at least 257 bytes |
offset | Starting index in buff to start storing data from |
desired_length | Deisred size of crypted data to take |
- Returns
- Number of crypted data bytes stored in buffer
int sp2plib::AESNetworkStream::ReadDeCrypted |
( |
unsigned char * |
buff, |
|
|
int |
offset, |
|
|
int |
desired_length |
|
) |
| |
Reads reads data from de-crypt buffer, decrypts it and stores it in buffer
- Parameters
-
buff | Buffer to store decrypted data to |
offset | Starting index in buff to start storing data from |
desired_length | Deisred size of decrypted data to take |
- Returns
- Number of decrypted data bytes stored in buffer
int sp2plib::AESNetworkStream::WriteForCrypt |
( |
unsigned char * |
buff, |
|
|
int |
offset, |
|
|
int |
length |
|
) |
| |
Writes unencrypted data to crypt buffer to be extracted crypted using ReadCrypted method
- Parameters
-
buff | Buffer containing data bytes |
offset | Starting index in buff to start reading from |
length | Total size of data to be read |
- Returns
- Number of bytes written to crypt buffer
int sp2plib::AESNetworkStream::WriteForDeCrypt |
( |
unsigned char * |
buff, |
|
|
int |
offset, |
|
|
int |
length |
|
) |
| |
Writes encrypted data to de-crypt buffer to be extracted decrypted using ReadDeCrypted method
- Parameters
-
buff | Buffer containing crypted data bytes. |
offset | Starting index in buff to start reading from. |
length | Total size of crypted data to be read. |
- Returns
- Number of bytes written to de-crypt buffer
The documentation for this class was generated from the following file: