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

fsl_shw_return_t fsl_shw_hash ( fsl_shw_uco_t user_ctx,
fsl_shw_hco_t hash_ctx,
const uint8_t *  msg,
uint32_t  length,
uint8_t *  result,
uint32_t  result_len 
)

Hash a stream of data with a cryptographic hash algorithm.

The flags in the hash_ctx control the operation of this function.

Hashing functions work on 64 octets of message at a time. Therefore, when any partial hashing of a long message is performed, the message length of each segment must be a multiple of 64. When ready to FSL_HASH_FLAGS_FINALIZE the hash, the length may be any value.

With the FSL_HASH_FLAGS_INIT and FSL_HASH_FLAGS_FINALIZE flags on, a one-shot complete hash, including padding, will be performed. The length may be any value.

The first octets of a data stream can be hashed by setting the FSL_HASH_FLAGS_INIT and FSL_HASH_FLAGS_SAVE flags. The length must be a multiple of 64.

The flag FSL_HASH_FLAGS_LOAD is used to load a context previously saved by FSL_HASH_FLAGS_SAVE. The two in combination will allow a (multiple-of-64 octets) 'middle sequence' of the data stream to be hashed with the beginning. The length must again be a multiple of 64.

Since the flag FSL_HASH_FLAGS_LOAD is used to load a context previously saved by FSL_HASH_FLAGS_SAVE, the FSL_HASH_FLAGS_LOAD and FSL_HASH_FLAGS_FINALIZE flags, used together, can be used to finish the stream. The length may be any value.

If the user program wants to do the padding for the hash, it can leave off the FSL_HASH_FLAGS_FINALIZE flag. The length must then be a multiple of 64 octets.

Parameters:
user_ctx A user context from fsl_shw_register_user().
[in,out] hash_ctx Hashing algorithm and state of the cipher.
msg Pointer to the data to be hashed.
length Length, in octets, of the msg.
[out] result If not null, pointer to where to store the hash digest.
result_len Number of octets to store in result.
Returns:
A return code of type fsl_shw_return_t.

Definition at line 67 of file fsl_shw_hash.c.

References fsl_shw_hco_t::algorithm, fsl_shw_hco_t::context, fsl_shw_hco_t::context_register_length, DESC_IN_IN, DESC_IN_OUT, fsl_shw_hco_t::digest_length, fsl_shw_hco_t::flags, FSL_HASH_FLAGS_FINALIZE, FSL_HASH_FLAGS_INIT, FSL_HASH_FLAGS_LOAD, FSL_HASH_FLAGS_SAVE, FSL_RETURN_BAD_FLAG_S, FSL_RETURN_ERROR_S, SAH_HDR_MDHA_HASH, SAH_HDR_MDHA_SET_MODE_HASH, SAH_HDR_MDHA_SET_MODE_MD_KEY, SAH_HDR_MDHA_STORE_DIGEST, and sah_insert_mdha_algorithm.

{
      fsl_shw_return_t ret = FSL_RETURN_ERROR_S;

      /* Unused */
      (void)user_ctx;
      (void)hash_ctx;
      (void)msg;
      (void)length;
      (void)result;
      (void)result_len;

      return ret;
}


Generated by  Doxygen 1.6.0   Back to index