@@ -3027,14 +3027,14 @@ static int _HandleSha512Dma(whServerContext* ctx, uint16_t magic, uint16_t seq,
30273027 whMessageCrypto_Sha512DmaResponse res ;
30283028 wc_Sha512 * sha512 = ctx -> crypto -> algoCtx .sha512 ;
30293029 int clientDevId ;
3030+ int hashType = WC_HASH_TYPE_SHA512 ;
30303031
30313032 /* Translate the request */
30323033 ret = wh_MessageCrypto_TranslateSha512DmaRequest (
30333034 magic , (whMessageCrypto_Sha512DmaRequest * )cryptoDataIn , & req );
30343035 if (ret != WH_ERROR_OK ) {
30353036 return ret ;
30363037 }
3037-
30383038 /* Ensure state sizes are the same */
30393039 if (req .state .sz != sizeof (* sha512 )) {
30403040 res .dmaAddrStatus .badAddr = req .state ;
@@ -3054,6 +3054,8 @@ static int _HandleSha512Dma(whServerContext* ctx, uint16_t magic, uint16_t seq,
30543054 clientDevId = sha512 -> devId ;
30553055 /* overwrite the devId to that of the server for local crypto */
30563056 sha512 -> devId = ctx -> crypto -> devId ;
3057+ /* retrieve hash Type to handle 512, 512-224, or 512-256 */
3058+ hashType = sha512 -> hashType ;
30573059 }
30583060 }
30593061
@@ -3073,8 +3075,19 @@ static int _HandleSha512Dma(whServerContext* ctx, uint16_t magic, uint16_t seq,
30733075 if (ret == WH_ERROR_OK ) {
30743076#ifdef DEBUG_CRYPTOCB_VERBOSE
30753077 printf ("[server] wc_Sha512Final: outAddr=%p\n" , outAddr );
3078+ printf ("[server] hashTpe: %d\n" , hashType );
30763079#endif
3077- ret = wc_Sha512Final (sha512 , outAddr );
3080+ switch (hashType ) {
3081+ case WC_HASH_TYPE_SHA512_224 :
3082+ ret = wc_Sha512_224Final (sha512 , outAddr );
3083+ break ;
3084+ case WC_HASH_TYPE_SHA512_256 :
3085+ ret = wc_Sha512_256Final (sha512 , outAddr );
3086+ break ;
3087+ default :
3088+ ret = wc_Sha512Final (sha512 , outAddr );
3089+ break ;
3090+ }
30783091 }
30793092
30803093 if (ret == WH_ERROR_OK ) {
0 commit comments