1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

crypt32: Fix CryptBinaryToString not adding a separator.

This commit is contained in:
Santino Mazza 2024-03-22 17:08:32 -03:00 committed by Alexandre Julliard
parent df97793045
commit 624e87a725
2 changed files with 17 additions and 7 deletions

View file

@ -111,8 +111,6 @@ static DWORD encodeBase64A(const BYTE *in_buf, int in_len, LPCSTR sep,
i = 0;
while (div > 0 && ptr < end)
{
if (i && i % 64 == 0)
ptr += stradd(ptr, end, sep, strlen(sep));
/* first char is the first 6 bits of the first byte*/
chunk[0] = b64[ ( d[0] >> 2) & 0x3f ];
/* second char is the last 2 bits of the first byte and the first 4
@ -127,6 +125,9 @@ static DWORD encodeBase64A(const BYTE *in_buf, int in_len, LPCSTR sep,
i += 4;
d += 3;
div--;
if (i && i % 64 == 0)
ptr += stradd(ptr, end, sep, strlen(sep));
}
switch(pad_bytes)
@ -393,11 +394,6 @@ static LONG encodeBase64W(const BYTE *in_buf, int in_len, LPCWSTR sep,
i = 0;
while (div > 0)
{
if (i && i % 64 == 0)
{
lstrcpyW(ptr, sep);
ptr += lstrlenW(sep);
}
/* first char is the first 6 bits of the first byte*/
*ptr++ = b64[ ( d[0] >> 2) & 0x3f ];
/* second char is the last 2 bits of the first byte and the first 4
@ -411,6 +407,12 @@ static LONG encodeBase64W(const BYTE *in_buf, int in_len, LPCWSTR sep,
i += 4;
d += 3;
div--;
if (i && i % 64 == 0)
{
lstrcpyW(ptr, sep);
ptr += lstrlenW(sep);
}
}
switch(pad_bytes)

View file

@ -57,6 +57,8 @@ static const BYTE toEncode4[] =
static const BYTE toEncode5[] =
"abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHI";
static const BYTE toEncode6[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
static const struct BinTests tests[] = {
{ toEncode1, sizeof(toEncode1), "AA==\r\n", },
{ toEncode2, sizeof(toEncode2), "AQI=\r\n", },
@ -69,6 +71,9 @@ static const struct BinTests tests[] = {
"SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\r\n" },
{ toEncode5, sizeof(toEncode5),
"YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=\r\n" },
{ toEncode6, sizeof(toEncode6),
"YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh\r\n"
"YQA=\r\n" },
};
static const struct BinTests testsNoCR[] = {
@ -83,6 +88,9 @@ static const struct BinTests testsNoCR[] = {
"SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\n" },
{ toEncode5, sizeof(toEncode5),
"YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=\n" },
{ toEncode6, sizeof(toEncode6),
"YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh\n"
"YQA=\n" },
};
static WCHAR *strdupAtoW(const char *str)