My Project
Functions
wolfCrypt Init and Cleanup

Functions

int wc_HashGetOID (enum wc_HashType hash_type)
 This function will return the OID for the wc_HashType provided. More...
 
int wc_HashGetDigestSize (enum wc_HashType hash_type)
 This function returns the size of the digest (output) for a hash_type. The returns size is used to make sure the output buffer provided to wc_Hash is large enough. More...
 
int wc_Hash (enum wc_HashType hash_type, const byte *data, word32 data_len, byte *hash, word32 hash_len)
 This function performs a hash on the provided data buffer and returns it in the hash buffer provided. More...
 
int wolfCrypt_Init (void)
 Used to initialize resources used by wolfCrypt. More...
 
int wolfCrypt_Cleanup (void)
 Used to clean up resources used by wolfCrypt. More...
 

Detailed Description

Function Documentation

◆ wc_Hash()

int wc_Hash ( enum wc_HashType  hash_type,
const byte *  data,
word32  data_len,
byte *  hash,
word32  hash_len 
)

This function performs a hash on the provided data buffer and returns it in the hash buffer provided.

Returns
0 Success, else error (such as BAD_FUNC_ARG or BUFFER_E).
Parameters
hash_typeA hash type from the “enum wc_HashType” such as “WC_HASH_TYPE_SHA256”.
dataPointer to buffer containing the data to hash.
data_lenLength of the data buffer.
hashPointer to buffer used to output the final hash to.
hash_lenLength of the hash buffer.

Example

enum wc_HashType hash_type = WC_HASH_TYPE_SHA256;
int hash_len = wc_HashGetDigestSize(hash_type);
if (hash_len > 0) {
int ret = wc_Hash(hash_type, data, data_len, hash_data, hash_len);
if(ret == 0) {
// Success
}
}
int wc_Hash(enum wc_HashType hash_type, const byte *data, word32 data_len, byte *hash, word32 hash_len)
This function performs a hash on the provided data buffer and returns it in the hash buffer provided.
int wc_HashGetDigestSize(enum wc_HashType hash_type)
This function returns the size of the digest (output) for a hash_type. The returns size is used to ma...
See also
wc_HashGetDigestSize

◆ wc_HashGetDigestSize()

int wc_HashGetDigestSize ( enum wc_HashType  hash_type)

This function returns the size of the digest (output) for a hash_type. The returns size is used to make sure the output buffer provided to wc_Hash is large enough.

Returns
Success A positive return value indicates the digest size for the hash.
Error Returns HASH_TYPE_E if hash_type is not supported.
Failure Returns BAD_FUNC_ARG if an invalid hash_type was used.
Parameters
hash_typeA hash type from the “enum wc_HashType” such as “WC_HASH_TYPE_SHA256”.

Example

int hash_len = wc_HashGetDigestSize(hash_type);
if (hash_len <= 0) {
WOLFSSL_MSG("Invalid hash type/len");
return BAD_FUNC_ARG;
}
See also
wc_Hash

◆ wc_HashGetOID()

int wc_HashGetOID ( enum wc_HashType  hash_type)

This function will return the OID for the wc_HashType provided.

Returns
OID returns value greater than 0
HASH_TYPE_E hash type not supported.
BAD_FUNC_ARG one of the provided arguments is incorrect.
Parameters
hash_typeA hash type from the “enum wc_HashType” such as “WC_HASH_TYPE_SHA256”.

Example

enum wc_HashType hash_type = WC_HASH_TYPE_SHA256;
int oid = wc_HashGetOID(hash_type);
if (oid > 0) {
// Success
}
int wc_HashGetOID(enum wc_HashType hash_type)
This function will return the OID for the wc_HashType provided.
See also
wc_HashGetDigestSize
wc_Hash

◆ wolfCrypt_Cleanup()

int wolfCrypt_Cleanup ( void  )

Used to clean up resources used by wolfCrypt.

Returns
0 upon success.
<0 upon failure of cleaning up resources.
Parameters
noneNo parameters.

Example

...
if (wolfCrypt_Cleanup() != 0) {
WOLFSSL_MSG("Error with wolfCrypt_Cleanup call");
}
int wolfCrypt_Cleanup(void)
Used to clean up resources used by wolfCrypt.
See also
wolfCrypt_Init

◆ wolfCrypt_Init()

int wolfCrypt_Init ( void  )

Used to initialize resources used by wolfCrypt.

Returns
0 upon success.
<0 upon failure of init resources.
Parameters
noneNo parameters.

Example

...
if (wolfCrypt_Init() != 0) {
WOLFSSL_MSG("Error with wolfCrypt_Init call");
}
int wolfCrypt_Init(void)
Used to initialize resources used by wolfCrypt.
See also
wolfCrypt_Cleanup