这是最新(主)开发分支的文档。如果您正在查找以前版本的文档,使用左侧的下拉菜单选择所需的版本。

Hash API 参考

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.

备注

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

参数:

dev_name – HASH device name

返回:

  • NULL: failed

  • others: HASH driver device

int wm_drv_hash_deinit(wm_device_t *dev)

Deinitialize HASH driver.

参数:

dev – HASH driver device

返回:

  • 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.

备注

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

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

  • ctx[in] Pointer to a MD5 Context.

返回:

  • 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.

备注

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

参数:
  • 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

返回:

  • 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

备注

Digest is available in pOutBuffer.

参数:
  • 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

参数:
  • 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.

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

  • ctx[in] Pointer to a SHA1 Context.

返回:

  • 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.

备注

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

参数:
  • 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

返回:

  • 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

备注

Digest is available in pOutBuffer.

参数:
  • 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.