My Project
Functions
Algorithms - MD5

Functions

int wc_Md5Hash (const byte *data, word32 len, byte *hash)
 Convenience function, handles all the hashing and places the result into hash. More...
 
int wc_InitMd5 (wc_Md5 *)
 This function initializes md5. This is automatically called by wc_Md5Hash. More...
 
int wc_Md5Update (wc_Md5 *md5, const byte *data, word32 len)
 Can be called to continually hash the provided byte array of length len. More...
 
int wc_Md5Final (wc_Md5 *md5, byte *hash)
 Finalizes hashing of data. Result is placed into hash. Md5 Struct is reset. Note: This function will also return the result of calling IntelQaSymMd5() in the case that HAVE_INTEL_QA is defined. More...
 
void wc_Md5Free (wc_Md5 *)
 Resets the Md5 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined. More...
 
int wc_Md5GetHash (wc_Md5 *md5, byte *hash)
 Gets hash data. Result is placed into hash. Md5 struct is not reset. More...
 

Detailed Description

Function Documentation

◆ wc_InitMd5()

int wc_InitMd5 ( wc_Md5 *  )

This function initializes md5. This is automatically called by wc_Md5Hash.

Returns
0 Returned upon successfully initializing.
BAD_FUNC_ARG Returned if the Md5 structure is passed as a NULL value.
Parameters
md5pointer to the md5 structure to use for encryption

Example

Md5 md5;
byte* hash;
if ((ret = wc_InitMd5(&md5)) != 0) {
WOLFSSL_MSG("wc_Initmd5 failed");
}
else {
ret = wc_Md5Update(&md5, data, len);
if (ret != 0) {
// Md5 Update Failure Case.
}
ret = wc_Md5Final(&md5, hash);
if (ret != 0) {
// Md5 Final Failure Case.
}
}
int wc_Md5Final(wc_Md5 *md5, byte *hash)
Finalizes hashing of data. Result is placed into hash. Md5 Struct is reset. Note: This function will ...
int wc_InitMd5(wc_Md5 *)
This function initializes md5. This is automatically called by wc_Md5Hash.
int wc_Md5Update(wc_Md5 *md5, const byte *data, word32 len)
Can be called to continually hash the provided byte array of length len.
See also
wc_Md5Hash
wc_Md5Update
wc_Md5Final

◆ wc_Md5Final()

int wc_Md5Final ( wc_Md5 *  md5,
byte *  hash 
)

Finalizes hashing of data. Result is placed into hash. Md5 Struct is reset. Note: This function will also return the result of calling IntelQaSymMd5() in the case that HAVE_INTEL_QA is defined.

Returns
0 Returned upon successfully finalizing.
BAD_FUNC_ARG Returned if the Md5 structure or hash pointer is passed in NULL.
Parameters
md5pointer to the md5 structure to use for encryption
hashByte array to hold hash value.

Example

md5 md5[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitMd5(md5)) != 0) {
WOLFSSL_MSG("wc_Initmd5 failed");
}
else {
ret = wc_Md5Update(md5, data, len);
if (ret != 0) {
// Md5 Update Failure Case.
}
ret = wc_Md5Final(md5, hash);
if (ret != 0) {
// Md5 Final Failure Case.
}
}
See also
wc_Md5Hash
wc_InitMd5
wc_Md5GetHash

◆ wc_Md5Free()

void wc_Md5Free ( wc_Md5 *  )

Resets the Md5 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined.

Returns
none No returns.
Parameters
md5Pointer to the Md5 structure to be reset.

Example

Md5 md5;
byte data[] = { Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitMd5(&md5)) != 0) {
WOLFSSL_MSG("wc_InitMd5 failed");
}
else {
wc_Md5Update(&md5, data, len);
wc_Md5Final(&md5, hash);
wc_Md5Free(&md5);
}
void wc_Md5Free(wc_Md5 *)
Resets the Md5 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined.
See also
wc_InitMd5
wc_Md5Update
wc_Md5Final

◆ wc_Md5GetHash()

int wc_Md5GetHash ( wc_Md5 *  md5,
byte *  hash 
)

Gets hash data. Result is placed into hash. Md5 struct is not reset.

Returns
none No returns
Parameters
md5pointer to the md5 structure to use for encryption.
hashByte array to hold hash value.

Example

md5 md5[1];
if ((ret = wc_InitMd5(md5)) != 0) {
WOLFSSL_MSG("wc_Initmd5 failed");
}
else {
wc_Md5Update(md5, data, len);
wc_Md5GetHash(md5, hash);
}
int wc_Md5GetHash(wc_Md5 *md5, byte *hash)
Gets hash data. Result is placed into hash. Md5 struct is not reset.
See also
wc_Md5Hash
wc_Md5Final
wc_InitMd5

◆ wc_Md5Hash()

int wc_Md5Hash ( const byte *  data,
word32  len,
byte *  hash 
)

Convenience function, handles all the hashing and places the result into hash.

Returns
0 Returned upon successfully hashing the data.
Memory_E memory error, unable to allocate memory. This is only possible with the small stack option enabled.
Parameters
datathe data to hash
lenthe length of data
hashByte array to hold hash value.

Example

const byte* data;
word32 data_len;
byte* hash;
int ret;
...
ret = wc_Md5Hash(data, data_len, hash);
if (ret != 0) {
// Md5 Hash Failure Case.
}
int wc_Md5Hash(const byte *data, word32 len, byte *hash)
Convenience function, handles all the hashing and places the result into hash.
See also
wc_Md5Hash
wc_Md5Final
wc_InitMd5

◆ wc_Md5Update()

int wc_Md5Update ( wc_Md5 *  md5,
const byte *  data,
word32  len 
)

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

Returns
0 Returned upon successfully adding the data to the digest.
BAD_FUNC_ARG Returned if the Md5 structure is NULL or if data is NULL and len is greater than zero. The function should not return an error if the data parameter is NULL and len is zero.
Parameters
md5pointer to the md5 structure to use for encryption
datathe data to be hashed
lenlength of data to be hashed

Example

Md5 md5;
byte data[] = { Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitMd5(&md5)) != 0) {
WOLFSSL_MSG("wc_Initmd5 failed");
}
else {
ret = wc_Md5Update(&md5, data, len);
if (ret != 0) {
// Md5 Update Error Case.
}
ret = wc_Md5Final(&md5, hash);
if (ret != 0) {
// Md5 Final Error Case.
}
}
See also
wc_Md5Hash
wc_Md5Final
wc_InitMd5