Starting from version 4.0, Serial to Ethernet Connector's installation package contains 2 security plugins: encryption plugin and authorization plugin. 


Now with the help of crypt.dll and auth.dll you are able to develop your own methods of input and output data encryption and authorization. The examples of using these plugins are located in: 


{app}\Source\crypt 

{app}\Source\auth 


crypt.dll - encrypts all the communication data, it has the following methods: 

If you are going to create your own crypt.dll, note that it should contain all the methods mentioned above.


BeginConnection 


The BeginConnection method initializes encrypted connection with the remote end. This method starts immediately after connection with remote end is established and data is not transmitted before BeginConnection does not return TRUE or FALSE. 


int BeginConnection( 

SOCKET sock, WCHAR *szInitString, void **ppContext


Parameters 


■ sock - opened socket, which can be used for Handshake communication with the remote end 

■ szInitString - is not used 

■ ppContext - pointer to interface-specific context information. This is an opaque entity that the caller must pass to all functions 


Return Values

 

If the function succeeds, the return value is 0, otherwise - error and connection is broken.


CloseConnection

 

The CloseConnection method closes already created connection. This method is initialized after connection is broken, in order to clear all variables connected with the connection correctly. 


int CloseConnection( 

SOCKET sock, void *pContext 


Parameters 


■ sock - opened socket, which can be used for Handshake communication with the remote end 

■ ppContext - pointer to interface-specific context information. This is an opaque entity that the caller must pass to the all functions 


Return Values 


If the function succeeds, the return value is 0, otherwise - error and connection is broken.


PreSendData


The PreSendData method is used to encrypt data, which is going to be sent.

 

int PreSendData( 

void * pContext , char * pIn , int iInSize , char * pOut , int * piOutSize 


Parameters


■ ppContext - pointer to interface-specific context information. This is an opaque entity that the caller must pass to the all functions 

■ pIn - input buffer with not encrypted data 

■ iInSize - input buffer size 

■ pOut - output buffer with encrypted data. If it has a NULL value, then piOutSize returns required pOut buffer size value 

■ piOutSize - returns the required pOut value 


Return Values 


If the function succeeds, the return value is 0, otherwise - error and connection is broken.  


PostRecvData 


The PostRecvData method is used to decrypt data to be written to local port and this method is initialized every time, when data is received. 

int PreSendData(

void * pContext , char * pIn , int iInSize , char * pOut , int * piOutSize


Parameters 


■ pContext - context, which was returned by BeginConnection function 

■ pIn - input buffer with encrypted data 

■ iInSize - input buffer size 

■ pOut - output buffer with decrypted data. If it has a NULL value, then piOutSize - returns required buffer size 

■ piOutSize - returns the required pOut value 

Return Values


If the function succeeds, the return value is 0, otherwise - error.