wolfSSL Manual

Docs -> wolfSSL Manual

Chapter 18: wolfCrypt API Reference


18.24  MD2


The functions in this section expose MD2 functionality to calling applications.






wc_InitMd2


Synopsis:

#include <wolfssl/wolfcrypt/md2.h>


int wc_InitMd2(md2* md2);


Description:

This function initializes MD2. This is automatically called by wc_Md2Hash.


Return Values:

0: Returned upon successfully initializing


Parameters:

md2 - pointer to the md2 structure to use for encryption


Example:

md2 md2[1];

if ((ret = wc_InitMd2(md2)) != 0) {

  WOLFSSL_MSG("wc_Initmd2 failed");

}

else {

  wc_Md2Update(md2, data, len);

  wc_Md2Final(md2, hash);

}


See Also:

wc_Md2Hash

wc_Md2Update

wc_Md2Final





wc_Md2Update


Synopsis:

#include <wolfssl/wolfcrypt/md2.h>


int wc_Md2Update(md2* md2, const byte* data, word32 len)


Description:

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


Return Values:

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


Parameters:

md2 - pointer to the md2 structure to use for encryption

data - the data to be hashed

len - length of data to be hashed


Example:

md2 md2[1];

if ((ret = wc_InitMd2(md2)) != 0) {

  WOLFSSL_MSG("wc_Initmd2 failed");

}

else {

  wc_Md2Update(md2, data, len);

  wc_Md2Final(md2, hash);

}


See Also:

wc_Md2Hash

wc_Md2Final

wc_InitMd2





wc_Md2Hash


Synopsis:

#include <wolfssl/wolfcrypt/md2.h>


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


Description:

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


Return Values:

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:

data - the data to hash

len - the length of data

hash - Byte array to hold hash value.


See Also:

wc_Md2Hash

wc_Md2Final

wc_InitMd2





wc_Md2Final


Synopsis:

#include <wolfssl/wolfcrypt/md2.h>


int wc_Md2Final(md2* md2, byte* hash)


Description:

Finalizes hashing of data. Result is placed into hash.


Return Values:

0: Returned upon successfully finalizing.


Parameters:

md2 - pointer to the md2 structure to use for encryption

hash - Byte array to hold hash value.


Example:

md2 md2[1];

if ((ret = wc_InitMd2(md2)) != 0) {

  WOLFSSL_MSG("wc_Initmd2 failed");

}

else {

  wc_Md2Update(md2, data, len);

  wc_Md2Final(md2, hash);

}


See Also:

wc_Md2Hash

wc_Md2Final

wc_InitMd2



 

Questions? +1 (425) 245-8247