Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

fsl_shw_return_t shw_hash_update ( shw_hash_state_t state,
const uint8_t *  input,
unsigned int  input_len 

Put data into the hash calculation

state Address of hash state structure.
msg Address of the message data for the hash.
msg_len Number of bytes of msg.
FSL_RETURN_OK_S if all went well, otherwise an error code.
Add input bytes to the hash

The bytes are added to the partial_block element of the hash state, and as the partial block is filled, it is processed by sha1_process_block(). This function also updates the bit_count element of the hash state.

state Address of hash state structure
input Address of bytes to add to the hash
input_len Numbef of bytes at input

Definition at line 229 of file shw_hash.c.

References shw_hash_state::bit_count, FSL_RETURN_OK_S, shw_hash_state::partial_block, shw_hash_state::partial_count_bytes, and sha256_process_block().

Referenced by shw_hash_final(), shw_hmac_final(), shw_hmac_init(), and shw_hmac_update().

      unsigned int bytes_needed;    /* Needed to fill a block */
      unsigned int bytes_to_copy;   /* to copy into the block */

      /* Account for new data */
      state->bit_count += 8 * input_len;

       * Process input bytes into the ongoing block; process the block when it
       * gets full.
      while (input_len > 0) {
            bytes_needed = SHW_HASH_BLOCK_LEN - state->partial_count_bytes;
            bytes_to_copy = ((input_len < bytes_needed) ?
                         input_len : bytes_needed);

            /* Add in the bytes and do the accounting */
            memcpy(state->partial_block + state->partial_count_bytes,
                   input, bytes_to_copy);
            input += bytes_to_copy;
            input_len -= bytes_to_copy;
            state->partial_count_bytes += bytes_to_copy;

            /* Run a full block through the transform */
            if (state->partial_count_bytes == SHW_HASH_BLOCK_LEN) {
                  state->partial_count_bytes = 0;

      return FSL_RETURN_OK_S;
}                       /* end fn shw_hash_update */

Generated by  Doxygen 1.6.0   Back to index