HAL HASH Use Cases

User application starting a HASH update process in polling mode using SHA1 algorithm

@startuml
hide footbox
participant "User Application" as part1
participant "HASH Driver" as part2

activate part1
activate part2

group #lightsalmon Initialize HASH
part1->part2 : HAL_HASH_Init()
part2 --> "part1"
part1->part2 : HASH HW Initialisation and HASH NVIC configuration for HASH interrupts
part2 --> part1

end

group #9898fb Set HASH configuration
"part1"->part2 : HAL_HASH_SetConfig()
note right: The user need to select the algorithm \n which must be set to HAL_HASH_ALGO_SHA1.
part2 --> "part1"
end

group #lightblue update process in polling mode
part1->part2 : HAL_HASH_Update()
part2 --> part1 : Return hal status

part1->part2 : HAL_HASH_Update()
part2 --> part1 : Return hal status
note right: The user continue feeding with N consecutive input \n buffers in polling mode using using HAL_HASH_Update API.

part1->part2 : HAL_HASH_Finish()
part2 --> part1 : Return hal status
note right: Retrieve the message digest in the output buffer.

part1->part2 : HAL_HASH_DeInit()
end
@enduml

Functions called:

User application starting a HASH Update process in IT mode using SHA256 algorithm

@startuml
hide footbox
participant "User Application" as part1
participant "HASH Driver" as part2
participant "NVIC" as part3

activate part1
activate part2

group #lightsalmon HASH initialization
part1->part2 : HAL_HASH_Init()
part2 --> part1
part1->part2 : HASH HW Initialisation and HASH NVIC configuration for HASH interrupts
part2 --> part1
end

group #9898fb HASH configuration 
part1->part2 : HAL_HASH_SetConfig()
note right: The user need to select the algorithm which \n must be set to HAL_HASH_ALGO_SHA256
part2 --> part1 : Return hal status
end
group #lightblue Update  process in IT mode
part1->part2 : HAL_HASH_Update_IT()
part2 --> part1 : Return hal status
part3 -> part2 : HAL_HASH_IRQ_HANDLER()
part2--> part1 : HAL_HASH_InputCpltCallback()

part1->part2 : HAL_HASH_Update_IT()
part2 --> part1 : Return hal status
part3 -> part2 : HAL_HASH_IRQ_HANDLER()
part2--> part1 : HAL_HASH_InputCpltCallback()
note right: The user can fed severals inputs data by calling the HAL_HASH_Update_IT.

part1->part2 : HAL_HASH_Finish()
part3 -> part2 : HAL_HASH_IRQ_HANDLER()
part2--> part1 : HAL_HASH_InputCpltCallback() \n HAL_HASH_DigestCpltCallback()
part2 --> part1 : Return hal status

part3 -> part2 : HAL_HASH_IRQ_HANDLER()
part2--> part1 : HAL_HASH_ErrorCallback()
note right: Or HASH error occured.
end 
@enduml

Functions called:

User application starting a HASH-HMAC computation process in DMA mode using SHA224 algorithm

@startuml
hide footbox
participant "User Application" as part1
participant "HASH Driver" as part2
participant "DMA Driver " as part3
participant "NVIC" as part4

activate part1
activate part2

group #lightsalmon HASH initialization
part1->part2 : HAL_HASH_Init()
part2 --> part1
part1->part2 : HASH HW Initialisation, DMA Initialization and HASH and DMA NVIC configuration.
part2 --> part1

part1->part2 : HAL_HASH_SetInDMA()
note right: Link In DMA handle to HASH handle 
end 

group #9898fb HASH configuration 
part1->part2 : HAL_HASH_HMAC_SetConfig
part2 --> part1 : Return hal status
end 

group #lightblue HMAC Computing process in DMA mode
part1->part2 : HAL_HASH_HMAC_Compute_DMA()
part2 --> part1 : Return hal status

part4 -> part3 : HAL_DMA_IRQ_HANDLER()
part3 -> part2 : DMA Transfer complete
note right: The HASH Peripheral state shall be \n in  HAL_HASH_STATE_IDLE.
part2--> part1 : HAL_HASH_InputCpltCallback() \n HAL_HASH_DigestCpltCallback()
part1->part2 : HAL_HASH_DeInit()
end
@enduml

Functions called:

User application suspending and Resuming a HASH process in IT mode

@startuml
hide footbox
participant "User Application" as part1
participant "HASH Driver" as part2
participant "DMA" as part3
participant "NVIC" as part4
activate part1
activate part2

group #lightsalmon HASH initialization
part1->part2 : HAL_HASH_Init()
part2 --> part1 : Return hal status
part1->part2 : HASH HW Initialisation and HASH NVIC configuration.
part2 --> part1
end

group #9898fb HASH configuration 
part1->part2 : HAL_HASH_SetConfig()
part2 --> part1 : Return hal status
end
group #lightblue Process 1 : Suspending IT process during an update process in IT mode
part1->part2 : HAL_HASH_Update_IT()
part1->part2 : HAL_HASH_RequestSuspendUpdate()
note right : The Update process shall be ongoing 
part4 -> part2 : HAL_HASH_IRQ_HANDLER()
part2--> part1 : HAL_HASH_SuspendCallback()
note right: HASH update suspended when an \n input buffer is entiry processed.

part1->part2 : HAL_HASH_SaveContext()
end 

group #lightblue Process 2 : HASH new process
part1->part2 : HAL_HASH_HMAC_SetConfig()
part2 --> part1 : Return hal status
note right: The configuration settings are optional. You can modify them \n if you need to change the default configuration to better suit your requirements.

part1->part2 : HAL_HASH_HMAC_Compute_DMA()
part2 --> part1 : Return hal status

part4 -> part3 : HAL_DMA_IRQ_HANDLER()
part3 -> part2 : DMA Transfer complete
note right: The HASH Peripheral state shall be \n in  HAL_HASH_STATE_IDLE.
part2--> part1 : HAL_HASH_InputCpltCallback() \n HAL_HASH_DigestCpltCallback()
part1->part2 : HAL_HASH_DeInit()

end

group #lightblue Process 1 : Resuming IT process
part1->part2 : HAL_HASH_RestoreContext()
part1->part2 : HAL_HASH_ResumeUpdate()
note right: The previous IT process is resumed.

part3--> part2 : HAL_HASH_IRQHandler()
note right: HASH Update process completed.
part2--> part1 : HAL_HASH_InputCpltCallback
part1->part2 : HAL_HASH_Update_IT()
part2 --> part1 : Return hal status
note right: The HASH peripheral feed the rest of the input buffer.
part3 -> part2 : HAL_HASH_IRQ_HANDLER()
part2--> part1 : HAL_HASH_InputCpltCallback

note right: The HASH peripheral state shall be in \n HAL_HASH_STATE_IDLE.


part1->part2 : HAL_HASH_Finish()
part3 -> part2 : HAL_HASH_IRQ_HANDLER()
note right: The HASH peripheral state shall be moved to \n HAL_HASH_STATE_IDLE.
part2--> part1 : HAL_HASH_DigestCpltCallback() \n HAL_HASH_InputCpltCallback
part2 --> part1 : Return hal status

part3 -> part2 : HAL_HASH_IRQ_HANDLER()
part2--> part1 : HAL_HASH_ErrorCallback()
note right: Or HASH error occured.

part1->part2 : HAL_HASH_DeInit()
end
@enduml

Functions called:

User application starting a HASH update process in polling mode using SHA512 algorithm

@startuml
hide footbox
participant "User Application" as part1
participant "HASH Driver" as part2

activate part1
activate part2

group #lightsalmon Initialize HASH
part1->part2 : HAL_HASH_Init()
part2 --> "part1"
part1->part2 : HASH HW Initialisation and HASH NVIC configuration for HASH interrupts
part2 --> part1

end

group #9898fb Set HASH configuration
"part1"->part2 : HAL_HASH_SetConfig()
note right: The user need to select the algorithm \n which must be set to HAL_HASH_ALGO_SHA512.
part2 --> "part1"
end

group #lightblue Update process in polling mode
part1->part2 : HAL_HASH_Update()
part2 --> part1 : Return hal status

part1->part2 : HAL_HASH_Update()
part2 --> part1 : Return hal status
note right: The user continue feeding with N consecutive input \n buffers in polling mode using using HAL_HASH_Update API.

part1->part2 : HAL_HASH_Finish()
part2 --> part1 : Return hal status
note right: Retrieve the message digest in the output buffer.

part1->part2 : HAL_HASH_DeInit()
end
@enduml

Functions called:

User application starting a HASH Update process in polling mode using SHAKE128 algorithm

@startuml
hide footbox
participant "User Application" as part1
participant "HASH Driver" as part2

activate part1
activate part2

group #lightsalmon Initialize HASH
part1->part2 : HAL_HASH_Init()
part2 --> "part1"
part1->part2 : HASH HW Initialisation and HASH NVIC configuration for HASH interrupts
part2 --> part1

end

group #9898fb Set HASH configuration
"part1"->part2 : HAL_HASH_SetConfig()
note right: The user need to select the algorithm \n which must be set to HAL_HASH_ALGO_SHAKE128.
part2 --> "part1"
end

group #lightblue Update process in polling mode
part1->part2 : HAL_HASH_Update()
part2 --> part1 : Return hal status

part1->part2 : HAL_HASH_Update()
part2 --> part1 : Return hal status
note right: The user continue feeding with N consecutive input \n buffers in polling mode using using HAL_HASH_Update API.

part1->part2 : HAL_HASH_Finish()
part2 --> part1 : Return hal status
note right: Retrieve the message digest in the output buffer.

part1->part2 : HAL_HASH_DeInit()
end
@enduml

Functions called:

User application starting a HASH-HMAC computation process in DMA mode using SHA3224 algorithm

@startuml
hide footbox
participant "User Application" as part1
participant "HASH Driver" as part2
participant "DMA Driver " as part3
participant "NVIC" as part4

activate part1
activate part2

group #lightsalmon HASH initialization
part1->part2 : HAL_HASH_Init()
part2 --> part1
part1->part2 : HASH HW Initialisation, DMA Initialization and HASH and DMA NVIC configuration.
part2 --> part1

part1->part2 : HAL_HASH_SetInDMA()
note right: Link In DMA handle to HASH handle 
end 

group #9898fb HASH configuration 
part1->part2 : HAL_HASH_HMAC_SetConfig
part2 --> part1 : Return hal status
note right: The user need to select the algorithm which \n must be set to HAL_HASH_ALGO_SHA3224.
end 

group #lightblue HMAC Computing process in DMA mode
part1->part2 : HAL_HASH_HMAC_Compute_DMA()
part2 --> part1 : Return hal status

part4 -> part3 : HAL_DMA_IRQ_HANDLER()
part3 -> part2 : DMA Transfer complete
note right: The HASH Peripheral state shall be \n in  HAL_HASH_STATE_IDLE.
part2--> part1 : HAL_HASH_InputCpltCallback() \n HAL_HASH_DigestCpltCallback()
part1->part2 : HAL_HASH_DeInit()
end
@enduml

Functions called:

User application starting a HASH Update process in IT mode using SHAKE256 algorithm

@startuml
hide footbox
participant "User Application" as part1
participant "HASH Driver" as part2
participant "NVIC" as part3

activate part1
activate part2

group #lightsalmon HASH initialization
part1->part2 : HAL_HASH_Init()
part2 --> part1
part1->part2 : HASH HW Initialisation and HASH NVIC configuration for HASH interrupts
part2 --> part1
end

group #9898fb HASH configuration 
part1->part2 : HAL_HASH_SetConfig()
note right: The user need to select the algorithm which \n must be set to HAL_HASH_ALGO_SHAKE256
part2 --> part1 : Return hal status
end
group #lightblue Update  process in IT mode
part1->part2 : HAL_HASH_Update_IT()
part2 --> part1 : Return hal status
part3 -> part2 : HAL_HASH_IRQ_HANDLER()
part2--> part1 : HAL_HASH_InputCpltCallback()
note right: The HASH peripheral state shall be in \n HAL_HASH_STATE_IDLE.

part1->part2 : HAL_HASH_Update_IT()
part2 --> part1 : Return hal status
part3 -> part2 : HAL_HASH_IRQ_HANDLER()
part2--> part1 : HAL_HASH_InputCpltCallback()
note right: The user can fed severals inputs data by calling the HAL_HASH_Update_IT.

part1->part2 : HAL_HASH_Finish()
part2 --> part1 : Return hal status
part3 -> part2 : HAL_HASH_IRQ_HANDLER()
part2--> part1 : HAL_HASH_InputCpltCallback() \n HAL_HASH_DigestCpltCallback()
note right: The HASH peripheral state shall be moved to \n HAL_HASH_STATE_IDLE.

part3 -> part2 : HAL_HASH_IRQ_HANDLER()
part2--> part1 : HAL_HASH_ErrorCallback()
note right: Or HASH error occured.
end 
@enduml

Functions called: