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

Header file for the Nanocrypto SHA1 API. More...

Go to the source code of this file.

Functions

MOC_EXTERN MSTATUS SHA1_allocDigest (MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *pp_context)
 Allocate SHA1 operation context data structure. More...
 
MOC_EXTERN MSTATUS SHA1_cloneCtx (MOC_HASH(hwAccelDescr hwAccelCtx) shaDescr *pDest, shaDescr *pSrc)
 Makes a clone of a previously allocated SHA1_CTX. More...
 
MOC_EXTERN MSTATUS SHA1_completeDigest (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pData, ubyte4 dataLen, ubyte *pShaOutput)
 Calculate single item's SHA1 digest value (with a single function call). More...
 
MOC_EXTERN MSTATUS SHA1_finalDigest (MOC_HASH(hwAccelDescr hwAccelCtx) shaDescr *p_shaContext, ubyte *pShaOutput)
 Calculate final SHA1 digest value. More...
 
MOC_EXTERN MSTATUS SHA1_freeDigest (MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *pp_context)
 Free (delete) SHA1 operation context data structure. More...
 
MOC_EXTERN MSTATUS SHA1_initDigest (MOC_HASH(hwAccelDescr hwAccelCtx) shaDescr *p_shaContext)
 Initialize SHA1 operation context data structure. More...
 
MOC_EXTERN MSTATUS SHA1_updateDigest (MOC_HASH(hwAccelDescr hwAccelCtx) shaDescr *p_shaContext, const ubyte *pData, ubyte4 dataLen)
 Calculate and update intermediate SHA1 digest value. More...
 

Detailed Description

Header file for the Nanocrypto SHA1 API.

For documentation for this file's functions, see sha1.c.

Function Documentation

◆ SHA1_allocDigest()

MOC_EXTERN MSTATUS SHA1_allocDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *  pp_context)

This function allocates a context data structure for SHA1 operations.

Although applications can allocate the structure directly, it's recommended that this function be used to ensure future portability.

Note
If you need a SHA1 value for only a single message, it is more efficient to call the SHA1_completeDigest() function.
FIPS Approved
x-red.gif
Suite B Algorithm
x-red.gif
Flowchart SHA1

sha1.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. But... what does the user specify? In the 5.3.1 docs, we just said that this was "Reserved for future use." Ditto this for all sha1.{c,h} functions.
pp_contextOn return, pointer to address of allocated context data structure.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

sha1.c

◆ SHA1_cloneCtx()

MOC_EXTERN MSTATUS SHA1_cloneCtx ( MOC_HASH(hwAccelDescr hwAccelCtx) shaDescr *  pDest,
shaDescr *  pSrc 
)

Makes a clone of a previously allocated SHA1_CTX.

sha1.h

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.

◆ SHA1_completeDigest()

MOC_EXTERN MSTATUS SHA1_completeDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *  pData,
ubyte4  dataLen,
ubyte *  pShaOutput 
)

This function calculates an SHA1 digest value for a single item.

Note
This function is the most efficient method to calculate the SHA1 value for a single message, saving both memory and time. However, if you need to calculate the SHA1 for two or more messages, you must use the "separate steps" methods, SHA1_allocDigest(), SHA1_initDigest(), SHA1_updateDigest(), SHA1_finalDigest(), and SHA1_freeDigest().
Warning
Before calling this function, be sure that the buffer pointed to by the pShaOutput parameter is large enough (at least SHA1_RESULT_SIZE(20) bytes); otherwise, buffer overflow will occur.
FIPS Approved
x-red.gif
Suite B Algorithm
x-red.gif
Flowchart SHA1

There are no flag dependencies to enable this function.

sha1.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
pDataPointer to data to hash or digest.
dataLenNumber of bytes of data to hash or digest (pData).
pShaOutputOn return, pointer to resultant SHA1 digest value. (The calling function must allocate sufficient memory — at least SHA1_RESULT_SIZE(20) bytes — for the pShaOutput; otherwise buffer overflow will occur.)
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

sha1.c

◆ SHA1_finalDigest()

MOC_EXTERN MSTATUS SHA1_finalDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) shaDescr *  p_shaContext,
ubyte *  pShaOutput 
)

This function calculates the final SHA1 digest value. Applications must call this function after completing their calls to SHA1_updateDigest().

Note
If you need a SHA1 value for only a single message, it is more efficient to call the SHA1_completeDigest() function.
FIPS Approved
x-red.gif
Suite B Algorithm
x-red.gif
Flowchart SHA1

There are no flag dependencies to enable this function.

Warning
Before calling this function, be sure that the buffer pointed to by the pShaOutput parameter is large enough (at least SHA1_RESULT_SIZE(20) bytes); otherwise, buffer overflow will occur.

sha1.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
pContextPointer to SHA1 context.
pOutputOn return, pointer to final SHA1 digest value. (The calling function must allocate sufficient memory — at least SHA1_RESULT_SIZE(20) bytes — for the resulting pShaOutput; otherwise buffer overflow will occur.)
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

sha1.c

◆ SHA1_freeDigest()

MOC_EXTERN MSTATUS SHA1_freeDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *  pp_context)

This function frees (deletes) a SHA1 operation context data structure.

Note
If you need a SHA1 value for only a single message, it is more efficient to call the SHA1_completeDigest() function.
FIPS Approved
x-red.gif
Suite B Algorithm
x-red.gif
Flowchart SHA1

There are no flag dependencies to enable this function.

sha1.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
pp_contextPointer to address of context to free (delete).
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

sha1.c

◆ SHA1_initDigest()

MOC_EXTERN MSTATUS SHA1_initDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) shaDescr *  p_shaContext)

This function initializes an SHA1 context data structure. Applications should call this function before beginning the hashing operation.

Warning
Be sure to check this function's return status. An unsuccessful return will cause subsequent SHA1 operations to fail.
Note
If you need a SHA1 value for only a single message, it is more efficient to call the SHA1_completeDigest() function.
Context pointers returned by the SHA1_allocDigest() function should be typecast to (shaDescr *) before calling this function.
FIPS Approved
x-red.gif
Suite B Algorithm
x-red.gif
Flowchart SHA1

There are no flag dependencies to enable this function.

sha1.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
p_shaContextPointer to SHA1 context to initialize.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

sha1.c

◆ SHA1_updateDigest()

MOC_EXTERN MSTATUS SHA1_updateDigest ( MOC_HASH(hwAccelDescr hwAccelCtx) shaDescr *  p_shaContext,
const ubyte *  pData,
ubyte4  dataLen 
)

This function calculates an intermediate SHA1 digest value.

Applications can repeatedly call this function to calculate digests for different data items. Every time this function is called, the intermediate digest value is stored within the SHA1 context data structure.

Note
If you need a SHA1 value for only a single message, it is more efficient to call the SHA1_completeDigest() function.
FIPS Approved
x-red.gif
Suite B Algorithm
x-red.gif
Flowchart SHA1

There are no flag dependencies to enable this function.

sha1.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
p_shaContextPointer to SHA1 context.
pDataPointer to data to hash or digest.
dataLenNumber of bytes of data to hash or digest (pData).
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

sha1.c