forked from wolfSSL/wolfssl
Made public the wc_PKCS7_GetPadSize
API. Cleanup to use GetPadSize for the wc_PKCS7_PadData
.
This commit is contained in:
@ -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 */
|
/* 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;
|
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
|
/* 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,
|
int wc_PKCS7_PadData(byte* in, word32 inSz, byte* out, word32 outSz,
|
||||||
word32 blockSz)
|
word32 blockSz)
|
||||||
{
|
{
|
||||||
@ -3015,7 +3015,7 @@ int wc_PKCS7_PadData(byte* in, word32 inSz, byte* out, word32 outSz,
|
|||||||
out == NULL || outSz == 0)
|
out == NULL || outSz == 0)
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
padSz = blockSz - (inSz % blockSz);
|
padSz = wc_PKCS7_GetPadSize(inSz, blockSz);
|
||||||
|
|
||||||
if (outSz < (inSz + padSz))
|
if (outSz < (inSz + padSz))
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
@ -146,6 +146,7 @@ WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg,
|
|||||||
word32 pkiMsgSz, byte* output,
|
word32 pkiMsgSz, byte* output,
|
||||||
word32 outputSz);
|
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,
|
WOLFSSL_API int wc_PKCS7_PadData(byte* in, word32 inSz, byte* out, word32 outSz,
|
||||||
word32 blockSz);
|
word32 blockSz);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user