EVP_EncodeBlock should not append a newline

This commit is contained in:
Juliusz Sosinowicz
2023-10-20 13:20:11 +02:00
parent a3bf7a66a4
commit 8cd6cd175d
2 changed files with 4 additions and 7 deletions

View File

@@ -4886,6 +4886,7 @@ static int test_wolfSSL_EVP_EncodeUpdate(void)
const unsigned char plain1[] = {"This is a base64 encodeing test."};
const unsigned char plain2[] = {"This is additional data."};
const unsigned char encBlock0[] = {"VGg="};
const unsigned char enc0[] = {"VGg=\n"};
/* expected encoded result for the first output 64 chars plus trailing LF*/
const unsigned char enc1[] = {"VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVpbmcgdGVzdC5UaGlzIGlzIGFkZGl0aW9u\n"};
@@ -4987,12 +4988,8 @@ static int test_wolfSSL_EVP_EncodeUpdate(void)
XMEMSET( encOutBuff,0, sizeof(encOutBuff));
ExpectIntEQ(EVP_EncodeBlock(encOutBuff, plain0, sizeof(plain0)-1),
sizeof(enc0)-1);
ExpectIntEQ(
XSTRNCMP(
(const char*)encOutBuff,
(const char*)enc0,sizeof(enc0) ),
0);
sizeof(encBlock0)-1);
ExpectStrEQ(encOutBuff, encBlock0);
/* pass small size( < 48bytes ) input, then make sure they are not
* encoded and just stored in ctx

View File

@@ -12028,7 +12028,7 @@ int wolfSSL_EVP_EncodeBlock(unsigned char *out, const unsigned char *in,
if (out == NULL || in == NULL)
return WOLFSSL_FATAL_ERROR;
if (Base64_Encode(in, (word32)inLen, out, &ret) == 0)
if (Base64_Encode_NoNl(in, (word32)inLen, out, &ret) == 0)
return (int)ret;
else
return WOLFSSL_FATAL_ERROR;