2017-12-29 10:45:37 -07:00
|
|
|
|
/*!
|
|
|
|
|
\ingroup RIPEMD
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
|
|
|
|
\brief This function initializes a ripemd structure by initializing
|
2017-12-29 10:45:37 -07:00
|
|
|
|
ripemd’s digest, buffer, loLen and hiLen.
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
|
|
|
|
\return 0 returned on successful execution of the function. The RipeMd
|
2017-12-29 10:45:37 -07:00
|
|
|
|
structure is initialized.
|
|
|
|
|
\return BAD_FUNC_ARG returned if the RipeMd structure is NULL.
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
|
\param ripemd pointer to the ripemd structure to initialize
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
|
_Example_
|
|
|
|
|
\code
|
|
|
|
|
RipeMd md;
|
|
|
|
|
int ret;
|
|
|
|
|
ret = wc_InitRipeMd(&md);
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
// Failure case.
|
|
|
|
|
}
|
|
|
|
|
\endcode
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
|
\sa wc_RipeMdUpdate
|
|
|
|
|
\sa wc_RipeMdFinal
|
|
|
|
|
*/
|
|
|
|
|
WOLFSSL_API int wc_InitRipeMd(RipeMd*);
|
2018-05-02 13:28:17 -06:00
|
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
|
/*!
|
|
|
|
|
\ingroup RIPEMD
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
|
|
|
|
\brief This function generates the RipeMd digest of the data input and
|
|
|
|
|
stores the result in the ripemd->digest buffer. After running
|
|
|
|
|
wc_RipeMdUpdate, one should compare the generated ripemd->digest to a
|
2017-12-29 10:45:37 -07:00
|
|
|
|
known authentication tag to verify the authenticity of a message.
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
|
\return 0 Returned on successful execution of the function.
|
2018-06-27 16:22:12 -06:00
|
|
|
|
\return BAD_FUNC_ARG Returned if the RipeMd structure is NULL or if data
|
|
|
|
|
is NULL and len is not zero. This function should execute if data is NULL
|
2017-12-29 10:45:37 -07:00
|
|
|
|
and len is 0.
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
|
|
|
|
\param ripemd: pointer to the ripemd structure to be initialized with
|
2017-12-29 10:45:37 -07:00
|
|
|
|
wc_InitRipeMd
|
|
|
|
|
\param data data to be hashed
|
|
|
|
|
\param len sizeof data in bytes
|
|
|
|
|
|
|
|
|
|
_Example_
|
|
|
|
|
\code
|
|
|
|
|
const byte* data; // The data to be hashed
|
|
|
|
|
....
|
|
|
|
|
RipeMd md;
|
|
|
|
|
int ret;
|
|
|
|
|
ret = wc_InitRipeMd(&md);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
ret = wc_RipeMdUpdate(&md, plain, sizeof(plain));
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
// Failure case …
|
|
|
|
|
\endcode
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
|
\sa wc_InitRipeMd
|
|
|
|
|
\sa wc_RipeMdFinal
|
|
|
|
|
*/
|
|
|
|
|
WOLFSSL_API int wc_RipeMdUpdate(RipeMd*, const byte*, word32);
|
2018-05-02 13:28:17 -06:00
|
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
|
/*!
|
2018-06-27 16:22:12 -06:00
|
|
|
|
\ingroup RIPEMD
|
|
|
|
|
|
|
|
|
|
\brief This function copies the computed digest into hash. If there is a
|
|
|
|
|
partial unhashed block, this method will pad the block with 0s, and
|
|
|
|
|
include that block’s round in the digest before copying to hash. State
|
2017-12-29 10:45:37 -07:00
|
|
|
|
of ripemd is reset.
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
|
|
|
|
\return 0 Returned on successful execution of the function. The state of
|
2017-12-29 10:45:37 -07:00
|
|
|
|
the RipeMd structure has been reset.
|
2018-06-27 16:22:12 -06:00
|
|
|
|
\return BAD_FUNC_ARG Returned if the RipeMd structure or hash parameters
|
2017-12-29 10:45:37 -07:00
|
|
|
|
are NULL.
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
|
|
|
|
\param ripemd pointer to the ripemd structure to be initialized with
|
|
|
|
|
wc_InitRipeMd, and containing hashes from wc_RipeMdUpdate. State will
|
2017-12-29 10:45:37 -07:00
|
|
|
|
be reset
|
|
|
|
|
\param hash buffer to copy digest to. Should be RIPEMD_DIGEST_SIZE bytes
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
|
_Example_
|
|
|
|
|
\code
|
|
|
|
|
RipeMd md;
|
|
|
|
|
int ret;
|
|
|
|
|
byte digest[RIPEMD_DIGEST_SIZE];
|
|
|
|
|
const byte* data; // The data to be hashed
|
2018-06-27 16:22:12 -06:00
|
|
|
|
...
|
2017-12-29 10:45:37 -07:00
|
|
|
|
ret = wc_InitRipeMd(&md);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
ret = wc_RipeMdUpdate(&md, plain, sizeof(plain));
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
// RipeMd Update Failure Case.
|
|
|
|
|
}
|
|
|
|
|
ret = wc_RipeMdFinal(&md, digest);
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
// RipeMd Final Failure Case.
|
|
|
|
|
}...
|
|
|
|
|
\endcode
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
|
\sa none
|
|
|
|
|
*/
|
|
|
|
|
WOLFSSL_API int wc_RipeMdFinal(RipeMd*, byte*);
|