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

Documentation file for the SHA3 APIs. More...

Go to the source code of this file.

Functions

MOC_EXTERN MSTATUS SHA3_allocDigest (MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *pSha3_ctx)
 Allocates the SHA3_CTX context data structure. More...
 
MOC_EXTERN MSTATUS SHA3_cloneCtx (MOC_HASH(hwAccelDescr hwAccelCtx) SHA3_CTX *pDest, SHA3_CTX *pSrc)
 Makes a clone of a previously allocated SHA3_CTX. More...
 
MOC_EXTERN MSTATUS SHA3_completeDigest (MOC_HASH(hwAccelDescr hwAccelCtx) ubyte4 mode, ubyte *pMessage, ubyte4 messageLen, ubyte *pResult, ubyte4 desiredResultLen)
 A one-shot context free computation of a SHA3 hash or extenable output function. More...
 
MOC_EXTERN MSTATUS SHA3_finalDigest (MOC_HASH(hwAccelDescr hwAccelCtx) SHA3_CTX *pSha3_ctx, ubyte *pResult, ubyte4 desiredResultLen)
 Finalizes a SHA3_CTX context and outputs the resulting output. More...
 
MOC_EXTERN MSTATUS SHA3_freeDigest (MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *pSha3_ctx)
 Zeroes and frees the SHA3_CTX context data structure. More...
 
MOC_EXTERN MSTATUS SHA3_initDigest (MOC_HASH(hwAccelDescr hwAccelCtx) SHA3_CTX *pSha3_ctx, ubyte4 mode)
 Initialize the SHA3_CTX context data structure. More...
 
MOC_EXTERN MSTATUS SHA3_updateDigest (MOC_HASH(hwAccelDescr hwAccelCtx) SHA3_CTX *pSha3_ctx, ubyte *pMessage, ubyte4 messageLen)
 Updates a previously initialized SHA3_CTX context with data. More...
 

Detailed Description

This file documents the APIs used for SHA3 hashing and extenable output.

To enable the methods in this file one must define

  • __ENABLE_MOCANA_SHA3__

sha3.h

Function Documentation

◆ SHA3_allocDigest()

MOC_EXTERN MSTATUS SHA3_allocDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *  pSha3_ctx)

This method allocates a SHA3_CTX context data structure for SHA3 hashing or extendable output function computation. Be sure to call SHA3_freeDigest to free memory when done.

Parameters
pSha3_ctxDouble pointer to the SHA3_CTX context to be allocated.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ SHA3_cloneCtx()

MOC_EXTERN MSTATUS SHA3_cloneCtx ( MOC_HASH(hwAccelDescr hwAccelCtx) SHA3_CTX *  pDest,
SHA3_CTX *  pSrc 
)

Makes a clone of a previously allocated SHA3_CTX.

Parameters
pDestPointer to an already allocated destination context.
pSrcPointer to the context to be copied.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ SHA3_completeDigest()

MOC_EXTERN MSTATUS SHA3_completeDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) ubyte4  mode,
ubyte *  pMessage,
ubyte4  messageLen,
ubyte *  pResult,
ubyte4  desiredResultLen 
)

A one-shot context free computation of a SHA3 hash or extenable output function.

Parameters
modeThe SHA3 mode. This is one of the following macros...
              + \c MOCANA_SHA3_MODE_SHA3_224
              + \c MOCANA_SHA3_MODE_SHA3_256
              + \c MOCANA_SHA3_MODE_SHA3_384
              + \c MOCANA_SHA3_MODE_SHA3_512
              + \c MOCANA_SHA3_MODE_SHAKE128
              + \c MOCANA_SHA3_MODE_SHAKE256
pMessagePointer to the input data.
messageLenThe length of the input data in bytes.
pResultPointer to a buffer that will hold the resulting output. The buffer must have space for the number of output bytes defined by the SHA3 hashing mode, or at least desiredResultLen bytes of space for the SHA3 extendable output modes.
desiredResultLenThe number of output bytes desired for SHA3 extendable output modes. This value is ignored for SHA3 hashing modes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ SHA3_finalDigest()

MOC_EXTERN MSTATUS SHA3_finalDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) SHA3_CTX *  pSha3_ctx,
ubyte *  pResult,
ubyte4  desiredResultLen 
)

Finalizes a SHA3_CTX context and outputs the resulting output.

Parameters
pSha3_ctxPointer to a previously initialized SHA3_CTX context.
pResultPointer to a buffer that will hold the resulting output. The buffer must have space for the number of output bytes defined by the SHA3 hashing mode, or at least desiredResultLen bytes of space for the SHA3 extendable output modes.
desiredResultLenThe number of output bytes desired for SHA3 extendable output modes. This value is ignored for SHA3 hashing modes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ SHA3_freeDigest()

MOC_EXTERN MSTATUS SHA3_freeDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *  pSha3_ctx)

This method zeroes and frees the SHA3_CTX context data structure allocated by the SHA3_allocDigest method.

Parameters
pSha3_ctxDouble pointer to the SHA3_CTX context to be freed.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ SHA3_initDigest()

MOC_EXTERN MSTATUS SHA3_initDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) SHA3_CTX *  pSha3_ctx,
ubyte4  mode 
)

This method initializes a SHA3_CTX context data structure for SHA3 hashing or extendable output function computation.

Parameters
pSha3_ctxPointer to the SHA3_CTX context to be initialized.
modeThe SHA3 mode. This is one of the following macros...
              + \c MOCANA_SHA3_MODE_SHA3_224
              + \c MOCANA_SHA3_MODE_SHA3_256
              + \c MOCANA_SHA3_MODE_SHA3_384
              + \c MOCANA_SHA3_MODE_SHA3_512
              + \c MOCANA_SHA3_MODE_SHAKE128
              + \c MOCANA_SHA3_MODE_SHAKE256
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.

◆ SHA3_updateDigest()

MOC_EXTERN MSTATUS SHA3_updateDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) SHA3_CTX *  pSha3_ctx,
ubyte *  pMessage,
ubyte4  messageLen 
)

This method updates a previously initialized SHA3_CTX context data structure with input data. SHA3_updateDigest may be called as many times as necessary.

Parameters
pSha3_ctxPointer to a previously initialized SHA3_CTX context.
pMessagePointer to the input data.
messageLenThe length of the input data in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h.