@@ -221,10 +221,25 @@ int wh_Client_RngGenerate(whClientContext* ctx, uint8_t* out, uint32_t size)
221221
222222 /* Send request and get response */
223223 ret = wh_Client_SendRequest (ctx , group , action , req_len , dataPtr );
224+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
225+ if (ret == WH_ERROR_OK ) {
226+ ret = wh_CommClient_InitCryptTimeout (ctx -> comm );
227+ }
228+ #endif
224229 if (ret == 0 ) {
225230 do {
226231 ret = wh_Client_RecvResponse (ctx , & group , & action , & res_len ,
227232 dataPtr );
233+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
234+ if (ret == WH_ERROR_NOTREADY ) {
235+ /* Check for crypto timeout */
236+ if (wh_CommClient_CheckTimeout (ctx -> comm )
237+ == WH_ERROR_CRYPTIMEOUT ) {
238+ ret = WH_ERROR_CRYPTIMEOUT ;
239+ break ;
240+ }
241+ }
242+ #endif
228243 } while (ret == WH_ERROR_NOTREADY );
229244 }
230245 if (ret == WH_ERROR_OK ) {
@@ -339,14 +354,30 @@ int wh_Client_AesCtr(whClientContext* ctx, Aes* aes, int enc, const uint8_t* in,
339354 wh_Utils_Hexdump ("[client] req packet: \n" , (uint8_t * )req , req_len );
340355#endif
341356 ret = wh_Client_SendRequest (ctx , group , action , req_len , dataPtr );
357+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
358+ if (ret == WH_ERROR_OK ) {
359+ ret = wh_CommClient_InitCryptTimeout (ctx -> comm );
360+ }
361+ #endif
342362 /* read response */
343363 if (ret == WH_ERROR_OK ) {
344364 /* Response packet */
345365 uint16_t res_len = 0 ;
346366 do {
347367 ret =
348368 wh_Client_RecvResponse (ctx , & group , & action , & res_len , dataPtr );
369+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
370+ if (ret == WH_ERROR_NOTREADY ) {
371+ /* Check for crypto timeout */
372+ if (wh_CommClient_CheckTimeout (ctx -> comm )
373+ == WH_ERROR_CRYPTIMEOUT ) {
374+ ret = WH_ERROR_CRYPTIMEOUT ;
375+ break ;
376+ }
377+ }
378+ #endif
349379 } while (ret == WH_ERROR_NOTREADY );
380+
350381 if (ret == WH_ERROR_OK ) {
351382 ret = _getCryptoResponse (dataPtr , type , (uint8_t * * )& res );
352383 if (ret == WH_ERROR_OK ) {
@@ -460,14 +491,30 @@ int wh_Client_AesEcb(whClientContext* ctx, Aes* aes, int enc, const uint8_t* in,
460491 wh_Utils_Hexdump ("[client] req packet: \n" , (uint8_t * )req , req_len );
461492#endif
462493 ret = wh_Client_SendRequest (ctx , group , action , req_len , dataPtr );
494+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
495+ if (ret == WH_ERROR_OK ) {
496+ ret = wh_CommClient_InitCryptTimeout (ctx -> comm );
497+ }
498+ #endif
463499 /* read response */
464500 if (ret == WH_ERROR_OK ) {
465501 /* Response packet */
466502 uint16_t res_len = 0 ;
467503 do {
468504 ret =
469505 wh_Client_RecvResponse (ctx , & group , & action , & res_len , dataPtr );
506+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
507+ if (ret == WH_ERROR_NOTREADY ) {
508+ /* Check for crypto timeout */
509+ if (wh_CommClient_CheckTimeout (ctx -> comm )
510+ == WH_ERROR_CRYPTIMEOUT ) {
511+ ret = WH_ERROR_CRYPTIMEOUT ;
512+ break ;
513+ }
514+ }
515+ #endif
470516 } while (ret == WH_ERROR_NOTREADY );
517+
471518 if (ret == WH_ERROR_OK ) {
472519 ret = _getCryptoResponse (dataPtr , type , (uint8_t * * )& res );
473520 if (ret == WH_ERROR_OK ) {
@@ -576,14 +623,30 @@ int wh_Client_AesCbc(whClientContext* ctx, Aes* aes, int enc, const uint8_t* in,
576623 wh_Utils_Hexdump ("[client] req packet: \n" , (uint8_t * )req , req_len );
577624#endif
578625 ret = wh_Client_SendRequest (ctx , group , action , req_len , dataPtr );
626+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
627+ if (ret == WH_ERROR_OK ) {
628+ ret = wh_CommClient_InitCryptTimeout (ctx -> comm );
629+ }
630+ #endif
579631 /* read response */
580632 if (ret == WH_ERROR_OK ) {
581633 /* Response packet */
582634 uint16_t res_len = 0 ;
583635 do {
584636 ret =
585637 wh_Client_RecvResponse (ctx , & group , & action , & res_len , dataPtr );
638+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
639+ if (ret == WH_ERROR_NOTREADY ) {
640+ /* Check for crypto timeout */
641+ if (wh_CommClient_CheckTimeout (ctx -> comm )
642+ == WH_ERROR_CRYPTIMEOUT ) {
643+ ret = WH_ERROR_CRYPTIMEOUT ;
644+ break ;
645+ }
646+ }
647+ #endif
586648 } while (ret == WH_ERROR_NOTREADY );
649+
587650 if (ret == WH_ERROR_OK ) {
588651 ret = _getCryptoResponse (dataPtr , type , (uint8_t * * )& res );
589652 if (ret == WH_ERROR_OK ) {
@@ -708,11 +771,26 @@ int wh_Client_AesGcm(whClientContext* ctx, Aes* aes, int enc, const uint8_t* in,
708771
709772 /* Send request and receive response */
710773 ret = wh_Client_SendRequest (ctx , group , action , req_len , dataPtr );
774+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
775+ if (ret == WH_ERROR_OK ) {
776+ ret = wh_CommClient_InitCryptTimeout (ctx -> comm );
777+ }
778+ #endif
711779 if (ret == 0 ) {
712780 uint16_t res_len = 0 ;
713781 do {
714782 ret =
715783 wh_Client_RecvResponse (ctx , & group , & action , & res_len , dataPtr );
784+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
785+ if (ret == WH_ERROR_NOTREADY ) {
786+ /* Check for crypto timeout */
787+ if (wh_CommClient_CheckTimeout (ctx -> comm )
788+ == WH_ERROR_CRYPTIMEOUT ) {
789+ ret = WH_ERROR_CRYPTIMEOUT ;
790+ break ;
791+ }
792+ }
793+ #endif
716794 } while (ret == WH_ERROR_NOTREADY );
717795
718796 if (ret == WH_ERROR_OK ) {
@@ -902,11 +980,26 @@ int wh_Client_AesGcmDma(whClientContext* ctx, Aes* aes, int enc,
902980 wh_Utils_Hexdump ("[client] AESGCM DMA req packet: \n" , dataPtr , reqLen );
903981#endif
904982 ret = wh_Client_SendRequest (ctx , group , action , reqLen , dataPtr );
983+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
984+ if (ret == WH_ERROR_OK ) {
985+ ret = wh_CommClient_InitCryptTimeout (ctx -> comm );
986+ }
987+ #endif
905988 if (ret == 0 ) {
906989 uint16_t resLen = 0 ;
907990 do {
908991 ret =
909992 wh_Client_RecvResponse (ctx , & group , & action , & resLen , dataPtr );
993+ #if defined(WOLFHSM_CFG_ENABLE_CLIENT_CRYPTIMEOUT )
994+ if (ret == WH_ERROR_NOTREADY ) {
995+ /* Check for crypto timeout */
996+ if (wh_CommClient_CheckTimeout (ctx -> comm )
997+ == WH_ERROR_CRYPTIMEOUT ) {
998+ ret = WH_ERROR_CRYPTIMEOUT ;
999+ break ;
1000+ }
1001+ }
1002+ #endif
9101003 } while (ret == WH_ERROR_NOTREADY );
9111004
9121005 if (ret == WH_ERROR_OK ) {
0 commit comments