Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY

 

CalculateAccessCode (FUN)

Description

This function calculates response code from challenge code, Epec specific encryption keys, and project specific encrypting key value.

 

This function is intended to be used in device that configures safety unit. E.g. a display unit.

 

This function is endianness-aware.

Separate endian format conversions shall NOT be used.

 

Operation

The function calculates checksum of i_ProjectKey (STRING) with seed value 245Fh and polynomial 63D9h (prime numbers). The sum is used as seed for checksum calculation of i_ChallengeCode (WORD). The same polynomial is used in both phases.

 

Inputs

Input variable name

Data type

Range

Description

i_ChallengeCode

WORD

-

Challenge code to be compared

i_ProjectKey

STRING(80)

-

Data for code encryption

Outputs

Output variable name

Data type

Range

Description

o_OutputValid

BOOL

TRUE/FALSE

Calculated value is valid.

o_ParameterError

BOOL

TRUE/FALSE

Error in input parameters.

Return value

Data type

Description

WORD

Calculated response code.

Error diagnostic

Conditions

Return value

o_OutputValid

o_ParameterError

i_ProjectKey length = 0

0

FALSE

TRUE

i_ProjectKey length > 0

Calculated result

TRUE

FALSE

 

Example code

Definitions:

 

ChallengeCode : WORD := WORD#0;

ResponseCode : WORD := WORD#0;

 

AccessCodeCalculationParError:BOOL;

AccessCodeCalculationValid:BOOL;

 

 

Init:

 

 

No init.

 

 

Code:

 

 

ResponseCode := EPEC_SDV.CalculateAccessCode(

    i_ChallengeCode := ChallengeCode,

    i_ProjectKey := 'MyProjectKey',

    o_ParameterError => AccessCodeCalculationParError,

    o_OutputValid => AccessCodeCalculationValid

);

 

 

See also

 

 

Source file topic100399.htm

Last updated 13-Jun-2024