hu_RngGetState()

Retrieves the RNG context state.

Synopsis:

#include "hurandom.h"
 
int hu_RngGetState(sb_RNGCtx rngCtx, size_t *stateLen, unsigned char *state, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

rngCtx

An RNG context object pointer.

stateLen

The length (in bytes) of v.

state

The PRNG running secret.

sbCtx

A global context.

Library:

libhuapi (For the qcc command, use the -l huapi option to link against this library)

Description:

This function allows you to retrieve the running secret, state, which is associated with the PRNG specification.

This function can be useful if you want the PRNG byte stream to survive a reboot or a program restart. In order to restore the PRNG byte stream, you need to know the initial seeding values, and call this API to retrieve the value of state before the rngCtx is destroyed. If you have these values, then after the reboot or program restart, the seeding values and state value can be passed to the RNG create function, which will restore the PRNG byte stream to its state prior to the disruption.

If you use this API, you must ensure that the stored seed and state are kept secret; otherwise this will reduce the overall security of your system. We recommend that you not use this API unless you are very familiar with cryptographic issues.

For PRNG X.931 the running state is v.

Returns:

SB_ERR_NULL_CONTEXT

The RNG context is NULL.

SB_ERR_NULL_OUTPUT_BUF_LEN

stateLen is NULL.

SB_ERR_BAD_CONTEXT

The RNG context is invalid.

SB_ERR_BAD_OUTPUT_BUF_LEN

stateLen is not big enough.

SB_SUCCESS

Success.