29#define CERT_HEADER "-----BEGIN CERTIFICATE-----\r\n"
30#define ALT_CERT_HEADER "-----BEGIN This is some arbitrary text that goes on and on-----\r\n"
31#define CERT_TRAILER "-----END CERTIFICATE-----\r\n"
32#define ALT_CERT_TRAILER "-----END More arbitrary text------\r\n"
33#define CERT_REQUEST_HEADER "-----BEGIN NEW CERTIFICATE REQUEST-----\r\n"
34#define CERT_REQUEST_TRAILER "-----END NEW CERTIFICATE REQUEST-----\r\n"
35#define X509_HEADER "-----BEGIN X509 CRL-----\r\n"
36#define X509_TRAILER "-----END X509 CRL-----\r\n"
37#define CERT_HEADER_NOCR "-----BEGIN CERTIFICATE-----\n"
38#define CERT_TRAILER_NOCR "-----END CERTIFICATE-----\n"
39#define CERT_REQUEST_HEADER_NOCR "-----BEGIN NEW CERTIFICATE REQUEST-----\n"
40#define CERT_REQUEST_TRAILER_NOCR "-----END NEW CERTIFICATE REQUEST-----\n"
41#define X509_HEADER_NOCR "-----BEGIN X509 CRL-----\n"
42#define X509_TRAILER_NOCR "-----END X509 CRL-----\n"
55 "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"
56 "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"
57 "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
59 "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHI";
66 "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISUpL\r\n"
67 "TE1OT1BRUlNUVVZXWFlaMDEyMzQ1Njc4OTBhYmNkZWZnaGlqbGttbm9wcXJzdHV2\r\n"
68 "d3h5ejAxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU2\r\n"
69 "Nzg5MGFiY2RlZmdoaWpsa21ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OTBBQkNERUZH\r\n"
70 "SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\r\n" },
72 "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=\r\n" },
80 "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISUpL\n"
81 "TE1OT1BRUlNUVVZXWFlaMDEyMzQ1Njc4OTBhYmNkZWZnaGlqbGttbm9wcXJzdHV2\n"
82 "d3h5ejAxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU2\n"
83 "Nzg5MGFiY2RlZmdoaWpsa21ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OTBBQkNERUZH\n"
84 "SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\n" },
86 "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=\n" },
105 DWORD strLen, strLen2, required;
114 required +=
strlen(trailer);
119 ok(strLen == required,
"Unexpected required length %u, expected %u.\n", required, strLen);
124 ok(strLen == strLen2,
"Unexpected required length.\n");
126 strLen2 = strLen - 1;
129 ok(strLen == strLen2,
"Unexpected required length.\n");
134 strLen2 = strLen - 1;
140 ok(strLen2 == strLen ||
broken(strLen2 == strLen - 1),
"Expected length %d, got %d\n", strLen - 1, strLen);
143 ok(
str[0] ==
header[0],
"Unexpected buffer contents %#x.\n",
str[0]);
150 ok(strLen2 == strLen - 1,
"Expected length %d, got %d\n", strLen - 1, strLen);
169 WCHAR *headerW, *trailerW, required;
170 DWORD strLen, strLen2;
179 required +=
strlen(trailer);
184 ok(strLen == required,
"Unexpected required length %u, expected %u.\n", strLen, required);
190 ok(strLen == strLen2,
"Unexpected required length.\n");
192 strLen2 = strLen - 1;
195 ok(strLen == strLen2,
"Unexpected required length.\n");
197 strLen2 = strLen - 1;
200 ok(strLen == strLen2,
"Unexpected required length.\n");
207 strLen2 = strLen - 1;
214 ok(
strW[0] == 0x1234,
"Unexpected buffer contents %#x.\n",
strW[0]);
216 ok(
strW[0] == 0x1234 ||
broken(
strW[0] != 0x1234) ,
"Unexpected buffer contents %#x.\n",
strW[0]);
222 ok(strLen2 == strLen - 1,
"Expected length %d, got %d\n", strLen - 1, strLen);
250 "Expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
255 "Expected ERROR_INVALID_PARAMETER, got %d\n",
GetLastError());
256 ok(strLen == 123,
"Unexpected length.\n");
264 ok(strLen == 123,
"Unexpected length.\n");
281 ok(strLen == strLen2,
"Expected length %u, got %u\n", strLen, strLen2);
294 ok(strLen == strLen2,
"Expected length %u, got %u\n", strLen, strLen2);
335 ok(strLen == strLen2,
"Expected length %d, got %d\n", strLen, strLen2);
370 static const char garbage[] =
"garbage\r\n";
398 DWORD skipped, usedFormat;
404 ok(bufLen == expectedLen,
405 "Expected length %d, got %d\n", expectedLen, bufLen);
409 &skipped, &usedFormat);
411 ok(skipped == 0,
"Expected skipped 0, got %d\n", skipped);
412 ok(usedFormat == expectedFormat,
"Expected format %d, got %d\n",
413 expectedFormat, usedFormat);
431 "Expected !ret and last error ERROR_INVALID_DATA, got ret=%d, error=%d\n",
ret,
GetLastError());
437 DWORD skipped, usedFormat;
440 &skipped, &usedFormat);
443 "Expected %d characters of \"%s\" skipped when trying format %08x, got %d (used format is %08x)\n",
444 lstrlenA(garbage),
str, useFormat, skipped, usedFormat);
456 DWORD bufLen =
sizeof(
buf)-1, fmtUsed = 0xdeadbeef;
462 ok(
ret == retA && bufLen == bufLenA &&
memcmp(bufA,
buf, bufLen) == 0
463 && fmtUsed == fmtUsedA,
"base64 \"%s\" len %d: W and A differ\n",
strA,
len);
469 DWORD bufLen =
sizeof(
buf)-1, fmtUsed = 0xdeadbeef;
477 "base64 \"%s\" len %d: expected \"%s\", got \"%s\" (ret %d, le %d)\n",
480 ok(fmtUsed ==
fmt,
"base64 \"%s\" len %d: expected fmt %d, used %d\n",
484 "base64 \"%s\" len %d: expected failure, got \"%s\" (ret %d, le %d)\n",
524 "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%u\n",
ret,
GetLastError());
527 "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%u\n",
ret,
GetLastError());
532 "Expected ERROR_INVALID_DATA, got ret=%d le=%u\n",
ret,
GetLastError());
537 "Expected ERROR_INVALID_DATA, got ret=%d le=%u\n",
ret,
GetLastError());
545 "%d: Expected ERROR_INVALID_DATA, got ret=%d le=%u\n",
i,
ret,
GetLastError());
601 ok(!
ret && bufLen == 4 &&
buf[0] == 0,
602 "Expected ret 0, bufLen 4, buf[0] '\\0', got ret %d, bufLen %d, buf[0] '%c'\n",
char * strcat(char *DstString, const char *SrcString)
int strcmp(const char *String1, const char *String2)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strcpy(char *DstString, const char *SrcString)
static void * heap_alloc(size_t len)
static BOOL heap_free(void *mem)
BOOL WINAPI CryptBinaryToStringW(const BYTE *pbBinary, DWORD cbBinary, DWORD dwFlags, LPWSTR pszString, DWORD *pcchString)
BOOL WINAPI CryptStringToBinaryW(LPCWSTR pszString, DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
BOOL WINAPI CryptStringToBinaryA(LPCSTR pszString, DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
#define CERT_REQUEST_HEADER
BOOL WINAPI CryptBinaryToStringA(const BYTE *pbBinary, DWORD cbBinary, DWORD dwFlags, LPSTR pszString, DWORD *pcchString)
#define CERT_REQUEST_TRAILER
#define ERROR_INVALID_PARAMETER
#define HeapFree(x, y, z)
#define MultiByteToWideChar
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
int WINAPI lstrlenA(LPCSTR lpString)
static const BYTE toEncode4[]
static void decodeBase64WithLen(LPCSTR str, int len, LPCSTR expected, int le)
static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen, DWORD format, const char *expected, const char *header, const char *trailer)
static const struct BinTests tests[]
#define CERT_REQUEST_HEADER_NOCR
static void decodeBase64WithFmt(LPCSTR str, DWORD fmt, LPCSTR expected, int le)
#define CERT_TRAILER_NOCR
static const BYTE toEncode1[]
static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWORD format, const WCHAR *expected, const char *header, const char *trailer)
static const struct BadString badStrings[]
static void decodeBase64WithLenFmt(LPCSTR str, int len, DWORD fmt, LPCSTR expected, int le, BOOL isBroken)
static const BYTE toEncode2[]
static const BYTE toEncode5[]
static void testStringToBinaryA(void)
static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header, LPCSTR trailer, DWORD useFormat, DWORD expectedFormat, const BYTE *expected, DWORD expectedLen)
static void decodeBase64WithLenFmtW(LPCSTR strA, int len, DWORD fmt, BOOL retA, const BYTE *bufA, DWORD bufLenA, DWORD fmtUsedA)
static WCHAR * strdupAtoW(const char *str)
static const struct BinTests testsNoCR[]
static void decodeBase64WithLenBroken(LPCSTR str, int len, LPCSTR expected, int le)
#define CERT_REQUEST_TRAILER_NOCR
static void test_CryptBinaryToString(void)
#define X509_TRAILER_NOCR
DWORD WINAPI GetLastError(void)
#define CRYPT_STRING_BINARY
#define CRYPT_STRING_BASE64X509CRLHEADER
#define CRYPT_STRING_BASE64REQUESTHEADER
#define CRYPT_STRING_BASE64HEADER
#define CRYPT_STRING_BASE64
#define CRYPT_STRING_BASE64_ANY
#define CRYPT_STRING_NOCR
#define ERROR_INVALID_DATA