Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cSecureChannel Class Reference

#include <cSecureChannel.h>

Inheritance diagram for GrayLib::cSecureChannel:
GrayLib::cSecureClient GrayLib::cSecureServerStream

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
 
cStreamInputget_SecureInp () const
 
cStreamOutputget_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< cCipherBasem_pCipherEnc
 the selected encryption of the channel. More...
 
cNewPtr< cStreamCipherEncm_pCipherOut
 m_pCipher as a encrypt/output stream. pads to get_BlockAlignSize(). m_pCipherEnc More...
 
cNewPtr< cCipherBasem_pCipherDec
 the selected decryption of the channel. More...
 
cNewPtr< cStreamCipherDecm_pCipherInp
 m_pCipher as a decrypt/input stream. m_pCipherDec More...
 

Detailed Description

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

Note
Secure (encrypted) channels may be allowed to unknown (Non authenticated) parties using RSA. (no password). How do we do KeyEx?

Member Enumeration Documentation

◆ STATE_TYPE

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 )

Constructor & Destructor Documentation

◆ cSecureChannel()

GrayLib::cSecureChannel::cSecureChannel ( )

◆ ~cSecureChannel()

GrayLib::cSecureChannel::~cSecureChannel ( )
virtual

Member Function Documentation

◆ ComputeHash()

void GRAYCALL GrayLib::cSecureChannel::ComputeHash ( OUT cSecureHash rHash,
const cHashCode r1,
const cHashCode r2 
)
static
  1. compute challenge response from challenge data + password hash.
  2. compute my crypt key from password + challenge.

◆ get_SecureInp()

cStreamInput * GrayLib::cSecureChannel::get_SecureInp ( ) const

Once the cSecureChannel connection is set up we can use this to receive.

◆ get_SecureOut()

cStreamOutput * GrayLib::cSecureChannel::get_SecureOut ( ) const

Once the cSecureChannel connection is set up we can use this to send.

◆ get_State()

STATE_TYPE GrayLib::cSecureChannel::get_State ( ) const
inlinenoexcept

◆ GetCipher()

HRESULT GrayLib::cSecureChannel::GetCipher ( OUT cNewPtr< cCipherBase > &  rCipher,
bool  bEncodeMode,
const cSecureHash hashKey 
)
protected

◆ isStateSecure()

bool GrayLib::cSecureChannel::isStateSecure ( ) const
inlinenoexcept

Is the channel set up (secure) and ready to go?

◆ SetStateSecure()

HRESULT GrayLib::cSecureChannel::SetStateSecure ( )
protectedvirtual

Init my crypto params.

Reimplemented in GrayLib::cSecureServerStream.

◆ UNITTEST_FRIEND()

GrayLib::cSecureChannel::UNITTEST_FRIEND ( cSecureChannel  )

Member Data Documentation

◆ m_Challenge

cHashCode GrayLib::cSecureChannel::m_Challenge

the random data used to form the challenge. part of crypto key for data stream.

◆ m_eCipherType

cSecureKnock::CIPHER_TYPE GrayLib::cSecureChannel::m_eCipherType
protected

the selected crypto type. <0=Failed login, 0=no crypt by choice, 1=cCipherRC4, 2=cCipherBlowfish

◆ m_eState

STATE_TYPE GrayLib::cSecureChannel::m_eState
protected

current state of the negotiation of the connection.

◆ m_HashPass

cHashCode GrayLib::cSecureChannel::m_HashPass

The working PASSCODE for login.

◆ m_Id

cSecureId GrayLib::cSecureChannel::m_Id

My USERNAME and APPNAME.

◆ m_pCipherDec

cNewPtr<cCipherBase> GrayLib::cSecureChannel::m_pCipherDec
protected

the selected decryption of the channel.

◆ m_pCipherEnc

cNewPtr<cCipherBase> GrayLib::cSecureChannel::m_pCipherEnc
protected

the selected encryption of the channel.

◆ m_pCipherInp

cNewPtr<cStreamCipherDec> GrayLib::cSecureChannel::m_pCipherInp
protected

m_pCipher as a decrypt/input stream. m_pCipherDec

◆ m_pCipherOut

cNewPtr<cStreamCipherEnc> GrayLib::cSecureChannel::m_pCipherOut
protected

m_pCipher as a encrypt/output stream. pads to get_BlockAlignSize(). m_pCipherEnc


The documentation for this class was generated from the following files: