mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 08:03:01 +00:00
Autosyncing with Wine HEAD
svn path=/trunk/; revision=22883
This commit is contained in:
parent
790e2352f2
commit
03475ee8e9
24 changed files with 6998 additions and 4412 deletions
579
reactos/dll/win32/crypt32/base64.c
Normal file
579
reactos/dll/win32/crypt32/base64.c
Normal file
|
@ -0,0 +1,579 @@
|
||||||
|
/*
|
||||||
|
* base64 encoder/decoder
|
||||||
|
*
|
||||||
|
* Copyright 2005 by Kai Blin
|
||||||
|
* Copyright 2006 Juan Lang
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "windef.h"
|
||||||
|
#include "winbase.h"
|
||||||
|
#include "winerror.h"
|
||||||
|
#include "wincrypt.h"
|
||||||
|
#include "wine/debug.h"
|
||||||
|
|
||||||
|
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
|
||||||
|
|
||||||
|
#define CERT_HEADER "-----BEGIN CERTIFICATE-----"
|
||||||
|
#define CERT_TRAILER "-----END CERTIFICATE-----"
|
||||||
|
#define CERT_REQUEST_HEADER "-----BEGIN NEW CERTIFICATE REQUEST-----"
|
||||||
|
#define CERT_REQUEST_TRAILER "-----END NEW CERTIFICATE REQUEST-----"
|
||||||
|
#define X509_HEADER "-----BEGIN X509 CRL-----"
|
||||||
|
#define X509_TRAILER "-----END X509 CRL-----"
|
||||||
|
|
||||||
|
static const char b64[] =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
|
typedef BOOL (*BinaryToStringAFunc)(const BYTE *pbBinary,
|
||||||
|
DWORD cbBinary, DWORD dwFlags, LPSTR pszString, DWORD *pcchString);
|
||||||
|
|
||||||
|
static BOOL EncodeBinaryToBinaryA(const BYTE *pbBinary,
|
||||||
|
DWORD cbBinary, DWORD dwFlags, LPSTR pszString, DWORD *pcchString)
|
||||||
|
{
|
||||||
|
BOOL ret = TRUE;
|
||||||
|
|
||||||
|
if (*pcchString < cbBinary)
|
||||||
|
{
|
||||||
|
if (!pszString)
|
||||||
|
*pcchString = cbBinary;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
*pcchString = cbBinary;
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (cbBinary)
|
||||||
|
memcpy(pszString, pbBinary, cbBinary);
|
||||||
|
*pcchString = cbBinary;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LONG encodeBase64A(const BYTE *in_buf, int in_len, LPCSTR sep,
|
||||||
|
char* out_buf, DWORD *out_len)
|
||||||
|
{
|
||||||
|
int div, i;
|
||||||
|
const BYTE *d = in_buf;
|
||||||
|
int bytes = (in_len*8 + 5)/6, pad_bytes = (bytes % 4) ? 4 - (bytes % 4) : 0;
|
||||||
|
DWORD needed;
|
||||||
|
LPSTR ptr;
|
||||||
|
|
||||||
|
TRACE("bytes is %d, pad bytes is %d\n", bytes, pad_bytes);
|
||||||
|
needed = bytes + pad_bytes + 1;
|
||||||
|
needed += (needed / 64 + 1) * strlen(sep);
|
||||||
|
|
||||||
|
if (needed > *out_len)
|
||||||
|
{
|
||||||
|
*out_len = needed;
|
||||||
|
return ERROR_INSUFFICIENT_BUFFER;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*out_len = needed;
|
||||||
|
|
||||||
|
/* Three bytes of input give 4 chars of output */
|
||||||
|
div = in_len / 3;
|
||||||
|
|
||||||
|
ptr = out_buf;
|
||||||
|
i = 0;
|
||||||
|
while (div > 0)
|
||||||
|
{
|
||||||
|
if (i && i % 64 == 0)
|
||||||
|
{
|
||||||
|
strcpy(ptr, sep);
|
||||||
|
ptr += strlen(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
|
||||||
|
* bits of the second byte */
|
||||||
|
*ptr++ = b64[ ((d[0] << 4) & 0x30) | (d[1] >> 4 & 0x0f)];
|
||||||
|
/* third char is the last 4 bits of the second byte and the first 2
|
||||||
|
* bits of the third byte */
|
||||||
|
*ptr++ = b64[ ((d[1] << 2) & 0x3c) | (d[2] >> 6 & 0x03)];
|
||||||
|
/* fourth char is the remaining 6 bits of the third byte */
|
||||||
|
*ptr++ = b64[ d[2] & 0x3f];
|
||||||
|
i += 4;
|
||||||
|
d += 3;
|
||||||
|
div--;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(pad_bytes)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
/* 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
|
||||||
|
* bits of the second byte */
|
||||||
|
*ptr++ = b64[ ((d[0] << 4) & 0x30) | (d[1] >> 4 & 0x0f)];
|
||||||
|
/* third char is the last 4 bits of the second byte padded with
|
||||||
|
* two zeroes */
|
||||||
|
*ptr++ = b64[ ((d[1] << 2) & 0x3c) ];
|
||||||
|
/* fourth char is a = to indicate one byte of padding */
|
||||||
|
*ptr++ = '=';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
/* 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 padded with
|
||||||
|
* four zeroes*/
|
||||||
|
*ptr++ = b64[ ((d[0] << 4) & 0x30)];
|
||||||
|
/* third char is = to indicate padding */
|
||||||
|
*ptr++ = '=';
|
||||||
|
/* fourth char is = to indicate padding */
|
||||||
|
*ptr++ = '=';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
strcpy(ptr, sep);
|
||||||
|
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL BinaryToBase64A(const BYTE *pbBinary,
|
||||||
|
DWORD cbBinary, DWORD dwFlags, LPSTR pszString, DWORD *pcchString)
|
||||||
|
{
|
||||||
|
static const char crlf[] = "\r\n", lf[] = "\n";
|
||||||
|
BOOL ret = TRUE;
|
||||||
|
LPCSTR header = NULL, trailer = NULL, sep = NULL;
|
||||||
|
DWORD charsNeeded;
|
||||||
|
|
||||||
|
if (dwFlags & CRYPT_STRING_NOCR)
|
||||||
|
sep = lf;
|
||||||
|
else
|
||||||
|
sep = crlf;
|
||||||
|
switch (dwFlags & 0x7fffffff)
|
||||||
|
{
|
||||||
|
case CRYPT_STRING_BASE64:
|
||||||
|
/* no header or footer */
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_BASE64HEADER:
|
||||||
|
header = CERT_HEADER;
|
||||||
|
trailer = CERT_TRAILER;
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_BASE64REQUESTHEADER:
|
||||||
|
header = CERT_REQUEST_HEADER;
|
||||||
|
trailer = CERT_REQUEST_TRAILER;
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_BASE64X509CRLHEADER:
|
||||||
|
header = X509_HEADER;
|
||||||
|
trailer = X509_TRAILER;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
charsNeeded = 0;
|
||||||
|
encodeBase64A(pbBinary, cbBinary, sep, NULL, &charsNeeded);
|
||||||
|
charsNeeded += strlen(sep);
|
||||||
|
if (header)
|
||||||
|
charsNeeded += strlen(header) + strlen(sep);
|
||||||
|
if (trailer)
|
||||||
|
charsNeeded += strlen(trailer) + strlen(sep);
|
||||||
|
if (charsNeeded <= *pcchString)
|
||||||
|
{
|
||||||
|
LPSTR ptr = pszString;
|
||||||
|
DWORD size = charsNeeded;
|
||||||
|
|
||||||
|
if (header)
|
||||||
|
{
|
||||||
|
strcpy(ptr, header);
|
||||||
|
ptr += strlen(ptr);
|
||||||
|
strcpy(ptr, sep);
|
||||||
|
ptr += strlen(sep);
|
||||||
|
}
|
||||||
|
encodeBase64A(pbBinary, cbBinary, sep, ptr, &size);
|
||||||
|
ptr += size - 1;
|
||||||
|
if (trailer)
|
||||||
|
{
|
||||||
|
strcpy(ptr, trailer);
|
||||||
|
ptr += strlen(ptr);
|
||||||
|
strcpy(ptr, sep);
|
||||||
|
ptr += strlen(sep);
|
||||||
|
}
|
||||||
|
*pcchString = charsNeeded - 1;
|
||||||
|
}
|
||||||
|
else if (pszString)
|
||||||
|
{
|
||||||
|
*pcchString = charsNeeded;
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*pcchString = charsNeeded;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CryptBinaryToStringA(const BYTE *pbBinary,
|
||||||
|
DWORD cbBinary, DWORD dwFlags, LPSTR pszString, DWORD *pcchString)
|
||||||
|
{
|
||||||
|
BinaryToStringAFunc encoder = NULL;
|
||||||
|
|
||||||
|
TRACE("(%p, %ld, %08lx, %p, %p)\n", pbBinary, cbBinary, dwFlags, pszString,
|
||||||
|
pcchString);
|
||||||
|
|
||||||
|
if (!pbBinary)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!pcchString)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (dwFlags & 0x7fffffff)
|
||||||
|
{
|
||||||
|
case CRYPT_STRING_BINARY:
|
||||||
|
encoder = EncodeBinaryToBinaryA;
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_BASE64:
|
||||||
|
case CRYPT_STRING_BASE64HEADER:
|
||||||
|
case CRYPT_STRING_BASE64REQUESTHEADER:
|
||||||
|
case CRYPT_STRING_BASE64X509CRLHEADER:
|
||||||
|
encoder = BinaryToBase64A;
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_HEX:
|
||||||
|
case CRYPT_STRING_HEXASCII:
|
||||||
|
case CRYPT_STRING_HEXADDR:
|
||||||
|
case CRYPT_STRING_HEXASCIIADDR:
|
||||||
|
FIXME("Unimplemented type %ld\n", dwFlags & 0x7fffffff);
|
||||||
|
/* fall through */
|
||||||
|
default:
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return encoder(pbBinary, cbBinary, dwFlags, pszString, pcchString);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline BYTE decodeBase64Byte(char c)
|
||||||
|
{
|
||||||
|
BYTE ret;
|
||||||
|
|
||||||
|
if (c >= 'A' && c <= 'Z')
|
||||||
|
ret = c - 'A';
|
||||||
|
else if (c >= 'a' && c <= 'z')
|
||||||
|
ret = c - 'a' + 26;
|
||||||
|
else if (c >= '0' && c <= '9')
|
||||||
|
ret = c - '0' + 52;
|
||||||
|
else if (c == '+')
|
||||||
|
ret = 62;
|
||||||
|
else if (c == '/')
|
||||||
|
ret = 63;
|
||||||
|
else
|
||||||
|
ret = 64;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LONG decodeBase64Block(const char *in_buf, int in_len,
|
||||||
|
const char **nextBlock, PBYTE out_buf, DWORD *out_len)
|
||||||
|
{
|
||||||
|
int len = in_len, i;
|
||||||
|
const char *d = in_buf;
|
||||||
|
int ip0, ip1, ip2, ip3;
|
||||||
|
|
||||||
|
if (len < 4)
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
if (d[2] == '=')
|
||||||
|
{
|
||||||
|
if ((ip0 = decodeBase64Byte(d[0])) > 63)
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
if ((ip1 = decodeBase64Byte(d[1])) > 63)
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
|
||||||
|
if (out_buf)
|
||||||
|
out_buf[i] = (ip0 << 2) | (ip1 >> 4);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else if (d[3] == '=')
|
||||||
|
{
|
||||||
|
if ((ip0 = decodeBase64Byte(d[0])) > 63)
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
if ((ip1 = decodeBase64Byte(d[1])) > 63)
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
if ((ip2 = decodeBase64Byte(d[2])) > 63)
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
|
||||||
|
if (out_buf)
|
||||||
|
{
|
||||||
|
out_buf[i + 0] = (ip0 << 2) | (ip1 >> 4);
|
||||||
|
out_buf[i + 1] = (ip1 << 4) | (ip2 >> 2);
|
||||||
|
}
|
||||||
|
i += 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((ip0 = decodeBase64Byte(d[0])) > 63)
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
if ((ip1 = decodeBase64Byte(d[1])) > 63)
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
if ((ip2 = decodeBase64Byte(d[2])) > 63)
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
if ((ip3 = decodeBase64Byte(d[3])) > 63)
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
|
||||||
|
if (out_buf)
|
||||||
|
{
|
||||||
|
out_buf[i + 0] = (ip0 << 2) | (ip1 >> 4);
|
||||||
|
out_buf[i + 1] = (ip1 << 4) | (ip2 >> 2);
|
||||||
|
out_buf[i + 2] = (ip2 << 6) | ip3;
|
||||||
|
}
|
||||||
|
i += 3;
|
||||||
|
}
|
||||||
|
if (len >= 6 && d[4] == '\r' && d[5] == '\n')
|
||||||
|
*nextBlock = d + 6;
|
||||||
|
else if (len >= 5 && d[4] == '\n')
|
||||||
|
*nextBlock = d + 5;
|
||||||
|
else if (len >= 4 && d[4])
|
||||||
|
*nextBlock = d + 4;
|
||||||
|
else
|
||||||
|
*nextBlock = NULL;
|
||||||
|
*out_len = i;
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlike CryptStringToBinaryA, cchString is guaranteed to be the length of the
|
||||||
|
* string to convert.
|
||||||
|
*/
|
||||||
|
typedef LONG (*StringToBinaryAFunc)(LPCSTR pszString, DWORD cchString,
|
||||||
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags);
|
||||||
|
|
||||||
|
static LONG Base64ToBinaryA(LPCSTR pszString, DWORD cchString,
|
||||||
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
|
{
|
||||||
|
LONG ret = ERROR_SUCCESS;
|
||||||
|
const char *nextBlock;
|
||||||
|
DWORD outLen = 0;
|
||||||
|
|
||||||
|
nextBlock = pszString;
|
||||||
|
while (nextBlock && !ret)
|
||||||
|
{
|
||||||
|
DWORD len = 0;
|
||||||
|
|
||||||
|
ret = decodeBase64Block(nextBlock, cchString - (nextBlock - pszString),
|
||||||
|
&nextBlock, pbBinary ? pbBinary + outLen : NULL, &len);
|
||||||
|
if (!ret)
|
||||||
|
outLen += len;
|
||||||
|
if (cchString - (nextBlock - pszString) <= 0)
|
||||||
|
nextBlock = NULL;
|
||||||
|
}
|
||||||
|
*pcbBinary = outLen;
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
if (pdwSkip)
|
||||||
|
*pdwSkip = 0;
|
||||||
|
if (pdwFlags)
|
||||||
|
*pdwFlags = CRYPT_STRING_BASE64;
|
||||||
|
}
|
||||||
|
else if (ret == ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
{
|
||||||
|
if (!pbBinary)
|
||||||
|
ret = ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LONG Base64WithHeaderAndTrailerToBinaryA(LPCSTR pszString,
|
||||||
|
DWORD cchString, LPCSTR header, LPCSTR trailer, BYTE *pbBinary,
|
||||||
|
DWORD *pcbBinary, DWORD *pdwSkip)
|
||||||
|
{
|
||||||
|
LONG ret;
|
||||||
|
LPCSTR ptr;
|
||||||
|
|
||||||
|
if (cchString > strlen(header) + strlen(trailer)
|
||||||
|
&& (ptr = strstr(pszString, header)) != NULL)
|
||||||
|
{
|
||||||
|
LPCSTR trailerSpot = pszString + cchString - strlen(trailer);
|
||||||
|
|
||||||
|
if (pszString[cchString - 1] == '\n')
|
||||||
|
{
|
||||||
|
cchString--;
|
||||||
|
trailerSpot--;
|
||||||
|
}
|
||||||
|
if (pszString[cchString - 1] == '\r')
|
||||||
|
{
|
||||||
|
cchString--;
|
||||||
|
trailerSpot--;
|
||||||
|
}
|
||||||
|
if (!strncmp(trailerSpot, trailer, strlen(trailer)))
|
||||||
|
{
|
||||||
|
if (pdwSkip)
|
||||||
|
*pdwSkip = ptr - pszString;
|
||||||
|
ptr += strlen(header);
|
||||||
|
if (*ptr == '\r') ptr++;
|
||||||
|
if (*ptr == '\n') ptr++;
|
||||||
|
cchString -= ptr - pszString + strlen(trailer);
|
||||||
|
ret = Base64ToBinaryA(ptr, cchString, pbBinary, pcbBinary, NULL,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = ERROR_INVALID_DATA;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LONG Base64HeaderToBinaryA(LPCSTR pszString, DWORD cchString,
|
||||||
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
|
{
|
||||||
|
LONG ret = Base64WithHeaderAndTrailerToBinaryA(pszString, cchString,
|
||||||
|
CERT_HEADER, CERT_TRAILER, pbBinary, pcbBinary, pdwSkip);
|
||||||
|
|
||||||
|
if (!ret && pdwFlags)
|
||||||
|
*pdwFlags = CRYPT_STRING_BASE64HEADER;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LONG Base64RequestHeaderToBinaryA(LPCSTR pszString, DWORD cchString,
|
||||||
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
|
{
|
||||||
|
LONG ret = Base64WithHeaderAndTrailerToBinaryA(pszString, cchString,
|
||||||
|
CERT_REQUEST_HEADER, CERT_REQUEST_TRAILER, pbBinary, pcbBinary, pdwSkip);
|
||||||
|
|
||||||
|
if (!ret && pdwFlags)
|
||||||
|
*pdwFlags = CRYPT_STRING_BASE64REQUESTHEADER;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LONG Base64X509HeaderToBinaryA(LPCSTR pszString, DWORD cchString,
|
||||||
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
|
{
|
||||||
|
LONG ret = Base64WithHeaderAndTrailerToBinaryA(pszString, cchString,
|
||||||
|
X509_HEADER, X509_TRAILER, pbBinary, pcbBinary, pdwSkip);
|
||||||
|
|
||||||
|
if (!ret && pdwFlags)
|
||||||
|
*pdwFlags = CRYPT_STRING_BASE64X509CRLHEADER;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LONG Base64AnyToBinaryA(LPCSTR pszString, DWORD cchString,
|
||||||
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
|
{
|
||||||
|
LONG ret;
|
||||||
|
|
||||||
|
ret = Base64HeaderToBinaryA(pszString, cchString, pbBinary, pcbBinary,
|
||||||
|
pdwSkip, pdwFlags);
|
||||||
|
if (ret == ERROR_INVALID_DATA)
|
||||||
|
ret = Base64ToBinaryA(pszString, cchString, pbBinary, pcbBinary,
|
||||||
|
pdwSkip, pdwFlags);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LONG DecodeBinaryToBinaryA(LPCSTR pszString, DWORD cchString,
|
||||||
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
|
{
|
||||||
|
LONG ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
if (*pcbBinary < cchString)
|
||||||
|
{
|
||||||
|
if (!pbBinary)
|
||||||
|
*pcbBinary = cchString;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
||||||
|
*pcbBinary = cchString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (cchString)
|
||||||
|
memcpy(pbBinary, pszString, cchString);
|
||||||
|
*pcbBinary = cchString;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LONG DecodeAnyA(LPCSTR pszString, DWORD cchString,
|
||||||
|
BYTE *pbBinary, DWORD *pcbBinary, DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
|
{
|
||||||
|
LONG ret;
|
||||||
|
|
||||||
|
ret = Base64HeaderToBinaryA(pszString, cchString, pbBinary, pcbBinary,
|
||||||
|
pdwSkip, pdwFlags);
|
||||||
|
if (ret == ERROR_INVALID_DATA)
|
||||||
|
ret = Base64ToBinaryA(pszString, cchString, pbBinary, pcbBinary,
|
||||||
|
pdwSkip, pdwFlags);
|
||||||
|
if (ret == ERROR_INVALID_DATA)
|
||||||
|
ret = DecodeBinaryToBinaryA(pszString, cchString, pbBinary, pcbBinary,
|
||||||
|
pdwSkip, pdwFlags);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CryptStringToBinaryA(LPCSTR pszString,
|
||||||
|
DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary,
|
||||||
|
DWORD *pdwSkip, DWORD *pdwFlags)
|
||||||
|
{
|
||||||
|
StringToBinaryAFunc decoder;
|
||||||
|
LONG ret;
|
||||||
|
|
||||||
|
TRACE("(%s, %ld, %08lx, %p, %p, %p, %p)\n", debugstr_a(pszString),
|
||||||
|
cchString, dwFlags, pbBinary, pcbBinary, pdwSkip, pdwFlags);
|
||||||
|
|
||||||
|
if (!pszString)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
/* Only the bottom byte contains valid types */
|
||||||
|
if (dwFlags & 0xfffffff0)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_DATA);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
switch (dwFlags)
|
||||||
|
{
|
||||||
|
case CRYPT_STRING_BASE64_ANY:
|
||||||
|
decoder = Base64AnyToBinaryA;
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_BASE64:
|
||||||
|
decoder = Base64ToBinaryA;
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_BASE64HEADER:
|
||||||
|
decoder = Base64HeaderToBinaryA;
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_BASE64REQUESTHEADER:
|
||||||
|
decoder = Base64RequestHeaderToBinaryA;
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_BASE64X509CRLHEADER:
|
||||||
|
decoder = Base64X509HeaderToBinaryA;
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_BINARY:
|
||||||
|
decoder = DecodeBinaryToBinaryA;
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_ANY:
|
||||||
|
decoder = DecodeAnyA;
|
||||||
|
break;
|
||||||
|
case CRYPT_STRING_HEX:
|
||||||
|
case CRYPT_STRING_HEXASCII:
|
||||||
|
case CRYPT_STRING_HEXADDR:
|
||||||
|
case CRYPT_STRING_HEXASCIIADDR:
|
||||||
|
FIXME("Unimplemented type %ld\n", dwFlags & 0x7fffffff);
|
||||||
|
/* fall through */
|
||||||
|
default:
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!cchString)
|
||||||
|
cchString = strlen(pszString);
|
||||||
|
ret = decoder(pszString, cchString, pbBinary, pcbBinary, pdwSkip, pdwFlags);
|
||||||
|
if (ret)
|
||||||
|
SetLastError(ret);
|
||||||
|
return (ret == ERROR_SUCCESS) ? TRUE : FALSE;
|
||||||
|
}
|
File diff suppressed because it is too large
Load diff
308
reactos/dll/win32/crypt32/context.c
Normal file
308
reactos/dll/win32/crypt32/context.c
Normal file
|
@ -0,0 +1,308 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2006 Juan Lang
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "windef.h"
|
||||||
|
#include "winbase.h"
|
||||||
|
#include "wincrypt.h"
|
||||||
|
#include "wine/debug.h"
|
||||||
|
#include "wine/list.h"
|
||||||
|
#include "crypt32_private.h"
|
||||||
|
|
||||||
|
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
|
||||||
|
|
||||||
|
typedef enum _ContextType {
|
||||||
|
ContextTypeData,
|
||||||
|
ContextTypeLink,
|
||||||
|
} ContextType;
|
||||||
|
|
||||||
|
typedef struct _BASE_CONTEXT
|
||||||
|
{
|
||||||
|
LONG ref;
|
||||||
|
ContextType type;
|
||||||
|
} BASE_CONTEXT, *PBASE_CONTEXT;
|
||||||
|
|
||||||
|
typedef struct _DATA_CONTEXT
|
||||||
|
{
|
||||||
|
LONG ref;
|
||||||
|
ContextType type; /* always ContextTypeData */
|
||||||
|
PCONTEXT_PROPERTY_LIST properties;
|
||||||
|
} DATA_CONTEXT, *PDATA_CONTEXT;
|
||||||
|
|
||||||
|
typedef struct _LINK_CONTEXT
|
||||||
|
{
|
||||||
|
LONG ref;
|
||||||
|
ContextType type; /* always ContextTypeLink */
|
||||||
|
PBASE_CONTEXT linked;
|
||||||
|
} LINK_CONTEXT, *PLINK_CONTEXT;
|
||||||
|
|
||||||
|
#define CONTEXT_FROM_BASE_CONTEXT(p, s) ((LPBYTE)(p) - (s))
|
||||||
|
#define BASE_CONTEXT_FROM_CONTEXT(p, s) (PBASE_CONTEXT)((LPBYTE)(p) + (s))
|
||||||
|
|
||||||
|
void *Context_CreateDataContext(size_t contextSize)
|
||||||
|
{
|
||||||
|
void *ret = CryptMemAlloc(contextSize + sizeof(DATA_CONTEXT));
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
PDATA_CONTEXT context = (PDATA_CONTEXT)((LPBYTE)ret + contextSize);
|
||||||
|
|
||||||
|
context->ref = 1;
|
||||||
|
context->type = ContextTypeData;
|
||||||
|
context->properties = ContextPropertyList_Create();
|
||||||
|
if (!context->properties)
|
||||||
|
{
|
||||||
|
CryptMemFree(ret);
|
||||||
|
ret = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned int extra,
|
||||||
|
BOOL addRef)
|
||||||
|
{
|
||||||
|
void *context = CryptMemAlloc(contextSize + sizeof(LINK_CONTEXT) + extra);
|
||||||
|
|
||||||
|
TRACE("(%d, %p, %d)\n", contextSize, linked, extra);
|
||||||
|
|
||||||
|
if (context)
|
||||||
|
{
|
||||||
|
PLINK_CONTEXT linkContext = (PLINK_CONTEXT)BASE_CONTEXT_FROM_CONTEXT(
|
||||||
|
context, contextSize);
|
||||||
|
PBASE_CONTEXT linkedBase = BASE_CONTEXT_FROM_CONTEXT(linked,
|
||||||
|
contextSize);
|
||||||
|
|
||||||
|
memcpy(context, linked, contextSize);
|
||||||
|
linkContext->ref = 1;
|
||||||
|
linkContext->type = ContextTypeLink;
|
||||||
|
linkContext->linked = linkedBase;
|
||||||
|
if (addRef)
|
||||||
|
InterlockedIncrement(&linkedBase->ref);
|
||||||
|
TRACE("%p's ref count is %ld\n", context, linkContext->ref);
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Context_AddRef(void *context, size_t contextSize)
|
||||||
|
{
|
||||||
|
PBASE_CONTEXT baseContext = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
|
||||||
|
|
||||||
|
InterlockedIncrement(&baseContext->ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *Context_GetExtra(const void *context, size_t contextSize)
|
||||||
|
{
|
||||||
|
PBASE_CONTEXT baseContext = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
|
||||||
|
|
||||||
|
assert(baseContext->type == ContextTypeLink);
|
||||||
|
return (LPBYTE)baseContext + sizeof(LINK_CONTEXT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *Context_GetLinkedContext(void *context, size_t contextSize)
|
||||||
|
{
|
||||||
|
PBASE_CONTEXT baseContext = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
|
||||||
|
|
||||||
|
assert(baseContext->type == ContextTypeLink);
|
||||||
|
return CONTEXT_FROM_BASE_CONTEXT(((PLINK_CONTEXT)baseContext)->linked,
|
||||||
|
contextSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
PCONTEXT_PROPERTY_LIST Context_GetProperties(void *context, size_t contextSize)
|
||||||
|
{
|
||||||
|
PBASE_CONTEXT ptr = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
|
||||||
|
|
||||||
|
while (ptr && ptr->type == ContextTypeLink)
|
||||||
|
ptr = ((PLINK_CONTEXT)ptr)->linked;
|
||||||
|
return (ptr && ptr->type == ContextTypeData) ?
|
||||||
|
((PDATA_CONTEXT)ptr)->properties : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Context_Release(void *context, size_t contextSize,
|
||||||
|
ContextFreeFunc dataContextFree)
|
||||||
|
{
|
||||||
|
PBASE_CONTEXT base = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
|
||||||
|
|
||||||
|
if (InterlockedDecrement(&base->ref) == 0)
|
||||||
|
{
|
||||||
|
TRACE("freeing %p\n", context);
|
||||||
|
switch (base->type)
|
||||||
|
{
|
||||||
|
case ContextTypeData:
|
||||||
|
ContextPropertyList_Free(((PDATA_CONTEXT)base)->properties);
|
||||||
|
dataContextFree(context);
|
||||||
|
break;
|
||||||
|
case ContextTypeLink:
|
||||||
|
/* The linked context is of the same type as this, so release
|
||||||
|
* it as well, using the same offset and data free function.
|
||||||
|
*/
|
||||||
|
Context_Release(CONTEXT_FROM_BASE_CONTEXT(
|
||||||
|
((PLINK_CONTEXT)base)->linked, contextSize), contextSize,
|
||||||
|
dataContextFree);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
CryptMemFree(context);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
TRACE("%p's ref count is %ld\n", context, base->ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Context_CopyProperties(const void *to, const void *from,
|
||||||
|
size_t contextSize)
|
||||||
|
{
|
||||||
|
PCONTEXT_PROPERTY_LIST toProperties, fromProperties;
|
||||||
|
|
||||||
|
toProperties = Context_GetProperties((void *)to, contextSize);
|
||||||
|
fromProperties = Context_GetProperties((void *)from, contextSize);
|
||||||
|
ContextPropertyList_Copy(toProperties, fromProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ContextList
|
||||||
|
{
|
||||||
|
PCWINE_CONTEXT_INTERFACE contextInterface;
|
||||||
|
size_t contextSize;
|
||||||
|
CRITICAL_SECTION cs;
|
||||||
|
struct list contexts;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ContextList *ContextList_Create(
|
||||||
|
PCWINE_CONTEXT_INTERFACE contextInterface, size_t contextSize)
|
||||||
|
{
|
||||||
|
struct ContextList *list = CryptMemAlloc(sizeof(struct ContextList));
|
||||||
|
|
||||||
|
if (list)
|
||||||
|
{
|
||||||
|
list->contextInterface = contextInterface;
|
||||||
|
list->contextSize = contextSize;
|
||||||
|
InitializeCriticalSection(&list->cs);
|
||||||
|
list_init(&list->contexts);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct list *ContextList_ContextToEntry(struct ContextList *list,
|
||||||
|
const void *context)
|
||||||
|
{
|
||||||
|
struct list *ret;
|
||||||
|
|
||||||
|
if (context)
|
||||||
|
ret = (struct list *)Context_GetExtra(context, list->contextSize);
|
||||||
|
else
|
||||||
|
ret = NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *ContextList_EntryToContext(struct ContextList *list,
|
||||||
|
struct list *entry)
|
||||||
|
{
|
||||||
|
return (LPBYTE)entry - sizeof(LINK_CONTEXT) - list->contextSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace)
|
||||||
|
{
|
||||||
|
void *context;
|
||||||
|
|
||||||
|
TRACE("(%p, %p, %p)\n", list, toLink, toReplace);
|
||||||
|
|
||||||
|
context = Context_CreateLinkContext(list->contextSize, toLink,
|
||||||
|
sizeof(struct list), TRUE);
|
||||||
|
if (context)
|
||||||
|
{
|
||||||
|
struct list *entry = ContextList_ContextToEntry(list, context);
|
||||||
|
|
||||||
|
TRACE("adding %p\n", context);
|
||||||
|
EnterCriticalSection(&list->cs);
|
||||||
|
if (toReplace)
|
||||||
|
{
|
||||||
|
struct list *existing = ContextList_ContextToEntry(list, toReplace);
|
||||||
|
|
||||||
|
entry->prev = existing->prev;
|
||||||
|
entry->next = existing->next;
|
||||||
|
entry->prev->next = entry;
|
||||||
|
entry->next->prev = entry;
|
||||||
|
existing->prev = existing->next = existing;
|
||||||
|
list->contextInterface->free(toReplace);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
list_add_tail(&list->contexts, entry);
|
||||||
|
LeaveCriticalSection(&list->cs);
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *ContextList_Enum(struct ContextList *list, void *pPrev)
|
||||||
|
{
|
||||||
|
struct list *listNext;
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
EnterCriticalSection(&list->cs);
|
||||||
|
if (pPrev)
|
||||||
|
{
|
||||||
|
struct list *prevEntry = ContextList_ContextToEntry(list, pPrev);
|
||||||
|
|
||||||
|
listNext = list_next(&list->contexts, prevEntry);
|
||||||
|
list->contextInterface->free(pPrev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
listNext = list_next(&list->contexts, &list->contexts);
|
||||||
|
LeaveCriticalSection(&list->cs);
|
||||||
|
|
||||||
|
if (listNext)
|
||||||
|
{
|
||||||
|
ret = ContextList_EntryToContext(list, listNext);
|
||||||
|
list->contextInterface->duplicate(ret);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContextList_Delete(struct ContextList *list, void *context)
|
||||||
|
{
|
||||||
|
struct list *entry = ContextList_ContextToEntry(list, context);
|
||||||
|
|
||||||
|
EnterCriticalSection(&list->cs);
|
||||||
|
list_remove(entry);
|
||||||
|
LeaveCriticalSection(&list->cs);
|
||||||
|
list->contextInterface->free(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContextList_Empty(struct ContextList *list)
|
||||||
|
{
|
||||||
|
struct list *entry, *next;
|
||||||
|
|
||||||
|
EnterCriticalSection(&list->cs);
|
||||||
|
LIST_FOR_EACH_SAFE(entry, next, &list->contexts)
|
||||||
|
{
|
||||||
|
const void *context = ContextList_EntryToContext(list, entry);
|
||||||
|
|
||||||
|
TRACE("removing %p\n", context);
|
||||||
|
list_remove(entry);
|
||||||
|
list->contextInterface->free(context);
|
||||||
|
}
|
||||||
|
LeaveCriticalSection(&list->cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContextList_Free(struct ContextList *list)
|
||||||
|
{
|
||||||
|
ContextList_Empty(list);
|
||||||
|
DeleteCriticalSection(&list->cs);
|
||||||
|
CryptMemFree(list);
|
||||||
|
}
|
535
reactos/dll/win32/crypt32/crl.c
Normal file
535
reactos/dll/win32/crypt32/crl.c
Normal file
|
@ -0,0 +1,535 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2006 Juan Lang
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "windef.h"
|
||||||
|
#include "winbase.h"
|
||||||
|
#include "wincrypt.h"
|
||||||
|
#include "wine/debug.h"
|
||||||
|
#include "crypt32_private.h"
|
||||||
|
|
||||||
|
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
|
||||||
|
|
||||||
|
PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType,
|
||||||
|
const BYTE* pbCrlEncoded, DWORD cbCrlEncoded)
|
||||||
|
{
|
||||||
|
PCRL_CONTEXT crl = NULL;
|
||||||
|
BOOL ret;
|
||||||
|
PCRL_INFO crlInfo = NULL;
|
||||||
|
DWORD size = 0;
|
||||||
|
|
||||||
|
TRACE("(%08lx, %p, %ld)\n", dwCertEncodingType, pbCrlEncoded,
|
||||||
|
cbCrlEncoded);
|
||||||
|
|
||||||
|
if ((dwCertEncodingType & CERT_ENCODING_TYPE_MASK) != X509_ASN_ENCODING)
|
||||||
|
{
|
||||||
|
SetLastError(E_INVALIDARG);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
ret = CryptDecodeObjectEx(dwCertEncodingType, X509_CERT_CRL_TO_BE_SIGNED,
|
||||||
|
pbCrlEncoded, cbCrlEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL,
|
||||||
|
(BYTE *)&crlInfo, &size);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
BYTE *data = NULL;
|
||||||
|
|
||||||
|
crl = (PCRL_CONTEXT)Context_CreateDataContext(sizeof(CRL_CONTEXT));
|
||||||
|
if (!crl)
|
||||||
|
goto end;
|
||||||
|
data = CryptMemAlloc(cbCrlEncoded);
|
||||||
|
if (!data)
|
||||||
|
{
|
||||||
|
CryptMemFree(crl);
|
||||||
|
crl = NULL;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
memcpy(data, pbCrlEncoded, cbCrlEncoded);
|
||||||
|
crl->dwCertEncodingType = dwCertEncodingType;
|
||||||
|
crl->pbCrlEncoded = data;
|
||||||
|
crl->cbCrlEncoded = cbCrlEncoded;
|
||||||
|
crl->pCrlInfo = crlInfo;
|
||||||
|
crl->hCertStore = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
return (PCCRL_CONTEXT)crl;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CertAddEncodedCRLToStore(HCERTSTORE hCertStore,
|
||||||
|
DWORD dwCertEncodingType, const BYTE *pbCrlEncoded, DWORD cbCrlEncoded,
|
||||||
|
DWORD dwAddDisposition, PCCRL_CONTEXT *ppCrlContext)
|
||||||
|
{
|
||||||
|
PCCRL_CONTEXT crl = CertCreateCRLContext(dwCertEncodingType,
|
||||||
|
pbCrlEncoded, cbCrlEncoded);
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
TRACE("(%p, %08lx, %p, %ld, %08lx, %p)\n", hCertStore, dwCertEncodingType,
|
||||||
|
pbCrlEncoded, cbCrlEncoded, dwAddDisposition, ppCrlContext);
|
||||||
|
|
||||||
|
if (crl)
|
||||||
|
{
|
||||||
|
ret = CertAddCRLContextToStore(hCertStore, crl, dwAddDisposition,
|
||||||
|
ppCrlContext);
|
||||||
|
CertFreeCRLContext(crl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = FALSE;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef BOOL (*CrlCompareFunc)(PCCRL_CONTEXT pCrlContext, DWORD dwType,
|
||||||
|
DWORD dwFlags, const void *pvPara);
|
||||||
|
|
||||||
|
static BOOL compare_crl_any(PCCRL_CONTEXT pCrlContext, DWORD dwType,
|
||||||
|
DWORD dwFlags, const void *pvPara)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL compare_crl_issued_by(PCCRL_CONTEXT pCrlContext, DWORD dwType,
|
||||||
|
DWORD dwFlags, const void *pvPara)
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
if (pvPara)
|
||||||
|
{
|
||||||
|
PCCERT_CONTEXT issuer = (PCCERT_CONTEXT)pvPara;
|
||||||
|
|
||||||
|
ret = CertCompareCertificateName(issuer->dwCertEncodingType,
|
||||||
|
&issuer->pCertInfo->Issuer, &pCrlContext->pCrlInfo->Issuer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = TRUE;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL compare_crl_existing(PCCRL_CONTEXT pCrlContext, DWORD dwType,
|
||||||
|
DWORD dwFlags, const void *pvPara)
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
if (pvPara)
|
||||||
|
{
|
||||||
|
PCCRL_CONTEXT crl = (PCCRL_CONTEXT)pvPara;
|
||||||
|
|
||||||
|
ret = CertCompareCertificateName(pCrlContext->dwCertEncodingType,
|
||||||
|
&pCrlContext->pCrlInfo->Issuer, &crl->pCrlInfo->Issuer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = TRUE;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
PCCRL_CONTEXT WINAPI CertFindCRLInStore(HCERTSTORE hCertStore,
|
||||||
|
DWORD dwCertEncodingType, DWORD dwFindFlags, DWORD dwFindType,
|
||||||
|
const void *pvFindPara, PCCRL_CONTEXT pPrevCrlContext)
|
||||||
|
{
|
||||||
|
PCCRL_CONTEXT ret;
|
||||||
|
CrlCompareFunc compare;
|
||||||
|
|
||||||
|
TRACE("(%p, %ld, %ld, %ld, %p, %p)\n", hCertStore, dwCertEncodingType,
|
||||||
|
dwFindFlags, dwFindType, pvFindPara, pPrevCrlContext);
|
||||||
|
|
||||||
|
switch (dwFindType)
|
||||||
|
{
|
||||||
|
case CRL_FIND_ANY:
|
||||||
|
compare = compare_crl_any;
|
||||||
|
break;
|
||||||
|
case CRL_FIND_ISSUED_BY:
|
||||||
|
compare = compare_crl_issued_by;
|
||||||
|
break;
|
||||||
|
case CRL_FIND_EXISTING:
|
||||||
|
compare = compare_crl_existing;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FIXME("find type %08lx unimplemented\n", dwFindType);
|
||||||
|
compare = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compare)
|
||||||
|
{
|
||||||
|
BOOL matches = FALSE;
|
||||||
|
|
||||||
|
ret = pPrevCrlContext;
|
||||||
|
do {
|
||||||
|
ret = CertEnumCRLsInStore(hCertStore, ret);
|
||||||
|
if (ret)
|
||||||
|
matches = compare(ret, dwFindType, dwFindFlags, pvFindPara);
|
||||||
|
} while (ret != NULL && !matches);
|
||||||
|
if (!ret)
|
||||||
|
SetLastError(CRYPT_E_NOT_FOUND);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetLastError(CRYPT_E_NOT_FOUND);
|
||||||
|
ret = NULL;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
PCCRL_CONTEXT WINAPI CertGetCRLFromStore(HCERTSTORE hCertStore,
|
||||||
|
PCCERT_CONTEXT pIssuerContext, PCCRL_CONTEXT pPrevCrlContext, DWORD *pdwFlags)
|
||||||
|
{
|
||||||
|
static const DWORD supportedFlags = CERT_STORE_SIGNATURE_FLAG |
|
||||||
|
CERT_STORE_TIME_VALIDITY_FLAG | CERT_STORE_BASE_CRL_FLAG |
|
||||||
|
CERT_STORE_DELTA_CRL_FLAG;
|
||||||
|
PCCRL_CONTEXT ret;
|
||||||
|
|
||||||
|
TRACE("(%p, %p, %p, %08lx)\n", hCertStore, pIssuerContext, pPrevCrlContext,
|
||||||
|
*pdwFlags);
|
||||||
|
|
||||||
|
if (*pdwFlags & ~supportedFlags)
|
||||||
|
{
|
||||||
|
SetLastError(E_INVALIDARG);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (pIssuerContext)
|
||||||
|
ret = CertFindCRLInStore(hCertStore, pIssuerContext->dwCertEncodingType,
|
||||||
|
0, CRL_FIND_ISSUED_BY, pIssuerContext, pPrevCrlContext);
|
||||||
|
else
|
||||||
|
ret = CertFindCRLInStore(hCertStore, 0, 0, CRL_FIND_ANY, NULL,
|
||||||
|
pPrevCrlContext);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
if (*pdwFlags & CERT_STORE_TIME_VALIDITY_FLAG)
|
||||||
|
{
|
||||||
|
if (0 == CertVerifyCRLTimeValidity(NULL, ret->pCrlInfo))
|
||||||
|
*pdwFlags &= ~CERT_STORE_TIME_VALIDITY_FLAG;
|
||||||
|
}
|
||||||
|
if (*pdwFlags & CERT_STORE_SIGNATURE_FLAG)
|
||||||
|
{
|
||||||
|
if (CryptVerifyCertificateSignatureEx(0, ret->dwCertEncodingType,
|
||||||
|
CRYPT_VERIFY_CERT_SIGN_SUBJECT_CRL, (void *)ret,
|
||||||
|
CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT, (void *)pIssuerContext, 0,
|
||||||
|
NULL))
|
||||||
|
*pdwFlags &= ~CERT_STORE_SIGNATURE_FLAG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext)
|
||||||
|
{
|
||||||
|
TRACE("(%p)\n", pCrlContext);
|
||||||
|
Context_AddRef((void *)pCrlContext, sizeof(CRL_CONTEXT));
|
||||||
|
return pCrlContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CrlDataContext_Free(void *context)
|
||||||
|
{
|
||||||
|
PCRL_CONTEXT crlContext = (PCRL_CONTEXT)context;
|
||||||
|
|
||||||
|
CryptMemFree(crlContext->pbCrlEncoded);
|
||||||
|
LocalFree(crlContext->pCrlInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext)
|
||||||
|
{
|
||||||
|
TRACE("(%p)\n", pCrlContext);
|
||||||
|
|
||||||
|
if (pCrlContext)
|
||||||
|
Context_Release((void *)pCrlContext, sizeof(CRL_CONTEXT),
|
||||||
|
CrlDataContext_Free);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI CertEnumCRLContextProperties(PCCRL_CONTEXT pCRLContext,
|
||||||
|
DWORD dwPropId)
|
||||||
|
{
|
||||||
|
PCONTEXT_PROPERTY_LIST properties = Context_GetProperties(
|
||||||
|
(void *)pCRLContext, sizeof(CRL_CONTEXT));
|
||||||
|
DWORD ret;
|
||||||
|
|
||||||
|
TRACE("(%p, %ld)\n", pCRLContext, dwPropId);
|
||||||
|
|
||||||
|
if (properties)
|
||||||
|
ret = ContextPropertyList_EnumPropIDs(properties, dwPropId);
|
||||||
|
else
|
||||||
|
ret = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI CRLContext_SetProperty(void *context, DWORD dwPropId,
|
||||||
|
DWORD dwFlags, const void *pvData);
|
||||||
|
|
||||||
|
static BOOL CRLContext_GetHashProp(void *context, DWORD dwPropId,
|
||||||
|
ALG_ID algID, const BYTE *toHash, DWORD toHashLen, void *pvData,
|
||||||
|
DWORD *pcbData)
|
||||||
|
{
|
||||||
|
BOOL ret = CryptHashCertificate(0, algID, 0, toHash, toHashLen, pvData,
|
||||||
|
pcbData);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
CRYPT_DATA_BLOB blob = { *pcbData, pvData };
|
||||||
|
|
||||||
|
ret = CRLContext_SetProperty(context, dwPropId, 0, &blob);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI CRLContext_GetProperty(void *context, DWORD dwPropId,
|
||||||
|
void *pvData, DWORD *pcbData)
|
||||||
|
{
|
||||||
|
PCCRL_CONTEXT pCRLContext = (PCCRL_CONTEXT)context;
|
||||||
|
PCONTEXT_PROPERTY_LIST properties =
|
||||||
|
Context_GetProperties(context, sizeof(CRL_CONTEXT));
|
||||||
|
BOOL ret;
|
||||||
|
CRYPT_DATA_BLOB blob;
|
||||||
|
|
||||||
|
TRACE("(%p, %ld, %p, %p)\n", context, dwPropId, pvData, pcbData);
|
||||||
|
|
||||||
|
if (properties)
|
||||||
|
ret = ContextPropertyList_FindProperty(properties, dwPropId, &blob);
|
||||||
|
else
|
||||||
|
ret = FALSE;
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
if (!pvData)
|
||||||
|
{
|
||||||
|
*pcbData = blob.cbData;
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
|
else if (*pcbData < blob.cbData)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_MORE_DATA);
|
||||||
|
*pcbData = blob.cbData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memcpy(pvData, blob.pbData, blob.cbData);
|
||||||
|
*pcbData = blob.cbData;
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Implicit properties */
|
||||||
|
switch (dwPropId)
|
||||||
|
{
|
||||||
|
case CERT_SHA1_HASH_PROP_ID:
|
||||||
|
ret = CRLContext_GetHashProp(context, dwPropId, CALG_SHA1,
|
||||||
|
pCRLContext->pbCrlEncoded, pCRLContext->cbCrlEncoded, pvData,
|
||||||
|
pcbData);
|
||||||
|
break;
|
||||||
|
case CERT_MD5_HASH_PROP_ID:
|
||||||
|
ret = CRLContext_GetHashProp(context, dwPropId, CALG_MD5,
|
||||||
|
pCRLContext->pbCrlEncoded, pCRLContext->cbCrlEncoded, pvData,
|
||||||
|
pcbData);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SetLastError(CRYPT_E_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TRACE("returning %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CertGetCRLContextProperty(PCCRL_CONTEXT pCRLContext,
|
||||||
|
DWORD dwPropId, void *pvData, DWORD *pcbData)
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
TRACE("(%p, %ld, %p, %p)\n", pCRLContext, dwPropId, pvData, pcbData);
|
||||||
|
|
||||||
|
switch (dwPropId)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
case CERT_CERT_PROP_ID:
|
||||||
|
case CERT_CRL_PROP_ID:
|
||||||
|
case CERT_CTL_PROP_ID:
|
||||||
|
SetLastError(E_INVALIDARG);
|
||||||
|
ret = FALSE;
|
||||||
|
break;
|
||||||
|
case CERT_ACCESS_STATE_PROP_ID:
|
||||||
|
if (!pvData)
|
||||||
|
{
|
||||||
|
*pcbData = sizeof(DWORD);
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
|
else if (*pcbData < sizeof(DWORD))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_MORE_DATA);
|
||||||
|
*pcbData = sizeof(DWORD);
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*(DWORD *)pvData =
|
||||||
|
CertStore_GetAccessState(pCRLContext->hCertStore);
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = CRLContext_GetProperty((void *)pCRLContext, dwPropId, pvData,
|
||||||
|
pcbData);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI CRLContext_SetProperty(void *context, DWORD dwPropId,
|
||||||
|
DWORD dwFlags, const void *pvData)
|
||||||
|
{
|
||||||
|
PCONTEXT_PROPERTY_LIST properties =
|
||||||
|
Context_GetProperties(context, sizeof(CERT_CONTEXT));
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
TRACE("(%p, %ld, %08lx, %p)\n", context, dwPropId, dwFlags, pvData);
|
||||||
|
|
||||||
|
if (!properties)
|
||||||
|
ret = FALSE;
|
||||||
|
else if (!pvData)
|
||||||
|
{
|
||||||
|
ContextPropertyList_RemoveProperty(properties, dwPropId);
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (dwPropId)
|
||||||
|
{
|
||||||
|
case CERT_AUTO_ENROLL_PROP_ID:
|
||||||
|
case CERT_CTL_USAGE_PROP_ID: /* same as CERT_ENHKEY_USAGE_PROP_ID */
|
||||||
|
case CERT_DESCRIPTION_PROP_ID:
|
||||||
|
case CERT_FRIENDLY_NAME_PROP_ID:
|
||||||
|
case CERT_HASH_PROP_ID:
|
||||||
|
case CERT_KEY_IDENTIFIER_PROP_ID:
|
||||||
|
case CERT_MD5_HASH_PROP_ID:
|
||||||
|
case CERT_NEXT_UPDATE_LOCATION_PROP_ID:
|
||||||
|
case CERT_PUBKEY_ALG_PARA_PROP_ID:
|
||||||
|
case CERT_PVK_FILE_PROP_ID:
|
||||||
|
case CERT_SIGNATURE_HASH_PROP_ID:
|
||||||
|
case CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID:
|
||||||
|
case CERT_SUBJECT_NAME_MD5_HASH_PROP_ID:
|
||||||
|
case CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID:
|
||||||
|
case CERT_ENROLLMENT_PROP_ID:
|
||||||
|
case CERT_CROSS_CERT_DIST_POINTS_PROP_ID:
|
||||||
|
case CERT_RENEWAL_PROP_ID:
|
||||||
|
{
|
||||||
|
PCRYPT_DATA_BLOB blob = (PCRYPT_DATA_BLOB)pvData;
|
||||||
|
|
||||||
|
ret = ContextPropertyList_SetProperty(properties, dwPropId,
|
||||||
|
blob->pbData, blob->cbData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CERT_DATE_STAMP_PROP_ID:
|
||||||
|
ret = ContextPropertyList_SetProperty(properties, dwPropId,
|
||||||
|
(LPBYTE)pvData, sizeof(FILETIME));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FIXME("%ld: stub\n", dwPropId);
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TRACE("returning %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CertSetCRLContextProperty(PCCRL_CONTEXT pCRLContext,
|
||||||
|
DWORD dwPropId, DWORD dwFlags, const void *pvData)
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
TRACE("(%p, %ld, %08lx, %p)\n", pCRLContext, dwPropId, dwFlags, pvData);
|
||||||
|
|
||||||
|
/* Handle special cases for "read-only"/invalid prop IDs. Windows just
|
||||||
|
* crashes on most of these, I'll be safer.
|
||||||
|
*/
|
||||||
|
switch (dwPropId)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
case CERT_ACCESS_STATE_PROP_ID:
|
||||||
|
case CERT_CERT_PROP_ID:
|
||||||
|
case CERT_CRL_PROP_ID:
|
||||||
|
case CERT_CTL_PROP_ID:
|
||||||
|
SetLastError(E_INVALIDARG);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
ret = CRLContext_SetProperty((void *)pCRLContext, dwPropId, dwFlags,
|
||||||
|
pvData);
|
||||||
|
TRACE("returning %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CertIsValidCRLForCertificate(PCCERT_CONTEXT pCert,
|
||||||
|
PCCRL_CONTEXT pCrl, DWORD dwFlags, void *pvReserved)
|
||||||
|
{
|
||||||
|
TRACE("(%p, %p, %08lx, %p)\n", pCert, pCrl, dwFlags, pvReserved);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PCRL_ENTRY CRYPT_FindCertificateInCRL(PCERT_INFO cert, PCRL_INFO crl)
|
||||||
|
{
|
||||||
|
DWORD i;
|
||||||
|
PCRL_ENTRY entry = NULL;
|
||||||
|
|
||||||
|
for (i = 0; !entry && i < crl->cCRLEntry; i++)
|
||||||
|
if (CertCompareIntegerBlob(&crl->rgCRLEntry[i].SerialNumber,
|
||||||
|
&cert->SerialNumber))
|
||||||
|
entry = &crl->rgCRLEntry[i];
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CertFindCertificateInCRL(PCCERT_CONTEXT pCert,
|
||||||
|
PCCRL_CONTEXT pCrlContext, DWORD dwFlags, void *pvReserved,
|
||||||
|
PCRL_ENTRY *ppCrlEntry)
|
||||||
|
{
|
||||||
|
TRACE("(%p, %p, %08lx, %p, %p)\n", pCert, pCrlContext, dwFlags, pvReserved,
|
||||||
|
ppCrlEntry);
|
||||||
|
|
||||||
|
*ppCrlEntry = CRYPT_FindCertificateInCRL(pCert->pCertInfo,
|
||||||
|
pCrlContext->pCrlInfo);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CertVerifyCRLRevocation(DWORD dwCertEncodingType,
|
||||||
|
PCERT_INFO pCertId, DWORD cCrlInfo, PCRL_INFO rgpCrlInfo[])
|
||||||
|
{
|
||||||
|
DWORD i;
|
||||||
|
PCRL_ENTRY entry = NULL;
|
||||||
|
|
||||||
|
TRACE("(%08lx, %p, %ld, %p)\n", dwCertEncodingType, pCertId, cCrlInfo,
|
||||||
|
rgpCrlInfo);
|
||||||
|
|
||||||
|
for (i = 0; !entry && i < cCrlInfo; i++)
|
||||||
|
entry = CRYPT_FindCertificateInCRL(pCertId, rgpCrlInfo[i]);
|
||||||
|
return entry == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG WINAPI CertVerifyCRLTimeValidity(LPFILETIME pTimeToVerify,
|
||||||
|
PCRL_INFO pCrlInfo)
|
||||||
|
{
|
||||||
|
FILETIME fileTime;
|
||||||
|
LONG ret;
|
||||||
|
|
||||||
|
if (!pTimeToVerify)
|
||||||
|
{
|
||||||
|
SYSTEMTIME sysTime;
|
||||||
|
|
||||||
|
GetSystemTime(&sysTime);
|
||||||
|
SystemTimeToFileTime(&sysTime, &fileTime);
|
||||||
|
pTimeToVerify = &fileTime;
|
||||||
|
}
|
||||||
|
if ((ret = CompareFileTime(pTimeToVerify, &pCrlInfo->ThisUpdate)) >= 0)
|
||||||
|
{
|
||||||
|
ret = CompareFileTime(pTimeToVerify, &pCrlInfo->NextUpdate);
|
||||||
|
if (ret < 0)
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
|
@ -1,22 +1,31 @@
|
||||||
<module name="crypt32" type="win32dll" baseaddress="${BASEADDRESS_CRYPT32}" installbase="system32" installname="crypt32.dll">
|
<module name="crypt32" type="win32dll" baseaddress="${BASEADDRESS_CRYPT32}" installbase="system32" installname="crypt32.dll" allowwarnings="true">
|
||||||
<importlibrary definition="crypt32.spec.def" />
|
<importlibrary definition="crypt32.spec.def" />
|
||||||
<include base="crypt32">.</include>
|
<include base="crypt32">.</include>
|
||||||
<include base="ReactOS">include/reactos/wine</include>
|
<include base="ReactOS">include/reactos/wine</include>
|
||||||
|
<define name="__REACTOS__" />
|
||||||
|
<define name="__WINESRC__" />
|
||||||
<define name="__USE_W32API" />
|
<define name="__USE_W32API" />
|
||||||
|
<define name="_WIN32_IE">0x600</define>
|
||||||
<define name="_WIN32_WINNT">0x501</define>
|
<define name="_WIN32_WINNT">0x501</define>
|
||||||
<library>ntdll</library>
|
<define name="WINVER">0x501</define>
|
||||||
<library>kernel32</library>
|
|
||||||
<library>wine</library>
|
<library>wine</library>
|
||||||
|
<library>user32</library>
|
||||||
<library>advapi32</library>
|
<library>advapi32</library>
|
||||||
<file>main.c</file>
|
<library>kernel32</library>
|
||||||
<file>encode.c</file>
|
<library>ntdll</library>
|
||||||
|
<file>base64.c</file>
|
||||||
<file>cert.c</file>
|
<file>cert.c</file>
|
||||||
|
<file>crl.c</file>
|
||||||
|
<file>context.c</file>
|
||||||
|
<file>decode.c</file>
|
||||||
|
<file>encode.c</file>
|
||||||
<file>oid.c</file>
|
<file>oid.c</file>
|
||||||
<file>proplist.c</file>
|
<file>proplist.c</file>
|
||||||
<file>protectdata.c</file>
|
<file>protectdata.c</file>
|
||||||
<file>serialize.c</file>
|
<file>serialize.c</file>
|
||||||
<file>store.c</file>
|
<file>store.c</file>
|
||||||
<file>str.c</file>
|
<file>str.c</file>
|
||||||
|
<file>main.c</file>
|
||||||
<file>crypt32.rc</file>
|
<file>crypt32.rc</file>
|
||||||
<file>crypt32.spec</file>
|
<file>crypt32.spec</file>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define REACTOS_VERSION_DLL
|
#define REACTOS_VERSION_DLL
|
||||||
|
|
|
@ -11,31 +11,34 @@
|
||||||
@ stdcall CertAddStoreToCollection(ptr ptr long long)
|
@ stdcall CertAddStoreToCollection(ptr ptr long long)
|
||||||
@ stdcall CertAlgIdToOID(long)
|
@ stdcall CertAlgIdToOID(long)
|
||||||
@ stdcall CertCloseStore(ptr long)
|
@ stdcall CertCloseStore(ptr long)
|
||||||
@ stub CertCompareCertificate
|
@ stdcall CertCompareCertificate(long ptr ptr)
|
||||||
@ stub CertCompareCertificateName
|
@ stdcall CertCompareCertificateName(long ptr ptr)
|
||||||
@ stub CertCompareIntegerBlob
|
@ stdcall CertCompareIntegerBlob(ptr ptr)
|
||||||
@ stub CertComparePublicKeyInfo
|
@ stdcall CertComparePublicKeyInfo(long ptr ptr)
|
||||||
@ stdcall CertControlStore(long long long ptr)
|
@ stdcall CertControlStore(long long long ptr)
|
||||||
@ stdcall CertCreateCRLContext(long ptr long)
|
@ stdcall CertCreateCRLContext(long ptr long)
|
||||||
@ stdcall CertCreateCTLContext(long ptr long)
|
@ stdcall CertCreateCTLContext(long ptr long)
|
||||||
@ stub CertCreateCertificateChainEngine
|
@ stub CertCreateCertificateChainEngine
|
||||||
@ stdcall CertCreateCertificateContext(long ptr long)
|
@ stdcall CertCreateCertificateContext(long ptr long)
|
||||||
|
@ stdcall CertCreateSelfSignCertificate(long ptr long ptr ptr ptr ptr ptr)
|
||||||
@ stdcall CertDeleteCRLFromStore(ptr)
|
@ stdcall CertDeleteCRLFromStore(ptr)
|
||||||
@ stdcall CertDeleteCTLFromStore(ptr)
|
@ stdcall CertDeleteCTLFromStore(ptr)
|
||||||
@ stdcall CertDeleteCertificateFromStore(ptr)
|
@ stdcall CertDeleteCertificateFromStore(ptr)
|
||||||
@ stub CertDuplicateCRLContext
|
@ stdcall CertDuplicateCRLContext(ptr)
|
||||||
@ stub CertDuplicateCTLContext
|
@ stdcall CertDuplicateCTLContext(ptr)
|
||||||
@ stdcall CertDuplicateCertificateContext(ptr)
|
@ stdcall CertDuplicateCertificateContext(ptr)
|
||||||
@ stdcall CertDuplicateStore(ptr)
|
@ stdcall CertDuplicateStore(ptr)
|
||||||
@ stub CertEnumCRLContextProperties
|
@ stdcall CertEnumCRLContextProperties(ptr long)
|
||||||
@ stdcall CertEnumCRLsInStore(ptr ptr)
|
@ stdcall CertEnumCRLsInStore(ptr ptr)
|
||||||
@ stub CertEnumCTLContextProperties
|
@ stdcall CertEnumCTLContextProperties(ptr long)
|
||||||
@ stdcall CertEnumCTLsInStore(ptr ptr)
|
@ stdcall CertEnumCTLsInStore(ptr ptr)
|
||||||
@ stdcall CertEnumCertificateContextProperties(ptr long)
|
@ stdcall CertEnumCertificateContextProperties(ptr long)
|
||||||
@ stdcall CertEnumCertificatesInStore(long ptr)
|
@ stdcall CertEnumCertificatesInStore(long ptr)
|
||||||
@ stdcall CertFindAttribute(str long ptr)
|
@ stdcall CertFindAttribute(str long ptr)
|
||||||
|
@ stdcall CertFindCRLInStore(long long long long ptr ptr)
|
||||||
@ stub CertFindCTLInStore
|
@ stub CertFindCTLInStore
|
||||||
@ stdcall CertFindCertificateInStore(long long long long ptr ptr)
|
@ stdcall CertFindCertificateInStore(long long long long ptr ptr)
|
||||||
|
@ stdcall CertFindCertificateInCRL(ptr ptr long ptr ptr)
|
||||||
@ stdcall CertFindExtension(str long ptr)
|
@ stdcall CertFindExtension(str long ptr)
|
||||||
@ stdcall CertFindRDNAttr(str ptr)
|
@ stdcall CertFindRDNAttr(str ptr)
|
||||||
@ stub CertFindSubjectInCTL
|
@ stub CertFindSubjectInCTL
|
||||||
|
@ -45,19 +48,20 @@
|
||||||
@ stub CertFreeCertificateChainEngine
|
@ stub CertFreeCertificateChainEngine
|
||||||
@ stdcall CertFreeCertificateContext(ptr)
|
@ stdcall CertFreeCertificateContext(ptr)
|
||||||
@ stdcall CertGetCRLContextProperty(ptr long ptr ptr)
|
@ stdcall CertGetCRLContextProperty(ptr long ptr ptr)
|
||||||
@ stub CertGetCRLFromStore
|
@ stdcall CertGetCRLFromStore(ptr ptr ptr ptr)
|
||||||
@ stdcall CertGetCTLContextProperty(ptr long ptr ptr)
|
@ stdcall CertGetCTLContextProperty(ptr long ptr ptr)
|
||||||
@ stub CertGetCertificateChain
|
@ stub CertGetCertificateChain
|
||||||
@ stdcall CertGetCertificateContextProperty(ptr long ptr ptr)
|
@ stdcall CertGetCertificateContextProperty(ptr long ptr ptr)
|
||||||
@ stdcall CertGetEnhancedKeyUsage(ptr long ptr ptr)
|
@ stdcall CertGetEnhancedKeyUsage(ptr long ptr ptr)
|
||||||
@ stub CertGetIntendedKeyUsage
|
@ stub CertGetIntendedKeyUsage
|
||||||
@ stub CertGetIssuerCertificateFromStore
|
@ stdcall CertGetIssuerCertificateFromStore(long ptr ptr ptr)
|
||||||
@ stdcall CertGetNameStringA(ptr long long ptr ptr long)
|
@ stdcall CertGetNameStringA(ptr long long ptr ptr long)
|
||||||
@ stdcall CertGetNameStringW(ptr long long ptr ptr long)
|
@ stdcall CertGetNameStringW(ptr long long ptr ptr long)
|
||||||
@ stub CertGetPublicKeyLength
|
@ stub CertGetPublicKeyLength
|
||||||
@ stub CertGetSubjectCertificateFromStore
|
@ stdcall CertGetSubjectCertificateFromStore(ptr long ptr)
|
||||||
@ stdcall CertGetValidUsages(long ptr ptr ptr ptr)
|
@ stdcall CertGetValidUsages(long ptr ptr ptr ptr)
|
||||||
@ stub CertIsRDNAttrsInCertificateName
|
@ stub CertIsRDNAttrsInCertificateName
|
||||||
|
@ stdcall CertIsValidCRLForCertificate(ptr ptr long ptr)
|
||||||
@ stdcall CertNameToStrA(long ptr long ptr long)
|
@ stdcall CertNameToStrA(long ptr long ptr long)
|
||||||
@ stdcall CertNameToStrW(long ptr long ptr long)
|
@ stdcall CertNameToStrW(long ptr long ptr long)
|
||||||
@ stdcall CertOIDToAlgId(str)
|
@ stdcall CertOIDToAlgId(str)
|
||||||
|
@ -78,15 +82,18 @@
|
||||||
@ stdcall CertSetEnhancedKeyUsage(ptr ptr)
|
@ stdcall CertSetEnhancedKeyUsage(ptr ptr)
|
||||||
@ stub CertStrToNameA
|
@ stub CertStrToNameA
|
||||||
@ stub CertStrToNameW
|
@ stub CertStrToNameW
|
||||||
@ stub CertVerifyCertificateChainPolicy
|
@ stdcall CertVerifyCRLRevocation(long ptr long ptr)
|
||||||
@ stub CertVerifyCRLRevocation
|
@ stdcall CertVerifyCRLTimeValidity(ptr ptr)
|
||||||
@ stub CertVerifyCRLTimeValidity
|
|
||||||
@ stub CertVerifyCTLUsage
|
@ stub CertVerifyCTLUsage
|
||||||
@ stub CertVerifyRevocation
|
@ stub CertVerifyRevocation
|
||||||
@ stub CertVerifySubjectCertificateContext
|
@ stdcall CertVerifySubjectCertificateContext(ptr ptr ptr)
|
||||||
@ stdcall CertVerifyTimeValidity(ptr ptr)
|
@ stdcall CertVerifyTimeValidity(ptr ptr)
|
||||||
@ stub CertVerifyValidityNesting
|
@ stub CertVerifyValidityNesting
|
||||||
@ stub CreateFileU
|
@ stub CreateFileU
|
||||||
|
@ stdcall CryptBinaryToStringA(ptr long long ptr ptr)
|
||||||
|
@ stub CryptBinaryToStringW # (ptr long long ptr ptr)
|
||||||
|
@ stdcall CryptStringToBinaryA(str long long ptr ptr ptr ptr)
|
||||||
|
@ stub CryptStringToBinaryW # (wstr long long ptr ptr ptr ptr)
|
||||||
@ stub CryptAcquireContextU
|
@ stub CryptAcquireContextU
|
||||||
@ stub CryptCloseAsyncHandle
|
@ stub CryptCloseAsyncHandle
|
||||||
@ stub CryptCreateAsyncHandle
|
@ stub CryptCreateAsyncHandle
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LANGUAGE LANG_GERMAN, SUBLANG_DEFAULT
|
LANGUAGE LANG_GERMAN, SUBLANG_DEFAULT
|
||||||
|
@ -117,7 +117,7 @@ STRINGTABLE DISCARDABLE
|
||||||
IDS_KEY_RECOVERY_AGENT "Agent zur Schlüsselwiederherstellung"
|
IDS_KEY_RECOVERY_AGENT "Agent zur Schlüsselwiederherstellung"
|
||||||
IDS_CERTIFICATE_TEMPLATE "Zertifikatsvorlageninformation"
|
IDS_CERTIFICATE_TEMPLATE "Zertifikatsvorlageninformation"
|
||||||
IDS_ENTERPRISE_ROOT_OID "Unternehmensstamm-OID"
|
IDS_ENTERPRISE_ROOT_OID "Unternehmensstamm-OID"
|
||||||
IDS_RDN_DUMMY_SIGNER "Atrappenunterzeichner"
|
IDS_RDN_DUMMY_SIGNER "Attrapenunterzeichner"
|
||||||
IDS_ARCHIVED_KEY_ATTR "Verschlüsselter, privater Schlüssel"
|
IDS_ARCHIVED_KEY_ATTR "Verschlüsselter, privater Schlüssel"
|
||||||
IDS_CRL_SELF_CDP "Veröffentlichte CRL Standorte"
|
IDS_CRL_SELF_CDP "Veröffentlichte CRL Standorte"
|
||||||
IDS_REQUIRE_CERT_CHAIN_POLICY "Erzwinge Zertifikatskettenrichtlinie"
|
IDS_REQUIRE_CERT_CHAIN_POLICY "Erzwinge Zertifikatskettenrichtlinie"
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
|
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT
|
LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL
|
LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL
|
||||||
|
|
|
@ -13,12 +13,24 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __CRYPT32_PRIVATE_H__
|
#ifndef __CRYPT32_PRIVATE_H__
|
||||||
#define __CRYPT32_PRIVATE_H__
|
#define __CRYPT32_PRIVATE_H__
|
||||||
|
|
||||||
|
/* a few asn.1 tags we need */
|
||||||
|
#define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01)
|
||||||
|
#define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
|
||||||
|
#define ASN_ENUMERATED (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0a)
|
||||||
|
#define ASN_SETOF (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x11)
|
||||||
|
#define ASN_NUMERICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x12)
|
||||||
|
#define ASN_PRINTABLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x13)
|
||||||
|
#define ASN_T61STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x14)
|
||||||
|
#define ASN_IA5STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x16)
|
||||||
|
#define ASN_UTCTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x17)
|
||||||
|
#define ASN_GENERALTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x18)
|
||||||
|
|
||||||
/* The following aren't defined in wincrypt.h, as they're "reserved" */
|
/* The following aren't defined in wincrypt.h, as they're "reserved" */
|
||||||
#define CERT_CERT_PROP_ID 32
|
#define CERT_CERT_PROP_ID 32
|
||||||
#define CERT_CRL_PROP_ID 33
|
#define CERT_CRL_PROP_ID 33
|
||||||
|
@ -32,6 +44,50 @@ HCRYPTPROV CRYPT_GetDefaultProvider(void);
|
||||||
void crypt_oid_init(HINSTANCE hinst);
|
void crypt_oid_init(HINSTANCE hinst);
|
||||||
void crypt_oid_free(void);
|
void crypt_oid_free(void);
|
||||||
|
|
||||||
|
/* Some typedefs that make it easier to abstract which type of context we're
|
||||||
|
* working with.
|
||||||
|
*/
|
||||||
|
typedef const void *(WINAPI *CreateContextFunc)(DWORD dwCertEncodingType,
|
||||||
|
const BYTE *pbCertEncoded, DWORD cbCertEncoded);
|
||||||
|
typedef BOOL (WINAPI *AddContextToStoreFunc)(HCERTSTORE hCertStore,
|
||||||
|
const void *context, DWORD dwAddDisposition, const void **ppStoreContext);
|
||||||
|
typedef BOOL (WINAPI *AddEncodedContextToStoreFunc)(HCERTSTORE hCertStore,
|
||||||
|
DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded,
|
||||||
|
DWORD dwAddDisposition, const void **ppContext);
|
||||||
|
typedef const void *(WINAPI *DuplicateContextFunc)(const void *context);
|
||||||
|
typedef const void *(WINAPI *EnumContextsInStoreFunc)(HCERTSTORE hCertStore,
|
||||||
|
const void *pPrevContext);
|
||||||
|
typedef DWORD (WINAPI *EnumPropertiesFunc)(const void *context, DWORD dwPropId);
|
||||||
|
typedef BOOL (WINAPI *GetContextPropertyFunc)(const void *context,
|
||||||
|
DWORD dwPropID, void *pvData, DWORD *pcbData);
|
||||||
|
typedef BOOL (WINAPI *SetContextPropertyFunc)(const void *context,
|
||||||
|
DWORD dwPropID, DWORD dwFlags, const void *pvData);
|
||||||
|
typedef BOOL (WINAPI *SerializeElementFunc)(const void *context, DWORD dwFlags,
|
||||||
|
BYTE *pbElement, DWORD *pcbElement);
|
||||||
|
typedef BOOL (WINAPI *FreeContextFunc)(const void *context);
|
||||||
|
typedef BOOL (WINAPI *DeleteContextFunc)(const void *context);
|
||||||
|
|
||||||
|
/* An abstract context (certificate, CRL, or CTL) interface */
|
||||||
|
typedef struct _WINE_CONTEXT_INTERFACE
|
||||||
|
{
|
||||||
|
CreateContextFunc create;
|
||||||
|
AddContextToStoreFunc addContextToStore;
|
||||||
|
AddEncodedContextToStoreFunc addEncodedToStore;
|
||||||
|
DuplicateContextFunc duplicate;
|
||||||
|
EnumContextsInStoreFunc enumContextsInStore;
|
||||||
|
EnumPropertiesFunc enumProps;
|
||||||
|
GetContextPropertyFunc getProp;
|
||||||
|
SetContextPropertyFunc setProp;
|
||||||
|
SerializeElementFunc serialize;
|
||||||
|
FreeContextFunc free;
|
||||||
|
DeleteContextFunc deleteFromStore;
|
||||||
|
} WINE_CONTEXT_INTERFACE, *PWINE_CONTEXT_INTERFACE;
|
||||||
|
typedef const WINE_CONTEXT_INTERFACE *PCWINE_CONTEXT_INTERFACE;
|
||||||
|
|
||||||
|
extern PCWINE_CONTEXT_INTERFACE pCertInterface;
|
||||||
|
extern PCWINE_CONTEXT_INTERFACE pCRLInterface;
|
||||||
|
extern PCWINE_CONTEXT_INTERFACE pCTLInterface;
|
||||||
|
|
||||||
/* Helper function for store reading functions and
|
/* Helper function for store reading functions and
|
||||||
* CertAddSerializedElementToStore. Returns a context of the appropriate type
|
* CertAddSerializedElementToStore. Returns a context of the appropriate type
|
||||||
* if it can, or NULL otherwise. Doesn't validate any of the properties in
|
* if it can, or NULL otherwise. Doesn't validate any of the properties in
|
||||||
|
@ -41,11 +97,61 @@ void crypt_oid_free(void);
|
||||||
const void *CRYPT_ReadSerializedElement(const BYTE *pbElement,
|
const void *CRYPT_ReadSerializedElement(const BYTE *pbElement,
|
||||||
DWORD cbElement, DWORD dwContextTypeFlags, DWORD *pdwContentType);
|
DWORD cbElement, DWORD dwContextTypeFlags, DWORD *pdwContentType);
|
||||||
|
|
||||||
|
DWORD CertStore_GetAccessState(HCERTSTORE hCertStore);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Allocates a new data context, a context which owns properties directly.
|
||||||
|
* contextSize is the size of the public data type associated with context,
|
||||||
|
* which should be one of CERT_CONTEXT, CRL_CONTEXT, or CTL_CONTEXT.
|
||||||
|
* Free with Context_Release.
|
||||||
|
*/
|
||||||
|
void *Context_CreateDataContext(size_t contextSize);
|
||||||
|
|
||||||
|
/* Creates a new link context with extra bytes. The context refers to linked
|
||||||
|
* rather than owning its own properties. If addRef is TRUE (which ordinarily
|
||||||
|
* it should be) linked is addref'd.
|
||||||
|
* Free with Context_Release.
|
||||||
|
*/
|
||||||
|
void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned int extra,
|
||||||
|
BOOL addRef);
|
||||||
|
|
||||||
|
/* Returns a pointer to the extra bytes allocated with context, which must be
|
||||||
|
* a link context.
|
||||||
|
*/
|
||||||
|
void *Context_GetExtra(const void *context, size_t contextSize);
|
||||||
|
|
||||||
|
/* Gets the context linked to by context, which must be a link context. */
|
||||||
|
void *Context_GetLinkedContext(void *context, size_t contextSize);
|
||||||
|
|
||||||
|
/* Copies properties from fromContext to toContext. */
|
||||||
|
void Context_CopyProperties(const void *to, const void *from,
|
||||||
|
size_t contextSize);
|
||||||
|
|
||||||
|
struct _CONTEXT_PROPERTY_LIST;
|
||||||
|
typedef struct _CONTEXT_PROPERTY_LIST *PCONTEXT_PROPERTY_LIST;
|
||||||
|
|
||||||
|
/* Returns context's properties, or the linked context's properties if context
|
||||||
|
* is a link context.
|
||||||
|
*/
|
||||||
|
PCONTEXT_PROPERTY_LIST Context_GetProperties(void *context, size_t contextSize);
|
||||||
|
|
||||||
|
void Context_AddRef(void *context, size_t contextSize);
|
||||||
|
|
||||||
|
typedef void (*ContextFreeFunc)(void *context);
|
||||||
|
|
||||||
|
/* Decrements context's ref count. If context is a link context, releases its
|
||||||
|
* linked context as well.
|
||||||
|
* If a data context has its ref count reach 0, calls dataContextFree on it.
|
||||||
|
*/
|
||||||
|
void Context_Release(void *context, size_t contextSize,
|
||||||
|
ContextFreeFunc dataContextFree);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context property list functions
|
* Context property list functions
|
||||||
*/
|
*/
|
||||||
struct _CONTEXT_PROPERTY_LIST;
|
|
||||||
typedef struct _CONTEXT_PROPERTY_LIST *PCONTEXT_PROPERTY_LIST;
|
|
||||||
|
|
||||||
PCONTEXT_PROPERTY_LIST ContextPropertyList_Create(void);
|
PCONTEXT_PROPERTY_LIST ContextPropertyList_Create(void);
|
||||||
|
|
||||||
|
@ -68,4 +174,22 @@ void ContextPropertyList_Copy(PCONTEXT_PROPERTY_LIST to,
|
||||||
|
|
||||||
void ContextPropertyList_Free(PCONTEXT_PROPERTY_LIST list);
|
void ContextPropertyList_Free(PCONTEXT_PROPERTY_LIST list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context list functions. A context list is a simple list of link contexts.
|
||||||
|
*/
|
||||||
|
struct ContextList;
|
||||||
|
|
||||||
|
struct ContextList *ContextList_Create(
|
||||||
|
PCWINE_CONTEXT_INTERFACE contextInterface, size_t contextSize);
|
||||||
|
|
||||||
|
void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace);
|
||||||
|
|
||||||
|
void *ContextList_Enum(struct ContextList *list, void *pPrev);
|
||||||
|
|
||||||
|
void ContextList_Delete(struct ContextList *list, void *context);
|
||||||
|
|
||||||
|
void ContextList_Empty(struct ContextList *list);
|
||||||
|
|
||||||
|
void ContextList_Free(struct ContextList *list);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,16 +22,3 @@ Index: crypt32.rc
|
||||||
|
|
||||||
#include "crypt32_De.rc"
|
#include "crypt32_De.rc"
|
||||||
#include "crypt32_En.rc"
|
#include "crypt32_En.rc"
|
||||||
Index: main.c
|
|
||||||
===================================================================
|
|
||||||
--- main.c (revision 22838)
|
|
||||||
+++ main.c (working copy)
|
|
||||||
@@ -294,7 +294,7 @@
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
-BOOL WINAPI CryptVerifyMessageSignature(/*PCRYPT_VERIFY_MESSAGE_PARA*/ void* pVerifyPara,
|
|
||||||
+BOOL WINAPI CryptVerifyMessageSignature(PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara,
|
|
||||||
DWORD dwSignerIndex, const BYTE* pbSignedBlob, DWORD cbSignedBlob,
|
|
||||||
BYTE* pbDecoded, DWORD* pcbDecoded, PCCERT_CONTEXT* ppSignerCert)
|
|
||||||
{
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
#ifndef __WINE_CRYPTRES_H__
|
#ifndef __WINE_CRYPTRES_H__
|
||||||
#define __WINE_CRYPTRES_H__
|
#define __WINE_CRYPTRES_H__
|
||||||
|
|
3281
reactos/dll/win32/crypt32/decode.c
Normal file
3281
reactos/dll/win32/crypt32/decode.c
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -23,7 +23,6 @@
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "wincrypt.h"
|
#include "wincrypt.h"
|
||||||
#include "winreg.h"
|
#include "winreg.h"
|
||||||
#include "wingdi.h"
|
|
||||||
#include "winuser.h"
|
#include "winuser.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "wine/list.h"
|
#include "wine/list.h"
|
||||||
|
@ -51,8 +50,8 @@ void crypt_oid_free(void)
|
||||||
free_oid_info();
|
free_oid_info();
|
||||||
}
|
}
|
||||||
|
|
||||||
CRITICAL_SECTION funcSetCS;
|
static CRITICAL_SECTION funcSetCS;
|
||||||
struct list funcSets;
|
static struct list funcSets;
|
||||||
|
|
||||||
struct OIDFunctionSet
|
struct OIDFunctionSet
|
||||||
{
|
{
|
||||||
|
@ -454,7 +453,7 @@ BOOL WINAPI CryptRegisterOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName,
|
||||||
*/
|
*/
|
||||||
if (!pszFuncName || !pszOID)
|
if (!pszFuncName || !pszOID)
|
||||||
{
|
{
|
||||||
SetLastError(HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER));
|
SetLastError(E_INVALIDARG);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,8 +578,8 @@ BOOL WINAPI CryptSetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName,
|
||||||
return rc ? FALSE : TRUE;
|
return rc ? FALSE : TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CRITICAL_SECTION oidInfoCS;
|
static CRITICAL_SECTION oidInfoCS;
|
||||||
struct list oidInfo;
|
static struct list oidInfo;
|
||||||
|
|
||||||
static const WCHAR tripledes[] = { '3','d','e','s',0 };
|
static const WCHAR tripledes[] = { '3','d','e','s',0 };
|
||||||
static const WCHAR cms3deswrap[] = { 'C','M','S','3','D','E','S','w','r','a',
|
static const WCHAR cms3deswrap[] = { 'C','M','S','3','D','E','S','w','r','a',
|
||||||
|
@ -678,7 +677,7 @@ static const CRYPT_DATA_BLOB printableStringBlob = { sizeof(printableString),
|
||||||
static const CRYPT_DATA_BLOB domainCompTypesBlob = { sizeof(domainCompTypes),
|
static const CRYPT_DATA_BLOB domainCompTypesBlob = { sizeof(domainCompTypes),
|
||||||
(LPBYTE)domainCompTypes };
|
(LPBYTE)domainCompTypes };
|
||||||
|
|
||||||
struct OIDInfoConstructor {
|
static const struct OIDInfoConstructor {
|
||||||
DWORD dwGroupId;
|
DWORD dwGroupId;
|
||||||
LPCSTR pszOID;
|
LPCSTR pszOID;
|
||||||
UINT Algid;
|
UINT Algid;
|
||||||
|
@ -952,7 +951,7 @@ static void init_oid_info(HINSTANCE hinst)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int len = LoadStringW(hinst, (UINT)oidInfoConstructors[i].pwszName,
|
int len = LoadStringW(hinst, (UINT_PTR)oidInfoConstructors[i].pwszName,
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
|
|
||||||
if (len)
|
if (len)
|
||||||
|
@ -969,7 +968,7 @@ static void init_oid_info(HINSTANCE hinst)
|
||||||
(LPWSTR)((LPBYTE)info + sizeof(struct OIDInfo));
|
(LPWSTR)((LPBYTE)info + sizeof(struct OIDInfo));
|
||||||
info->info.dwGroupId = oidInfoConstructors[i].dwGroupId;
|
info->info.dwGroupId = oidInfoConstructors[i].dwGroupId;
|
||||||
info->info.u.Algid = oidInfoConstructors[i].Algid;
|
info->info.u.Algid = oidInfoConstructors[i].Algid;
|
||||||
LoadStringW(hinst, (UINT)oidInfoConstructors[i].pwszName,
|
LoadStringW(hinst, (UINT_PTR)oidInfoConstructors[i].pwszName,
|
||||||
(LPWSTR)info->info.pwszName, len + 1);
|
(LPWSTR)info->info.pwszName, len + 1);
|
||||||
if (oidInfoConstructors[i].blob)
|
if (oidInfoConstructors[i].blob)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -132,7 +132,6 @@ BOOL ContextPropertyList_SetProperty(PCONTEXT_PROPERTY_LIST list, DWORD id,
|
||||||
{
|
{
|
||||||
prop->propID = id;
|
prop->propID = id;
|
||||||
prop->cbData = cbData;
|
prop->cbData = cbData;
|
||||||
list_init(&prop->entry);
|
|
||||||
prop->pbData = data;
|
prop->pbData = data;
|
||||||
list_add_tail(&list->properties, &prop->entry);
|
list_add_tail(&list->properties, &prop->entry);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
@ -158,6 +157,7 @@ void ContextPropertyList_RemoveProperty(PCONTEXT_PROPERTY_LIST list, DWORD id)
|
||||||
list_remove(&prop->entry);
|
list_remove(&prop->entry);
|
||||||
CryptMemFree(prop->pbData);
|
CryptMemFree(prop->pbData);
|
||||||
CryptMemFree(prop);
|
CryptMemFree(prop);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&list->cs);
|
LeaveCriticalSection(&list->cs);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -843,8 +843,6 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn,
|
||||||
HCRYPTKEY hKey;
|
HCRYPTKEY hKey;
|
||||||
DWORD dwLength;
|
DWORD dwLength;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TRACE("called\n");
|
TRACE("called\n");
|
||||||
|
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
|
@ -863,7 +861,7 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn,
|
||||||
/* Windows appears to create an empty szDataDescr instead of maintaining
|
/* Windows appears to create an empty szDataDescr instead of maintaining
|
||||||
* a NULL */
|
* a NULL */
|
||||||
if (!szDataDescr)
|
if (!szDataDescr)
|
||||||
szDataDescr = L'\0';
|
szDataDescr=(WCHAR[]){'\0'};
|
||||||
|
|
||||||
/* get crypt context */
|
/* get crypt context */
|
||||||
if (!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,CRYPT_VERIFYCONTEXT))
|
if (!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,CRYPT_VERIFYCONTEXT))
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
|
@ -26,77 +26,6 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
|
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
|
||||||
|
|
||||||
/* Some typedefs that make it easier to abstract which type of context we're
|
|
||||||
* working with.
|
|
||||||
*/
|
|
||||||
typedef const void *(WINAPI *CreateContextFunc)(DWORD dwCertEncodingType,
|
|
||||||
const BYTE *pbCertEncoded, DWORD cbCertEncoded);
|
|
||||||
typedef BOOL (WINAPI *AddContextToStoreFunc)(HCERTSTORE hCertStore,
|
|
||||||
const void *context, DWORD dwAddDisposition, const void **ppStoreContext);
|
|
||||||
typedef BOOL (WINAPI *AddEncodedContextToStoreFunc)(HCERTSTORE hCertStore,
|
|
||||||
DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded,
|
|
||||||
DWORD dwAddDisposition, const void **ppContext);
|
|
||||||
typedef const void *(WINAPI *EnumContextsInStoreFunc)(HCERTSTORE hCertStore,
|
|
||||||
const void *pPrevContext);
|
|
||||||
typedef BOOL (WINAPI *GetContextPropertyFunc)(const void *context,
|
|
||||||
DWORD dwPropID, void *pvData, DWORD *pcbData);
|
|
||||||
typedef BOOL (WINAPI *SetContextPropertyFunc)(const void *context,
|
|
||||||
DWORD dwPropID, DWORD dwFlags, const void *pvData);
|
|
||||||
typedef BOOL (WINAPI *SerializeElementFunc)(const void *context, DWORD dwFlags,
|
|
||||||
BYTE *pbElement, DWORD *pcbElement);
|
|
||||||
typedef BOOL (WINAPI *FreeContextFunc)(const void *context);
|
|
||||||
typedef BOOL (WINAPI *DeleteContextFunc)(const void *context);
|
|
||||||
|
|
||||||
/* An abstract context (certificate, CRL, or CTL) interface */
|
|
||||||
typedef struct _WINE_CONTEXT_INTERFACE
|
|
||||||
{
|
|
||||||
CreateContextFunc create;
|
|
||||||
AddContextToStoreFunc addContextToStore;
|
|
||||||
AddEncodedContextToStoreFunc addEncodedToStore;
|
|
||||||
EnumContextsInStoreFunc enumContextsInStore;
|
|
||||||
GetContextPropertyFunc getProp;
|
|
||||||
SetContextPropertyFunc setProp;
|
|
||||||
SerializeElementFunc serialize;
|
|
||||||
FreeContextFunc free;
|
|
||||||
DeleteContextFunc deleteFromStore;
|
|
||||||
} WINE_CONTEXT_INTERFACE, *PWINE_CONTEXT_INTERFACE;
|
|
||||||
|
|
||||||
static const WINE_CONTEXT_INTERFACE gCertInterface = {
|
|
||||||
(CreateContextFunc)CertCreateCertificateContext,
|
|
||||||
(AddContextToStoreFunc)CertAddCertificateContextToStore,
|
|
||||||
(AddEncodedContextToStoreFunc)CertAddEncodedCertificateToStore,
|
|
||||||
(EnumContextsInStoreFunc)CertEnumCertificatesInStore,
|
|
||||||
(GetContextPropertyFunc)CertGetCertificateContextProperty,
|
|
||||||
(SetContextPropertyFunc)CertSetCertificateContextProperty,
|
|
||||||
(SerializeElementFunc)CertSerializeCertificateStoreElement,
|
|
||||||
(FreeContextFunc)CertFreeCertificateContext,
|
|
||||||
(DeleteContextFunc)CertDeleteCertificateFromStore,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const WINE_CONTEXT_INTERFACE gCRLInterface = {
|
|
||||||
(CreateContextFunc)CertCreateCRLContext,
|
|
||||||
(AddContextToStoreFunc)CertAddCRLContextToStore,
|
|
||||||
(AddEncodedContextToStoreFunc)CertAddEncodedCRLToStore,
|
|
||||||
(EnumContextsInStoreFunc)CertEnumCRLsInStore,
|
|
||||||
(GetContextPropertyFunc)CertGetCRLContextProperty,
|
|
||||||
(SetContextPropertyFunc)CertSetCRLContextProperty,
|
|
||||||
(SerializeElementFunc)CertSerializeCRLStoreElement,
|
|
||||||
(FreeContextFunc)CertFreeCRLContext,
|
|
||||||
(DeleteContextFunc)CertDeleteCRLFromStore,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const WINE_CONTEXT_INTERFACE gCTLInterface = {
|
|
||||||
(CreateContextFunc)CertCreateCTLContext,
|
|
||||||
(AddContextToStoreFunc)CertAddCTLContextToStore,
|
|
||||||
(AddEncodedContextToStoreFunc)CertAddEncodedCTLToStore,
|
|
||||||
(EnumContextsInStoreFunc)CertEnumCTLsInStore,
|
|
||||||
(GetContextPropertyFunc)CertGetCTLContextProperty,
|
|
||||||
(SetContextPropertyFunc)CertSetCTLContextProperty,
|
|
||||||
(SerializeElementFunc)CertSerializeCTLStoreElement,
|
|
||||||
(FreeContextFunc)CertFreeCTLContext,
|
|
||||||
(DeleteContextFunc)CertDeleteCTLFromStore,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* An extended certificate property in serialized form is prefixed by this
|
/* An extended certificate property in serialized form is prefixed by this
|
||||||
* header.
|
* header.
|
||||||
*/
|
*/
|
||||||
|
@ -107,45 +36,29 @@ typedef struct _WINE_CERT_PROP_HEADER
|
||||||
DWORD cb;
|
DWORD cb;
|
||||||
} WINE_CERT_PROP_HEADER, *PWINE_CERT_PROP_HEADER;
|
} WINE_CERT_PROP_HEADER, *PWINE_CERT_PROP_HEADER;
|
||||||
|
|
||||||
BOOL WINAPI CertSerializeCRLStoreElement(PCCRL_CONTEXT pCrlContext,
|
static BOOL CRYPT_SerializeStoreElement(const void *context,
|
||||||
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
|
const BYTE *encodedContext, DWORD cbEncodedContext, DWORD contextPropID,
|
||||||
{
|
PCWINE_CONTEXT_INTERFACE contextInterface, DWORD dwFlags, BYTE *pbElement,
|
||||||
FIXME("(%p, %08lx, %p, %p): stub\n", pCrlContext, dwFlags, pbElement,
|
DWORD *pcbElement)
|
||||||
pcbElement);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL WINAPI CertSerializeCTLStoreElement(PCCTL_CONTEXT pCtlContext,
|
|
||||||
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
|
|
||||||
{
|
|
||||||
FIXME("(%p, %08lx, %p, %p): stub\n", pCtlContext, dwFlags, pbElement,
|
|
||||||
pcbElement);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
|
|
||||||
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
|
|
||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
TRACE("(%p, %08lx, %p, %p)\n", pCertContext, dwFlags, pbElement,
|
TRACE("(%p, %p, %08lx, %p, %p)\n", context, contextInterface, dwFlags,
|
||||||
pcbElement);
|
pbElement, pcbElement);
|
||||||
|
|
||||||
if (pCertContext)
|
if (context)
|
||||||
{
|
{
|
||||||
DWORD bytesNeeded = sizeof(WINE_CERT_PROP_HEADER) +
|
DWORD bytesNeeded = sizeof(WINE_CERT_PROP_HEADER) + cbEncodedContext;
|
||||||
pCertContext->cbCertEncoded;
|
|
||||||
DWORD prop = 0;
|
DWORD prop = 0;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
do {
|
do {
|
||||||
prop = CertEnumCertificateContextProperties(pCertContext, prop);
|
prop = contextInterface->enumProps(context, prop);
|
||||||
if (prop)
|
if (prop)
|
||||||
{
|
{
|
||||||
DWORD propSize = 0;
|
DWORD propSize = 0;
|
||||||
|
|
||||||
ret = CertGetCertificateContextProperty(pCertContext,
|
ret = contextInterface->getProp(context, prop, NULL, &propSize);
|
||||||
prop, NULL, &propSize);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
bytesNeeded += sizeof(WINE_CERT_PROP_HEADER) + propSize;
|
bytesNeeded += sizeof(WINE_CERT_PROP_HEADER) + propSize;
|
||||||
}
|
}
|
||||||
|
@ -170,13 +83,13 @@ BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
|
||||||
|
|
||||||
prop = 0;
|
prop = 0;
|
||||||
do {
|
do {
|
||||||
prop = CertEnumCertificateContextProperties(pCertContext, prop);
|
prop = contextInterface->enumProps(context, prop);
|
||||||
if (prop)
|
if (prop)
|
||||||
{
|
{
|
||||||
DWORD propSize = 0;
|
DWORD propSize = 0;
|
||||||
|
|
||||||
ret = CertGetCertificateContextProperty(pCertContext,
|
ret = contextInterface->getProp(context, prop, NULL,
|
||||||
prop, NULL, &propSize);
|
&propSize);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
if (bufSize < propSize)
|
if (bufSize < propSize)
|
||||||
|
@ -189,8 +102,8 @@ BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
|
||||||
}
|
}
|
||||||
if (buf)
|
if (buf)
|
||||||
{
|
{
|
||||||
ret = CertGetCertificateContextProperty(
|
ret = contextInterface->getProp(context, prop, buf,
|
||||||
pCertContext, prop, buf, &propSize);
|
&propSize);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
hdr = (PWINE_CERT_PROP_HEADER)pbElement;
|
hdr = (PWINE_CERT_PROP_HEADER)pbElement;
|
||||||
|
@ -213,11 +126,11 @@ BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
|
||||||
CryptMemFree(buf);
|
CryptMemFree(buf);
|
||||||
|
|
||||||
hdr = (PWINE_CERT_PROP_HEADER)pbElement;
|
hdr = (PWINE_CERT_PROP_HEADER)pbElement;
|
||||||
hdr->propID = CERT_CERT_PROP_ID;
|
hdr->propID = contextPropID;
|
||||||
hdr->unknown = 1;
|
hdr->unknown = 1;
|
||||||
hdr->cb = pCertContext->cbCertEncoded;
|
hdr->cb = cbEncodedContext;
|
||||||
memcpy(pbElement + sizeof(WINE_CERT_PROP_HEADER),
|
memcpy(pbElement + sizeof(WINE_CERT_PROP_HEADER),
|
||||||
pCertContext->pbCertEncoded, pCertContext->cbCertEncoded);
|
encodedContext, cbEncodedContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -225,6 +138,30 @@ BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CertSerializeCertificateStoreElement(PCCERT_CONTEXT pCertContext,
|
||||||
|
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
|
||||||
|
{
|
||||||
|
return CRYPT_SerializeStoreElement(pCertContext,
|
||||||
|
pCertContext->pbCertEncoded, pCertContext->cbCertEncoded,
|
||||||
|
CERT_CERT_PROP_ID, pCertInterface, dwFlags, pbElement, pcbElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CertSerializeCRLStoreElement(PCCRL_CONTEXT pCrlContext,
|
||||||
|
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
|
||||||
|
{
|
||||||
|
return CRYPT_SerializeStoreElement(pCrlContext,
|
||||||
|
pCrlContext->pbCrlEncoded, pCrlContext->cbCrlEncoded,
|
||||||
|
CERT_CRL_PROP_ID, pCRLInterface, dwFlags, pbElement, pcbElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI CertSerializeCTLStoreElement(PCCTL_CONTEXT pCtlContext,
|
||||||
|
DWORD dwFlags, BYTE *pbElement, DWORD *pcbElement)
|
||||||
|
{
|
||||||
|
return CRYPT_SerializeStoreElement(pCtlContext,
|
||||||
|
pCtlContext->pbCtlEncoded, pCtlContext->cbCtlEncoded,
|
||||||
|
CERT_CTL_PROP_ID, pCRLInterface, dwFlags, pbElement, pcbElement);
|
||||||
|
}
|
||||||
|
|
||||||
/* Looks for the property with ID propID in the buffer buf. Returns a pointer
|
/* Looks for the property with ID propID in the buffer buf. Returns a pointer
|
||||||
* to its header if a valid header is found, NULL if not. Valid means the
|
* to its header if a valid header is found, NULL if not. Valid means the
|
||||||
* length of thte property won't overrun buf, and the unknown field is 1.
|
* length of thte property won't overrun buf, and the unknown field is 1.
|
||||||
|
@ -251,7 +188,7 @@ static const WINE_CERT_PROP_HEADER *CRYPT_findPropID(const BYTE *buf,
|
||||||
buf += sizeof(WINE_CERT_PROP_HEADER);
|
buf += sizeof(WINE_CERT_PROP_HEADER);
|
||||||
if (size < hdr->cb)
|
if (size < hdr->cb)
|
||||||
{
|
{
|
||||||
SetLastError(HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER));
|
SetLastError(E_INVALIDARG);
|
||||||
done = TRUE;
|
done = TRUE;
|
||||||
}
|
}
|
||||||
else if (!hdr->propID)
|
else if (!hdr->propID)
|
||||||
|
@ -339,16 +276,16 @@ const void *CRYPT_ReadSerializedElement(const BYTE *pbElement, DWORD cbElement,
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case CERT_STORE_CERTIFICATE_CONTEXT:
|
case CERT_STORE_CERTIFICATE_CONTEXT:
|
||||||
contextInterface = &gCertInterface;
|
contextInterface = pCertInterface;
|
||||||
break;
|
break;
|
||||||
case CERT_STORE_CRL_CONTEXT:
|
case CERT_STORE_CRL_CONTEXT:
|
||||||
contextInterface = &gCRLInterface;
|
contextInterface = pCRLInterface;
|
||||||
break;
|
break;
|
||||||
case CERT_STORE_CTL_CONTEXT:
|
case CERT_STORE_CTL_CONTEXT:
|
||||||
contextInterface = &gCTLInterface;
|
contextInterface = pCTLInterface;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SetLastError(HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER));
|
SetLastError(E_INVALIDARG);
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
}
|
}
|
||||||
if (!hdr)
|
if (!hdr)
|
||||||
|
@ -375,8 +312,7 @@ const void *CRYPT_ReadSerializedElement(const BYTE *pbElement, DWORD cbElement,
|
||||||
pbElement += sizeof(WINE_CERT_PROP_HEADER);
|
pbElement += sizeof(WINE_CERT_PROP_HEADER);
|
||||||
if (cbElement < hdr->cb)
|
if (cbElement < hdr->cb)
|
||||||
{
|
{
|
||||||
SetLastError(HRESULT_FROM_WIN32(
|
SetLastError(E_INVALIDARG);
|
||||||
ERROR_INVALID_PARAMETER));
|
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
}
|
}
|
||||||
else if (!hdr->propID)
|
else if (!hdr->propID)
|
||||||
|
@ -483,16 +419,16 @@ BOOL WINAPI CertAddSerializedElementToStore(HCERTSTORE hCertStore,
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case CERT_STORE_CERTIFICATE_CONTEXT:
|
case CERT_STORE_CERTIFICATE_CONTEXT:
|
||||||
contextInterface = &gCertInterface;
|
contextInterface = pCertInterface;
|
||||||
break;
|
break;
|
||||||
case CERT_STORE_CRL_CONTEXT:
|
case CERT_STORE_CRL_CONTEXT:
|
||||||
contextInterface = &gCRLInterface;
|
contextInterface = pCRLInterface;
|
||||||
break;
|
break;
|
||||||
case CERT_STORE_CTL_CONTEXT:
|
case CERT_STORE_CTL_CONTEXT:
|
||||||
contextInterface = &gCTLInterface;
|
contextInterface = pCTLInterface;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SetLastError(HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER));
|
SetLastError(E_INVALIDARG);
|
||||||
}
|
}
|
||||||
if (contextInterface)
|
if (contextInterface)
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
|
|
28
reactos/dll/win32/crypt32/version.rc
Normal file
28
reactos/dll/win32/crypt32/version.rc
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* crypt32 dll version resources
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Juan Lang
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define WINE_FILEDESCRIPTION_STR "Wine CryptoAPI Library"
|
||||||
|
#define WINE_FILENAME_STR "crypt32.dll"
|
||||||
|
#define WINE_FILEVERSION 5,131,2600,1243
|
||||||
|
#define WINE_FILEVERSION_STR "5.131.2600.1243"
|
||||||
|
#define WINE_PRODUCTVERSION 5,131,2600,1243
|
||||||
|
#define WINE_PRODUCTVERSION_STR "5.131.2600.1243"
|
||||||
|
|
||||||
|
#include "wine/wine_common_ver.rc"
|
Loading…
Add table
Add a link
Reference in a new issue