![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cSecureChannel.h>
Public Types | |
| enum | STATE_TYPE { STATE_0 = 0 , Client_Knock , Server_Challenge , Client_Login , STATE_Secure , STATE_Failed } |
Public Member Functions | |
| cSecureChannel () | |
| virtual | ~cSecureChannel () |
| STATE_TYPE | get_State () const noexcept |
| bool | isStateSecure () const noexcept |
| cStreamInput * | get_SecureInp () const |
| cStreamOutput * | get_SecureOut () const |
| UNITTEST_FRIEND (cSecureChannel) | |
Static Public Member Functions | |
| static void GRAYCALL | ComputeHash (OUT cSecureHash &rHash, const cHashCode &r1, const cHashCode &r2) |
Public Attributes | |
| cHashCode | m_Challenge |
| the random data used to form the challenge. part of crypto key for data stream. More... | |
| cHashCode | m_HashPass |
| The working PASSCODE for login. More... | |
| cSecureId | m_Id |
| My USERNAME and APPNAME. More... | |
Protected Member Functions | |
| virtual HRESULT | SetStateSecure () |
| HRESULT | GetCipher (OUT cNewPtr< cCipherBase > &rCipher, bool bEncodeMode, const cSecureHash &hashKey) |
Protected Attributes | |
| STATE_TYPE | m_eState |
| current state of the negotiation of the connection. More... | |
| cSecureKnock::CIPHER_TYPE | m_eCipherType |
| the selected crypto type. <0=Failed login, 0=no crypt by choice, 1=cCipherRC4, 2=cCipherBlowfish More... | |
| cNewPtr< cCipherBase > | m_pCipherEnc |
| the selected encryption of the channel. More... | |
| cNewPtr< cStreamCipherEnc > | m_pCipherOut |
| m_pCipher as a encrypt/output stream. pads to get_BlockAlignSize(). m_pCipherEnc More... | |
| cNewPtr< cCipherBase > | m_pCipherDec |
| the selected decryption of the channel. More... | |
| cNewPtr< cStreamCipherDec > | m_pCipherInp |
| m_pCipher as a decrypt/input stream. m_pCipherDec More... | |
Build a secure TCP connection. similar to Transport Layer Security (TLS) and its predecessor, Secure Sockets Layer (SSL) Similar to CRAM-MD5 for SMTP-AUTH http://en.wikipedia.org/wiki/CRAM-MD5 Assumes its on a TCP (stream) connection so packets are never lost or out of order. common base for client and server sides
The connection goes through N states in the process of setting up.
| Enumerator | |
|---|---|
| STATE_0 | Connection is created but the Knock has not been sent or received. |
| Client_Knock | Client starts by sending cSecureKnock. protocol id,version,cipher ability. time? server host? |
| Server_Challenge | Server sends response as protocol id,version,preferred CIPHER_TYPE, length prefix, random numbers to use as a challenge. length prefix is usually 64 bytes = 512 bits. |
| Client_Login | Client sends a set of random numbers, user, purpose, cSecureHash( cHashCode password + Challenge/salt + Login/salt ) to login user. allows multiple possible legal passwords. |
| STATE_Secure | Server sends Error or Success code + selected CIPHER_TYPE. else if other error the connection is dropped. After this the conversation is fully encrypted. The channel is secure/ready for any traffic by duping the usage of the cHashCode password. |
| STATE_Failed | Channel is junk. Server sends CIPHER_TYPE using key cSecureHash( Challenge/salt + cHashCode password X 2 ) Client sends CIPHER_TYPE using key cSecureHash( Challenge/salt + cHashCode password X 2 ) |
| GrayLib::cSecureChannel::cSecureChannel | ( | ) |
|
virtual |
|
static |
| cStreamInput * GrayLib::cSecureChannel::get_SecureInp | ( | ) | const |
Once the cSecureChannel connection is set up we can use this to receive.
| cStreamOutput * GrayLib::cSecureChannel::get_SecureOut | ( | ) | const |
Once the cSecureChannel connection is set up we can use this to send.
|
inlinenoexcept |
|
protected |
|
inlinenoexcept |
Is the channel set up (secure) and ready to go?
|
protectedvirtual |
Init my crypto params.
Reimplemented in GrayLib::cSecureServerStream.
| GrayLib::cSecureChannel::UNITTEST_FRIEND | ( | cSecureChannel | ) |
| cHashCode GrayLib::cSecureChannel::m_Challenge |
the random data used to form the challenge. part of crypto key for data stream.
|
protected |
the selected crypto type. <0=Failed login, 0=no crypt by choice, 1=cCipherRC4, 2=cCipherBlowfish
|
protected |
current state of the negotiation of the connection.
| cHashCode GrayLib::cSecureChannel::m_HashPass |
The working PASSCODE for login.
| cSecureId GrayLib::cSecureChannel::m_Id |
My USERNAME and APPNAME.
|
protected |
the selected decryption of the channel.
|
protected |
the selected encryption of the channel.
|
protected |
m_pCipher as a decrypt/input stream. m_pCipherDec
|
protected |
m_pCipher as a encrypt/output stream. pads to get_BlockAlignSize(). m_pCipherEnc