Hello,
While developping firmware I wanted to use the PSA API psa_hash_compute() to compute a hash over 8 bytes but to no avail. The function returns -134 and the out parameter holding the hash value is all 0s.
I Tried running the sample from nrf/samples/crypto/sha256 and got the same results. I setup the sample on SDK v2.7.0 with nrf5340dk/nrf5340/cpuapp/ns as Board Target. I removed the return statements in the main.c function to let also verify_sha256() and the following functions execute, otherwise the code would return on line 178 after hash_singlepart_sha256 had failed.
Here is the log output:
*** Booting nRF Connect SDK v2.7.0-5cb85570ca43 *** *** Using Zephyr OS v3.6.99-100befc70c74 *** [00:00:00.260,742] <inf> sha256: Starting SHA256 example... [00:00:00.260,772] <inf> sha256: ---- Plaintext to hash (len: 150): ---- [00:00:00.260,803] <inf> sha256: Content: 45 78 61 6d 70 6c 65 20 73 74 72 69 6e 67 20 74 |Example string t 6f 20 64 65 6d 6f 6e 73 74 72 61 74 65 20 62 61 |o demons trate ba 73 69 63 20 75 73 61 67 65 20 6f 66 20 53 48 41 |sic usag e of SHA 32 35 36 2e 54 68 61 74 20 75 73 65 73 20 73 69 |256.That uses si 6e 67 6c 65 20 61 6e 64 20 6d 75 6c 74 69 2d 70 |ngle and multi-p 61 72 74 20 50 53 41 20 63 72 79 70 74 6f 20 41 |art PSA crypto A 50 49 27 73 20 74 6f 20 70 65 72 66 6f 72 6d 20 |PI's to perform 61 20 53 48 41 2d 32 35 36 20 68 61 73 68 69 6e |a SHA-25 6 hashin 67 20 6f 70 65 72 61 74 69 6f 6e 2e 00 00 00 00 |g operat ion..... 00 00 00 00 00 00 |...... [00:00:00.260,833] <inf> sha256: ---- Plaintext to hash end ---- [00:00:00.260,833] <inf> sha256: Hashing using SHA256... [00:00:00.260,925] <inf> sha256: psa_hash_compute failed! (Error: -134) [00:00:00.260,925] <inf> sha256: Example exited with error! [00:00:00.260,955] <inf> sha256: Verifying the SHA256 hash... [00:00:00.261,016] <inf> sha256: psa_hash_compare failed! (Error: -134) [00:00:00.261,016] <inf> sha256: Example exited with error! [00:00:00.261,047] <inf> sha256: Hashing using multi-part SHA256... [00:00:00.261,108] <err> sha256: Could not setup the hash operation! Error -134 [00:00:00.261,108] <inf> sha256: Example exited with error! [00:00:00.261,108] <inf> sha256: Verifying the SHA256 hash... [00:00:00.261,199] <inf> sha256: psa_hash_compare failed! (Error: -134) [00:00:00.261,199] <inf> sha256: Example exited with error! [00:00:00.261,199] <inf> sha256: Example finished successfully!
What am I missing? Can you try to run the sample on a DK to confirm the behaviour that I get? Could it be possible to add rudimentary explanations on how to interact with the PSA API in the README of the sample?
Regards
Colin