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

RNG API Reference

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.

Note

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

Parameters:

dev_name – RNG device name

Returns:

  • NULL: failed

  • others: RNG driver device

int wm_drv_rng_deinit(wm_device_t *dev)

Release access to GPSEC hardware and deinitialize RNG driver.

Parameters:

dev – RNG driver device

Returns:

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

Parameters:

dev[in] Pointer to the RNG device structure.

Returns:

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.

Parameters:
  • 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

Returns:

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

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

  • len[in] Length of buffer in bytes

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed