@@ -123,6 +123,9 @@ typedef struct otCryptoKey
123123 * @struct otCryptoContext
124124 *
125125 * Stores the context object for platform APIs.
126+ *
127+ * If `OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS` is enabled, platform allocates and populates this.
128+ * Otherwise it is input.
126129 */
127130typedef struct otCryptoContext
128131{
@@ -319,12 +322,15 @@ void otPlatCryptoFree(void *aPtr);
319322/**
320323 * Initialize the HMAC operation.
321324 *
322- * @param[in] aContext Context for HMAC operation.
325+ * @param[in,out ] aContext Context for HMAC operation.
323326 *
324327 * @retval OT_ERROR_NONE Successfully initialized HMAC operation.
325328 * @retval OT_ERROR_FAILED Failed to initialize HMAC operation.
326329 * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
327330 *
331+ * @note If `OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS` is enabled, @p aContext is output and platform MUST
332+ * populate it. Otherwise @p aContext is input.
333+ *
328334 * @note The platform driver shall point the context to the correct object such as psa_mac_operation_t or
329335 * mbedtls_md_context_t.
330336 */
@@ -382,13 +388,16 @@ otError otPlatCryptoHmacSha256Finish(otCryptoContext *aContext, uint8_t *aBuf, s
382388/**
383389 * Initialise the AES operation.
384390 *
385- * @param[in] aContext Context for AES operation.
391+ * @param[in,out ] aContext Context for AES operation.
386392 *
387393 * @retval OT_ERROR_NONE Successfully Initialised AES operation.
388394 * @retval OT_ERROR_FAILED Failed to Initialise AES operation.
389395 * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
390396 * @retval OT_ERROR_NO_BUFS Cannot allocate the context.
391397 *
398+ * @note If `OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS` is enabled, @p aContext is output and platform MUST
399+ * populate it. Otherwise @p aContext is input.
400+ *
392401 * @note The platform driver shall point the context to the correct object such as psa_key_id
393402 * or mbedtls_aes_context_t.
394403 */
@@ -433,12 +442,15 @@ otError otPlatCryptoAesFree(otCryptoContext *aContext);
433442/**
434443 * Initialise the HKDF context.
435444 *
436- * @param[in] aContext Context for HKDF operation.
445+ * @param[in,out ] aContext Context for HKDF operation.
437446 *
438447 * @retval OT_ERROR_NONE Successfully Initialised AES operation.
439448 * @retval OT_ERROR_FAILED Failed to Initialise AES operation.
440449 * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
441450 *
451+ * @note If `OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS` is enabled, @p aContext is output and platform MUST
452+ * populate it. Otherwise @p aContext is input.
453+ *
442454 * @note The platform driver shall point the context to the correct object such as psa_key_derivation_operation_t
443455 * or HmacSha256::Hash
444456 */
@@ -493,12 +505,14 @@ otError otPlatCryptoHkdfDeinit(otCryptoContext *aContext);
493505/**
494506 * Initialise the SHA-256 operation.
495507 *
496- * @param[in] aContext Context for SHA-256 operation.
508+ * @param[in,out ] aContext Context for SHA-256 operation.
497509 *
498510 * @retval OT_ERROR_NONE Successfully initialised SHA-256 operation.
499511 * @retval OT_ERROR_FAILED Failed to initialise SHA-256 operation.
500512 * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL
501513 *
514+ * @note If `OPENTHREAD_CONFIG_PLATFORM_ALLOCS_CRYPTO_CONTEXTS` is enabled, @p aContext is output and platform MUST
515+ * populate it. Otherwise @p aContext is input.
502516 *
503517 * @note The platform driver shall point the context to the correct object such as psa_hash_operation_t
504518 * or mbedtls_sha256_context.
0 commit comments