@@ -427,10 +427,17 @@ static const char WC_NAME_SHA512[] = "sha512";
427427/* create KCAPI handle for SHA512 operation */
428428int wc_InitSha512_ex (wc_Sha512 * sha , void * heap , int devid )
429429{
430+ int ret ;
430431 if (sha == NULL ) {
431432 return BAD_FUNC_ARG ;
432433 }
433- return KcapiHashInit (& sha -> kcapi , heap , devid , WC_NAME_SHA512 );
434+ ret = KcapiHashInit (& sha -> kcapi , heap , devid , WC_NAME_SHA512 );
435+ #if defined(WOLFSSL_SHA512_HASHTYPE )
436+ if (ret == 0 ) {
437+ sha -> hashType = WC_HASH_TYPE_SHA512 ;
438+ }
439+ #endif
440+ return ret ;
434441}
435442
436443
@@ -473,13 +480,20 @@ int wc_Sha512Copy(wc_Sha512* src, wc_Sha512* dst)
473480#if !defined(WOLFSSL_NOSHA512_224 )
474481static const char WC_NAME_SHA512_224 [] = "sha512-224" ;
475482
476- /* create KCAPI handle for SHA512 operation */
483+ /* create KCAPI handle for SHA512/224 operation */
477484int wc_InitSha512_224_ex (wc_Sha512 * sha , void * heap , int devid )
478485{
486+ int ret ;
479487 if (sha == NULL ) {
480488 return BAD_FUNC_ARG ;
481489 }
482- return KcapiHashInit (& sha -> kcapi , heap , devid , WC_NAME_SHA512_224 );
490+ ret = KcapiHashInit (& sha -> kcapi , heap , devid , WC_NAME_SHA512_224 );
491+ #if defined(WOLFSSL_SHA512_HASHTYPE )
492+ if (ret == 0 ) {
493+ sha -> hashType = WC_HASH_TYPE_SHA512_224 ;
494+ }
495+ #endif
496+ return ret ;
483497}
484498
485499
@@ -512,13 +526,20 @@ int wc_Sha512_224Copy(wc_Sha512* src, wc_Sha512* dst)
512526#if !defined(WOLFSSL_NOSHA512_256 )
513527static const char WC_NAME_SHA512_256 [] = "sha512-256" ;
514528
515- /* create KCAPI handle for SHA512 operation */
529+ /* create KCAPI handle for SHA512/256 operation */
516530int wc_InitSha512_256_ex (wc_Sha512 * sha , void * heap , int devid )
517531{
532+ int ret ;
518533 if (sha == NULL ) {
519534 return BAD_FUNC_ARG ;
520535 }
521- return KcapiHashInit (& sha -> kcapi , heap , devid , WC_NAME_SHA512_256 );
536+ ret = KcapiHashInit (& sha -> kcapi , heap , devid , WC_NAME_SHA512_256 );
537+ #if defined(WOLFSSL_SHA512_HASHTYPE )
538+ if (ret == 0 ) {
539+ sha -> hashType = WC_HASH_TYPE_SHA512_256 ;
540+ }
541+ #endif
542+ return ret ;
522543}
523544
524545
0 commit comments