hu_RngANSIX931Create()

Creates an ANSI X9.31 RNG context object.

Synopsis:

#include "hurandom.h"
 
int hu_RngANSIX931Create(int alg, size_t keyLen, const unsigned char *key, size_t vLen, const unsigned char *v, hu_ReseedCallbackFunc *timeFunc, void *rsourceParam, sb_YieldCtx yieldCtx, sb_RNGCtx *rngCtx, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

alg

The algorithm to use. The acceptable values are: HU_RNG_X931_ALG_AES and HU_RNG_X931_ALG_3DES.

keyLen

The length (in bytes) of key. For AES, the acceptable values are: SB_AES_128_KEY_BYTES, SB_AES_192_KEY_BYTES and SB_AES_256_KEY_BYTES. For DES, the acceptable value is: 3*SB_DES_KEY_SIZE.

key

The symmetric algorithm key.

vLen

The length (in bytes) of the initial seed (v). When alg is set to HU_RNG_X931_ALG_AES, the buffer size must be 16 bytes. When alg is set to HU_RNG_X931_ALG_3DES, the buffer size must be 8 bytes.

v

The initial seed value.

timeFunc

A user-provided callback function. When called, the user is required to fill the buffer with the current time and date.

rsourceParam

This is user-defined data that will be passed to seedFunc. (Optional - set to NULL if not used.)

yieldCtx

A yield context. (Optional - set to NULL if not used.)

rngCtx

An RNG context object pointer.

sbCtx

A global context.

Library:

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

Description:

Any reseeding information in calls to hu_RngReseed() or hu_RngReseedGetBytes() will update the internal v state but will not affect the internal symmetric key.

Note: You must call hu_RngANSIX931Destroy() to destroy the context; the hu_RngDestroy() function cannot destroy an RNG context object created by hu_RngANSIX931Create().

Returns:

SB_ERR_NULL_CONTEXT_PTR

The RNG context object pointer is NULL.

SB_ERR_BAD_ALGORITHM

Unacceptable alg.

SB_ERR_BAD_KEY_LEN

Unacceptable keyLen.

SB_ERR_NULL_KEY

key is NULL.

SB_ERR_NULL_INPUT_BUF

seed is NULL.

SB_ERR_RNG_NULL_TIME_CALLBACK

timeFunc is NULL.

SB_ERR_BAD_INPUT_BUF_LEN

seedLen is less than required.

SB_SUCCESS

Success.