Made public the wc_PKCS7_GetPadSize API. Cleanup to use GetPadSize for the wc_PKCS7_PadData.

This commit is contained in:
David Garske
2018-01-25 08:14:56 -08:00
parent 138bc3e6cc
commit 058c2a7a25
2 changed files with 4 additions and 3 deletions

View File

@ -2991,7 +2991,7 @@ static int wc_PKCS7_GenerateIV(PKCS7* pkcs7, WC_RNG* rng, byte* iv, word32 ivSz)
/* return size of padded data, padded to blockSz chunks, or negative on error */
static int wc_PKCS7_GetPadSize(word32 inputSz, word32 blockSz)
int wc_PKCS7_GetPadSize(word32 inputSz, word32 blockSz)
{
int padSz;
@ -3005,7 +3005,7 @@ static int wc_PKCS7_GetPadSize(word32 inputSz, word32 blockSz)
/* pad input data to blockSz chunk, place in outSz. out must be big enough
* for input + pad bytes. See wc_PKCS7_GetPadLength() helper. */
* for input + pad bytes. See wc_PKCS7_GetPadSize() helper. */
int wc_PKCS7_PadData(byte* in, word32 inSz, byte* out, word32 outSz,
word32 blockSz)
{
@ -3015,7 +3015,7 @@ int wc_PKCS7_PadData(byte* in, word32 inSz, byte* out, word32 outSz,
out == NULL || outSz == 0)
return BAD_FUNC_ARG;
padSz = blockSz - (inSz % blockSz);
padSz = wc_PKCS7_GetPadSize(inSz, blockSz);
if (outSz < (inSz + padSz))
return BAD_FUNC_ARG;

View File

@ -146,6 +146,7 @@ WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg,
word32 pkiMsgSz, byte* output,
word32 outputSz);
WOLFSSL_API int wc_PKCS7_GetPadSize(word32 inputSz, word32 blockSz);
WOLFSSL_API int wc_PKCS7_PadData(byte* in, word32 inSz, byte* out, word32 outSz,
word32 blockSz);