TrustCore SDK Crypto Interface API reference  version 2.0
crypto_interface_nist_ctr_drbg.h File Reference

Cryptographic Interface header file for declaring NIST CTR DRBG functions. More...

Go to the source code of this file.

Functions

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_deleteContext (MOC_SYM(hwAccelDescr hwAccelCtx) randomContext **ppContext)
 Deletes a NIST Counter DRBG type context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_generate (MOC_SYM(hwAccelDescr hwAccelCtx) randomContext *pContext, const ubyte *pAdditionalInput, ubyte4 additionalInputLen, ubyte *pOutput, ubyte4 outputLenBits)
 Generates determinstic random bits from a previously initialized context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_generateSecret (MOC_SYM(hwAccelDescr hwAccelCtx) randomContext *pContext, ubyte *pAdditionalInput, ubyte4 additionalInputLen, ubyte *pSecret, ubyte4 secretLen)
 Generates a "secret" which consist of the internal state, ie the V and key, followed by the deterministic random bits that can be generated by that state. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_newContext (MOC_SYM(hwAccelDescr hwAccelCtx) randomContext **ppNewContext, const ubyte *pEntropyInput, ubyte4 keyLenBytes, ubyte4 outLenBytes, const ubyte *pPersonalization, ubyte4 personalizationLen)
 Creates and seeds a new random context of NIST Counter DRBG type with no derivation function. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_newDFContext (MOC_SYM(hwAccelDescr hwAccelCtx) randomContext **ppNewContext, ubyte4 keyLenBytes, ubyte4 outLenBytes, const ubyte *pEntropyInput, ubyte4 entropyInputLen, const ubyte *pNonce, ubyte4 nonceLen, const ubyte *pPersonalization, ubyte4 personalizationLen)
 Creates and seeds a new random context of NIST Counter DRBG type with the derivation function. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_numberGenerator (MOC_SYM(hwAccelDescr hwAccelCtx) randomContext *pContext, ubyte *pOutput, sbyte4 outputLenBytes)
 Generates determinstic random bytes from a previously initialized context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_reseed (MOC_SYM(hwAccelDescr hwAccelCtx) randomContext *pContext, const ubyte *pEntropyInput, ubyte4 entropyInputLen, const ubyte *pAdditionalInput, ubyte4 additionalInputLen)
 Reseeds a NICE counter DRBG type context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_setStateFromSecret (MOC_SYM(hwAccelDescr hwAccelCtx) randomContext *pContext, ubyte *pAdditionalInput, ubyte4 additionalInputLen, ubyte *pSecret, ubyte4 secretLen)
 Sets the state of a context to the state within the secret passed in. More...
 

Detailed Description

Function Documentation

◆ CRYPTO_INTERFACE_NIST_CTRDRBG_deleteContext()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_deleteContext ( MOC_SYM(hwAccelDescr hwAccelCtx) randomContext **  ppContext)
Parameters
ppContextPointer to the location that holds the context to be deleted.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_NIST_CTRDRBG_generate()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_generate ( MOC_SYM(hwAccelDescr hwAccelCtx) randomContext *  pContext,
const ubyte *  pAdditionalInput,
ubyte4  additionalInputLen,
ubyte *  pOutput,
ubyte4  outputLenBits 
)
Parameters
pContextPointer to an initialized randomContext.
pAdditionalInputAdditional input. This is optional and may be NULL.
additionalInputLenThe length of the additional input in bytes.
pOutputBuffer to hold the resulting deterministic bits. There should be enough space in this buffer to hold the number of requested bits rounded up to the next byte (ie multiple of 8).
outputLenBitsThe number of bits requested.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_NIST_CTRDRBG_generateSecret()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_generateSecret ( MOC_SYM(hwAccelDescr hwAccelCtx) randomContext *  pContext,
ubyte *  pAdditionalInput,
ubyte4  additionalInputLen,
ubyte *  pSecret,
ubyte4  secretLen 
)
Parameters
pContextPointer to an initialized randomContext.
pSecretPointer to a buffer that will hold the resulting secret.
secretLenThe length of the secret you desire. This must be at least the length of the key plus the output length.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_NIST_CTRDRBG_newContext()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_newContext ( MOC_SYM(hwAccelDescr hwAccelCtx) randomContext **  ppNewContext,
const ubyte *  pEntropyInput,
ubyte4  keyLenBytes,
ubyte4  outLenBytes,
const ubyte *  pPersonalization,
ubyte4  personalizationLen 
)
Parameters
ppNewContextPointer to the location that will receive the new context.
pEntropyInputThe seed. This must be keyLenBytes + outLenBytes in length.
keyLenBytesThe length of the block cipher key in bytes. This is typically 16, 24, or 32 for AES and 21 for 3DES.
outLenBytesThe block size of the block cipher, 16 for AES, 8 for 3DES.
pPersonalizationThe personalization string. This is optional and may be NULL.
personalizationLenThe length of the personalization string in bytes. This may not be bigger than keyLenBytes + outLenBytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_NIST_CTRDRBG_newDFContext()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_newDFContext ( MOC_SYM(hwAccelDescr hwAccelCtx) randomContext **  ppNewContext,
ubyte4  keyLenBytes,
ubyte4  outLenBytes,
const ubyte *  pEntropyInput,
ubyte4  entropyInputLen,
const ubyte *  pNonce,
ubyte4  nonceLen,
const ubyte *  pPersonalization,
ubyte4  personalizationLen 
)
Parameters
ppNewContextPointer to the location that will receive the new context.
keyLenBytesThe length of the block cipher key in bytes. This is typically 16, 24, or 32 for AES and 21 for 3DES.
outLenBytesThe block size of the block cipher, 16 for AES, 8 for 3DES.
pEntropyInputThe seed. This is required.
entropyInputLenThe length of the seed in bytes.
pNonceThe nonce. This is optional and may be NULL.
nonceLenThe length of the nonce in bytes.
pPersonalizationThe personalization string. This is optional and may be NULL.
personalizationLenThe length of the personalization string in bytes. No restriction on this length.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_NIST_CTRDRBG_numberGenerator()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_numberGenerator ( MOC_SYM(hwAccelDescr hwAccelCtx) randomContext *  pContext,
ubyte *  pOutput,
sbyte4  outputLenBytes 
)

This API does not allow the caller to pass in any additional entropy. Use CRYPTO_INTERFACE_NIST_CTRDRBG_generate to pass in additional entropy.

IMPORTANT: This API takes in a byte length for the output buffer as opposed to CRYPTO_INTERFACE_NIST_CTRDRBG_generate which takes in a bit length for the output buffer.

Parameters
pContextPointer to an initialized randomContext.
pOutputBuffer to hold the resulting deterministic bytes. There should be enough space in this buffer to hold the number of requested bytes.
outputLenBytesThe number of bytes requested.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_NIST_CTRDRBG_reseed()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_reseed ( MOC_SYM(hwAccelDescr hwAccelCtx) randomContext *  pContext,
const ubyte *  pEntropyInput,
ubyte4  entropyInputLen,
const ubyte *  pAdditionalInput,
ubyte4  additionalInputLen 
)
Parameters
pContextPointer to the context to be reseeded.
pEntropyInputThe new seed.
entropyInputLenThe length of the new seed in bytes.
pAdditionalInputAdditional input. This is optional and may be NULL.
additionalInputLenThe length of the additional input in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_NIST_CTRDRBG_setStateFromSecret()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_NIST_CTRDRBG_setStateFromSecret ( MOC_SYM(hwAccelDescr hwAccelCtx) randomContext *  pContext,
ubyte *  pAdditionalInput,
ubyte4  additionalInputLen,
ubyte *  pSecret,
ubyte4  secretLen 
)

The rest of the secret will be verified that it contains the deterministic bits that can be generated from that state and the state will be incrememted to the next state.

Parameters
pContextPointer to an initialized randomContext.
pSecretPointer to a buffer containing a secret.
secretLenThe length of the pSecret buffer in bytes.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.