Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

auth.c File Reference

Authentication functions. More...

#include <config.h>
#include <auth.h>
#include <crypt.h>
#include <fs.h>
#include <fstream.h>
#include <hal.h>
#include <string.h>
#include <sw.h>
#include <tea.h>
#include <tools.h>
#include <transaction.h>
#include <types.h>

Functions

bool auth_init (void)
 Initialize authentication variables. More...

bool auth_checkAc (iu8 ac)
 Check fullfillment of access condition. More...

bool auth_getCheckPinLen (iu8 pintype, iu8 pinlen, iu16 *addr, iu8 *len, iu16 *rcaddr, iu8 *maxret)
 Verifies length of PIN and returns addresses of PIN in EEPROM. More...

bool auth_setPin (iu8 pintype, iu8 *pin, iu8 pinlen)
 Write PIN, PUK, External Authentication key or Internal Authentication key. More...

bool auth_verifyPin (iu8 pintype, iu8 *pin, iu8 pinlen)
 Verifies PIN, PUK or External Authentication key and sets flags in authstate. More...

bool auth_getChallenge (iu8 *dst, iu8 rndlen)
 Returns 8 byte challenge for External Authentication. More...

bool auth_createVerifyCryptogram (iu8 *cry, iu8 crylen, bool create, bool enc)
 Encrypt or decrypt challenge or verify cryptogram. More...


Variables

iu8 challenge [CRYPT_BLOCK_LEN]
 Value of the last with Get Challenge fetched random challenge. More...

iu8 challvalidity
iu8 authstate
 Variable indicating current authentication state. More...


Detailed Description

Authentication functions.

Id:
auth.c,v 1.21 2003/03/30 19:43:15 m Exp


Function Documentation

bool auth_checkAc iu8    ac
 

Check fullfillment of access condition.

This function checks, if the current setting of authstate fullfills the condition specified with ac.

Parameters:
ac  A nibble specifying an access condition.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool auth_createVerifyCryptogram iu8   cry,
iu8    crylen,
bool    create,
bool    enc
 

Encrypt or decrypt challenge or verify cryptogram.

To include the decryption process CONF_WITH_DECRYPT must be set to 1.

Parameters:
cry  Pointer to byte array, which supplies challenge and which is used to return the encrypted or decrypted challenge or a cryptogram.
crylen  Length of challenge or cryptogram.
create  If set to TRUE, a challenge is processed, else a cryptogram is verified.
enc  If CONF_WITH_DECRYPT is not set to 1, this has no effect. Otherwise, if TRUE encrypt the challenge, else decrypt it. If create is FALSE, this parameter is ignored.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool auth_getChallenge iu8   dst,
iu8    rndlen
 

Returns 8 byte challenge for External Authentication.

The challenge is also written to the challenge array and challvalidity is set to 2.

Parameters:
dst  Destination byte array.
rndlen  Length of requested data. This must be 8.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool auth_getCheckPinLen iu8    pintype,
iu8    pinlen,
iu16   addr,
iu8   len,
iu16   rcaddr,
iu8   maxret
 

Verifies length of PIN and returns addresses of PIN in EEPROM.

This functions does depending on pintype:

  • Check the length of the PIN or key.
  • Return the address of the PIN or key in EEPROM.
  • Return the length of the PIN or key in EEPROM.
  • Return the address of the retry counter in EEPROM.
  • Return the default max. value for the retry counter.
Parameters:
pintype  PIN type. One of the PIN_TYPE defines.
pinlen  Length of supplied PIN or key.
addr  Returns the address of the PIN or key in EEPROM.
len  Returns the length ofthe PIN or key in EEPROM.
rcaddr  Returns the address of the retry counter for the PIN or key.
maxret  Returns the default max. value for the retry counter.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool auth_init void   
 

Initialize authentication variables.

This function resets authstate and challvalidity. It must be called after reset.

Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool auth_setPin iu8    pintype,
iu8   pin,
iu8    pinlen
 

Write PIN, PUK, External Authentication key or Internal Authentication key.

The process is secured by transactions.

Parameters:
pintype  Type of the PIN/Key. May be one of the PIN_TYPE_* defines.
pin  Pointer to byte array containing PIN/Key.
pinlen  Length of PIN/Key.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool auth_verifyPin iu8    pintype,
iu8   pin,
iu8    pinlen
 

Verifies PIN, PUK or External Authentication key and sets flags in authstate.

The update of the retry counter is secured by transactions.

Warning: Currently the retry counter is not handled in a secure way. For more information see e.g. Rankl/Effing.

Parameters:
pintype  Type of the PIN/Key. May be one of the PIN_TYPE_* defines.
pin  Pointer to byte array containing PIN/Key.
pinlen  Length of PIN/Key.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.


Variable Documentation

iu8 authstate
 

Variable indicating current authentication state.

Single bit flags indicate, which authorization process has been successful. The flag is cleared, at the reset of the card and after unsuccessful authorization processes.

Valid flags are:

  • AUTH_FLAG_PIN
  • AUTH_FLAG_KEY

iu8 challenge[CRYPT_BLOCK_LEN]
 

Value of the last with Get Challenge fetched random challenge.

iu8 challvalidity
 


Copyright 2002 by Matthias Bruestle. This is licensed under the GNU General Public License.