--- vendor/wine/dlls/crypt32/current/encode.c 2005-11-17 20:59:05 UTC (rev 19309)
+++ trunk/reactos/lib/crypt32/encode.c 2005-11-17 21:02:48 UTC (rev 19310)
@@ -31,22 +31,9 @@
* MSDN, especially:
* http://msdn.microsoft.com/library/en-us/seccrypto/security/constants_for_cryptencodeobject_and_cryptdecodeobject.asp
*/
-#include <assert.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#define NONAMELESSUNION
+#include "precomp.h"
-#include "windef.h"
-#include "winbase.h"
-#include "excpt.h"
-#include "wincrypt.h"
-#include "winreg.h"
-#include "snmp.h"
-#include "wine/debug.h"
-#include "wine/exception.h"
-
/* This is a bit arbitrary, but to set some limit: */
#define MAX_ENCODED_LEN 0x02000000
@@ -730,7 +717,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
const CERT_PUBLIC_KEY_INFO *info =
(const CERT_PUBLIC_KEY_INFO *)pvStructInfo;
@@ -745,12 +732,12 @@
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -760,7 +747,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
const CERT_SIGNED_CONTENT_INFO *info =
(const CERT_SIGNED_CONTENT_INFO *)pvStructInfo;
@@ -776,12 +763,12 @@
sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -795,7 +782,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
const CERT_INFO *info = (const CERT_INFO *)pvStructInfo;
struct AsnEncodeSequenceItem items[10] = {
@@ -845,12 +832,12 @@
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, cItem,
dwFlags, pEncodePara, pbEncoded, pcbEncoded);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -955,7 +942,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
const CRL_INFO *info = (const CRL_INFO *)pvStructInfo;
struct AsnEncodeSequenceItem items[7] = {
@@ -989,12 +976,12 @@
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, cItem,
dwFlags, pEncodePara, pbEncoded, pcbEncoded);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -1033,7 +1020,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
DWORD bytesNeeded, dataLen, lenBytes, i;
const CERT_EXTENSIONS *exts = (const CERT_EXTENSIONS *)pvStructInfo;
@@ -1073,12 +1060,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -1322,7 +1309,7 @@
BOOL ret;
CRYPT_DER_BLOB *blobs = NULL;
- __TRY
+ _SEH_TRY
{
DWORD bytesNeeded = 0, lenBytes, i;
@@ -1390,12 +1377,12 @@
CryptMemFree(blobs[i].pbData);
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
return FALSE;
}
- __ENDTRY
+ _SEH_END
CryptMemFree(blobs);
return ret;
}
@@ -1406,7 +1393,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
const CERT_NAME_INFO *info = (const CERT_NAME_INFO *)pvStructInfo;
DWORD bytesNeeded = 0, lenBytes, size, i;
@@ -1452,12 +1439,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -1585,7 +1572,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
const CERT_ALT_NAME_INFO *info =
(const CERT_ALT_NAME_INFO *)pvStructInfo;
@@ -1649,12 +1636,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -1664,7 +1651,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
const CERT_BASIC_CONSTRAINTS2_INFO *info =
(const CERT_BASIC_CONSTRAINTS2_INFO *)pvStructInfo;
@@ -1686,12 +1673,12 @@
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, cItem,
dwFlags, pEncodePara, pbEncoded, pcbEncoded);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -1701,7 +1688,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
const BLOBHEADER *hdr =
(const BLOBHEADER *)pvStructInfo;
@@ -1727,12 +1714,12 @@
pcbEncoded);
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -1742,7 +1729,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
const CRYPT_DATA_BLOB *blob = (const CRYPT_DATA_BLOB *)pvStructInfo;
DWORD bytesNeeded, lenBytes;
@@ -1772,12 +1759,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
TRACE("returning %d (%08lx)\n", ret, GetLastError());
return ret;
}
@@ -1788,7 +1775,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
const CRYPT_BIT_BLOB *blob = (const CRYPT_BIT_BLOB *)pvStructInfo;
DWORD bytesNeeded, lenBytes, dataBytes;
@@ -1843,12 +1830,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -1858,7 +1845,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
const CRYPT_BIT_BLOB *blob = (const CRYPT_BIT_BLOB *)pvStructInfo;
CRYPT_BIT_BLOB newBlob = { blob->cbData, NULL, blob->cUnusedBits };
@@ -1882,12 +1869,12 @@
&newBlob, dwFlags, pEncodePara, pbEncoded, pcbEncoded);
CryptMemFree(newBlob.pbData);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -1907,7 +1894,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
DWORD significantBytes, lenBytes;
BYTE padByte = 0, bytesNeeded;
@@ -1981,12 +1968,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -1996,7 +1983,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
DWORD significantBytes, lenBytes;
BYTE bytesNeeded;
@@ -2052,12 +2039,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -2088,7 +2075,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
SYSTEMTIME sysTime;
/* sorry, magic number: enough for tag, len, YYMMDDHHMMSSZ\0. I use a
@@ -2131,12 +2118,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -2146,7 +2133,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
SYSTEMTIME sysTime;
/* sorry, magic number: enough for tag, len, YYYYMMDDHHMMSSZ\0. I use a
@@ -2180,12 +2167,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -2195,7 +2182,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
SYSTEMTIME sysTime;
@@ -2210,12 +2197,12 @@
lpszStructType, pvStructInfo, dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -2225,7 +2212,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
DWORD bytesNeeded, dataLen, lenBytes, i;
const CRYPT_SEQUENCE_OF_ANY *seq =
@@ -2259,12 +2246,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -2837,7 +2824,7 @@
TRACE("%p, %ld, %08lx, %p, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, *pcbStructInfo);
- __TRY
+ _SEH_TRY
{
struct AsnDecodeSequenceItem items[] = {
{ offsetof(CERT_SIGNED_CONTENT_INFO, ToBeSigned),
@@ -2858,12 +2845,12 @@
sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, pcbStructInfo, NULL);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -2949,7 +2936,7 @@
TRACE("%p, %ld, %08lx, %p, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, *pcbStructInfo);
- __TRY
+ _SEH_TRY
{
struct AsnDecodeSequenceItem items[] = {
{ offsetof(CERT_INFO, dwVersion), CRYPT_AsnDecodeCertVersion,
@@ -2986,12 +2973,12 @@
sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, pcbStructInfo, NULL);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -3138,7 +3125,7 @@
TRACE("%p, %ld, %08lx, %p, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, *pcbStructInfo);
- __TRY
+ _SEH_TRY
{
struct AsnDecodeSequenceItem items[] = {
{ offsetof(CRL_INFO, dwVersion), CRYPT_AsnDecodeCertVersion,
@@ -3166,12 +3153,12 @@
sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, pcbStructInfo, NULL);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
TRACE("Returning %d (%08lx)\n", ret, GetLastError());
return ret;
@@ -3337,7 +3324,7 @@
{
BOOL ret = TRUE;
- __TRY
+ _SEH_TRY
{
ret = CRYPT_AsnDecodeExtensionsInternal(dwCertEncodingType,
lpszStructType, pbEncoded, cbEncoded,
@@ -3362,12 +3349,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -3380,7 +3367,7 @@
TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags, pszObjId,
*pcbObjId);
- __TRY
+ _SEH_TRY
{
if (pbEncoded[0] == ASN_OBJECTIDENTIFIER)
{
@@ -3477,12 +3464,12 @@
ret = FALSE;
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -3495,7 +3482,7 @@
{
BOOL ret = TRUE;
- __TRY
+ _SEH_TRY
{
DWORD dataLen;
@@ -3579,12 +3566,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -3596,7 +3583,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SEQUENCE))
{
@@ -3708,12 +3695,12 @@
ret = FALSE;
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -3722,7 +3709,7 @@
{
BOOL ret = TRUE;
- __TRY
+ _SEH_TRY
{
if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SETOF))
{
@@ -3823,12 +3810,12 @@
ret = FALSE;
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -3838,7 +3825,7 @@
{
BOOL ret = TRUE;
- __TRY
+ _SEH_TRY
{
if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SEQUENCEOF))
{
@@ -3933,12 +3920,12 @@
ret = FALSE;
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -4015,7 +4002,7 @@
{
BOOL ret = TRUE;
- __TRY
+ _SEH_TRY
{
struct AsnDecodeSequenceItem items[] = {
{ offsetof(CERT_PUBLIC_KEY_INFO, Algorithm),
@@ -4031,12 +4018,12 @@
sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, pcbStructInfo, NULL);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -4186,7 +4173,7 @@
{
BOOL ret = TRUE;
- __TRY
+ _SEH_TRY
{
if (pbEncoded[0] == ASN_SEQUENCEOF)
{
@@ -4284,12 +4271,12 @@
ret = FALSE;
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -4350,7 +4337,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
struct AsnDecodeSequenceItem items[] = {
{ offsetof(CERT_BASIC_CONSTRAINTS2_INFO, fCA), CRYPT_AsnDecodeBool,
@@ -4364,12 +4351,12 @@
sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, pcbStructInfo, NULL);
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -4387,7 +4374,7 @@
{
BOOL ret;
- __TRY
+ _SEH_TRY
{
struct AsnDecodeSequenceItem items[] = {
{ offsetof(struct DECODED_RSA_PUB_KEY, modulus),
@@ -4438,12 +4425,12 @@
LocalFree(decodedKey);
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -4510,7 +4497,7 @@
TRACE("%p, %ld, %08lx, %p, %p, %ld\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, *pcbStructInfo);
- __TRY
+ _SEH_TRY
{
DWORD bytesNeeded;
@@ -4541,12 +4528,12 @@
ret = FALSE;
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
- __ENDTRY
+ _SEH_END
return ret;
}
@@ -4623,7 +4610,7 @@
TRACE("(%p, %ld, 0x%08lx, %p, %p, %p)\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, pcbStructInfo);
- __TRY
+ _SEH_TRY
{
DWORD bytesNeeded;
@@ -4649,12 +4636,12 @@
}
}
}
- __EXCEPT(page_fault)
+ _SEH_EXCEPT(page_fault)
{
SetLastError(STATUS_ACCESS_VIOLATION);
ret = FALSE;
}
[truncated at 1000 lines; 403 more skipped]