diff options
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 20 |
1 files changed, 7 insertions, 13 deletions
@@ -302,7 +302,7 @@ static inline hal_hash_state_t *alloc_static_hash_state(void) #if HAL_STATIC_HASH_STATE_BLOCKS > 0 - for (int i = 0; i < sizeof(static_hash_state)/sizeof(*static_hash_state); i++) + for (size_t i = 0; i < sizeof(static_hash_state)/sizeof(*static_hash_state); i++) if ((static_hash_state[i].flags & STATE_FLAG_STATE_ALLOCATED) == 0) return &static_hash_state[i]; @@ -316,7 +316,7 @@ static inline hal_hmac_state_t *alloc_static_hmac_state(void) #if HAL_STATIC_HMAC_STATE_BLOCKS > 0 - for (int i = 0; i < sizeof(static_hmac_state)/sizeof(*static_hmac_state); i++) + for (size_t i = 0; i < sizeof(static_hmac_state)/sizeof(*static_hmac_state); i++) if ((static_hmac_state[i].hash_state.flags & STATE_FLAG_STATE_ALLOCATED) == 0) return &static_hmac_state[i]; @@ -347,8 +347,8 @@ static inline void swytebop(void *out_, const void * const in_, const size_t n, return; case 0x04030201: - for (int i = 0; i < n; i += w) - for (int j = 0; j < w && i + j < n; j++) + for (size_t i = 0; i < n; i += w) + for (size_t j = 0; j < w && i + j < n; j++) out[i + j] = in[i + w - j - 1]; return; @@ -443,10 +443,7 @@ hal_error_t hal_hash_initialize(hal_core_t *core, state->descriptor = descriptor; state->driver = driver; state->core = core; - state->flags = flags; - - if (state_buffer == NULL) - state->flags |= STATE_FLAG_STATE_ALLOCATED; + state->flags = flags | STATE_FLAG_STATE_ALLOCATED; *state_ = state; @@ -650,7 +647,7 @@ hal_error_t hal_hash_finalize(hal_hash_state_t *state, /* Opaqu hal_error_t err; uint8_t *p; size_t n; - int i; + size_t i; if (state == NULL || digest_buffer == NULL) return HAL_ERROR_BAD_ARGUMENTS; @@ -748,7 +745,7 @@ hal_error_t hal_hmac_initialize(hal_core_t *core, const hal_hash_driver_t * const driver = check_driver(descriptor); hal_hmac_state_t *state = state_buffer; hal_error_t err; - int i; + size_t i; if (descriptor == NULL || driver == NULL || state_ == NULL) return HAL_ERROR_BAD_ARGUMENTS; @@ -777,9 +774,6 @@ hal_error_t hal_hmac_initialize(hal_core_t *core, sizeof(state->hash_state))) != HAL_OK) goto fail; - if (state_buffer == NULL) - h->flags |= STATE_FLAG_STATE_ALLOCATED; - /* * If the supplied HMAC key is longer than the hash block length, we * need to hash the supplied HMAC key to get the real HMAC key. |