HashDataDefSrv returns Paramter Invalid

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HashDataDefSrv returns Paramter Invalid

Jump to solution
757 Views
R_S002
Contributor III

Hi, @lukaszadrapa 

I'm using 

HseResponse = HashDataDefSrv(HSE_HASH_ALGO_SHA2_256,(uint32_t) sizeof(test), test, &image_hash_length, image_hash, HSE_SGT_OPTION_NONE);

function for calculating the HASH of an image stored as const uint_8 [], and I'm getting returned with Parameter Invalid. So I decided to test the hash on a smaller array, but with a similar issue.

Please help in resolving this issue!

Additionally, I found a glitch when using HSE with RTD 3.0.0, which is:-

When I run my code without any breakpoint, my HSE API are always responding NOT_OK(not ok means anything besides the HSE_OK or HSE_SUCCESS), but when I manually jump over these API, I get HSE_SUCCESS

Tags (2)
0 Kudos
Reply
1 Solution
276 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Here is simple example I used in the past:

 

int main(void) {

hseSrvResponse_t HseResponse;
uint8_t hash_result[64] = {0U};
uint32_t hash_length = 64U;

/*Check Fw Install Status*/
WaitForHSEFWInitToFinish();

/* used test vectors: https://www.di-mgt.com.au/sha_testvectors.html */
/* Input message: one million (1,000,000) repetitions of the character "a" (0x61). */
/* SHA-512 */
/* Expected result: */
/* e718483d0ce76964 4e2e42c7bc15b463 8e1f98b13b204428 5632a803afa973eb de0ff244877ea60a 4cb0432ce577c31b eb009c5c2c49aa2e 4eadb217ad8cc09b */

HseResponse = HSE_HashDataBlocking
(
MU0,
HSE_ACCESS_MODE_ONE_PASS,
0,
HSE_HASH_ALGO_SHA2_512,
0x408000U, /* use attached cmm script to program one million of 'a' characters to this address */
1000000, /* length of data one million */
hash_result,
&hash_length
);

 

for (;;) {

}

}

 

The data to hash were programmed by external script to the flash. 

View solution in original post

0 Kudos
Reply
9 Replies
731 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @R_S002 

As a first step, could  you try to disable data cache in your project? This is common reason for HSE_SRV_RSP_INVALID_PARAM error. All data objects used for communication with HSE must be forced to non-cacheable memory. Disabling of the data cache will quickly confirm if this is the case.

Regards,

Lukas

0 Kudos
Reply
706 Views
R_S002
Contributor III

Hi @lukaszadrapa 
I tried your solution(Disabling D_CACHE_ENABLE), but it didn't work.

and you didnt mention anything about my additional issue.

Tags (2)
0 Kudos
Reply
681 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

If it is not caused by data cache, I would need more details for both issues. 

For the hash service, could you take a screenshot of the service descriptor right before sending it to HSE? 

And regarding the second issue - could you check what error code was returned by HSE exactly? If it works when stepping the code, it could be some kind of timing issue or coherency issue. Did you try to disable interrupts when executing these HSE services?

0 Kudos
Reply
635 Views
R_S002
Contributor III

R_S002_0-1764847866495.png

Hi @lukaszadrapa 

Image of HASH Function before execution

0 Kudos
Reply
599 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

I did very quick test on my board and I can see the same problem. I have never had a problem with hashing, so let me check what's going on. I'm running out of time today, so I will check it next week. 

Regards,

Lukas

0 Kudos
Reply
402 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Ok, it's caused by pHashLength, most likely. The variable where this pointer points must be initialized to size of your hash buffer. It must not be zero. HSE Service API reference manual says:

"INPUT/OUTPUT: Pointer to a uint32_t location in which the hash length
in bytes is stored. On calling this service, this parameter shall contain the
size of the buffer provided by host. When the request has fi nished, the
actual length of the returned value shall be stored. If the buffer is smaller
than the size of the hash, the hash will be truncated"

So, please check the content of this parameter. 

 

0 Kudos
Reply
301 Views
R_S002
Contributor III

Can you share an example of how you tried and verified the HASH Function?

Tags (2)
0 Kudos
Reply
277 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Here is simple example I used in the past:

 

int main(void) {

hseSrvResponse_t HseResponse;
uint8_t hash_result[64] = {0U};
uint32_t hash_length = 64U;

/*Check Fw Install Status*/
WaitForHSEFWInitToFinish();

/* used test vectors: https://www.di-mgt.com.au/sha_testvectors.html */
/* Input message: one million (1,000,000) repetitions of the character "a" (0x61). */
/* SHA-512 */
/* Expected result: */
/* e718483d0ce76964 4e2e42c7bc15b463 8e1f98b13b204428 5632a803afa973eb de0ff244877ea60a 4cb0432ce577c31b eb009c5c2c49aa2e 4eadb217ad8cc09b */

HseResponse = HSE_HashDataBlocking
(
MU0,
HSE_ACCESS_MODE_ONE_PASS,
0,
HSE_HASH_ALGO_SHA2_512,
0x408000U, /* use attached cmm script to program one million of 'a' characters to this address */
1000000, /* length of data one million */
hash_result,
&hash_length
);

 

for (;;) {

}

}

 

The data to hash were programmed by external script to the flash. 

0 Kudos
Reply
672 Views
R_S002
Contributor III

hi @lukaszadrapa 

I'll provide the service descriptor once I get back to the office

Second issue returns HSE_SRV_RSP_NOT_SUPPORTED. Can you elaborate more precisely about "disabling interrupts"?

Tags (2)
0 Kudos
Reply