Skip to content

sha512.h

Functions

Name
int wc_InitSha512(wc_Sha512 * sha)
This function initializes SHA512. This is automatically called by wc_Sha512Hash.
int wc_Sha512Update(wc_Sha512 * sha, const byte * data, word32 len)
Can be called to continually hash the provided byte array of length len.
int wc_Sha512Final(wc_Sha512 * sha512, byte * hash)
Finalizes hashing of data. Result is placed into hash.
int wc_InitSha384(wc_Sha384 * sha)
This function initializes SHA384. This is automatically called by wc_Sha384Hash.
int wc_Sha384Update(wc_Sha384 * sha, const byte * data, word32 len)
Can be called to continually hash the provided byte array of length len.
int wc_Sha384Final(wc_Sha384 * sha384, byte * hash)
Finalizes hashing of data. Result is placed into hash.
int wc_InitSha512_ex(wc_Sha512 * sha, void * heap, int devId)
Initializes SHA512 with heap and device ID.
int wc_Sha512FinalRaw(wc_Sha512 * sha512, byte * hash)
Gets raw hash without finalizing.
void wc_Sha512Free(wc_Sha512 * sha)
Frees SHA512 resources.
int wc_Sha512GetHash(wc_Sha512 * sha512, byte * hash)
Gets SHA512 hash without finalizing.
int wc_Sha512Copy(wc_Sha512 * src, wc_Sha512 * dst)
Copies SHA512 context.
int wc_Sha512_Grow(wc_Sha512 * sha512, const byte * in, int inSz)
Grows SHA512 buffer with input data.
int wc_Sha512SetFlags(wc_Sha512 * sha512, word32 flags)
Sets SHA512 flags.
int wc_Sha512GetFlags(wc_Sha512 * sha512, word32 * flags)
Gets SHA512 flags.
int wc_Sha512Transform(wc_Sha512 * sha, const unsigned char * data)
Transforms SHA512 block.
int wc_InitSha512_224(wc_Sha512 * sha)
Initializes SHA512/224.
int wc_InitSha512_224_ex(wc_Sha512 * sha, void * heap, int devId)
Initializes SHA512/224 with heap and device ID.
int wc_Sha512_224Update(wc_Sha512 * sha, const byte * data, word32 len)
Updates SHA512/224 hash with data.
int wc_Sha512_224FinalRaw(wc_Sha512 * sha512, byte * hash)
Gets raw SHA512/224 hash without finalizing.
int wc_Sha512_224Final(wc_Sha512 * sha512, byte * hash)
Finalizes SHA512/224 hash.
void wc_Sha512_224Free(wc_Sha512 * sha)
Frees SHA512/224 resources.
int wc_Sha512_224GetHash(wc_Sha512 * sha512, byte * hash)
Gets SHA512/224 hash without finalizing.
int wc_Sha512_224Copy(wc_Sha512 * src, wc_Sha512 * dst)
Copies SHA512/224 context.
int wc_Sha512_224SetFlags(wc_Sha512 * sha512, word32 flags)
Sets SHA512/224 flags.
int wc_Sha512_224GetFlags(wc_Sha512 * sha512, word32 * flags)
Gets SHA512/224 flags.
int wc_Sha512_224Transform(wc_Sha512 * sha, const unsigned char * data)
Transforms SHA512/224 block.
int wc_InitSha512_256(wc_Sha512 * sha)
Initializes SHA512/256.
int wc_InitSha512_256_ex(wc_Sha512 * sha, void * heap, int devId)
Initializes SHA512/256 with heap and device ID.
int wc_Sha512_256Update(wc_Sha512 * sha, const byte * data, word32 len)
Updates SHA512/256 hash with data.
int wc_Sha512_256FinalRaw(wc_Sha512 * sha512, byte * hash)
Gets raw SHA512/256 hash without finalizing.
int wc_Sha512_256Final(wc_Sha512 * sha512, byte * hash)
Finalizes SHA512/256 hash.
void wc_Sha512_256Free(wc_Sha512 * sha)
Frees SHA512/256 resources.
int wc_Sha512_256GetHash(wc_Sha512 * sha512, byte * hash)
Gets SHA512/256 hash without finalizing.
int wc_Sha512_256Copy(wc_Sha512 * src, wc_Sha512 * dst)
Copies SHA512/256 context.
int wc_Sha512_256SetFlags(wc_Sha512 * sha512, word32 flags)
Sets SHA512/256 flags.
int wc_Sha512_256GetFlags(wc_Sha512 * sha512, word32 * flags)
Gets SHA512/256 flags.
int wc_Sha512_256Transform(wc_Sha512 * sha, const unsigned char * data)
Transforms SHA512/256 block.
int wc_InitSha384_ex(wc_Sha384 * sha, void * heap, int devId)
Initializes SHA384 with heap and device ID.
int wc_Sha384FinalRaw(wc_Sha384 * sha384, byte * hash)
Gets raw SHA384 hash without finalizing.
void wc_Sha384Free(wc_Sha384 * sha)
Frees SHA384 resources.
int wc_Sha384GetHash(wc_Sha384 * sha384, byte * hash)
Gets SHA384 hash without finalizing.
int wc_Sha384Copy(wc_Sha384 * src, wc_Sha384 * dst)
Copies SHA384 context.
int wc_Sha384_Grow(wc_Sha384 * sha384, const byte * in, int inSz)
Grows SHA384 buffer with input data.
int wc_Sha384SetFlags(wc_Sha384 * sha384, word32 flags)
Sets SHA384 flags.
int wc_Sha384GetFlags(wc_Sha384 * sha384, word32 * flags)
Gets SHA384 flags.
int wc_Sha384Transform(wc_Sha384 * sha, const unsigned char * data)
Transforms SHA384 block.

Functions Documentation

function wc_InitSha512

int wc_InitSha512(
    wc_Sha512 * sha
)

This function initializes SHA512. This is automatically called by wc_Sha512Hash.

Parameters:

  • sha512 pointer to the sha512 structure to use for encryption

See:

Return: 0 Returned upon successfully initializing

Example

Sha512 sha512[1];
if ((ret = wc_InitSha512(sha512)) != 0) {
   WOLFSSL_MSG("wc_InitSha512 failed");
}
else {
   wc_Sha512Update(sha512, data, len);
   wc_Sha512Final(sha512, hash);
}

function wc_Sha512Update

int wc_Sha512Update(
    wc_Sha512 * sha,
    const byte * data,
    word32 len
)

Can be called to continually hash the provided byte array of length len.

Parameters:

  • sha512 pointer to the sha512 structure to use for encryption
  • data the data to be hashed
  • len length of data to be hashed

See:

Return: 0 Returned upon successfully adding the data to the digest.

Example

Sha512 sha512[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);

if ((ret = wc_InitSha512(sha512)) != 0) {
   WOLFSSL_MSG("wc_InitSha512 failed");
}
else {
   wc_Sha512Update(sha512, data, len);
   wc_Sha512Final(sha512, hash);
}

function wc_Sha512Final

int wc_Sha512Final(
    wc_Sha512 * sha512,
    byte * hash
)

Finalizes hashing of data. Result is placed into hash.

Parameters:

  • sha512 pointer to the sha512 structure to use for encryption
  • hash Byte array to hold hash value.

See:

Return: 0 Returned upon successfully finalizing the hash.

Example

Sha512 sha512[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);

if ((ret = wc_InitSha512(sha512)) != 0) {
    WOLFSSL_MSG("wc_InitSha512 failed");
}
else {
   wc_Sha512Update(sha512, data, len);
   wc_Sha512Final(sha512, hash);
}

function wc_InitSha384

int wc_InitSha384(
    wc_Sha384 * sha
)

This function initializes SHA384. This is automatically called by wc_Sha384Hash.

Parameters:

  • sha384 pointer to the sha384 structure to use for encryption

See:

Return: 0 Returned upon successfully initializing

Example

Sha384 sha384[1];
if ((ret = wc_InitSha384(sha384)) != 0) {
   WOLFSSL_MSG("wc_InitSha384 failed");
}
else {
   wc_Sha384Update(sha384, data, len);
   wc_Sha384Final(sha384, hash);
}

function wc_Sha384Update

int wc_Sha384Update(
    wc_Sha384 * sha,
    const byte * data,
    word32 len
)

Can be called to continually hash the provided byte array of length len.

Parameters:

  • sha384 pointer to the sha384 structure to use for encryption
  • data the data to be hashed
  • len length of data to be hashed

See:

Return: 0 Returned upon successfully adding the data to the digest.

Example

Sha384 sha384[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);

if ((ret = wc_InitSha384(sha384)) != 0) {
   WOLFSSL_MSG("wc_InitSha384 failed");
}
else {
   wc_Sha384Update(sha384, data, len);
   wc_Sha384Final(sha384, hash);
}

function wc_Sha384Final

int wc_Sha384Final(
    wc_Sha384 * sha384,
    byte * hash
)

Finalizes hashing of data. Result is placed into hash.

Parameters:

  • sha384 pointer to the sha384 structure to use for encryption
  • hash Byte array to hold hash value.

See:

Return: 0 Returned upon successfully finalizing.

Example

Sha384 sha384[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);

if ((ret = wc_InitSha384(sha384)) != 0) {
   WOLFSSL_MSG("wc_InitSha384 failed");
}
else {
   wc_Sha384Update(sha384, data, len);
   wc_Sha384Final(sha384, hash);
}

function wc_InitSha512_ex

int wc_InitSha512_ex(
    wc_Sha512 * sha,
    void * heap,
    int devId
)

Initializes SHA512 with heap and device ID.

Parameters:

  • sha SHA512 structure
  • heap Heap hint
  • devId Device ID

See: wc_InitSha512

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
int ret = wc_InitSha512_ex(&sha, NULL, INVALID_DEVID);

function wc_Sha512FinalRaw

int wc_Sha512FinalRaw(
    wc_Sha512 * sha512,
    byte * hash
)

Gets raw hash without finalizing.

Parameters:

  • sha512 SHA512 structure
  • hash Output hash buffer

See: wc_Sha512Final

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
byte hash[WC_SHA512_DIGEST_SIZE];
int ret = wc_Sha512FinalRaw(&sha, hash);

function wc_Sha512Free

void wc_Sha512Free(
    wc_Sha512 * sha
)

Frees SHA512 resources.

Parameters:

  • sha SHA512 structure

See: wc_InitSha512

Return: none No returns

Example

wc_Sha512 sha;
wc_InitSha512(&sha);
wc_Sha512Free(&sha);

function wc_Sha512GetHash

int wc_Sha512GetHash(
    wc_Sha512 * sha512,
    byte * hash
)

Gets SHA512 hash without finalizing.

Parameters:

  • sha512 SHA512 structure
  • hash Output hash buffer

See: wc_Sha512Final

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
byte hash[WC_SHA512_DIGEST_SIZE];
int ret = wc_Sha512GetHash(&sha, hash);

function wc_Sha512Copy

int wc_Sha512Copy(
    wc_Sha512 * src,
    wc_Sha512 * dst
)

Copies SHA512 context.

Parameters:

  • src Source SHA512 structure
  • dst Destination SHA512 structure

See: wc_InitSha512

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 src, dst;
int ret = wc_Sha512Copy(&src, &dst);

function wc_Sha512_Grow

int wc_Sha512_Grow(
    wc_Sha512 * sha512,
    const byte * in,
    int inSz
)

Grows SHA512 buffer with input data.

Parameters:

  • sha512 SHA512 structure
  • in Input data
  • inSz Input size

See: wc_Sha512Update

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
byte data[100];
int ret = wc_Sha512_Grow(&sha, data, sizeof(data));

function wc_Sha512SetFlags

int wc_Sha512SetFlags(
    wc_Sha512 * sha512,
    word32 flags
)

Sets SHA512 flags.

Parameters:

  • sha512 SHA512 structure
  • flags Flags to set

See: wc_InitSha512

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
int ret = wc_Sha512SetFlags(&sha, WC_HASH_FLAG_WILLCOPY);

function wc_Sha512GetFlags

int wc_Sha512GetFlags(
    wc_Sha512 * sha512,
    word32 * flags
)

Gets SHA512 flags.

Parameters:

  • sha512 SHA512 structure
  • flags Pointer to store flags

See: wc_Sha512SetFlags

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
word32 flags;
int ret = wc_Sha512GetFlags(&sha, &flags);

function wc_Sha512Transform

int wc_Sha512Transform(
    wc_Sha512 * sha,
    const unsigned char * data
)

Transforms SHA512 block.

Parameters:

  • sha SHA512 structure
  • data Block data

See: wc_Sha512Update

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
unsigned char block[WC_SHA512_BLOCK_SIZE];
int ret = wc_Sha512Transform(&sha, block);

function wc_InitSha512_224

int wc_InitSha512_224(
    wc_Sha512 * sha
)

Initializes SHA512/224.

Parameters:

  • sha SHA512 structure

See: wc_Sha512_224Update

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
int ret = wc_InitSha512_224(&sha);

function wc_InitSha512_224_ex

int wc_InitSha512_224_ex(
    wc_Sha512 * sha,
    void * heap,
    int devId
)

Initializes SHA512/224 with heap and device ID.

Parameters:

  • sha SHA512 structure
  • heap Heap hint
  • devId Device ID

See: wc_InitSha512_224

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
int ret = wc_InitSha512_224_ex(&sha, NULL, INVALID_DEVID);

function wc_Sha512_224Update

int wc_Sha512_224Update(
    wc_Sha512 * sha,
    const byte * data,
    word32 len
)

Updates SHA512/224 hash with data.

Parameters:

  • sha SHA512 structure
  • data Input data
  • len Input size

See: wc_InitSha512_224

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
byte data[100];
int ret = wc_Sha512_224Update(&sha, data, sizeof(data));

function wc_Sha512_224FinalRaw

int wc_Sha512_224FinalRaw(
    wc_Sha512 * sha512,
    byte * hash
)

Gets raw SHA512/224 hash without finalizing.

Parameters:

  • sha512 SHA512 structure
  • hash Output hash buffer

See: wc_Sha512_224Final

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
byte hash[WC_SHA512_224_DIGEST_SIZE];
int ret = wc_Sha512_224FinalRaw(&sha, hash);

function wc_Sha512_224Final

int wc_Sha512_224Final(
    wc_Sha512 * sha512,
    byte * hash
)

Finalizes SHA512/224 hash.

Parameters:

  • sha512 SHA512 structure
  • hash Output hash buffer

See: wc_Sha512_224Update

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
byte hash[WC_SHA512_224_DIGEST_SIZE];
int ret = wc_Sha512_224Final(&sha, hash);

function wc_Sha512_224Free

void wc_Sha512_224Free(
    wc_Sha512 * sha
)

Frees SHA512/224 resources.

Parameters:

  • sha SHA512 structure

See: wc_InitSha512_224

Return: none No returns

Example

wc_Sha512 sha;
wc_InitSha512_224(&sha);
wc_Sha512_224Free(&sha);

function wc_Sha512_224GetHash

int wc_Sha512_224GetHash(
    wc_Sha512 * sha512,
    byte * hash
)

Gets SHA512/224 hash without finalizing.

Parameters:

  • sha512 SHA512 structure
  • hash Output hash buffer

See: wc_Sha512_224Final

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
byte hash[WC_SHA512_224_DIGEST_SIZE];
int ret = wc_Sha512_224GetHash(&sha, hash);

function wc_Sha512_224Copy

int wc_Sha512_224Copy(
    wc_Sha512 * src,
    wc_Sha512 * dst
)

Copies SHA512/224 context.

Parameters:

  • src Source SHA512 structure
  • dst Destination SHA512 structure

See: wc_InitSha512_224

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 src, dst;
int ret = wc_Sha512_224Copy(&src, &dst);

function wc_Sha512_224SetFlags

int wc_Sha512_224SetFlags(
    wc_Sha512 * sha512,
    word32 flags
)

Sets SHA512/224 flags.

Parameters:

  • sha512 SHA512 structure
  • flags Flags to set

See: wc_InitSha512_224

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
int ret = wc_Sha512_224SetFlags(&sha, WC_HASH_FLAG_WILLCOPY);

function wc_Sha512_224GetFlags

int wc_Sha512_224GetFlags(
    wc_Sha512 * sha512,
    word32 * flags
)

Gets SHA512/224 flags.

Parameters:

  • sha512 SHA512 structure
  • flags Pointer to store flags

See: wc_Sha512_224SetFlags

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
word32 flags;
int ret = wc_Sha512_224GetFlags(&sha, &flags);

function wc_Sha512_224Transform

int wc_Sha512_224Transform(
    wc_Sha512 * sha,
    const unsigned char * data
)

Transforms SHA512/224 block.

Parameters:

  • sha SHA512 structure
  • data Block data

See: wc_Sha512_224Update

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
unsigned char block[WC_SHA512_BLOCK_SIZE];
int ret = wc_Sha512_224Transform(&sha, block);

function wc_InitSha512_256

int wc_InitSha512_256(
    wc_Sha512 * sha
)

Initializes SHA512/256.

Parameters:

  • sha SHA512 structure

See: wc_Sha512_256Update

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
int ret = wc_InitSha512_256(&sha);

function wc_InitSha512_256_ex

int wc_InitSha512_256_ex(
    wc_Sha512 * sha,
    void * heap,
    int devId
)

Initializes SHA512/256 with heap and device ID.

Parameters:

  • sha SHA512 structure
  • heap Heap hint
  • devId Device ID

See: wc_InitSha512_256

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
int ret = wc_InitSha512_256_ex(&sha, NULL, INVALID_DEVID);

function wc_Sha512_256Update

int wc_Sha512_256Update(
    wc_Sha512 * sha,
    const byte * data,
    word32 len
)

Updates SHA512/256 hash with data.

Parameters:

  • sha SHA512 structure
  • data Input data
  • len Input size

See: wc_InitSha512_256

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
byte data[100];
int ret = wc_Sha512_256Update(&sha, data, sizeof(data));

function wc_Sha512_256FinalRaw

int wc_Sha512_256FinalRaw(
    wc_Sha512 * sha512,
    byte * hash
)

Gets raw SHA512/256 hash without finalizing.

Parameters:

  • sha512 SHA512 structure
  • hash Output hash buffer

See: wc_Sha512_256Final

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
byte hash[WC_SHA512_256_DIGEST_SIZE];
int ret = wc_Sha512_256FinalRaw(&sha, hash);

function wc_Sha512_256Final

int wc_Sha512_256Final(
    wc_Sha512 * sha512,
    byte * hash
)

Finalizes SHA512/256 hash.

Parameters:

  • sha512 SHA512 structure
  • hash Output hash buffer

See: wc_Sha512_256Update

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
byte hash[WC_SHA512_256_DIGEST_SIZE];
int ret = wc_Sha512_256Final(&sha, hash);

function wc_Sha512_256Free

void wc_Sha512_256Free(
    wc_Sha512 * sha
)

Frees SHA512/256 resources.

Parameters:

  • sha SHA512 structure

See: wc_InitSha512_256

Return: none No returns

Example

wc_Sha512 sha;
wc_InitSha512_256(&sha);
wc_Sha512_256Free(&sha);

function wc_Sha512_256GetHash

int wc_Sha512_256GetHash(
    wc_Sha512 * sha512,
    byte * hash
)

Gets SHA512/256 hash without finalizing.

Parameters:

  • sha512 SHA512 structure
  • hash Output hash buffer

See: wc_Sha512_256Final

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
byte hash[WC_SHA512_256_DIGEST_SIZE];
int ret = wc_Sha512_256GetHash(&sha, hash);

function wc_Sha512_256Copy

int wc_Sha512_256Copy(
    wc_Sha512 * src,
    wc_Sha512 * dst
)

Copies SHA512/256 context.

Parameters:

  • src Source SHA512 structure
  • dst Destination SHA512 structure

See: wc_InitSha512_256

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 src, dst;
int ret = wc_Sha512_256Copy(&src, &dst);

function wc_Sha512_256SetFlags

int wc_Sha512_256SetFlags(
    wc_Sha512 * sha512,
    word32 flags
)

Sets SHA512/256 flags.

Parameters:

  • sha512 SHA512 structure
  • flags Flags to set

See: wc_InitSha512_256

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
int ret = wc_Sha512_256SetFlags(&sha, WC_HASH_FLAG_WILLCOPY);

function wc_Sha512_256GetFlags

int wc_Sha512_256GetFlags(
    wc_Sha512 * sha512,
    word32 * flags
)

Gets SHA512/256 flags.

Parameters:

  • sha512 SHA512 structure
  • flags Pointer to store flags

See: wc_Sha512_256SetFlags

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
word32 flags;
int ret = wc_Sha512_256GetFlags(&sha, &flags);

function wc_Sha512_256Transform

int wc_Sha512_256Transform(
    wc_Sha512 * sha,
    const unsigned char * data
)

Transforms SHA512/256 block.

Parameters:

  • sha SHA512 structure
  • data Block data

See: wc_Sha512_256Update

Return:

  • 0 on success
  • negative on error

Example

wc_Sha512 sha;
unsigned char block[WC_SHA512_BLOCK_SIZE];
int ret = wc_Sha512_256Transform(&sha, block);

function wc_InitSha384_ex

int wc_InitSha384_ex(
    wc_Sha384 * sha,
    void * heap,
    int devId
)

Initializes SHA384 with heap and device ID.

Parameters:

  • sha SHA384 structure
  • heap Heap hint
  • devId Device ID

See: wc_InitSha384

Return:

  • 0 on success
  • negative on error

Example

wc_Sha384 sha;
int ret = wc_InitSha384_ex(&sha, NULL, INVALID_DEVID);

function wc_Sha384FinalRaw

int wc_Sha384FinalRaw(
    wc_Sha384 * sha384,
    byte * hash
)

Gets raw SHA384 hash without finalizing.

Parameters:

  • sha384 SHA384 structure
  • hash Output hash buffer

See: wc_Sha384Final

Return:

  • 0 on success
  • negative on error

Example

wc_Sha384 sha;
byte hash[WC_SHA384_DIGEST_SIZE];
int ret = wc_Sha384FinalRaw(&sha, hash);

function wc_Sha384Free

void wc_Sha384Free(
    wc_Sha384 * sha
)

Frees SHA384 resources.

Parameters:

  • sha SHA384 structure

See: wc_InitSha384

Return: none No returns

Example

wc_Sha384 sha;
wc_InitSha384(&sha);
wc_Sha384Free(&sha);

function wc_Sha384GetHash

int wc_Sha384GetHash(
    wc_Sha384 * sha384,
    byte * hash
)

Gets SHA384 hash without finalizing.

Parameters:

  • sha384 SHA384 structure
  • hash Output hash buffer

See: wc_Sha384Final

Return:

  • 0 on success
  • negative on error

Example

wc_Sha384 sha;
byte hash[WC_SHA384_DIGEST_SIZE];
int ret = wc_Sha384GetHash(&sha, hash);

function wc_Sha384Copy

int wc_Sha384Copy(
    wc_Sha384 * src,
    wc_Sha384 * dst
)

Copies SHA384 context.

Parameters:

  • src Source SHA384 structure
  • dst Destination SHA384 structure

See: wc_InitSha384

Return:

  • 0 on success
  • negative on error

Example

wc_Sha384 src, dst;
int ret = wc_Sha384Copy(&src, &dst);

function wc_Sha384_Grow

int wc_Sha384_Grow(
    wc_Sha384 * sha384,
    const byte * in,
    int inSz
)

Grows SHA384 buffer with input data.

Parameters:

  • sha384 SHA384 structure
  • in Input data
  • inSz Input size

See: wc_Sha384Update

Return:

  • 0 on success
  • negative on error

Example

wc_Sha384 sha;
byte data[100];
int ret = wc_Sha384_Grow(&sha, data, sizeof(data));

function wc_Sha384SetFlags

int wc_Sha384SetFlags(
    wc_Sha384 * sha384,
    word32 flags
)

Sets SHA384 flags.

Parameters:

  • sha384 SHA384 structure
  • flags Flags to set

See: wc_InitSha384

Return:

  • 0 on success
  • negative on error

Example

wc_Sha384 sha;
int ret = wc_Sha384SetFlags(&sha, WC_HASH_FLAG_WILLCOPY);

function wc_Sha384GetFlags

int wc_Sha384GetFlags(
    wc_Sha384 * sha384,
    word32 * flags
)

Gets SHA384 flags.

Parameters:

  • sha384 SHA384 structure
  • flags Pointer to store flags

See: wc_Sha384SetFlags

Return:

  • 0 on success
  • negative on error

Example

wc_Sha384 sha;
word32 flags;
int ret = wc_Sha384GetFlags(&sha, &flags);

function wc_Sha384Transform

int wc_Sha384Transform(
    wc_Sha384 * sha,
    const unsigned char * data
)

Transforms SHA384 block.

Parameters:

  • sha SHA384 structure
  • data Block data

See: wc_Sha384Update

Return:

  • 0 on success
  • negative on error

Example

wc_Sha384 sha;
unsigned char block[WC_SHA384_BLOCK_SIZE];
int ret = wc_Sha384Transform(&sha, block);

Source code


int wc_InitSha512(wc_Sha512* sha);

int wc_Sha512Update(wc_Sha512* sha, const byte* data, word32 len);

int wc_Sha512Final(wc_Sha512* sha512, byte* hash);

int wc_InitSha384(wc_Sha384* sha);

int wc_Sha384Update(wc_Sha384* sha, const byte* data, word32 len);

int wc_Sha384Final(wc_Sha384* sha384, byte* hash);

int wc_InitSha512_ex(wc_Sha512* sha, void* heap, int devId);

int wc_Sha512FinalRaw(wc_Sha512* sha512, byte* hash);

void wc_Sha512Free(wc_Sha512* sha);

int wc_Sha512GetHash(wc_Sha512* sha512, byte* hash);

int wc_Sha512Copy(wc_Sha512* src, wc_Sha512* dst);

int wc_Sha512_Grow(wc_Sha512* sha512, const byte* in, int inSz);

int wc_Sha512SetFlags(wc_Sha512* sha512, word32 flags);

int wc_Sha512GetFlags(wc_Sha512* sha512, word32* flags);

int wc_Sha512Transform(wc_Sha512* sha, const unsigned char* data);

int wc_InitSha512_224(wc_Sha512* sha);

int wc_InitSha512_224_ex(wc_Sha512* sha, void* heap, int devId);

int wc_Sha512_224Update(wc_Sha512* sha, const byte* data, word32 len);

int wc_Sha512_224FinalRaw(wc_Sha512* sha512, byte* hash);

int wc_Sha512_224Final(wc_Sha512* sha512, byte* hash);

void wc_Sha512_224Free(wc_Sha512* sha);

int wc_Sha512_224GetHash(wc_Sha512* sha512, byte* hash);

int wc_Sha512_224Copy(wc_Sha512* src, wc_Sha512* dst);

int wc_Sha512_224SetFlags(wc_Sha512* sha512, word32 flags);

int wc_Sha512_224GetFlags(wc_Sha512* sha512, word32* flags);

int wc_Sha512_224Transform(wc_Sha512* sha, const unsigned char* data);

int wc_InitSha512_256(wc_Sha512* sha);

int wc_InitSha512_256_ex(wc_Sha512* sha, void* heap, int devId);

int wc_Sha512_256Update(wc_Sha512* sha, const byte* data, word32 len);

int wc_Sha512_256FinalRaw(wc_Sha512* sha512, byte* hash);

int wc_Sha512_256Final(wc_Sha512* sha512, byte* hash);

void wc_Sha512_256Free(wc_Sha512* sha);

int wc_Sha512_256GetHash(wc_Sha512* sha512, byte* hash);

int wc_Sha512_256Copy(wc_Sha512* src, wc_Sha512* dst);

int wc_Sha512_256SetFlags(wc_Sha512* sha512, word32 flags);

int wc_Sha512_256GetFlags(wc_Sha512* sha512, word32* flags);

int wc_Sha512_256Transform(wc_Sha512* sha, const unsigned char* data);

int wc_InitSha384_ex(wc_Sha384* sha, void* heap, int devId);

int wc_Sha384FinalRaw(wc_Sha384* sha384, byte* hash);

void wc_Sha384Free(wc_Sha384* sha);

int wc_Sha384GetHash(wc_Sha384* sha384, byte* hash);

int wc_Sha384Copy(wc_Sha384* src, wc_Sha384* dst);

int wc_Sha384_Grow(wc_Sha384* sha384, const byte* in, int inSz);

int wc_Sha384SetFlags(wc_Sha384* sha384, word32 flags);

int wc_Sha384GetFlags(wc_Sha384* sha384, word32* flags);

int wc_Sha384Transform(wc_Sha384* sha, const unsigned char* data);

Updated on 2026-01-07 at 01:17:17 +0000