@@ -9,21 +9,19 @@ LOG_MODULE_DECLARE(updatehub, CONFIG_UPDATEHUB_LOG_LEVEL);
99
1010#include "updatehub_integrity.h"
1111
12- #define SUCCESS_VALUE PSA_SUCCESS
13-
1412int updatehub_integrity_init (updatehub_crypto_context_t * ctx )
1513{
16- int ret ;
14+ psa_status_t status ;
1715
1816 if (ctx == NULL ) {
1917 LOG_DBG ("Invalid integrity context" );
2018 return - EINVAL ;
2119 }
2220
2321 * ctx = psa_hash_operation_init ();
24- ret = psa_hash_setup (ctx , PSA_ALG_SHA_256 );
25- if (ret != SUCCESS_VALUE ) {
26- LOG_DBG ("Failed to %s SHA-256 operation. (%d)" , "set up" , ret );
22+ status = psa_hash_setup (ctx , PSA_ALG_SHA_256 );
23+ if (status != PSA_SUCCESS ) {
24+ LOG_DBG ("Failed to %s SHA-256 operation. (%d)" , "set up" , status );
2725 return - EFAULT ;
2826 }
2927
@@ -33,7 +31,7 @@ int updatehub_integrity_init(updatehub_crypto_context_t *ctx)
3331int updatehub_integrity_update (updatehub_crypto_context_t * ctx ,
3432 const uint8_t * buffer , const uint32_t len )
3533{
36- int ret ;
34+ psa_status_t status ;
3735
3836 if (ctx == NULL || buffer == NULL ) {
3937 return - EINVAL ;
@@ -44,10 +42,10 @@ int updatehub_integrity_update(updatehub_crypto_context_t *ctx,
4442 return 0 ;
4543 }
4644
47- ret = psa_hash_update (ctx , buffer , len );
48- if (ret != SUCCESS_VALUE ) {
45+ status = psa_hash_update (ctx , buffer , len );
46+ if (status != PSA_SUCCESS ) {
4947 psa_hash_abort (ctx );
50- LOG_DBG ("Failed to %s SHA-256 operation. (%d)" , "update" , ret );
48+ LOG_DBG ("Failed to %s SHA-256 operation. (%d)" , "update" , status );
5149 return - EFAULT ;
5250 }
5351
@@ -57,7 +55,7 @@ int updatehub_integrity_update(updatehub_crypto_context_t *ctx,
5755int updatehub_integrity_finish (updatehub_crypto_context_t * ctx ,
5856 uint8_t * hash , const uint32_t size )
5957{
60- int ret ;
58+ psa_status_t status ;
6159 size_t hash_len ;
6260
6361 if (ctx == NULL || hash == NULL ) {
@@ -69,10 +67,10 @@ int updatehub_integrity_finish(updatehub_crypto_context_t *ctx,
6967 return - EINVAL ;
7068 }
7169
72- ret = psa_hash_finish (ctx , hash , size , & hash_len );
73- if (ret != SUCCESS_VALUE ) {
70+ status = psa_hash_finish (ctx , hash , size , & hash_len );
71+ if (status != PSA_SUCCESS ) {
7472 psa_hash_abort (ctx );
75- LOG_DBG ("Failed to %s SHA-256 operation. (%d)" , "finish" , ret );
73+ LOG_DBG ("Failed to %s SHA-256 operation. (%d)" , "finish" , status );
7674 return - EFAULT ;
7775 }
7876
0 commit comments