mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
Add corner test cases for EVP_EncodeFinal and EVP_DecodeFinal
This commit is contained in:
16
tests/api.c
16
tests/api.c
@ -2615,6 +2615,16 @@ static void test_wolfSSL_EVP_EncodeUpdate(void)
|
||||
AssertIntEQ(XSTRNCMP(
|
||||
(const char*)encOutBuff,(const char*)enc2,sizeof(enc2) ),0);
|
||||
|
||||
/* test with illeagal parameters */
|
||||
outl = 1;
|
||||
EVP_EncodeFinal(NULL, encOutBuff + outl, &outl);
|
||||
AssertIntEQ(outl, 0);
|
||||
outl = 1;
|
||||
EVP_EncodeFinal(ctx, NULL, &outl);
|
||||
AssertIntEQ(outl, 0);
|
||||
EVP_EncodeFinal(ctx, encOutBuff + outl, NULL);
|
||||
EVP_EncodeFinal(NULL, NULL, NULL);
|
||||
|
||||
EVP_ENCODE_CTX_free(ctx);
|
||||
printf(resultFmt, passed);
|
||||
#endif /* OPENSSL_EXTRA && WOLFSSL_BASE64_ENCODE*/
|
||||
@ -2852,6 +2862,12 @@ static void test_wolfSSL_EVP_DecodeUpdate(void)
|
||||
|
||||
AssertIntEQ(outl,sizeof(plain4)-1);
|
||||
|
||||
/* test with illegal parameters */
|
||||
AssertIntEQ(EVP_DecodeFinal(NULL,decOutBuff + outl,&outl), -1);
|
||||
AssertIntEQ(EVP_DecodeFinal(ctx,NULL,&outl), -1);
|
||||
AssertIntEQ(EVP_DecodeFinal(ctx,decOutBuff + outl, NULL), -1);
|
||||
AssertIntEQ(EVP_DecodeFinal(NULL,NULL, NULL), -1);
|
||||
|
||||
EVP_DecodeFinal(
|
||||
ctx,
|
||||
decOutBuff + outl,
|
||||
|
@ -6958,9 +6958,10 @@ int wolfSSL_EVP_EncodeUpdate(WOLFSSL_EVP_ENCODE_CTX* ctx,
|
||||
outsz = BASE64_ENCODE_RESULT_BLOCK_SIZE + 1;
|
||||
res = Base64_Encode(ctx->data, BASE64_ENCODE_BLOCK_SIZE, out,
|
||||
&outsz);
|
||||
ctx->remaining = 0;
|
||||
if (res == 0)
|
||||
if (res == 0) {
|
||||
ctx->remaining = 0;
|
||||
*outl = outsz;
|
||||
}
|
||||
else
|
||||
return 0; /* return with error */
|
||||
}
|
||||
|
Reference in New Issue
Block a user