![]() |
TrustCore SDK NanoCrypto API reference
version 7.0
|
SHA512 - Secure Hash Algorithm Header. More...
Go to the source code of this file.
Typedefs | |
typedef SHA512_CTX | sha384Descr |
typedef SHA512_CTX | sha512Descr |
Functions | |
MOC_EXTERN MSTATUS | SHA384_allocDigest (MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *pp_shaContext) |
Allocate SHA384 operation context data structure. More... | |
MOC_EXTERN MSTATUS | SHA384_cloneCtx (MOC_HASH(hwAccelDescr hwAccelCtx) SHA384_CTX *pDest, SHA384_CTX *pSrc) |
Makes a clone of a previously allocated SHA384_CTX . More... | |
MOC_EXTERN MSTATUS | SHA384_completeDigest (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pData, ubyte4 dataLen, ubyte *pShaOutput) |
Calculate single item's SHA384 digest value (with a single function call). More... | |
MOC_EXTERN MSTATUS | SHA384_finalDigest (MOC_HASH(hwAccelDescr hwAccelCtx) SHA384_CTX *pCtx, ubyte *pOutput) |
Calculate final SHA384 digest value. More... | |
MOC_EXTERN MSTATUS | SHA384_freeDigest (MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *pp_shaContext) |
Free (delete) SHA384 operation context data structure. More... | |
MOC_EXTERN MSTATUS | SHA384_initDigest (MOC_HASH(hwAccelDescr hwAccelCtx) SHA384_CTX *pCtx) |
Initialize SHA384 operation context data structure. More... | |
MOC_EXTERN MSTATUS | SHA384_updateDigest (MOC_HASH(hwAccelDescr hwAccelCtx) SHA512_CTX *pCtx, const ubyte *pData, ubyte4 dataLen) |
Calculate and update intermediate SHA384 digest value. More... | |
MOC_EXTERN MSTATUS | SHA512_allocDigest (MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *pp_shaContext) |
Allocate SHA512 operation context data structure. More... | |
MOC_EXTERN MSTATUS | SHA512_cloneCtx (MOC_HASH(hwAccelDescr hwAccelCtx) SHA512_CTX *pDest, SHA512_CTX *pSrc) |
Makes a clone of a previously allocated SHA512_CTX . More... | |
MOC_EXTERN MSTATUS | SHA512_completeDigest (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pData, ubyte4 dataLen, ubyte *pShaOutput) |
Calculate single item's SHA512 digest value (with a single function call). More... | |
MOC_EXTERN MSTATUS | SHA512_finalDigest (MOC_HASH(hwAccelDescr hwAccelCtx) SHA512_CTX *pCtx, ubyte *pOutput) |
Calculate final SHA512 digest value. More... | |
MOC_EXTERN MSTATUS | SHA512_freeDigest (MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx *pp_shaContext) |
Free (delete) SHA512 operation context data structure. More... | |
MOC_EXTERN MSTATUS | SHA512_initDigest (MOC_HASH(hwAccelDescr hwAccelCtx) SHA512_CTX *pCtx) |
Initialize SHA512 operation context data structure. More... | |
MOC_EXTERN MSTATUS | SHA512_updateDigest (MOC_HASH(hwAccelDescr hwAccelCtx) SHA512_CTX *pCtx, const ubyte *pData, ubyte4 dataLen) |
Calculate and update intermediate SHA512 digest value. More... | |
Copyright 2019-2024 DigiCert, Inc. All Rights Reserved. Proprietary and Confidential Material.
MOC_EXTERN MSTATUS SHA384_allocDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx * | pp_shaContext | ) |
This function allocates a context data structure for SHA384 operations.
Although applications can allocate the structure directly, it's recommended that this function be used to ensure future portability.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA384 |
To enable this function, the following flag must not be defined:
__DISABLE_MOCANA_SHA384__
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pp_context | On return, pointer to allocated context data structure. |
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.MOC_EXTERN MSTATUS SHA384_cloneCtx | ( | MOC_HASH(hwAccelDescr hwAccelCtx) SHA384_CTX * | pDest, |
SHA384_CTX * | pSrc | ||
) |
Makes a clone of a previously allocated SHA384_CTX
.
pDest | Pointer to an already allocated destination context. |
pSrc | Pointer to the context to be copied. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS SHA384_completeDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte * | pData, |
ubyte4 | dataLen, | ||
ubyte * | pShaOutput | ||
) |
This function calculates an SHA384 digest value for a single item.
pShaOutput
parameter is large enough (at least SHA384_RESULT_SIZE(48) bytes); otherwise, buffer overflow will occur.FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA384 |
To enable this function, the following flags must not be defined:
__DISABLE_MOCANA_SHA384__
__SHA384_ONE_STEP_HARDWARE_HASH__
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pData | Pointer to data to hash or digest. |
dataLen | Number of bytes of data to hash or digest (pData ). |
pShaOutput | On return, pointer to resultant SHA384 digest value. (The calling function must allocate sufficient memory — at least SHA384_RESULT_SIZE(48) bytes — for the pShaOutput ; otherwise buffer overflow may occur.) |
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.MOC_EXTERN MSTATUS SHA384_finalDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) SHA384_CTX * | pCtx, |
ubyte * | pOutput | ||
) |
This function calculates the final SHA384 digest value. Applications must call this function after completing their calls to SHA384_updateDigest().
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA384 |
To enable this function, the following flag must not be defined:
__DISABLE_MOCANA_SHA384__
pOutput
parameter is large enough (at least SHA384_RESULT_SIZE(64) bytes); otherwise, buffer overflow will occur.hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pContext | Pointer to SHA384 context. |
pOutput | On return, pointer to final SHA384 digest value. (The calling function must allocate sufficient memory — at least SHA384_RESULT_SIZE(48) bytes — for the resulting pOutput ; otherwise buffer overflow will occur.) |
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.MOC_EXTERN MSTATUS SHA384_freeDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx * | pp_shaContext | ) |
This function frees (deletes) an SHA384 operation context data structure.
The sha512.h header file defines SHA384_freeDigest
as:
#define SHA384_freeDigest SHA512_freeDigest
Therefore, when you call SHA384_freeDigest(), you are actually making a call to SHA512_freeDigest(). However, to keep your code more readable and unambiguous when working with SHA384, you should use SHA384_freeDigest(), not SHA512_freeDigest().
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA384 |
To enable this function, the following flag must not be defined:
__DISABLE_MOCANA_SHA384__
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pp_shaContext | Double pointer to context to free (delete). On return, value is NULL. |
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.MOC_EXTERN MSTATUS SHA384_initDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) SHA384_CTX * | pCtx | ) |
This function initializes an SHA384 context data structure. Applications should call this function before beginning the hashing operation.
shaDescr
) before calling this function.FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA384 |
To enable this function, the following flag must not be defined:
__DISABLE_MOCANA_SHA384__
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pContext | Pointer to SHA384 context to initialize. |
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.MOC_EXTERN MSTATUS SHA384_updateDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) SHA512_CTX * | pCtx, |
const ubyte * | pData, | ||
ubyte4 | dataLen | ||
) |
This function calculates an intermediate SHA384 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 SHA384 context data structure.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA384 |
The sha512.h header file defines SHA384_updateDigest
as:
#define SHA384_updateDigest SHA512_updateDigest
Therefore, when you call SHA384_updateDigest(), you are actually making a call to SHA512_updateDigest(). However, to keep your code more readable and unambiguous when working with SHA384, you should use SHA384_updateDigest(), not SHA512_updateDigest().
To enable this function, the following flag must not be defined:
__DISABLE_MOCANA_SHA384__
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pCtx | Pointer to SHA384 context. How should this pCtx param be explained given that the function signature has it as a SHA512_CTX? |
pData | Pointer to data to hash or digest. |
dataLen | Number of bytes of data to hash or digest (pData ). |
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.MOC_EXTERN MSTATUS SHA512_allocDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx * | pp_shaContext | ) |
This function allocates a context data structure for SHA512 operations.
Although applications can allocate the structure directly (stack or heap), it's recommended that this function be used to ensure future portability.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA512 |
To enable this function, the following flag must not be defined:
__DISABLE_MOCANA_SHA512__
hwAccelCtx | If 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 sha512.{c,h} functions. |
pp_context | On return, pointer to allocated context data structure. |
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.MOC_EXTERN MSTATUS SHA512_cloneCtx | ( | MOC_HASH(hwAccelDescr hwAccelCtx) SHA512_CTX * | pDest, |
SHA512_CTX * | pSrc | ||
) |
Makes a clone of a previously allocated SHA512_CTX
.
pDest | Pointer to an already allocated destination context. |
pSrc | Pointer to the context to be copied. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS SHA512_completeDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte * | pData, |
ubyte4 | dataLen, | ||
ubyte * | pShaOutput | ||
) |
This function calculates an SHA512 digest value for a single item.
pShaOutput
parameter is large enough (at least SHA512_RESULT_SIZE(64) bytes); otherwise, buffer overflow will occur.FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA512 |
To enable this function, the following flags must not be defined:
__DISABLE_MOCANA_SHA512__
__SHA512_ONE_STEP_HARDWARE_HASH__
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pData | Pointer to data to hash or digest. |
dataLen | Number of bytes of data to hash or digest (pData ). |
pShaOutput | On return, pointer to resultant SHA512 digest value. (The calling function must allocate sufficient memory — at least SHA512_RESULT_SIZE(64) bytes — for the pShaOutput ; otherwise buffer overflow may occur.) |
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.MOC_EXTERN MSTATUS SHA512_finalDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) SHA512_CTX * | pCtx, |
ubyte * | pOutput | ||
) |
This function calculates the final SHA512 digest value. Applications must call this function after completing their calls to SHA512_updateDigest().
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA512 |
To enable this function, the following flag must not be defined:
__DISABLE_MOCANA_SHA512__
pOutput
parameter is large enough (at least SHA512_RESULT_SIZE(64) bytes); otherwise, buffer overflow will occur.hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pContext | Pointer to SHA512 context. |
pOutput | On return, pointer to final SHA512 digest value. (The calling function must allocate sufficient memory — at least SHA512_RESULT_SIZE(64) bytes — for the resulting pOutput ; otherwise buffer overflow will occur.) |
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.MOC_EXTERN MSTATUS SHA512_freeDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) BulkCtx * | pp_shaContext | ) |
This function frees (deletes) an SHA512 operation context data structure.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA512 |
To enable this function, the following flag must not be defined:
__DISABLE_MOCANA_SHA512__
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pp_context | Double pointer to context to free (delete). On return, value is NULL. |
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.MOC_EXTERN MSTATUS SHA512_initDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) SHA512_CTX * | pCtx | ) |
This function initializes an SHA512 context data structure. Applications should call this function before beginning the hashing operation.
shaDescr
) before calling this function.FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA512 |
To enable this function, the following flag must not be defined:
__DISABLE_MOCANA_SHA512__
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pContext | Pointer to SHA512 context to initialize. |
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.MOC_EXTERN MSTATUS SHA512_updateDigest | ( | MOC_HASH(hwAccelDescr hwAccelCtx) SHA512_CTX * | pCtx, |
const ubyte * | pData, | ||
ubyte4 | dataLen | ||
) |
This function calculates an intermediate SHA512 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 SHA512 context data structure.
FIPS Approved | ![]() |
Suite B Algorithm | ![]() |
Flowchart | SHA512 |
To enable this function, the following flag must not be defined:
__DISABLE_MOCANA_SHA512__
hwAccelCtx | If a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing. |
pContext | Pointer to SHA512 context. |
pData | Pointer to data to hash or digest. |
dataLen | Number of bytes of data to hash or digest (pData ). |
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.