STM32L443xx HAL User Manual
Functions
Initialization and deinitialization functions
CRYP Exported Functions

Initialization and Configuration functions. More...

Functions

HAL_StatusTypeDef HAL_CRYP_Init (CRYP_HandleTypeDef *hcryp)
 Initialize the CRYP according to the specified parameters in the CRYP_InitTypeDef and initialize the associated handle.
HAL_StatusTypeDef HAL_CRYP_DeInit (CRYP_HandleTypeDef *hcryp)
 DeInitialize the CRYP peripheral.
__weak void HAL_CRYP_MspInit (CRYP_HandleTypeDef *hcryp)
 Initialize the CRYP MSP.
__weak void HAL_CRYP_MspDeInit (CRYP_HandleTypeDef *hcryp)
 DeInitialize CRYP MSP.

Detailed Description

Initialization and Configuration functions.

  ==============================================================================
              ##### Initialization and deinitialization functions #####
  ==============================================================================
    [..]  This section provides functions allowing to:
      (+) Initialize the CRYP according to the specified parameters
          in the CRYP_InitTypeDef and creates the associated handle
      (+) DeInitialize the CRYP peripheral
      (+) Initialize the CRYP MSP (MCU Specific Package)
      (+) De-Initialize the CRYP MSP

    [..]
    (@) Specific care must be taken to format the key and the Initialization Vector IV!

   [..] If the key is defined as a 128-bit long array key[127..0] = {b127 ... b0} where
        b127 is the MSB and b0 the LSB, the key must be stored in MCU memory
        (+) as a sequence of words where the MSB word comes first (occupies the
          lowest memory address)
        (+) where each word is byte-swapped:
         (++)   address n+0 : 0b b103 .. b96 b111 .. b104 b119 .. b112 b127 .. b120
         (++)   address n+4 : 0b b71 .. b64 b79 .. b72 b87 .. b80 b95 .. b88
         (++)   address n+8 : 0b b39 .. b32 b47 .. b40 b55 .. b48 b63 .. b56
         (++)   address n+C : 0b b7 .. b0 b15 .. b8 b23 .. b16 b31 .. b24
    [..] Hereafter, another illustration when considering a 128-bit long key made of 16 bytes {B15..B0}.
        The 4 32-bit words that make the key must be stored as follows in MCU memory:
         (+)    address n+0 : 0x B12 B13 B14 B15
         (+)    address n+4 : 0x B8 B9 B10 B11
         (+)    address n+8 : 0x B4 B5 B6 B7
         (+)    address n+C : 0x B0 B1 B2 B3
    [..]  which leads to the expected setting
      (+)       AES_KEYR3 = 0x B15 B14 B13 B12
      (+)       AES_KEYR2 = 0x B11 B10 B9 B8
      (+)       AES_KEYR1 = 0x B7 B6 B5 B4
      (+)       AES_KEYR0 = 0x B3 B2 B1 B0

   [..]  Same format must be applied for a 256-bit long key made of 32 bytes {B31..B0}.
         The 8 32-bit words that make the key must be stored as follows in MCU memory:
         (+)    address n+00 : 0x B28 B29 B30 B31
         (+)    address n+04 : 0x B24 B25 B26 B27
         (+)    address n+08 : 0x B20 B21 B22 B23
         (+)    address n+0C : 0x B16 B17 B18 B19
         (+)    address n+10 : 0x B12 B13 B14 B15
         (+)    address n+14 : 0x B8 B9 B10 B11
         (+)    address n+18 : 0x B4 B5 B6 B7
         (+)    address n+1C : 0x B0 B1 B2 B3
    [..]  which leads to the expected setting
      (+)       AES_KEYR7 = 0x B31 B30 B29 B28
      (+)       AES_KEYR6 = 0x B27 B26 B25 B24
      (+)       AES_KEYR5 = 0x B23 B22 B21 B20
      (+)       AES_KEYR4 = 0x B19 B18 B17 B16
      (+)       AES_KEYR3 = 0x B15 B14 B13 B12
      (+)       AES_KEYR2 = 0x B11 B10 B9 B8
      (+)       AES_KEYR1 = 0x B7 B6 B5 B4
      (+)       AES_KEYR0 = 0x B3 B2 B1 B0

   [..] Initialization Vector IV (4 32-bit words) format must follow the same as
        that of a 128-bit long key.

  [..]


Function Documentation

HAL_StatusTypeDef HAL_CRYP_DeInit ( CRYP_HandleTypeDef hcryp)
HAL_StatusTypeDef HAL_CRYP_Init ( CRYP_HandleTypeDef hcryp)

Initialize the CRYP according to the specified parameters in the CRYP_InitTypeDef and initialize the associated handle.

Parameters:
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module
Note:
Specific care must be taken to format the key and the Initialization Vector IV stored in the MCU memory before calling HAL_CRYP_Init(). Refer to explanations hereabove.
Return values:
HALstatus

Definition at line 241 of file stm32l4xx_hal_cryp.c.

References __HAL_CRYP_DISABLE, __HAL_CRYP_ENABLE, assert_param, CRYP_InitTypeDef::ChainingMode, __CRYP_HandleTypeDef::CompCpltCallback, CRYP_ALGOMODE_KEYDERIVATION, CRYP_ALGOMODE_KEYDERIVATION_DECRYPT, CRYP_CHAINMODE_AES_CMAC, CRYP_CHAINMODE_AES_CTR, CRYP_CHAINMODE_AES_ECB, CRYP_CHAINMODE_AES_GCM_GMAC, CRYP_KEY_WRITE_ENABLE, CRYP_SetInitVector(), CRYP_SetKey(), __CRYP_HandleTypeDef::CrypInCount, __CRYP_HandleTypeDef::CrypOutCount, CRYP_InitTypeDef::DataType, __CRYP_HandleTypeDef::ErrorCallback, __CRYP_HandleTypeDef::ErrorCode, CRYP_InitTypeDef::GCMCMACPhase, HAL_CRYP_ERROR_NONE, HAL_CRYP_ErrorCallback(), HAL_CRYP_InCpltCallback(), HAL_CRYP_MspInit(), HAL_CRYP_OutCpltCallback(), HAL_CRYP_PHASE_NOT_USED, HAL_CRYP_PHASE_START, HAL_CRYP_STATE_BUSY, HAL_CRYP_STATE_READY, HAL_CRYP_STATE_RESET, HAL_CRYP_SUSPEND_NONE, HAL_CRYPEx_ComputationCpltCallback(), __CRYP_HandleTypeDef::InCpltCallback, __CRYP_HandleTypeDef::Init, __CRYP_HandleTypeDef::Instance, IS_CRYP_ALGOMODE, IS_CRYP_CHAINMODE, IS_CRYP_DATATYPE, IS_CRYP_KEYSIZE, IS_CRYP_WRITE, CRYP_InitTypeDef::KeySize, CRYP_InitTypeDef::KeyWriteFlag, __CRYP_HandleTypeDef::Lock, __CRYP_HandleTypeDef::MspInitCallback, CRYP_InitTypeDef::OperatingMode, __CRYP_HandleTypeDef::OutCpltCallback, __CRYP_HandleTypeDef::Phase, __CRYP_HandleTypeDef::State, and __CRYP_HandleTypeDef::SuspendRequest.

Referenced by HAL_CRYP_AESCBC_Decrypt(), HAL_CRYP_AESCBC_Decrypt_DMA(), HAL_CRYP_AESCBC_Decrypt_IT(), HAL_CRYP_AESCBC_Encrypt(), HAL_CRYP_AESCBC_Encrypt_DMA(), HAL_CRYP_AESCBC_Encrypt_IT(), HAL_CRYP_AESCTR_Decrypt(), HAL_CRYP_AESCTR_Decrypt_DMA(), HAL_CRYP_AESCTR_Decrypt_IT(), HAL_CRYP_AESCTR_Encrypt(), HAL_CRYP_AESCTR_Encrypt_DMA(), HAL_CRYP_AESCTR_Encrypt_IT(), HAL_CRYP_AESECB_Decrypt(), HAL_CRYP_AESECB_Decrypt_DMA(), HAL_CRYP_AESECB_Decrypt_IT(), HAL_CRYP_AESECB_Encrypt(), HAL_CRYP_AESECB_Encrypt_DMA(), and HAL_CRYP_AESECB_Encrypt_IT().

DeInitialize CRYP MSP.

Parameters:
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module
Return values:
None

Definition at line 509 of file stm32l4xx_hal_cryp.c.

Referenced by HAL_CRYP_DeInit(), and HAL_CRYP_UnRegisterCallback().

Initialize the CRYP MSP.

Parameters:
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module
Return values:
None

Definition at line 493 of file stm32l4xx_hal_cryp.c.

Referenced by HAL_CRYP_Init(), and HAL_CRYP_UnRegisterCallback().