Autosyncing with Wine

svn path=/trunk/; revision=22826
This commit is contained in:
The Wine Synchronizer 2006-07-04 13:51:21 +00:00
parent bed42ce391
commit 8405953e75
14 changed files with 4763 additions and 32 deletions

View 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;
}

View 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);
}

View 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;
}

View file

@ -1,22 +1,27 @@
<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" />
<include base="crypt32">.</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="__REACTOS__" />
<define name="__WINESRC__" />
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x600</define>
<define name="_WIN32_WINNT">0x501</define>
<library>ntdll</library>
<library>kernel32</library>
<define name="WINVER">0x501</define>
<library>wine</library>
<library>user32</library>
<library>advapi32</library>
<file>main.c</file>
<file>encode.c</file>
<library>kernel32</library>
<library>ntdll</library>
<file>cert.c</file>
<file>encode.c</file>
<file>oid.c</file>
<file>proplist.c</file>
<file>protectdata.c</file>
<file>serialize.c</file>
<file>store.c</file>
<file>str.c</file>
<file>main.c</file>
<file>crypt32.rc</file>
<file>crypt32.spec</file>
</module>

View file

@ -17,18 +17,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "CryptoAPI Library\0"
#define REACTOS_STR_INTERNAL_NAME "crypt32\0"
#define REACTOS_STR_ORIGINAL_FILENAME "crypt32.dll\0"
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "cryptres.h"
#include <reactos/version.rc>
#include "version.rc"
#include "crypt32_De.rc"
#include "crypt32_En.rc"

View file

@ -78,7 +78,6 @@
@ stdcall CertSetEnhancedKeyUsage(ptr ptr)
@ stub CertStrToNameA
@ stub CertStrToNameW
@ stub CertVerifyCertificateChainPolicy
@ stub CertVerifyCRLRevocation
@ stub CertVerifyCRLTimeValidity
@ stub CertVerifyCTLUsage

View file

@ -117,7 +117,7 @@ STRINGTABLE DISCARDABLE
IDS_KEY_RECOVERY_AGENT "Agent zur Schlüsselwiederherstellung"
IDS_CERTIFICATE_TEMPLATE "Zertifikatsvorlageninformation"
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_CRL_SELF_CDP "Veröffentlichte CRL Standorte"
IDS_REQUIRE_CERT_CHAIN_POLICY "Erzwinge Zertifikatskettenrichtlinie"

File diff suppressed because it is too large Load diff

View file

@ -294,7 +294,7 @@ BOOL WINAPI CryptQueryObject(DWORD dwObjectType, const void* pvObject,
return FALSE;
}
BOOL WINAPI CryptVerifyMessageSignature(PCRYPT_VERIFY_MESSAGE_PARA pVerifyPara,
BOOL WINAPI CryptVerifyMessageSignature(/*PCRYPT_VERIFY_MESSAGE_PARA*/ void* pVerifyPara,
DWORD dwSignerIndex, const BYTE* pbSignedBlob, DWORD cbSignedBlob,
BYTE* pbDecoded, DWORD* pcbDecoded, PCCERT_CONTEXT* ppSignerCert)
{

View file

@ -23,7 +23,6 @@
#include "winbase.h"
#include "wincrypt.h"
#include "winreg.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/debug.h"
#include "wine/list.h"

View file

@ -843,8 +843,6 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn,
HCRYPTKEY hKey;
DWORD dwLength;
TRACE("called\n");
SetLastError(ERROR_SUCCESS);
@ -863,7 +861,7 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn,
/* Windows appears to create an empty szDataDescr instead of maintaining
* a NULL */
if (!szDataDescr)
szDataDescr = L'\0';
szDataDescr=(WCHAR[]){'\0'};
/* get crypt context */
if (!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,CRYPT_VERIFYCONTEXT))

View 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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"

View file

@ -13,7 +13,7 @@
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
@ -32,8 +32,6 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
switch (fdwReason) {
case DLL_WINE_PREATTACH:
return FALSE; /* prefer native version */
case DLL_PROCESS_ATTACH:
{
DisableThreadLibraryCalls(hinstDLL);

View file

@ -1,10 +1,17 @@
<module name="cryptdll" type="win32dll" baseaddress="${BASEADDRESS_CRYPTDLL}" installbase="system32" installname="cryptdll.dll">
<importlibrary definition="cryptdll.spec.def" />
<include base="cryptdll">.</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="__USE_W32API" />
<define name="_WIN32_WINNT">0x501</define>
<define name="DLL_WINE_PREATTACH">8</define>
<file>cryptdll.c</file>
<file>cryptdll.spec</file>
</module>
<module name="cryptdll" type="win32dll" baseaddress="${BASEADDRESS_CRYPTDLL}" installbase="system32" installname="cryptdll.dll" allowwarnings="true">
<importlibrary definition="cryptdll.spec.def" />
<include base="cryptdll">.</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="__REACTOS__" />
<define name="__WINESRC__" />
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x600</define>
<define name="_WIN32_WINNT">0x501</define>
<define name="WINVER">0x501</define>
<library>wine</library>
<library>advapi32</library>
<library>kernel32</library>
<library>ntdll</library>
<file>cryptdll.c</file>
<file>cryptdll.spec</file>
</module>