The latest development version of this page may be more current than this released 2.3-beta.1 version.

Hash API Reference

Hash

typedef wm_hal_hash_cfg_t wm_drv_hash_cfg_t
wm_device_t *wm_drv_hash_init(const char *dev_name)

Initialize HASH driver.

Note

This API must be called before all other HASH API can be called

Parameters:

dev_name – HASH device name

Returns:

  • NULL: failed

  • others: HASH driver device

int wm_drv_hash_deinit(wm_device_t *dev)

Deinitialize HASH driver.

Parameters:

dev – HASH driver device

Returns:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

int wm_drv_md5_start(wm_device_t *dev, wm_drv_hash_cfg_t *ctx)

Setup the MD5 configuration.

Note

The parameter ctx must be a structure which is allocated externally.

Parameters:
  • dev[in] Pointer to the MD5 device structure.

  • ctx[in] Pointer to a MD5 Context.

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_md5_update(wm_device_t *dev, wm_drv_hash_cfg_t *ctx, const unsigned char *in, uint32_t len)

Process a message block using MD5 algorithm. This function performs a MD5 block update operation. It continues an MD5 message-digest operation, by processing len length message block pointed to by in, and by updating the MD5 context pointed to by dev. This function may be called as many times as necessary, so the message may be processed in blocks.

Note

Digest is not retrieved by this API, user must resort to wm_drv_md5_final() to read it.

Parameters:
  • dev[in] Pointer to the MD5 device structure.

  • ctx[in] Pointer to a MD5 Context.

  • in[in] Pointer to the input buffer (buffer to be hashed).

  • len[in] input data length in bytes

Returns:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • Other error codes based on the update process

int wm_drv_md5_final(wm_device_t *dev, wm_drv_hash_cfg_t *ctx, unsigned char *out)

End computation of a single HASH signature after several calls to wm_drv_md5_update() API.

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • Other error codes based on the update process

Note

Digest is available in pOutBuffer.

Parameters:
  • dev[in] Pointer to the MD5 device structure.

  • ctx[in] Pointer to a MD5 Context.

  • out[out] pointer to the computed digest. Digest size is 20 bytes.

int wm_drv_md5(const void *in_buf, unsigned int in_len, void *md5_hash)

Compute a single HASH signature.

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • Other error codes based on the update process

Parameters:
  • in_buf[in] Pointer to the input buffer (buffer to be hashed).

  • in_len[in] input data length in bytes.

  • md5_hash[out] pointer to the computed digest. Digest size is 20 bytes..

int wm_drv_sha1_start(wm_device_t *dev, wm_drv_hash_cfg_t *ctx)

Setup the SHA1 configuration.

Parameters:
  • dev[in] Pointer to the SHA1 device structure.

  • ctx[in] Pointer to a SHA1 Context.

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_sha1_update(wm_device_t *dev, wm_drv_hash_cfg_t *ctx, const unsigned char *in, uint32_t len)

Process a message block using SHA1 algorithm. This function performs a SHA1 block update operation. It continues an SHA1 message-digest operation, by processing len length message block pointed to by in, and by updating the SHA1 context pointed to by dev. This function may be called as many times as necessary, so the message may be processed in blocks.

Note

Digest is not retrieved by this API, user must resort to wm_drv_sha1_final() to read it.

Parameters:
  • dev[in] Pointer to the SHA1 device structure.

  • ctx[in] Pointer to a SHA1 Context.

  • in[in] Pointer to the input buffer (buffer to be hashed).

  • len[in] input data length in bytes

Returns:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • Other error codes based on the update process

int wm_drv_sha1_final(wm_device_t *dev, wm_drv_hash_cfg_t *ctx, unsigned char *out)

End computation of a single HASH signature after several calls to wm_drv_sha1_update() API.

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • Other error codes based on the update process

Note

Digest is available in pOutBuffer.

Parameters:
  • dev[in] Pointer to the SHA1 device structure.

  • ctx[in] Pointer to a SHA1 Context.

  • out[out] pointer to the computed digest. Digest size is 20 bytes.