Main Page | Data Structures | File List | Data Fields | Globals

sec-game.c File Reference


Detailed Description

This is the security library that interfaces to the smart card.

This module makes avaliable as access functions the interface to the smart-card. This moudle useds the commands defined to the security.bas program once programmed into a smart-card to reterive session keys and authenticate the fpga with the smart-card. The functions defined in this module are used by the game and the admin code to interface to the smart card.

Author:
Rod Boyce
Date:
06/12/04

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zccri.h>
#include <zcbci.h>
#include "key-game.h"
#include "sec-game.h"

Include dependency graph for sec-game.c:

Include dependency graph

Defines

#define _GNU_SOURCE

Functions

int sec_OpenSmartCard (tsSMARTCARD_INFO *psSmartCard, BYTE bKeyId, BYTE *abKey, int zlKeySize)
 Open the smart card and enable security.

int sec_CloseSmartCard (tsSMARTCARD_INFO *psSmartCard)
 Close the smart card comms channel.

char * sec_GetZcbriErorStr (ZCBCIRET tRv)
 Return the error code from a ZCBRI fn in string form.

char * sec_GetZccriErorStr (ZCCRIRET tRv)
 Convert an error code form a ZCCRI function to string form.

int sec_SetSessionId (tsSMARTCARD_INFO *psSmartCard, unsigned long CurSessionId)
 Use by the application to set a session ID for communicating with the smart card.

int sec_AuthFpga (tsSMARTCARD_INFO *psSmartCard, unsigned char *pabData, int zLen)
 Send a packet of data ot the FPGA and return the response,.

int sec_GetDesSessionKey (tsSMARTCARD_INFO *psSmartCard, LONG lIdx, BYTE *pabDesKeyBuf)
 get a DES session key from the smart card


Variables

unsigned char abKeyGame [8] = { 0xae, 0x98, 0xd9, 0x55, 0xd9, 0x1b, 0x8e, 0x50 }

Define Documentation

#define _GNU_SOURCE
 


Function Documentation

sec_AuthFpga tsSMARTCARD_INFO psSmartCard,
unsigned char *  pabData,
int  zLen
 

Send a packet of data ot the FPGA and return the response,.

Given a block of data send that to the FPGA and send the reply back to the calling applicaiton. The basic declaration for this command is: Command &H80 &H02 AuthFPGA( SessionId As Long, FpgaData As String*8 )

Date:
02/11/04
Author:
Rod Boyce
Parameters:
psSmartCard - pointer to the smart card structure
pabData - pointer to the block of data to send to the smart card.
zLen - the nu,ber to bytes to send
Returns:
0 on success anything else on failure

History

Here is the call graph for this function:

sec_CloseSmartCard tsSMARTCARD_INFO psSmartCard  ) 
 

Close the smart card comms channel.

Given the reader and the card infomation close the channel to that smart card.

Date:
02/12/04
Author:
Rod Boyce
Parameters:
psSmartCard - pointer to the smart card structure
Returns:
0 on success and anything els eon failure

History

Here is the call graph for this function:

sec_GetDesSessionKey tsSMARTCARD_INFO psSmartCard,
LONG  lIdx,
BYTE *  pabDesKeyBuf
 

get a DES session key from the smart card

This command is called from the game to obtain DES session keys to decrypt encrypted game data. There is not restriction on the number of different keys except the size of the storage space in the smart card. The basic declaration is: Command &H80 &H06 GetSessionKey( SessionId As Long, Indx As Byte, SessionKey As Des3Key )

Date:
03/12/04
Author:
Rod Boyce
Parameters:
psSmartCard - pointer to the smart card structure
lIdx - The index of the session key to get from the smart card
pabDesKeyBuf - a pointer to the buffer to store the 3DES key in this MUST be 24 bytes
Returns:
0 for success anything else on failure
Note:
The DESkey buffer pointer is not checked for size if MUST be big enough to store the return value from the smart card. A 3DES key is 24-bytes or 192-bits.

Basic arrays are 1 based but arrays in C are 0 based this code will do on checking on the array size the basic card will return and error code and require resetting if the requested value is out of range.

History

Here is the call graph for this function:

sec_GetZcbriErorStr ZCBCIRET  tRv  ) 
 

Return the error code from a ZCBRI fn in string form.

Date:
02/12/04
Author:
Rod Boyce
Parameters:
tRv - An error code
Returns:
pointer to a string form of the error code.

History

Error codes returned by the ZcBri library calls

sec_GetZccriErorStr ZCCRIRET  tRv  ) 
 

Convert an error code form a ZCCRI function to string form.

Date:
02/12/04
Author:
Rod Boyce
Parameters:
tRv - Error code
Returns:
pointer to a string of the error code

History

Error codes returned by the ZCCri library calls

sec_OpenSmartCard tsSMARTCARD_INFO psSmartCard,
BYTE  bKeyId,
BYTE *  abKey,
int  zlKeySize
 

Open the smart card and enable security.

Firstly connect to the Reader and then connect to the smart card. Once this is established enable security on the smart card channel.

Date:
01/12/04
Author:
Rod Boyce
Parameters:
psSmartCard - pointer to the smart card structure
bKeyId - The key number to set
abKey - Pointer to the encryption key to use
zlKeySize - The number of bytes in the encryption key
Returns:
0 on success and anything else on failure.

History

Here is the call graph for this function:

sec_SetSessionId tsSMARTCARD_INFO psSmartCard,
unsigned long  CurSessionId
 

Use by the application to set a session ID for communicating with the smart card.

This is called at the initiation of communications with the smart card it is passed to as an extra parameter to the smart card if this value changes then the smart card will reject any further communication requests The basic declaration for this command is: Command &H80 &H00 SetSessionId( SessionId As Long )

Date:
02/12/04
Author:
Rod Boyce
Parameters:
psSmartCard - pointer to the smart card structure
CurSessionId - a 32-bit value that makes up a session id from the application
Returns:
0 on success anything else indicates a failure

History

Here is the call graph for this function:


Variable Documentation

unsigned char abKeyGame[8] = { 0xae, 0x98, 0xd9, 0x55, 0xd9, 0x1b, 0x8e, 0x50 }
 

This key is the general key used by the game application for authentication and retrevial of encrypted session keys.


Generated on Thu Jan 20 16:17:30 2005 for Axis smart-card FPGA authentication scheme by doxygen 1.3.6