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

RNG API 参考

RNG

typedef wm_hal_rng_cfg_t wm_drv_rng_cfg_t
wm_device_t *wm_drv_rng_init(const char *dev_name)

Initialize RNG driver.

备注

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

参数:

dev_name – RNG device name

返回:

  • NULL: failed

  • others: RNG driver device

int wm_drv_rng_deinit(wm_device_t *dev)

Release access to GPSEC hardware and deinitialize RNG driver.

参数:

dev – RNG driver device

返回:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

uint32_t wm_drv_rng_read(wm_device_t *dev)

Get one random from hardware RNG.

参数:

dev[in] Pointer to the RNG device structure.

返回:

Random value

int wm_drv_rng_read_bytes(wm_device_t *dev, void *buf, uint32_t len)

Fill a buffer with random from hardware RNG.

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

  • buf[in] Pointer to buffer to fill with random numbers.

  • len[in] Length of buffer in bytes

返回:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

int wm_drv_fill_random(void *buf, uint32_t len)

Fill a buffer with random from hardware RNG.

参数:
  • buf[in] Pointer to buffer to fill with random numbers.

  • len[in] Length of buffer in bytes

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed