Skip to content

Commit 96977d1

Browse files
Merge pull request #6900 from julek-wolfssl/zd/16868
EVP_EncodeBlock should not append a newline
2 parents 2ee9402 + 8cd6cd1 commit 96977d1

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

tests/api.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4888,6 +4888,7 @@ static int test_wolfSSL_EVP_EncodeUpdate(void)
48884888
const unsigned char plain1[] = {"This is a base64 encodeing test."};
48894889
const unsigned char plain2[] = {"This is additional data."};
48904890

4891+
const unsigned char encBlock0[] = {"VGg="};
48914892
const unsigned char enc0[] = {"VGg=\n"};
48924893
/* expected encoded result for the first output 64 chars plus trailing LF*/
48934894
const unsigned char enc1[] = {"VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVpbmcgdGVzdC5UaGlzIGlzIGFkZGl0aW9u\n"};
@@ -4989,12 +4990,8 @@ static int test_wolfSSL_EVP_EncodeUpdate(void)
49894990

49904991
XMEMSET( encOutBuff,0, sizeof(encOutBuff));
49914992
ExpectIntEQ(EVP_EncodeBlock(encOutBuff, plain0, sizeof(plain0)-1),
4992-
sizeof(enc0)-1);
4993-
ExpectIntEQ(
4994-
XSTRNCMP(
4995-
(const char*)encOutBuff,
4996-
(const char*)enc0,sizeof(enc0) ),
4997-
0);
4993+
sizeof(encBlock0)-1);
4994+
ExpectStrEQ(encOutBuff, encBlock0);
49984995

49994996
/* pass small size( < 48bytes ) input, then make sure they are not
50004997
* encoded and just stored in ctx

wolfcrypt/src/evp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12028,7 +12028,7 @@ int wolfSSL_EVP_EncodeBlock(unsigned char *out, const unsigned char *in,
1202812028
if (out == NULL || in == NULL)
1202912029
return WOLFSSL_FATAL_ERROR;
1203012030

12031-
if (Base64_Encode(in, (word32)inLen, out, &ret) == 0)
12031+
if (Base64_Encode_NoNl(in, (word32)inLen, out, &ret) == 0)
1203212032
return (int)ret;
1203312033
else
1203412034
return WOLFSSL_FATAL_ERROR;

0 commit comments

Comments
 (0)