About Store Forum Documentation Contact



Post Reply 
TCP/IP encryption key ...
Author Message
alkirah Offline
Member

Post: #1
TCP/IP encryption key ...
from include\EsenthelEngine\Net\Connection.h

PHP Code:
/******************************************************************************/
struct Connection // reliable TCP based client/server connection with automatic data encryption and boundaries management, data always reaches the target, data is always received in the same order as it was sent, received data size will always be the same as when it was sent
{
   
File data// received data from the external connection, use it for reading incoming data

   // manage
   
void del                  (                     );
   
Bool serverAcceptClient   (Socket   &server     );
   
Bool clientConnectToServer(SockAddr &server_addr);

   
// get
   
CONNECT_STATE state   () {return _state             ;} // get connection state
   
C SockAddr&   address () {return _address           ;} // get destination address
   
Int   expectedDataSize() {return _expected_data_size;} // expected size of streamed data, -1=unknown
   
Int           received() {return  _in_offset        ;} // get total  amount of received data
   
Int           sent    () {return _out_offset        ;} // get total  amount of sent     data
   
Int           queued  () {return _out.size()        ;} // get queued amount of bytes currently awaiting to be sent
   
UInt          life    ();                              // how long the connection is alive (in milliseconds)

   
Bool receive(Int timeout); // wait up to 'timeout' milliseconds to receive data, false if no data is available

   // send commands
   
Bool bye               (                                   ); // send goodbye message, requesting connection termination
   
Bool dataFull          (CPtr  bufInt sizeBool send=true); //             'send'=if automatically send command instead of adding to the queue
   
Bool dataFull          (File &f  Int sizeBool send=true); //             'send'=if automatically send command instead of adding to the queue
   
Bool dataStreamStart   (Int   total_size=-1Bool send=true); // -1=unknown, 'send'=if automatically send command instead of adding to the queue
   
Bool dataStreamContinue(CPtr  bufInt sizeBool send=true); //             'send'=if automatically send command instead of adding to the queue
   
Bool dataStreamContinue(File &f  Int sizeBool send=true); //             'send'=if automatically send command instead of adding to the queue
   
Bool dataStreamFinished(                     Bool send=true); //             'send'=if automatically send command instead of adding to the queue
   
Bool dataStreamAbort   (                     Bool send=true); //             'send'=if automatically send command instead of adding to the queue

   
Bool send(); // send all queued commands

   // operations
   
Bool tcpNoDelay(Bool on) {return _socket.tcpNoDelay(on);} // set TCP_NODELAY option, false on fail

   
Connection() {_expected_data_size=-1_state=CONNECT_INVALID_packet_size_progress=_in_offset=_out_offset=_expected_packet_size=_birth=0;}
  ~
Connection() {del();}

private:
   
CONNECT_STATE _state;
   
Int           _packet_size_progress_in_offset_out_offset;
   
UInt          _expected_data_size_expected_packet_size_birth;
   
File          _in_out;
   
Socket        _socket;
   
SockAddr      _address;
   
Secure        _secure;
};
/******************************************************************************/ 

is there a way I can change the key used so every client will have their unique encryption key that will change every login?

can I add this to the Connection.h file?

PHP Code:
void changeKey(Secure newKey){_secure newKey;} 

then add in my auth function (after the server sent the key to the client) on both client and server

SERVER
PHP Code:
Secure newKey;
FREP(32)newKey.key[i]=rnd(0xff);
client(current).connection.changeKey(newKey); 

CLIENT
PHP Code:
Secure newKey;
FREP(32)newKey.key[i]=Server.data.getByte();
Server.changeKey(newKey); 
(This post was last modified: 09-08-2011 07:21 PM by alkirah.)
09-08-2011 07:20 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: TCP/IP encryption key ...
every Connection always uses unique encryption
09-09-2011 12:17 PM
Find all posts by this user Quote this message in a reply
Post Reply