HAL RNG Use Cases

rng_uc_user_application_starting_driver

@startuml

hide footbox

' To add a number by line

'autonumber



' Fix order of each column

skinparam ParticipantPadding 40



participant "User Application" as part1

participant "Driver RNG" as part2

participant "System" as part3



activate part1



group #9898fb Initializes the Flash interface and the Systick

part1->part3 : HAL_Init()

activate part3

part3 --> part1

deactivate part3

end



group #lightsalmon Configure the system clock

part1->part3 : SystemClock_Config()

activate part3

part3 --> part1

deactivate part3

end



group #lightblue Initialize RNG peripheral

part1->part2 ++ : HAL_RNG_Init()

note right: One instance available : \n- HAL_RNG \n enabled when USE_RNG_CLK_ENABLE_MODEL \n is set to HAL_CLK_ENABLE_PERIPH_ONLY



part2 --> part1



part1->part2 : - RNG HW Initialization\n- NVIC configuration for RNG interrupts

part2 --> part1

end



@enduml

Called functions:

rng_uc_generate_nist_compliant_random_numbers_polling

@startuml

group #lightblue RNG Initialization

"User Application"->"HAL RNG Driver" : HAL_RNG_Init()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group  #tomato RNG Configuration

"User Application"->"HAL RNG Driver" : HAL_RNG_SetCertifiedNISTConfig()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #lightgreen Random number generation in polling mode

"User Application"->"HAL RNG Driver" : HAL_RNG_GenerateRandomNumber()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

note right : N x 32-bit random numbers generated

deactivate "HAL RNG Driver"

end



@enduml

Called functions:

rng_uc_generate_nist_compliant_random_numbers_interrupt

@startuml

group #lightblue RNG Initialization

"User Application"->"HAL RNG Driver" : HAL_RNG_Init()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group  #tomato RNG Configuration

"User Application"->"HAL RNG Driver" : HAL_RNG_SetCertifiedNISTConfig()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #lightgreen Random number generation in interrupt mode

"User Application"->"HAL RNG Driver" : HAL_RNG_GenerateRandomNumber_IT()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

"IRQHandler" <-: Interrupt

"IRQHandler"->"HAL RNG Driver": HAL_RNG_IRQHandler()

"HAL RNG Driver" --> "User Application" : HAL_RNG_GenerationCpltCallback()

note left: N x 32-bit random numbers

end



@enduml

Called functions:

rng_uc_generate_germanbsi_candidate_random_numbers_polling

@startuml

group #lightblue RNG Initialization

"User Application"->"HAL RNG Driver" : HAL_RNG_Init()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group  #tomato RNG Configuration

"User Application"->"HAL RNG Driver" : HAL_RNG_SetCandidateGermanBSIConfig()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #lightgreen Random number generation in polling mode

"User Application"->"HAL RNG Driver" : HAL_RNG_GenerateRandomNumber()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

note right : N x 32-bit random numbers generated

deactivate "HAL RNG Driver"

end



@enduml

Called functions:

rng_uc_generate_germanbsi_candidate_random_numbers_interrupt

@startuml

group #lightblue RNG Initialization

"User Application"->"HAL RNG Driver" : HAL_RNG_Init()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #tomato RNG Configuration

"User Application"->"HAL RNG Driver" : HAL_RNG_SetCandidateGermanBSIConfig()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #lightgreen Random number generation in interrupt mode

"User Application"->"HAL RNG Driver" : HAL_RNG_GenerateRandomNumber_IT()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

"IRQHandler" <-: Interrupt

"IRQHandler"->"HAL RNG Driver": HAL_RNG_IRQHandler()

"HAL RNG Driver" --> "User Application" : HAL_RNG_GenerationCpltCallback()

note left: N x 32-bit random numbers

end



@enduml

Called functions:

rng_uc_generate_random_numbers_customized_config_polling

@startuml

group #lightblue RNG Initialization

"User Application"->"HAL RNG Driver" : HAL_RNG_Init()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #tomato RNG Configuration

"User Application"->"HAL RNG Driver" : HAL_RNG_SetConfig()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #lightgreen Random number generation in polling mode

"User Application"->"HAL RNG Driver" : HAL_RNG_GenerateRandomNumber()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

note right: N x 32-bit random numbers

deactivate "HAL RNG Driver"

end



@enduml

Called functions:

rng_uc_set_nist_configuration_after_lock

@startuml

group #lightblue RNG Initialization

"User Application"->"HAL RNG Driver" : HAL_RNG_Init()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #tomato RNG Configuration

"User Application"->"HAL RNG Driver" : HAL_RNG_SetConfig()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

"User Application"->"HAL RNG Driver"  : HAL_RNG_LockConfig()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

"User Application"->"HAL RNG Driver"  : Perform an RNG hard reset with RCC

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

"User Application"->"HAL RNG Driver"  : HAL_RNG_SeCertifiedtNISTConfig()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



@enduml

Called functions:

rng_uc_generate_random_numbers_customized_config_interrupt

@startuml

group #lightblue RNG Initialization

"User Application"->"HAL RNG Driver" : HAL_RNG_Init()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #tomato RNG Configuration

"User Application"->"HAL RNG Driver" : HAL_RNG_SetConfig()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #lightgreen Random number generation in interrupt mode

"User Application"->"HAL RNG Driver" : HAL_RNG_GenerateRandomNumber_IT()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

"IRQHandler" <-: Interrupt

"IRQHandler"->"HAL RNG Driver": HAL_RNG_IRQHandler()

"HAL RNG Driver" --> "User Application" : HAL_RNG_GenerationCpltCallback()

note right : 32-bit random number

end



@enduml

Called functions:

rng_uc_recover_seed_error_polling

@startuml

group #lightblue RNG Initialization

"User Application"->"HAL RNG Driver" : HAL_RNG_Init()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #tomato RNG Configuration

"User Application"->"HAL RNG Driver" : HAL_RNG_SetConfig()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" :  HAL_OK

deactivate "HAL RNG Driver"

end



group #lightgreen Random number generation in polling mode

"User Application"->"HAL RNG Driver" : HAL_RNG_GenerateRandomNumber()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_ERROR (Seed error occured)

deactivate "HAL RNG Driver"

end



group #red Recover the seed error

"User Application"->"HAL RNG Driver" : HAL_RNG_RecoverSeedError()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #lightgreen restart random number generations

"User Application"->"HAL RNG Driver" :  HAL_RNG_GenerateRandomNumber()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

note right : N x 32-bit random numbers

deactivate "HAL RNG Driver"

end



@enduml

Called functions:

rng_uc_setting_additional_health_tests_interrupt

@startuml

group #lightblue RNG Initialization

"User Application"->"HAL RNG Driver" : HAL_RNG_Init()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #tomato RNG Configuration

"User Application"->"HAL RNG Driver" : HAL_RNG_SetConfig()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #lightgreen Random number generation in interrupt mode

"User Application"->"HAL RNG Driver" : HAL_RNG_GenerateRandomNumber_IT()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

"IRQHandler" <-: Interrupt

"IRQHandler"->"HAL RNG Driver": HAL_RNG_IRQHandler()

note left : HAL_ERROR: seed error detected

end



group #red Seed error recovery

"HAL RNG Driver" --> "User Application" : HAL_RNG_ErrorCallback()

"User Application"->"HAL RNG Driver" : HAL_RNG_RecoverSeedError()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

end



group #lightgreen Start a new process

"User Application"->"HAL RNG Driver" : HAL_RNG_GenerateRandomNumber_IT()

activate "HAL RNG Driver"

"HAL RNG Driver"-->"User Application" : HAL_OK

deactivate "HAL RNG Driver"

"IRQHandler" <-: Interrupt

"IRQHandler"-> "HAL RNG Driver" : HAL_RNG_IRQHandler()

note left : HAL_OK: N x 32-bit random numbers generated

"HAL RNG Driver" --> "User Application" : HAL_RNG_GenerationCpltCallback()

end



@enduml

Called functions: