Download user manual
Transcript
Client/Server Examples
305
return( status );
}
Client/Server Examples
The finals set of code samples work with secure client/server sessions.
fetchFromSecureServer fetches data from a secure server:
int fetchFromSecureServer( const char *serverName,
const char *command, void *outData,
const int outDataMaxLength,
int *outDataLength )
{
CRYPT_SESSION cryptSession;
int bytesCopied, status;
/* Clear the return value */
*outDataLength = 0;
/* Create a client session */
status = createClientSession( &cryptSession, CRYPT_SESSION_SSL,
serverName );
if( cryptStatusError( status ) )
return( status );
/* Activate the session */
status = cryptSetAttribute( cryptSession, CRYPT_SESSINFO_ACTIVE,
1 );
if( cryptStatusError( status ) )
{
cryptDestroySession( cryptSession );
return( status );
}
/* Send a command to the remote system */
status = cryptPushData( cryptSession, command, strlen( command ),
&bytesCopied );
if( cryptStatusOK( status ) )
{
if( bytesCopied != ( int ) strlen( command ) )
status = -1; /* Not all data was processed */
else
status = cryptFlushData( cryptSession );
}
if( cryptStatusError( status ) )
{
cryptDestroySession( cryptSession );
return( status );
}
/* Read back the response */
status = cryptPopData( cryptSession, outData, outDataMaxLength,
outDataLength );
cryptDestroySession( cryptSession );
return( status );
}
runSecureServer runs a secure server:
int runSecureServer( const char *privKeysetName,
const char *privKeyLabel,
const char *privKeyPassword, void *outData,
const int outDataMaxLength, int *outDataLength )
{
CRYPT_SESSION cryptSession;
int status;
/* Clear the return value */
*outDataLength = 0;
/* Create a server session and add the server's key to it */
status = createServerSession( &cryptSession,
CRYPT_SESSION_SSL_SERVER, privKeysetName, privKeyLabel,
privKeyPassword );
Related documents
the Cryptlib manual
Security Toolkit
Security Toolkit
Introduction cryptlib Overview
ACS SASSI ACS SASSI-ANSYS* Integration - ghiocel
The TIES final report
Administrator`s Manual Software Architecture
Messages and Codes - ServiceNet - T
Crypta File Security Programme User`s manual
manual de instalação e inicialização do token safenet 5100
Tutorial 1