STM32L4xx_HAL_Driver  1.14.0
AES suspension/resumption functions

Extended processing functions. More...

Functions

void HAL_CRYPEx_Read_IVRegisters (CRYP_HandleTypeDef *hcryp, uint8_t *Output)
 In case of message processing suspension, read the Initialization Vector. More...
 
void HAL_CRYPEx_Write_IVRegisters (CRYP_HandleTypeDef *hcryp, uint8_t *Input)
 In case of message processing resumption, rewrite the Initialization Vector in the AES_IVRx registers. More...
 
void HAL_CRYPEx_Read_SuspendRegisters (CRYP_HandleTypeDef *hcryp, uint8_t *Output)
 In case of message GCM/GMAC (CCM/CMAC when applicable) processing suspension, read the Suspend Registers. More...
 
void HAL_CRYPEx_Write_SuspendRegisters (CRYP_HandleTypeDef *hcryp, uint8_t *Input)
 In case of message GCM/GMAC (CCM/CMAC when applicable) processing resumption, rewrite the Suspend Registers in the AES_SUSPxR registers. More...
 
void HAL_CRYPEx_Read_KeyRegisters (CRYP_HandleTypeDef *hcryp, uint8_t *Output, uint32_t KeySize)
 In case of message GCM/GMAC (CCM/CMAC when applicable) processing suspension, read the Key Registers. More...
 
void HAL_CRYPEx_Write_KeyRegisters (CRYP_HandleTypeDef *hcryp, uint8_t *Input, uint32_t KeySize)
 In case of message GCM/GMAC (CCM/CMAC when applicable) processing resumption, rewrite the Key Registers in the AES_KEYRx registers. More...
 
void HAL_CRYPEx_Read_ControlRegister (CRYP_HandleTypeDef *hcryp, uint8_t *Output)
 In case of message GCM/GMAC (CCM/CMAC when applicable) processing suspension, read the Control Register. More...
 
void HAL_CRYPEx_Write_ControlRegister (CRYP_HandleTypeDef *hcryp, uint8_t *Input)
 In case of message GCM/GMAC (CCM/CMAC when applicable) processing resumption, rewrite the Control Registers in the AES_CR register. More...
 
void HAL_CRYPEx_ProcessSuspend (CRYP_HandleTypeDef *hcryp)
 Request CRYP processing suspension when in polling or interruption mode. More...
 

Detailed Description

Extended processing functions.

  ==============================================================================
                    ##### AES extended suspension and resumption functions #####
  ==============================================================================
    [..]  This section provides functions allowing to:
      (+) save in memory the Initialization Vector, the Key registers, the Control register or
          the Suspend registers when a process is suspended by a higher priority message
      (+) write back in CRYP hardware block the saved values listed above when the suspended
          lower priority message processing is resumed.

Function Documentation

◆ HAL_CRYPEx_ProcessSuspend()

void HAL_CRYPEx_ProcessSuspend ( CRYP_HandleTypeDef hcryp)

Request CRYP processing suspension when in polling or interruption mode.

Parameters
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module.
Note
Set the handle field SuspendRequest to the appropriate value so that the on-going CRYP processing is suspended as soon as the required conditions are met.
It is advised not to suspend the CRYP processing when the DMA controller is managing the data transfer
Return values
None

Definition at line 2098 of file stm32l4xx_hal_cryp_ex.c.

2099 {
2100  /* Set Handle Suspend Request field */
2102 }
HAL_SuspendTypeDef SuspendRequest

◆ HAL_CRYPEx_Read_ControlRegister()

void HAL_CRYPEx_Read_ControlRegister ( CRYP_HandleTypeDef hcryp,
uint8_t *  Output 
)

In case of message GCM/GMAC (CCM/CMAC when applicable) processing suspension, read the Control Register.

Parameters
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module.
OutputPointer to the buffer containing the saved Control Register.
Note
This values has to be stored for reuse by writing back the AES_CR register as soon as the interrupted processing has to be resumed.
Return values
None

Definition at line 2065 of file stm32l4xx_hal_cryp_ex.c.

2066 {
2067  *(uint32_t*)(void *)(Output) = hcryp->Instance->CR; /* Derogation MisraC2012 R.11.5 */
2068 }

◆ HAL_CRYPEx_Read_IVRegisters()

void HAL_CRYPEx_Read_IVRegisters ( CRYP_HandleTypeDef hcryp,
uint8_t *  Output 
)

In case of message processing suspension, read the Initialization Vector.

Parameters
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module.
OutputPointer to the buffer containing the saved Initialization Vector.
Note
This value has to be stored for reuse by writing the AES_IVRx registers as soon as the interrupted processing has to be resumed. Applicable to all chaining modes.
AES must be disabled when reading or resetting the IV values.
Return values
None

Definition at line 1864 of file stm32l4xx_hal_cryp_ex.c.

1865 {
1866  uint32_t outputaddr = (uint32_t)Output;
1867 
1868  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->IVR3);
1869  outputaddr+=4U;
1870  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->IVR2);
1871  outputaddr+=4U;
1872  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->IVR1);
1873  outputaddr+=4U;
1874  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->IVR0);
1875 }

◆ HAL_CRYPEx_Read_KeyRegisters()

void HAL_CRYPEx_Read_KeyRegisters ( CRYP_HandleTypeDef hcryp,
uint8_t *  Output,
uint32_t  KeySize 
)

In case of message GCM/GMAC (CCM/CMAC when applicable) processing suspension, read the Key Registers.

Parameters
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module.
OutputPointer to the buffer containing the saved Key Registers.
KeySizeIndicates the key size (128 or 256 bits).
Note
These values have to be stored for reuse by writing back the AES_KEYRx registers as soon as the interrupted processing has to be resumed.
Return values
None

Definition at line 1995 of file stm32l4xx_hal_cryp_ex.c.

1996 {
1997  uint32_t keyaddr = (uint32_t)Output;
1998 
1999  if (KeySize == CRYP_KEYSIZE_256B)
2000  {
2001  *(uint32_t*)(keyaddr) = __REV(hcryp->Instance->KEYR7);
2002  keyaddr+=4U;
2003  *(uint32_t*)(keyaddr) = __REV(hcryp->Instance->KEYR6);
2004  keyaddr+=4U;
2005  *(uint32_t*)(keyaddr) = __REV(hcryp->Instance->KEYR5);
2006  keyaddr+=4U;
2007  *(uint32_t*)(keyaddr) = __REV(hcryp->Instance->KEYR4);
2008  keyaddr+=4U;
2009  }
2010 
2011  *(uint32_t*)(keyaddr) = __REV(hcryp->Instance->KEYR3);
2012  keyaddr+=4U;
2013  *(uint32_t*)(keyaddr) = __REV(hcryp->Instance->KEYR2);
2014  keyaddr+=4U;
2015  *(uint32_t*)(keyaddr) = __REV(hcryp->Instance->KEYR1);
2016  keyaddr+=4U;
2017  *(uint32_t*)(keyaddr) = __REV(hcryp->Instance->KEYR0);
2018 }

◆ HAL_CRYPEx_Read_SuspendRegisters()

void HAL_CRYPEx_Read_SuspendRegisters ( CRYP_HandleTypeDef hcryp,
uint8_t *  Output 
)

In case of message GCM/GMAC (CCM/CMAC when applicable) processing suspension, read the Suspend Registers.

Parameters
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module.
OutputPointer to the buffer containing the saved Suspend Registers.
Note
These values have to be stored for reuse by writing back the AES_SUSPxR registers as soon as the interrupted processing has to be resumed.
Return values
None

Definition at line 1912 of file stm32l4xx_hal_cryp_ex.c.

1913 {
1914  uint32_t outputaddr = (uint32_t)Output;
1915 
1916  /* In case of GCM payload phase encryption, check that suspension can be carried out */
1917  if (READ_BIT(hcryp->Instance->CR, (AES_CR_CHMOD|AES_CR_GCMPH|AES_CR_MODE)) == (CRYP_CHAINMODE_AES_GCM_GMAC|CRYP_PAYLOAD_PHASE|CRYP_ALGOMODE_ENCRYPT))
1918  {
1919  /* Ensure that Busy flag is reset */
1920  if(CRYP_WaitOnBusyFlagReset(hcryp, CRYP_BUSY_TIMEOUTVALUE) != HAL_OK)
1921  {
1922  hcryp->ErrorCode |= HAL_CRYP_BUSY_ERROR;
1923  hcryp->State = HAL_CRYP_STATE_ERROR;
1924 
1925  /* Process Unlocked */
1926  __HAL_UNLOCK(hcryp);
1927 
1928 #if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1)
1929  hcryp->ErrorCallback(hcryp);
1930 #else
1931  HAL_CRYP_ErrorCallback(hcryp);
1932 #endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
1933  return ;
1934  }
1935  }
1936 
1937  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->SUSP7R);
1938  outputaddr+=4U;
1939  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->SUSP6R);
1940  outputaddr+=4U;
1941  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->SUSP5R);
1942  outputaddr+=4U;
1943  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->SUSP4R);
1944  outputaddr+=4U;
1945  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->SUSP3R);
1946  outputaddr+=4U;
1947  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->SUSP2R);
1948  outputaddr+=4U;
1949  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->SUSP1R);
1950  outputaddr+=4U;
1951  *(uint32_t*)(outputaddr) = __REV(hcryp->Instance->SUSP0R);
1952 }
void(* ErrorCallback)(struct __CRYP_HandleTypeDef *hcryp)
__IO HAL_CRYP_STATETypeDef State
return(brrresult)
__HAL_UNLOCK(hrtc)
static HAL_StatusTypeDef CRYP_WaitOnBusyFlagReset(CRYP_HandleTypeDef const *const hcryp, uint32_t Timeout)
Wait for Busy Flag to be reset during a GCM payload encryption process suspension.
return HAL_OK
void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp)
CRYP error callback.

◆ HAL_CRYPEx_Write_ControlRegister()

void HAL_CRYPEx_Write_ControlRegister ( CRYP_HandleTypeDef hcryp,
uint8_t *  Input 
)

In case of message GCM/GMAC (CCM/CMAC when applicable) processing resumption, rewrite the Control Registers in the AES_CR register.

Parameters
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module.
InputPointer to the buffer containing the saved Control Register to write back in the CRYP hardware block.
Return values
None

Definition at line 2079 of file stm32l4xx_hal_cryp_ex.c.

2080 {
2081  hcryp->Instance->CR = *(uint32_t*)(void *)(Input); /* Derogation MisraC2012 R.11.5 */
2082  /* At the same time, set handle state back to READY to be able to resume the AES calculations
2083  without the processing APIs returning HAL_BUSY when called. */
2084  hcryp->State = HAL_CRYP_STATE_READY;
2085 }
__IO HAL_CRYP_STATETypeDef State

◆ HAL_CRYPEx_Write_IVRegisters()

void HAL_CRYPEx_Write_IVRegisters ( CRYP_HandleTypeDef hcryp,
uint8_t *  Input 
)

In case of message processing resumption, rewrite the Initialization Vector in the AES_IVRx registers.

Parameters
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module.
InputPointer to the buffer containing the saved Initialization Vector to write back in the CRYP hardware block.
Note
Applicable to all chaining modes.
AES must be disabled when reading or resetting the IV values.
Return values
None

Definition at line 1888 of file stm32l4xx_hal_cryp_ex.c.

1889 {
1890  uint32_t ivaddr = (uint32_t)Input;
1891 
1892  hcryp->Instance->IVR3 = __REV(*(uint32_t*)(ivaddr));
1893  ivaddr+=4U;
1894  hcryp->Instance->IVR2 = __REV(*(uint32_t*)(ivaddr));
1895  ivaddr+=4U;
1896  hcryp->Instance->IVR1 = __REV(*(uint32_t*)(ivaddr));
1897  ivaddr+=4U;
1898  hcryp->Instance->IVR0 = __REV(*(uint32_t*)(ivaddr));
1899 }

◆ HAL_CRYPEx_Write_KeyRegisters()

void HAL_CRYPEx_Write_KeyRegisters ( CRYP_HandleTypeDef hcryp,
uint8_t *  Input,
uint32_t  KeySize 
)

In case of message GCM/GMAC (CCM/CMAC when applicable) processing resumption, rewrite the Key Registers in the AES_KEYRx registers.

Parameters
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module.
InputPointer to the buffer containing the saved key registers to write back in the CRYP hardware block.
KeySizeIndicates the key size (128 or 256 bits)
Return values
None

Definition at line 2030 of file stm32l4xx_hal_cryp_ex.c.

2031 {
2032  uint32_t keyaddr = (uint32_t)Input;
2033 
2034  if (KeySize == CRYP_KEYSIZE_256B)
2035  {
2036  hcryp->Instance->KEYR7 = __REV(*(uint32_t*)(keyaddr));
2037  keyaddr+=4U;
2038  hcryp->Instance->KEYR6 = __REV(*(uint32_t*)(keyaddr));
2039  keyaddr+=4U;
2040  hcryp->Instance->KEYR5 = __REV(*(uint32_t*)(keyaddr));
2041  keyaddr+=4U;
2042  hcryp->Instance->KEYR4 = __REV(*(uint32_t*)(keyaddr));
2043  keyaddr+=4U;
2044  }
2045 
2046  hcryp->Instance->KEYR3 = __REV(*(uint32_t*)(keyaddr));
2047  keyaddr+=4U;
2048  hcryp->Instance->KEYR2 = __REV(*(uint32_t*)(keyaddr));
2049  keyaddr+=4U;
2050  hcryp->Instance->KEYR1 = __REV(*(uint32_t*)(keyaddr));
2051  keyaddr+=4U;
2052  hcryp->Instance->KEYR0 = __REV(*(uint32_t*)(keyaddr));
2053 }

◆ HAL_CRYPEx_Write_SuspendRegisters()

void HAL_CRYPEx_Write_SuspendRegisters ( CRYP_HandleTypeDef hcryp,
uint8_t *  Input 
)

In case of message GCM/GMAC (CCM/CMAC when applicable) processing resumption, rewrite the Suspend Registers in the AES_SUSPxR registers.

Parameters
hcryppointer to a CRYP_HandleTypeDef structure that contains the configuration information for CRYP module.
InputPointer to the buffer containing the saved suspend registers to write back in the CRYP hardware block.
Return values
None

Definition at line 1963 of file stm32l4xx_hal_cryp_ex.c.

1964 {
1965  uint32_t ivaddr = (uint32_t)Input;
1966 
1967  hcryp->Instance->SUSP7R = __REV(*(uint32_t*)(ivaddr));
1968  ivaddr+=4U;
1969  hcryp->Instance->SUSP6R = __REV(*(uint32_t*)(ivaddr));
1970  ivaddr+=4U;
1971  hcryp->Instance->SUSP5R = __REV(*(uint32_t*)(ivaddr));
1972  ivaddr+=4U;
1973  hcryp->Instance->SUSP4R = __REV(*(uint32_t*)(ivaddr));
1974  ivaddr+=4U;
1975  hcryp->Instance->SUSP3R = __REV(*(uint32_t*)(ivaddr));
1976  ivaddr+=4U;
1977  hcryp->Instance->SUSP2R = __REV(*(uint32_t*)(ivaddr));
1978  ivaddr+=4U;
1979  hcryp->Instance->SUSP1R = __REV(*(uint32_t*)(ivaddr));
1980  ivaddr+=4U;
1981  hcryp->Instance->SUSP0R = __REV(*(uint32_t*)(ivaddr));
1982 }