crypt32: CryptStringToBinary accepts any header.
For example, X509 CRL accepts -----BEGIN foo-----. Signed-off-by: Lauri Kenttä <lauri.kentta@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
552820acbf
commit
a2f2de1e96
|
@ -603,10 +603,12 @@ static LONG Base64ToBinaryA(LPCSTR pszString, DWORD cchString,
|
||||||
}
|
}
|
||||||
|
|
||||||
static LONG Base64WithHeaderAndTrailerToBinaryA(LPCSTR pszString,
|
static LONG Base64WithHeaderAndTrailerToBinaryA(LPCSTR pszString,
|
||||||
DWORD cchString, LPCSTR header, LPCSTR trailer, BYTE *pbBinary,
|
DWORD cchString, BYTE *pbBinary,
|
||||||
DWORD *pcbBinary, DWORD *pdwSkip, BOOL exactHeaderAndTrailerMatch)
|
DWORD *pcbBinary, DWORD *pdwSkip, BOOL exactHeaderAndTrailerMatch)
|
||||||
{
|
{
|
||||||
LONG ret;
|
LONG ret;
|
||||||
|
LPCSTR header = CERT_HEADER_START;
|
||||||
|
LPCSTR trailer = CERT_TRAILER_START;
|
||||||
|
|
||||||
LPCSTR headerBegins;
|
LPCSTR headerBegins;
|
||||||
LPCSTR dataBegins;
|
LPCSTR dataBegins;
|
||||||
|
@ -678,7 +680,7 @@ static LONG Base64HeaderToBinaryA(LPCSTR pszString, DWORD cchString,
|
||||||
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
{
|
{
|
||||||
LONG ret = Base64WithHeaderAndTrailerToBinaryA(pszString, cchString,
|
LONG ret = Base64WithHeaderAndTrailerToBinaryA(pszString, cchString,
|
||||||
CERT_HEADER_START, CERT_TRAILER_START, pbBinary, pcbBinary, pdwSkip, FALSE);
|
pbBinary, pcbBinary, pdwSkip, FALSE);
|
||||||
|
|
||||||
if (!ret && pdwFlags)
|
if (!ret && pdwFlags)
|
||||||
*pdwFlags = CRYPT_STRING_BASE64HEADER;
|
*pdwFlags = CRYPT_STRING_BASE64HEADER;
|
||||||
|
@ -689,7 +691,7 @@ static LONG Base64RequestHeaderToBinaryA(LPCSTR pszString, DWORD cchString,
|
||||||
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
{
|
{
|
||||||
LONG ret = Base64WithHeaderAndTrailerToBinaryA(pszString, cchString,
|
LONG ret = Base64WithHeaderAndTrailerToBinaryA(pszString, cchString,
|
||||||
CERT_REQUEST_HEADER, CERT_REQUEST_TRAILER, pbBinary, pcbBinary, pdwSkip, TRUE);
|
pbBinary, pcbBinary, pdwSkip, FALSE);
|
||||||
|
|
||||||
if (!ret && pdwFlags)
|
if (!ret && pdwFlags)
|
||||||
*pdwFlags = CRYPT_STRING_BASE64REQUESTHEADER;
|
*pdwFlags = CRYPT_STRING_BASE64REQUESTHEADER;
|
||||||
|
@ -700,7 +702,7 @@ static LONG Base64X509HeaderToBinaryA(LPCSTR pszString, DWORD cchString,
|
||||||
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
{
|
{
|
||||||
LONG ret = Base64WithHeaderAndTrailerToBinaryA(pszString, cchString,
|
LONG ret = Base64WithHeaderAndTrailerToBinaryA(pszString, cchString,
|
||||||
X509_HEADER, X509_TRAILER, pbBinary, pcbBinary, pdwSkip, TRUE);
|
pbBinary, pcbBinary, pdwSkip, FALSE);
|
||||||
|
|
||||||
if (!ret && pdwFlags)
|
if (!ret && pdwFlags)
|
||||||
*pdwFlags = CRYPT_STRING_BASE64X509CRLHEADER;
|
*pdwFlags = CRYPT_STRING_BASE64X509CRLHEADER;
|
||||||
|
@ -835,10 +837,12 @@ static LONG Base64ToBinaryW(LPCWSTR pszString, DWORD cchString,
|
||||||
}
|
}
|
||||||
|
|
||||||
static LONG Base64WithHeaderAndTrailerToBinaryW(LPCWSTR pszString,
|
static LONG Base64WithHeaderAndTrailerToBinaryW(LPCWSTR pszString,
|
||||||
DWORD cchString, LPCWSTR header, LPCWSTR trailer, BYTE *pbBinary,
|
DWORD cchString, BYTE *pbBinary,
|
||||||
DWORD *pcbBinary, DWORD *pdwSkip, BOOL exactHeaderAndTrailerMatch)
|
DWORD *pcbBinary, DWORD *pdwSkip, BOOL exactHeaderAndTrailerMatch)
|
||||||
{
|
{
|
||||||
LONG ret;
|
LONG ret;
|
||||||
|
LPCWSTR header = CERT_HEADER_START_W;
|
||||||
|
LPCWSTR trailer = CERT_TRAILER_START_W;
|
||||||
|
|
||||||
LPCWSTR headerBegins;
|
LPCWSTR headerBegins;
|
||||||
LPCWSTR dataBegins;
|
LPCWSTR dataBegins;
|
||||||
|
@ -910,8 +914,7 @@ static LONG Base64HeaderToBinaryW(LPCWSTR pszString, DWORD cchString,
|
||||||
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
{
|
{
|
||||||
LONG ret = Base64WithHeaderAndTrailerToBinaryW(pszString, cchString,
|
LONG ret = Base64WithHeaderAndTrailerToBinaryW(pszString, cchString,
|
||||||
CERT_HEADER_START_W, CERT_TRAILER_START_W, pbBinary, pcbBinary,
|
pbBinary, pcbBinary, pdwSkip, FALSE);
|
||||||
pdwSkip, FALSE);
|
|
||||||
|
|
||||||
if (!ret && pdwFlags)
|
if (!ret && pdwFlags)
|
||||||
*pdwFlags = CRYPT_STRING_BASE64HEADER;
|
*pdwFlags = CRYPT_STRING_BASE64HEADER;
|
||||||
|
@ -922,8 +925,7 @@ static LONG Base64RequestHeaderToBinaryW(LPCWSTR pszString, DWORD cchString,
|
||||||
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
{
|
{
|
||||||
LONG ret = Base64WithHeaderAndTrailerToBinaryW(pszString, cchString,
|
LONG ret = Base64WithHeaderAndTrailerToBinaryW(pszString, cchString,
|
||||||
CERT_REQUEST_HEADER_W, CERT_REQUEST_TRAILER_W, pbBinary, pcbBinary,
|
pbBinary, pcbBinary, pdwSkip, FALSE);
|
||||||
pdwSkip, TRUE);
|
|
||||||
|
|
||||||
if (!ret && pdwFlags)
|
if (!ret && pdwFlags)
|
||||||
*pdwFlags = CRYPT_STRING_BASE64REQUESTHEADER;
|
*pdwFlags = CRYPT_STRING_BASE64REQUESTHEADER;
|
||||||
|
@ -934,7 +936,7 @@ static LONG Base64X509HeaderToBinaryW(LPCWSTR pszString, DWORD cchString,
|
||||||
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
{
|
{
|
||||||
LONG ret = Base64WithHeaderAndTrailerToBinaryW(pszString, cchString,
|
LONG ret = Base64WithHeaderAndTrailerToBinaryW(pszString, cchString,
|
||||||
X509_HEADER_W, X509_TRAILER_W, pbBinary, pcbBinary, pdwSkip, TRUE);
|
pbBinary, pcbBinary, pdwSkip, FALSE);
|
||||||
|
|
||||||
if (!ret && pdwFlags)
|
if (!ret && pdwFlags)
|
||||||
*pdwFlags = CRYPT_STRING_BASE64X509CRLHEADER;
|
*pdwFlags = CRYPT_STRING_BASE64X509CRLHEADER;
|
||||||
|
|
|
@ -419,7 +419,6 @@ static void testStringToBinaryA(void)
|
||||||
decodeBase64WithFmt("-----BEGIN foo-----V-----END -----", CRYPT_STRING_BASE64HEADER, "T", 0);
|
decodeBase64WithFmt("-----BEGIN foo-----V-----END -----", CRYPT_STRING_BASE64HEADER, "T", 0);
|
||||||
decodeBase64WithFmt("-----BEGIN foo-----V-----END foo-----", CRYPT_STRING_BASE64HEADER, "T", 0);
|
decodeBase64WithFmt("-----BEGIN foo-----V-----END foo-----", CRYPT_STRING_BASE64HEADER, "T", 0);
|
||||||
decodeBase64WithFmt("-----BEGIN -----V-----END foo-----", CRYPT_STRING_BASE64HEADER, "T", 0);
|
decodeBase64WithFmt("-----BEGIN -----V-----END foo-----", CRYPT_STRING_BASE64HEADER, "T", 0);
|
||||||
todo_wine {
|
|
||||||
decodeBase64WithFmt("-----BEGIN -----V-----END -----", CRYPT_STRING_BASE64X509CRLHEADER, "T", 0);
|
decodeBase64WithFmt("-----BEGIN -----V-----END -----", CRYPT_STRING_BASE64X509CRLHEADER, "T", 0);
|
||||||
decodeBase64WithFmt("-----BEGIN foo-----V-----END -----", CRYPT_STRING_BASE64X509CRLHEADER, "T", 0);
|
decodeBase64WithFmt("-----BEGIN foo-----V-----END -----", CRYPT_STRING_BASE64X509CRLHEADER, "T", 0);
|
||||||
decodeBase64WithFmt("-----BEGIN foo-----V-----END foo-----", CRYPT_STRING_BASE64X509CRLHEADER, "T", 0);
|
decodeBase64WithFmt("-----BEGIN foo-----V-----END foo-----", CRYPT_STRING_BASE64X509CRLHEADER, "T", 0);
|
||||||
|
@ -428,7 +427,6 @@ static void testStringToBinaryA(void)
|
||||||
decodeBase64WithFmt("-----BEGIN foo-----V-----END -----", CRYPT_STRING_BASE64REQUESTHEADER, "T", 0);
|
decodeBase64WithFmt("-----BEGIN foo-----V-----END -----", CRYPT_STRING_BASE64REQUESTHEADER, "T", 0);
|
||||||
decodeBase64WithFmt("-----BEGIN foo-----V-----END foo-----", CRYPT_STRING_BASE64REQUESTHEADER, "T", 0);
|
decodeBase64WithFmt("-----BEGIN foo-----V-----END foo-----", CRYPT_STRING_BASE64REQUESTHEADER, "T", 0);
|
||||||
decodeBase64WithFmt("-----BEGIN -----V-----END foo-----", CRYPT_STRING_BASE64REQUESTHEADER, "T", 0);
|
decodeBase64WithFmt("-----BEGIN -----V-----END foo-----", CRYPT_STRING_BASE64REQUESTHEADER, "T", 0);
|
||||||
}
|
|
||||||
|
|
||||||
/* Too small buffer */
|
/* Too small buffer */
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
|
|
Loading…
Reference in New Issue