NXP NFC Reader Library  v4.040.05.011646
Component : Software

Software implementation of the Symmetric Cryptography interface. More...

Collaboration diagram for Component : Software:

Data Structures

struct  phCryptoSym_Sw_DataParams_t
 Software parameter structure. More...
 

Macros

#define PH_CRYPTOSYM_SW_ID   0x01
 ID for Software crypto component. More...
 
#define PH_CRYTOSYM_SW_FAST_RAM
 Enables 8051 data storage specifier. More...
 
#define PH_CRYPTOSYM_SW_CONST_ROM
 ROM specifier - not set per default.
 
#define PH_CRYPTOSYM_SW_MAX_BLOCK_SIZE   PH_CRYPTOSYM_AES_BLOCK_SIZE
 Maximum Block Size of the currently supported ciphers.
 

Functions

phStatus_t phCryptoSym_Sw_Init (phCryptoSym_Sw_DataParams_t *pDataParams, uint16_t wSizeOfDataParams, void *pKeyStoreDataParams)
 Initialise the CryptoSym component. More...
 

Compile Switches.

Compile switches used to find the optimum trade-off between performance, memory footprint and supported features.

#define PH_CRYPTOSYM_SW_DES
 Enables DES support. More...
 
#define PH_CRYPTOSYM_SW_AES
 Enables AES support. More...
 
#define PH_CRYPTOSYM_SW_ONLINE_KEYSCHEDULING
 Enables online key scheduling. More...
 
#define PH_CRYPTOSYM_SW_ONLINE_CMAC_SUBKEY_CALCULATION
 Enables online CMAC subkey calculation. More...
 
#define PH_CRYPTOSYM_SW_ROM_OPTIMIZATION
 Enables ROM optimizations in the AES algorithm. More...
 

Detailed Description

Software implementation of the Symmetric Cryptography interface.

This implementation was designed to optimize the footprint of crypto libraries used in embedded systems. The following standards are implemented:

Hints for compiling the library:

Architecture of the phCryptoSym_Sw Component:

Macro Definition Documentation

§ PH_CRYPTOSYM_SW_ID

#define PH_CRYPTOSYM_SW_ID   0x01

ID for Software crypto component.

§ PH_CRYPTOSYM_SW_DES

#define PH_CRYPTOSYM_SW_DES

Enables DES support.

Defines that the DES algorithm is supported. The defines for general DES capabilities like block sizes etc. are not affected as they do not add to the memory footprint.

§ PH_CRYPTOSYM_SW_AES

#define PH_CRYPTOSYM_SW_AES

Enables AES support.

Defines that the AES algorithm is supported. The defines for general AES capabilities like block sizes etc. are not affected as they do not add to the memory footprint.

§ PH_CRYPTOSYM_SW_ONLINE_KEYSCHEDULING

#define PH_CRYPTOSYM_SW_ONLINE_KEYSCHEDULING

Enables online key scheduling.

This define enables for both AES and DES the online key scheduling. This means, that the round keys are not pre-calculated at key loading, but they are always calculated when a new block is going to be encrypted or decrypted.

The following advantages come out of enabling online key scheduling:

  • The pKey entry of the private data param structure decreases significantly from 384(DES enabled)/256(DES disabled) to 32 bytes.
  • As the private data structure has to be created for each instance, the above mentioned savings count for each instance.
  • Key loading is very fast (as there is almost nothing performed any more.
  • On 8051 the keys can be located in fast RAM which counters some of the performance decrease compared to disabling that feature.

The following disadvantages come out of enabling online key scheduling:

  • Encryption gets slower as in addition to the ciphering also the round key generation has to be performed.
  • For decryption in AES the situation is even worse, as the key scheduling is executed twice for each decryption.
  • On small platforms like 8051 big key buffers can never reside in fast RAM as they exceed the memory size of data and idata.

On 8051 platforms in combination with the PH_CRYPTOSYM_SW_USE_8051_DATA_STORAGE enabling online key scheduling even gives better results on execution time if only 1 or 2 blocks are encryted with a given key. In case of keys are used longer (which is most likely the standard case), it is faster to disable that feature. Also note, that e.g. for a MIFARE Plus (R) instance of the library, two crypto instances are required, and as a consequence online key scheduling can save 704(DES enabled)/(DES disabled)448 bytes of RAM.

§ PH_CRYPTOSYM_SW_ONLINE_CMAC_SUBKEY_CALCULATION

#define PH_CRYPTOSYM_SW_ONLINE_CMAC_SUBKEY_CALCULATION

Enables online CMAC subkey calculation.

This define enables for both AES and DES the online CMAC subkey calculation. This means, that the CMAC subkeys are not stored in the context of the individual instance of the crypto lib, but they are newly calculated for each MAC.

The following advantages come out of enabling online CMAC subkey calculation:

  • 32 bytes of RAM can be saved in the private data params (so they are saved on each instance of the crypto library).

The following disadvantages come out of online CMAC subkey calculation:

  • Each CMAC calculation needs 1 additional encryption and 2 additional shift operations, so the execution speed decreases.

§ PH_CRYPTOSYM_SW_ROM_OPTIMIZATION

#define PH_CRYPTOSYM_SW_ROM_OPTIMIZATION

Enables ROM optimizations in the AES algorithm.

This define removes some of the lookup tables in the AES implementation to save ROM space.

The following advantages come out of enabling ROM optimizations:

  • 3 lookup tables of 256 bytes can be saved (some additional code is needed, so in fact only ~600 bytes are saved).

The following disadvantages come out of enabling ROM optimizations:

  • The MixColumn and MixColumnInv implementation of the AES are getting slower.

§ PH_CRYTOSYM_SW_FAST_RAM

#define PH_CRYTOSYM_SW_FAST_RAM

Enables 8051 data storage specifier.

This define allows to specify any value for PH_CRYTOSYM_SW_FAST_RAM. It takes care, that the buffers are recopied correctly, and that most of the time consuming calculations are done on this fast mempory. In case of PH_CRYPTOSYM_SW_ONLINE_KEYSCHEDULING is set, even the key scheduling can be performed on this fast memory.Fast RAM specifier - not set per default

Function Documentation

§ phCryptoSym_Sw_Init()

phStatus_t phCryptoSym_Sw_Init ( phCryptoSym_Sw_DataParams_t pDataParams,
uint16_t  wSizeOfDataParams,
void *  pKeyStoreDataParams 
)

Initialise the CryptoSym component.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]wSizeOfDataParamsSpecifies the size of the data parameter structure.
[in]pKeyStoreDataParamsPointer to a key store structure (can be null).