Skip to content

Commit 8cd6cd1

Browse files
committed
EVP_EncodeBlock should not append a newline
1 parent a3bf7a6 commit 8cd6cd1

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
@@ -4886,6 +4886,7 @@ static int test_wolfSSL_EVP_EncodeUpdate(void)
48864886
const unsigned char plain1[] = {"This is a base64 encodeing test."};
48874887
const unsigned char plain2[] = {"This is additional data."};
48884888

4889+
const unsigned char encBlock0[] = {"VGg="};
48894890
const unsigned char enc0[] = {"VGg=\n"};
48904891
/* expected encoded result for the first output 64 chars plus trailing LF*/
48914892
const unsigned char enc1[] = {"VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVpbmcgdGVzdC5UaGlzIGlzIGFkZGl0aW9u\n"};
@@ -4987,12 +4988,8 @@ static int test_wolfSSL_EVP_EncodeUpdate(void)
49874988

49884989
XMEMSET( encOutBuff,0, sizeof(encOutBuff));
49894990
ExpectIntEQ(EVP_EncodeBlock(encOutBuff, plain0, sizeof(plain0)-1),
4990-
sizeof(enc0)-1);
4991-
ExpectIntEQ(
4992-
XSTRNCMP(
4993-
(const char*)encOutBuff,
4994-
(const char*)enc0,sizeof(enc0) ),
4995-
0);
4991+
sizeof(encBlock0)-1);
4992+
ExpectStrEQ(encOutBuff, encBlock0);
49964993

49974994
/* pass small size( < 48bytes ) input, then make sure they are not
49984995
* 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)