Skip to main content
Associate
Oct 24, 2026 5:05 PM UTC
Solved

X-CUBE-CRYPTOLIB V5.x.x – Thread safety and reentrancy confirmation

Hello ST team,

In a previous discussion, ​@Jocelyn RICARD confirmed that X-CUBE-CRYPTOLIB V4.x was not reentrant, partly due to its use of the CRC hardware peripheral.

I understand that V5.0.0 no longer depends on the CRC peripheral, but I could not find an explicit statement in the documentation regarding thread safety or reentrancy.

Could you please clarify the following?

  1. Is X-CUBE-CRYPTOLIB V5.0.0 fully reentrant and thread-safe when called concurrently from different RTOS tasks, provided that each task uses independent contexts and buffers?

  2. Does this also apply to single-call APIs such as cmox_hash_compute() and cmox_cipher_encrypt(), which do not expose an explicit context?

  3. Can ST confirm that V5.0.0 does not use any shared mutable internal state that could prevent concurrent execution?

  4. Is any external synchronization (e.g., an RTOS mutex) required when calling CMOX APIs from multiple tasks?

We would like to determine whether a global mutex, previously necessary with V4.x, can safely be removed when migrating to V5.0.0.

Thank you for your support.

Jocelyn RICARD
Jocelyn RICARDBest answer
ST Employee
Oct 29, 2026 5:50 PM UTC

Hello ​@Step70 ,

Here are the answers to your questions

  1. “provided that each task uses independent contexts and buffers” X-CUBE-CRYPTOLIB V5.0.0 is fully reentrant and thread-safe
  2. Single calls internally define local contexts, so no issues at all with that.
  3. V5.0.0 does not use any shared mutable internal state or global variable
  4. The library does not make use of any synchronization mechanism. So, if you use independent contexts and buffers, there are no problems. But if you want to share some resources among threads, you need to implement your own synchronization mechanisms

Best regards

Jocelyn

2 replies

Jocelyn RICARD
Jocelyn RICARDBest answer
ST Employee
Oct 29, 2026 5:50 PM UTC

Hello ​@Step70 ,

Here are the answers to your questions

  1. “provided that each task uses independent contexts and buffers” X-CUBE-CRYPTOLIB V5.0.0 is fully reentrant and thread-safe
  2. Single calls internally define local contexts, so no issues at all with that.
  3. V5.0.0 does not use any shared mutable internal state or global variable
  4. The library does not make use of any synchronization mechanism. So, if you use independent contexts and buffers, there are no problems. But if you want to share some resources among threads, you need to implement your own synchronization mechanisms

Best regards

Jocelyn

Step70Author
Associate
Nov 4, 2026 10:14 AM UTC

Thank you very much for your kind reply.

Stefano