TrustCore SDK NanoCrypto API reference  version 7.0
nist_drbg_hash.h File Reference

Header file for the NanoCrypto NIST Deterministic Random Bit Generator. More...

Go to the source code of this file.

Typedefs

typedef MSTATUS(* DrbgHashMethod) (ubyte *pInput, ubyte4 inputLen, ubyte *pOutput)
 Function pointer type for a method that hashes input data in one shot. More...
 

Functions

MOC_EXTERN MSTATUS NIST_HASHDRBG_deleteContext (MOC_SYM(hwAccelDescr hwAccelCtx) NIST_HASH_DRBG_Ctx **ppContext)
 Deletes a hash drbg context. More...
 
MOC_EXTERN MSTATUS NIST_HASHDRBG_generate (MOC_SYM(hwAccelDescr hwAccelCtx) NIST_HASH_DRBG_Ctx *pContext, ubyte *pAdditionalInput, ubyte4 additionalInputLen, ubyte *pOutput, ubyte4 outputLenBytes)
 Generates deterministic bits from a seeded drbg hash context with an additional data input option. More...
 
MOC_EXTERN MSTATUS NIST_HASHDRBG_newSeededContext (MOC_SYM(hwAccelDescr hwAccelCtx) NIST_HASH_DRBG_Ctx **ppNewContext, ubyte *pEntropyInput, ubyte4 entropyInputLen, ubyte *pNonce, ubyte4 nonceLen, ubyte *pPersonalization, ubyte4 personalizationLen, DrbgHashMethod hashMethod, ubyte4 hashOutLenBytes)
 Allocates and seeds a new hash drbg context. More...
 
MOC_EXTERN MSTATUS NIST_HASHDRBG_numberGenerator (MOC_SYM(hwAccelDescr hwAccelCtx) NIST_HASH_DRBG_Ctx *pRandomContext, ubyte *pBuffer, sbyte4 bufferLen)
 Generates deterministic bits from a seeded drbg hash context. More...
 
MOC_EXTERN MSTATUS NIST_HASHDRBG_reSeed (MOC_SYM(hwAccelDescr hwAccelCtx) NIST_HASH_DRBG_Ctx *pContext, ubyte *pEntropyInput, ubyte4 entropyInputLen, ubyte *pAdditionalInput, ubyte4 additionalInputLen)
 Reseeds a previously existing hash drbg context. More...
 
MOC_EXTERN sbyte4 NIST_HASHDRBG_rngFun (MOC_SYM(hwAccelDescr hwAccelCtx) void *pRngFunArg, ubyte4 length, ubyte *pBuffer)
 Generates deterministic bits in an RNGFun function pointer form. More...
 

Detailed Description

Header file for the NanoCrypto NIST Deterministic Random Bit Generator.

To enable this file's methods define the following flag:

  • __ENABLE_MOCANA_NIST_DRBG_HASH__

nist_drbg_hash.h

Typedef Documentation

◆ DrbgHashMethod

typedef MSTATUS(* DrbgHashMethod) (ubyte *pInput, ubyte4 inputLen, ubyte *pOutput)

Function pointer type for a method that hashes input data in one shot.

nist_drbg_hash.h

Parameters
pInputBuffer holding the input data.
inputLenThe length of the input data in bytes.
pOutputBuffer to hold the resulting output.

To enable this method define the following flag:

  • __ENABLE_MOCANA_NIST_DRBG_HASH__
Returns
Must return OK (0) if successful and non-zero if unsuccessful.

nist_drbg_hash.h

Function Documentation

◆ NIST_HASHDRBG_deleteContext()

MOC_EXTERN MSTATUS NIST_HASHDRBG_deleteContext ( MOC_SYM(hwAccelDescr hwAccelCtx) NIST_HASH_DRBG_Ctx **  ppContext)

Zeroes and frees memory allocated for a hash drbg context.

Parameters
ppContextPointer to the location of the context to be deleted.

To enable this method define the following flag:

  • __ENABLE_MOCANA_NIST_DRBG_HASH__
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

nist_drbg_hash.h

◆ NIST_HASHDRBG_generate()

MOC_EXTERN MSTATUS NIST_HASHDRBG_generate ( MOC_SYM(hwAccelDescr hwAccelCtx) NIST_HASH_DRBG_Ctx *  pContext,
ubyte *  pAdditionalInput,
ubyte4  additionalInputLen,
ubyte *  pOutput,
ubyte4  outputLenBytes 
)

Generates deterministic bits from a seeded drbg hash context with an additional data input option. The number of bits requested and output will actually be measured in bytes.

Parameters
pContextPointer to a previously seeded context.
pAdditionalInputOptional. Buffer holding additional input data as a byte array.
additionalInputLenThe length of the additional input data in bytes.
pOutputBuffer to hold the resulting output bytes.
outputLenBytesThe number of output bytes requested.

To enable this method define the following flag:

  • __ENABLE_MOCANA_NIST_DRBG_HASH__
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

nist_drbg_hash.h

◆ NIST_HASHDRBG_newSeededContext()

MOC_EXTERN MSTATUS NIST_HASHDRBG_newSeededContext ( MOC_SYM(hwAccelDescr hwAccelCtx) NIST_HASH_DRBG_Ctx **  ppNewContext,
ubyte *  pEntropyInput,
ubyte4  entropyInputLen,
ubyte *  pNonce,
ubyte4  nonceLen,
ubyte *  pPersonalization,
ubyte4  personalizationLen,
DrbgHashMethod  hashMethod,
ubyte4  hashOutLenBytes 
)

Allocates and seeds a new hash drbg context. Please be sure to call NIST_HASHDRBG_deleteContext to free this context when done with it.

Parameters
ppNewContextPointer to the location that will receive the newly allocated and seeded context.
pEntropyInputBuffer of input entropy (also known as the seed).
entropyInputLenThe length of the input entropy in bytes.
pNonceOptional. Buffer holding the nonce as a byte array.
nonceLenThe length of the nonce in bytes.
pPersonalizationOptional. Buffer holding the personalization data as a byte array.
personalizationLenThe length of the personalization data in bytes.
hashMethodFunction pointer to the hashing method to be used.
hashOutLenBytesThe output length of the hashMethod chosen.

To enable this method define the following flag:

  • __ENABLE_MOCANA_NIST_DRBG_HASH__
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

nist_drbg_hash.h

◆ NIST_HASHDRBG_numberGenerator()

MOC_EXTERN MSTATUS NIST_HASHDRBG_numberGenerator ( MOC_SYM(hwAccelDescr hwAccelCtx) NIST_HASH_DRBG_Ctx *  pRandomContext,
ubyte *  pBuffer,
sbyte4  bufferLen 
)

Generates deterministic bits from a seeded drbg hash context. The number of bits requested and output will actually be measured in bytes. For generating bits from additional input use NIST_HASHDRBG_generate instead.

Parameters
pContextPointer to a previously seeded context.
pOutputBuffer to hold the resulting output bytes.
outputLenBytesThe number of output bytes requested.

To enable this method define the following flag:

  • __ENABLE_MOCANA_NIST_DRBG_HASH__
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

nist_drbg_hash.h

◆ NIST_HASHDRBG_reSeed()

MOC_EXTERN MSTATUS NIST_HASHDRBG_reSeed ( MOC_SYM(hwAccelDescr hwAccelCtx) NIST_HASH_DRBG_Ctx *  pContext,
ubyte *  pEntropyInput,
ubyte4  entropyInputLen,
ubyte *  pAdditionalInput,
ubyte4  additionalInputLen 
)

Reseeds a previously existing hash drbg context.

Parameters
pContextPointer to the context to be reseeded.
pEntropyInputBuffer of input entropy (also known as the seed).
entropyInputLenThe length of the input entropy in bytes.
pAdditionalInputOptional. Buffer holding additional input data as a byte array.
additionalInputLenThe length of the additional input data in bytes.

To enable this method define the following flag:

  • __ENABLE_MOCANA_NIST_DRBG_HASH__
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

nist_drbg_hash.h

◆ NIST_HASHDRBG_rngFun()

MOC_EXTERN sbyte4 NIST_HASHDRBG_rngFun ( MOC_SYM(hwAccelDescr hwAccelCtx) void *  pRngFunArg,
ubyte4  length,
ubyte *  pBuffer 
)

Generates deterministic bits in an RNGFun function pointer form. Please see random.h for a description of this form. The number of bits requested and output will actually be measured in bytes.

Parameters
pRngFunArgPointer to a previously seeded hash drbg context.
lengthThe number of output bytes requested.
pBufferBuffer to hold the resulting output bytes.

To enable this method define the following flag:

  • __ENABLE_MOCANA_NIST_DRBG_HASH__
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

nist_drbg_hash.h