* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
-#include <stdarg.h>
+//#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
-#include <winerror.h>
+//#include <winerror.h>
#include <wincrypt.h>
-#include "wine/test.h"
+#include <wine/test.h>
static BOOL (WINAPI *pCryptDecodeObjectEx)(DWORD,LPCSTR,const BYTE*,DWORD,DWORD,PCRYPT_DECODE_PARA,void*,DWORD*);
ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
buf[0]);
ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
buf[0]);
ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
buf[0]);
ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
buf[0]);
ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError());
ok(bufSize == sizeof(int), "Wrong size %d\n", bufSize);
ok(buf != NULL, "Expected allocated buffer\n");
- if (buf)
+ if (ret)
{
ok(!memcmp(buf, &ints[i].val, bufSize), "Expected %d, got %d\n",
ints[i].val, *(int *)buf);
ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError());
ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %d\n", bufSize);
ok(buf != NULL, "Expected allocated buffer\n");
- if (buf)
+ if (ret)
{
CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf;
ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError());
ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %d\n", bufSize);
ok(buf != NULL, "Expected allocated buffer\n");
- if (buf)
+ if (ret)
{
CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf;
ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, longForm,
sizeof(longForm), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(*(int *)buf == 1, "Expected 1, got %d\n", *(int *)buf);
LocalFree(buf);
ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, extraBytes,
sizeof(extraBytes), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(*(int *)buf == 1, "Expected 1, got %d\n", *(int *)buf);
LocalFree(buf);
&enums[j].val, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf,
&bufSize);
ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(buf[0] == 0xa,
"Got unexpected type %d for enumerated (expected 0xa)\n",
ok(ret, "CryptEncodeObjectEx failed: %d (0x%08x)\n", GetLastError(),
GetLastError());
ok(buf != NULL, "Expected an allocated buffer\n");
- if (buf)
+ if (ret)
{
ok(buf[0] == time->encodedTime[0],
"Expected type 0x%02x, got 0x%02x\n", time->encodedTime[0],
ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(!memcmp(buf, emptySequence, sizeof(emptySequence)),
"Got unexpected encoding for empty name\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(!memcmp(buf, emptyRDNs, sizeof(emptyRDNs)),
"Got unexpected encoding for empty RDN array\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(!memcmp(buf, twoRDNs, sizeof(twoRDNs)),
"Got unexpected encoding for two RDN array\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(encodedTwoRDNs), "Unexpected size %d\n", size);
ok(!memcmp(buf, encodedTwoRDNs, size),
- "Unexpected value for re-endoded two RDN array\n");
+ "Unexpected value for re-encoded two RDN array\n");
LocalFree(buf);
}
/* CERT_RDN_ANY_TYPE is too vague for X509_NAMEs, check the return */
ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(!memcmp(buf, emptySequence, sizeof(emptySequence)),
"Got unexpected encoding for empty name\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(!memcmp(buf, twoRDNsNoNull, sizeof(twoRDNsNoNull)),
"Got unexpected encoding for two RDN array\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(encodedTwoRDNs), "Unexpected size %d\n", size);
ok(!memcmp(buf, encodedTwoRDNs, size),
- "Unexpected value for re-endoded two RDN array\n");
+ "Unexpected value for re-encoded two RDN array\n");
LocalFree(buf);
}
/* Unicode names infer the type for CERT_RDN_ANY_TYPE */
ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
todo_wine ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(anyType), "Unexpected size %d\n", size);
ok(!memcmp(buf, anyType, size), "Unexpected value\n");
ok(got->dwValueType == expected->dwValueType,
"Expected string type %d, got %d\n", expected->dwValueType,
got->dwValueType);
- ok(got->Value.cbData == expected->Value.cbData,
+ ok(got->Value.cbData == expected->Value.cbData ||
+ got->Value.cbData == expected->Value.cbData - sizeof(WCHAR) /* Win8 */,
"String type %d: unexpected data size, got %d, expected %d\n",
expected->dwValueType, got->Value.cbData, expected->Value.cbData);
if (got->Value.cbData && got->Value.pbData)
/* Interestingly, in Windows, if cRDN is 0, rgRGN may not be NULL. My
* decoder works the same way, so only test the count.
*/
- if (buf)
+ if (ret)
{
ok(bufSize == sizeof(CERT_NAME_INFO), "Wrong bufSize %d\n", bufSize);
ok(((CERT_NAME_INFO *)buf)->cRDN == 0,
CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
&buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_NAME_INFO *info = (CERT_NAME_INFO *)buf;
CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
&buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
static CHAR oid_sur_name[] = szOID_SUR_NAME,
oid_common_name[] = szOID_COMMON_NAME;
CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
&buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(bufSize == sizeof(CERT_NAME_INFO),
"Got wrong bufSize %d\n", bufSize);
CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
&buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_NAME_INFO *info = (CERT_NAME_INFO *)buf;
CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
&buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
static CHAR oid_sur_name[] = szOID_SUR_NAME,
oid_common_name[] = szOID_COMMON_NAME;
ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &value,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(printableCommonNameValue), "Unexpected size %d\n",
size);
/* Test with empty info */
ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptySequence), "Wrong size %d\n", size);
ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
entry.dwAltNameChoice = CERT_ALT_NAME_URL;
ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptyURL), "Wrong size %d\n", size);
ok(!memcmp(buf, emptyURL, size), "Unexpected value\n");
U(entry).pwszURL = (LPWSTR)url;
ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(encodedURL), "Wrong size %d\n", size);
ok(!memcmp(buf, encodedURL, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
/* This succeeds, but it shouldn't, so don't worry about conforming */
LocalFree(buf);
ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(encodedDnsName), "Wrong size %d\n", size);
ok(!memcmp(buf, encodedDnsName, size), "Unexpected value\n");
U(entry).IPAddress.pbData = (LPBYTE)localhost;
ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(encodedIPAddr), "Wrong size %d\n", size);
ok(!memcmp(buf, encodedIPAddr, size), "Unexpected value\n");
U(entry).pszRegisteredID = oid;
ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(encodedOidName), "Wrong size %d\n", size);
ok(!memcmp(buf, encodedOidName, size), "Unexpected value\n");
U(entry).DirectoryName.pbData = (LPBYTE)encodedCommonName;
ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(encodedDirectoryName), "Wrong size %d\n", size);
ok(!memcmp(buf, encodedDirectoryName, size), "Unexpected value\n");
ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptySequence,
emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CERT_ALT_NAME_INFO *)buf;
ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptyURL,
emptyURL[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CERT_ALT_NAME_INFO *)buf;
ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedURL,
encodedURL[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CERT_ALT_NAME_INFO *)buf;
ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedDnsName,
encodedDnsName[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CERT_ALT_NAME_INFO *)buf;
ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedIPAddr,
encodedIPAddr[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CERT_ALT_NAME_INFO *)buf;
ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedOidName,
sizeof(encodedOidName), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CERT_ALT_NAME_INFO *)buf;
encodedDirectoryName, sizeof(encodedDirectoryName),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CERT_ALT_NAME_INFO *)buf;
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret || broken(GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == unicodeResults[i].encoded.cbData,
"Value type %d: expected size %d, got %d\n",
ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == unicodeWeirdness[i].encoded.cbData,
"Value type %d: expected size %d, got %d\n",
ret = pCryptEncodeObjectEx(dwEncoding, X509_OCTET_STRING, &blob,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(buf[0] == 4,
"Got unexpected type %d for octet string (expected 4)\n", buf[0]);
"Expected size >= %d, got %d\n",
(int)sizeof(CRYPT_DATA_BLOB) + octets[i].encoded[1], bufSize);
ok(buf != NULL, "Expected allocated buffer\n");
- if (buf)
+ if (ret)
{
CRYPT_DATA_BLOB *blob = (CRYPT_DATA_BLOB *)buf;
static const unsigned char bin55[] = { 0xff,0xfe };
static const unsigned char bin56[] = { 0x03,0x02,0x01,0xfe };
static const unsigned char bin57[] = { 0xfe };
-static const unsigned char bin58[] = { 0x03,0x01,0x00 };
static const struct encodedBits bits[] = {
/* normal test cases */
ret = pCryptEncodeObjectEx(dwEncoding, X509_BITS, &blob,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(bufSize == bits[i].encoded[1] + 2,
"%d: Got unexpected size %d, expected %d\n", i, bufSize,
bits[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf,
&bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CRYPT_BIT_BLOB *blob;
ret = pCryptDecodeObjectEx(dwEncoding, X509_BITS, ber, ber[1] + 2,
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CRYPT_BIT_BLOB *blob;
&constraints2[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf,
&bufSize);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(bufSize == constraints2[i].encoded[1] + 2,
"Expected %d bytes, got %d\n", constraints2[i].encoded[1] + 2,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(bufSize == sizeof(emptyConstraint), "Wrong size %d\n", bufSize);
ok(!memcmp(buf, emptyConstraint, sizeof(emptyConstraint)),
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(bufSize == sizeof(constraintWithDomainName), "Wrong size %d\n", bufSize);
ok(!memcmp(buf, constraintWithDomainName,
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed for item %d: %08x\n", i,
GetLastError());
- if (buf)
+ if (ret)
{
CERT_BASIC_CONSTRAINTS2_INFO *info =
(CERT_BASIC_CONSTRAINTS2_INFO *)buf;
badBool.encoded, badBool.encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
&buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_BASIC_CONSTRAINTS2_INFO *info =
(CERT_BASIC_CONSTRAINTS2_INFO *)buf;
emptyConstraint, sizeof(emptyConstraint), CRYPT_DECODE_ALLOC_FLAG, NULL,
&buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_BASIC_CONSTRAINTS_INFO *info = (CERT_BASIC_CONSTRAINTS_INFO *)buf;
constraintWithDomainName, sizeof(constraintWithDomainName),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_BASIC_CONSTRAINTS_INFO *info = (CERT_BASIC_CONSTRAINTS_INFO *)buf;
size_t decodedModulusLen;
};
-struct EncodedRSAPubKey rsaPubKeys[] = {
+static const struct EncodedRSAPubKey rsaPubKeys[] = {
{ modulus1, sizeof(modulus1), mod1_encoded, sizeof(modulus1) },
{ modulus2, sizeof(modulus2), mod2_encoded, 5 },
{ modulus3, sizeof(modulus3), mod3_encoded, 5 },
hdr->reserved = 1;
ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB,
toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
- if (buf)
+ if (ret)
{
ok(bufSize == rsaPubKeys[0].encoded[1] + 2,
"Expected size %d, got %d\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
hdr->bVersion = 0;
ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB,
toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
- if (buf)
+ if (ret)
{
ok(bufSize == rsaPubKeys[0].encoded[1] + 2,
"Expected size %d, got %d\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
hdr->aiKeyAlg = CALG_DES;
ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB,
toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
- if (buf)
+ if (ret)
{
ok(bufSize == rsaPubKeys[0].encoded[1] + 2,
"Expected size %d, got %d\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB,
toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(bufSize == rsaPubKeys[i].encoded[1] + 2,
"Expected size %d, got %d\n", rsaPubKeys[i].encoded[1] + 2,
rsaPubKeys[i].encoded, rsaPubKeys[i].encoded[1] + 2,
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
BLOBHEADER *hdr = (BLOBHEADER *)buf;
RSAPUBKEY *rsaPubKey = (RSAPUBKEY *)(buf + sizeof(BLOBHEADER));
ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(bufSize == sizeof(intSequence), "Wrong size %d\n", bufSize);
ok(!memcmp(buf, intSequence, intSequence[1] + 2), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(bufSize == sizeof(mixedSequence), "Wrong size %d\n", bufSize);
ok(!memcmp(buf, mixedSequence, mixedSequence[1] + 2),
ret = pCryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, intSequence,
intSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf;
DWORD i;
mixedSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf,
&bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf;
ret = pCryptEncodeObjectEx(dwEncoding, X509_EXTENSIONS, &exts[i].exts,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(bufSize == exts[i].encoded[1] + 2,
"Expected %d bytes, got %d\n", exts[i].encoded[1] + 2, bufSize);
exts[i].encoded, exts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG,
NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_EXTENSIONS *ext = (CERT_EXTENSIONS *)buf;
DWORD j;
}
LocalFree(buf);
}
+ ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS,
+ exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufSize);
+ if (buf)
+ {
+ ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS,
+ exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, buf, &bufSize);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ HeapFree(GetProcessHeap(), 0, buf);
+ }
}
}
&bufSize);
ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(bufSize == pubKeys[i].encoded[1] + 2,
"Expected %d bytes, got %d\n", pubKeys[i].encoded[1] + 2, bufSize);
pubKeys[i].encoded, pubKeys[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG,
NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
comparePublicKeyInfo(&pubKeys[i].decoded,
(CERT_PUBLIC_KEY_INFO *)buf);
pubKeys[i].encodedNoNull, pubKeys[i].encodedNoNull[1] + 2,
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
comparePublicKeyInfo(&pubKeys[i].info, (CERT_PUBLIC_KEY_INFO *)buf);
LocalFree(buf);
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == v1Cert[1] + 2, "Expected size %d, got %d\n",
v1Cert[1] + 2, size);
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(v2Cert), "Wrong size %d\n", size);
ok(!memcmp(buf, v2Cert, size), "Got unexpected value\n");
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(v3Cert), "Wrong size %d\n", size);
ok(!memcmp(buf, v3Cert, size), "Got unexpected value\n");
info.dwVersion = 3; /* Not a typo, CERT_V3 is 2 */
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(v4Cert), "Wrong size %d\n", size);
ok(!memcmp(buf, v4Cert, size), "Unexpected value\n");
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CertWithConstraints), "Wrong size %d\n", size);
ok(!memcmp(buf, v1CertWithConstraints, size), "Got unexpected value\n");
info.SerialNumber.pbData = (BYTE *)serialNum;
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CertWithSerial), "Wrong size %d\n", size);
ok(!memcmp(buf, v1CertWithSerial, size), "Got unexpected value\n");
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret || broken(GetLastError() == OSS_BAD_PTR /* Win98 */),
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CertWithIssuerUniqueId), "Wrong size %d\n", size);
ok(!memcmp(buf, v1CertWithIssuerUniqueId, size),
info.Subject.pbData = (BYTE *)encodedCommonName;
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(bigCert), "Wrong size %d\n", size);
ok(!memcmp(buf, bigCert, size), "Got unexpected value\n");
info.SubjectPublicKeyInfo.PublicKey.pbData = (LPBYTE)aKey;
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CertWithPubKey) ||
size == sizeof(v1CertWithPubKeyNoNull), "Wrong size %d\n", size);
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueId) ||
size == sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueIdNoNull),
info.rgExtension = &ext;
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CertWithSubjectKeyId), "Wrong size %d\n", size);
ok(!memcmp(buf, v1CertWithSubjectKeyId, size), "Unexpected value\n");
ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, bigCert,
sizeof(bigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_INFO *info = (CERT_INFO *)buf;
v1CertWithPubKey, sizeof(v1CertWithPubKey), CRYPT_DECODE_ALLOC_FLAG, NULL,
&buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_INFO *info = (CERT_INFO *)buf;
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(bufSize == sizeof(signedBigCert), "Wrong size %d\n", bufSize);
ok(!memcmp(buf, signedBigCert, bufSize), "Unexpected cert\n");
ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT, signedBigCert,
sizeof(signedBigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_SIGNED_CONTENT_INFO *info = (CERT_SIGNED_CONTENT_INFO *)buf;
ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCert,
sizeof(signedBigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_INFO *info = (CERT_INFO *)buf;
ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptyDistPoint), "Wrong size %d\n", size);
ok(!memcmp(buf, emptyDistPoint, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(distPointWithUrl), "Wrong size %d\n", size);
ok(!memcmp(buf, distPointWithUrl, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(distPointWithReason), "Wrong size %d\n", size);
ok(!memcmp(buf, distPointWithReason, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(distPointWithIssuer), "Wrong size %d\n", size);
ok(!memcmp(buf, distPointWithIssuer, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(distPointWithUrlAndIssuer),
"Wrong size %d\n", size);
ok(!lstrcmpW(U(*entry).pwszURL, url), "Unexpected name\n");
LocalFree(buf);
}
+ ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS,
+ distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, 0,
+ NULL, NULL, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
+ if (buf)
+ {
+ ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS,
+ distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, 0,
+ NULL, buf, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ HeapFree(GetProcessHeap(), 0, buf);
+ }
}
static const BYTE badFlagsIDP[] = { 0x30,0x06,0x81,0x01,0xff,0x82,0x01,0xff };
ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptySequence), "Unexpected size %d\n", size);
ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(badFlagsIDP), "Unexpected size %d\n", size);
ok(!memcmp(buf, badFlagsIDP, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptyNameIDP), "Unexpected size %d\n", size);
ok(!memcmp(buf, emptyNameIDP, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(urlIDP), "Unexpected size %d\n", size);
ok(!memcmp(buf, urlIDP, size), "Unexpected value\n");
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CRL), "Wrong size %d\n", size);
ok(!memcmp(buf, v1CRL, size), "Got unexpected value\n");
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
"CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == v2CRL[1] + 2, "Expected size %d, got %d\n",
v2CRL[1] + 2, size);
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CRLWithIssuer), "Wrong size %d\n", size);
ok(!memcmp(buf, v1CRLWithIssuer, size), "Got unexpected value\n");
info.rgCRLEntry = &entry;
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CRLWithIssuerAndEmptyEntry),
"Wrong size %d\n", size);
entry.SerialNumber.pbData = (BYTE *)serialNum;
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CRLWithIssuerAndEntry),
"Wrong size %d\n", size);
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CRLWithEntryExt), "Wrong size %d\n", size);
ok(!memcmp(buf, v1CRLWithEntryExt, size), "Got unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(v1CRLWithExt), "Wrong size %d\n", size);
ok(!memcmp(buf, v1CRLWithExt, size), "Got unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(v2CRLWithExt), "Wrong size %d\n", size);
ok(!memcmp(buf, v2CRLWithExt, size), "Got unexpected value\n");
v1CRLWithIssuer, v1CRLWithIssuer[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
&buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CRL_INFO *info = (CRL_INFO *)buf;
v1CRLWithIssuerAndEmptyEntry, v1CRLWithIssuerAndEmptyEntry[1] + 2,
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT ||
- GetLastError() == OSS_DATA_ERROR /* Win9x */),
+ GetLastError() == OSS_DATA_ERROR /* Win9x */ ||
+ GetLastError() == CRYPT_E_BAD_ENCODE /* Win8 */),
"Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n",
GetLastError());
/* with a real CRL entry */
v1CRLWithIssuerAndEntry, v1CRLWithIssuerAndEntry[1] + 2,
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CRL_INFO *info = (CRL_INFO *)buf;
CRL_ENTRY *entry;
verisignCRL, sizeof(verisignCRL), CRYPT_DECODE_ALLOC_FLAG,
NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CRL_INFO *info = (CRL_INFO *)buf;
verisignCRLWithLotsOfEntries, sizeof(verisignCRLWithLotsOfEntries),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CRL_INFO *info = (CRL_INFO *)buf;
v1CRLWithExt, sizeof(v1CRLWithExt), CRYPT_DECODE_ALLOC_FLAG,
NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CRL_INFO *info = (CRL_INFO *)buf;
CRL_ENTRY *entry;
v2CRLWithExt, sizeof(v2CRLWithExt), CRYPT_DECODE_ALLOC_FLAG,
NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CRL_INFO *info = (CRL_INFO *)buf;
ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptySequence), "Wrong size %d\n", size);
ok(!memcmp(buf, emptySequence, size), "Got unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(encodedUsage), "Wrong size %d\n", size);
ok(!memcmp(buf, encodedUsage, size), "Got unexpected value\n");
emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
&buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_ENHKEY_USAGE *usage = (CERT_ENHKEY_USAGE *)buf;
encodedUsage, sizeof(encodedUsage), CRYPT_DECODE_ALLOC_FLAG, NULL,
&buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_ENHKEY_USAGE *usage = (CERT_ENHKEY_USAGE *)buf;
DWORD i;
usage->rgpszUsageIdentifier[i]);
LocalFree(buf);
}
+ ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE,
+ encodedUsage, sizeof(encodedUsage), 0, NULL, NULL, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
+ if (buf)
+ {
+ ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE,
+ encodedUsage, sizeof(encodedUsage), 0, NULL, buf, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ HeapFree(GetProcessHeap(), 0, buf);
+ }
}
static BYTE keyId[] = { 1,2,3,4 };
ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptySequence), "Unexpected size %d\n", size);
ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %d\n", size);
ok(!memcmp(buf, authorityKeyIdWithId, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(authorityKeyIdWithIssuer), "Unexpected size %d\n",
size);
ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %d\n",
size);
emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
&buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf;
authorityKeyIdWithId, sizeof(authorityKeyIdWithId),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf;
authorityKeyIdWithIssuer, sizeof(authorityKeyIdWithIssuer),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf;
authorityKeyIdWithSerial, sizeof(authorityKeyIdWithSerial),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf;
ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptySequence), "Unexpected size %d\n", size);
ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %d\n",
size);
ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(authorityKeyIdWithIssuerUrl), "Unexpected size %d\n",
size);
ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %d\n",
size);
emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
&buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf;
authorityKeyIdWithId, sizeof(authorityKeyIdWithId),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf;
authorityKeyIdWithIssuerUrl, sizeof(authorityKeyIdWithIssuerUrl),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf;
authorityKeyIdWithSerial, sizeof(authorityKeyIdWithSerial),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf;
ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptySequence), "unexpected size %d\n", size);
ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(authorityInfoAccessWithUrl), "unexpected size %d\n",
size);
ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(authorityInfoAccessWithUrlAndIPAddr),
"unexpected size %d\n", size);
emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
&buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_AUTHORITY_INFO_ACCESS aia = { 0, NULL };
authorityInfoAccessWithUrl, sizeof(authorityInfoAccessWithUrl),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_ACCESS_DESCRIPTION accessDescription;
CERT_AUTHORITY_INFO_ACCESS aia;
sizeof(authorityInfoAccessWithUrlAndIPAddr), CRYPT_DECODE_ALLOC_FLAG,
NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
CERT_ACCESS_DESCRIPTION accessDescription[2];
CERT_AUTHORITY_INFO_ACCESS aia;
LocalFree(buf);
buf = NULL;
}
+ ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS,
+ authorityInfoAccessWithUrlAndIPAddr,
+ sizeof(authorityInfoAccessWithUrlAndIPAddr), 0, NULL, NULL, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+ buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
+ if (buf)
+ {
+ ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS,
+ authorityInfoAccessWithUrlAndIPAddr,
+ sizeof(authorityInfoAccessWithUrlAndIPAddr), 0, NULL, buf, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+ HeapFree(GetProcessHeap(), 0, buf);
+ }
}
static const BYTE emptyCTL[] = {
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptyCTL), "unexpected size %d\n", size);
ok(!memcmp(buf, emptyCTL, size), "unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptyCTLWithVersion1), "unexpected size %d\n", size);
ok(!memcmp(buf, emptyCTLWithVersion1, size), "unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(ctlWithUsageIdentifier), "unexpected size %d\n",
size);
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(ctlWithListIdentifier), "unexpected size %d\n", size);
ok(!memcmp(buf, ctlWithListIdentifier, size), "unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(ctlWithSequenceNumber), "unexpected size %d\n",
size);
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(ctlWithThisUpdate), "unexpected size %d\n", size);
ok(!memcmp(buf, ctlWithThisUpdate, size), "unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(ctlWithThisAndNextUpdate), "unexpected size %d\n",
size);
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(ctlWithAlgId), "unexpected size %d\n", size);
ok(!memcmp(buf, ctlWithAlgId, size), "unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(ctlWithBogusEntry), "unexpected size %d\n", size);
ok(!memcmp(buf, ctlWithBogusEntry, size), "unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(ctlWithOneEntry), "unexpected size %d\n", size);
ok(!memcmp(buf, ctlWithOneEntry, size), "unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(ctlWithTwoEntries), "unexpected size %d\n", size);
ok(!memcmp(buf, ctlWithTwoEntries, size), "unexpected value\n");
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTL, sizeof(emptyCTL),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
compareCTLInfo("empty CTL", &info, (CTL_INFO *)buf);
LocalFree(buf);
sizeof(emptyCTLWithVersion1), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf,
&size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
compareCTLInfo("v1 CTL", &info, (CTL_INFO *)buf);
LocalFree(buf);
sizeof(ctlWithUsageIdentifier), CRYPT_DECODE_ALLOC_FLAG, NULL,
&buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
compareCTLInfo("CTL with usage identifier", &info, (CTL_INFO *)buf);
LocalFree(buf);
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithListIdentifier,
sizeof(ctlWithListIdentifier), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
compareCTLInfo("CTL with list identifier", &info, (CTL_INFO *)buf);
LocalFree(buf);
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithSequenceNumber,
sizeof(ctlWithSequenceNumber), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
compareCTLInfo("CTL with sequence number", &info, (CTL_INFO *)buf);
LocalFree(buf);
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithThisUpdate,
sizeof(ctlWithThisUpdate), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
compareCTLInfo("CTL with this update", &info, (CTL_INFO *)buf);
LocalFree(buf);
sizeof(ctlWithThisAndNextUpdate), CRYPT_DECODE_ALLOC_FLAG, NULL,
&buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
compareCTLInfo("CTL with this and next update", &info, (CTL_INFO *)buf);
LocalFree(buf);
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithAlgId,
sizeof(ctlWithAlgId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
compareCTLInfo("CTL with algorithm identifier", &info, (CTL_INFO *)buf);
LocalFree(buf);
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithOneEntry,
sizeof(ctlWithOneEntry), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
compareCTLInfo("CTL with one entry", &info, (CTL_INFO *)buf);
LocalFree(buf);
ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithTwoEntries,
sizeof(ctlWithTwoEntries), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
compareCTLInfo("CTL with two entries", &info, (CTL_INFO *)buf);
LocalFree(buf);
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptyPKCSContentInfo), "Unexpected size %d\n", size);
ok(!memcmp(buf, emptyPKCSContentInfo, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed; %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(bogusPKCSContentInfo), "Unexpected size %d\n", size);
ok(!memcmp(buf, bogusPKCSContentInfo, size), "Unexpected value\n");
info.Content.cbData = ints[0].encoded[1] + 2;
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(intPKCSContentInfo), "Unexpected size %d\n", size);
ok(!memcmp(buf, intPKCSContentInfo, size), "Unexpected value\n");
emptyPKCSContentInfo, sizeof(emptyPKCSContentInfo),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CRYPT_CONTENT_INFO *)buf;
intPKCSContentInfo, sizeof(intPKCSContentInfo),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CRYPT_CONTENT_INFO *)buf;
indefiniteSignedPKCSContent, sizeof(indefiniteSignedPKCSContent),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CRYPT_CONTENT_INFO *)buf;
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptyPKCSAttr), "Unexpected size %d\n", size);
ok(!memcmp(buf, emptyPKCSAttr, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(bogusPKCSAttr), "Unexpected size %d\n", size);
ok(!memcmp(buf, bogusPKCSAttr, size), "Unexpected value\n");
blob.cbData = ints[0].encoded[1] + 2;
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(intPKCSAttr), "Unexpected size %d\n", size);
ok(!memcmp(buf, intPKCSAttr, size), "Unexpected value\n");
emptyPKCSAttr, sizeof(emptyPKCSAttr),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
attr = (CRYPT_ATTRIBUTE *)buf;
intPKCSAttr, sizeof(intPKCSAttr),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
attr = (CRYPT_ATTRIBUTE *)buf;
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptyPKCSAttributes), "Unexpected size %d\n", size);
ok(!memcmp(buf, emptyPKCSAttributes, size), "Unexpected value\n");
attr[0].pszObjId = oid1;
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
ok(size == sizeof(singlePKCSAttributes), "Unexpected size %d\n", size);
ok(!memcmp(buf, singlePKCSAttributes, size), "Unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(doublePKCSAttributes), "Unexpected size %d\n", size);
ok(!memcmp(buf, doublePKCSAttributes, size), "Unexpected value\n");
emptyPKCSAttributes, sizeof(emptyPKCSAttributes),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
attributes = (CRYPT_ATTRIBUTES *)buf;
ok(attributes->cAttr == 0, "Expected no attributes, got %d\n",
singlePKCSAttributes, sizeof(singlePKCSAttributes),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
attributes = (CRYPT_ATTRIBUTES *)buf;
ok(attributes->cAttr == 1, "Expected 1 attribute, got %d\n",
doublePKCSAttributes, sizeof(doublePKCSAttributes),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
attributes = (CRYPT_ATTRIBUTES *)buf;
ok(attributes->cAttr == 2, "Expected 2 attributes, got %d\n",
attributes->rgAttr[1].rgValue[0].cbData), "Unexpected value\n");
LocalFree(buf);
}
+ ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES,
+ doublePKCSAttributes, sizeof(doublePKCSAttributes), 0, NULL, NULL, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+ buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
+ if (buf)
+ {
+ ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES,
+ doublePKCSAttributes, sizeof(doublePKCSAttributes), 0, NULL, buf, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+ HeapFree(GetProcessHeap(), 0, buf);
+ }
}
static const BYTE singleCapability[] = {
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
&capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(emptySequence), "unexpected size %d\n", size);
ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
&capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(singleCapability), "unexpected size %d\n", size);
ok(!memcmp(buf, singleCapability, size), "unexpected value\n");
ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
&capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(twoCapabilities), "unexpected size %d\n", size);
ok(!memcmp(buf, twoCapabilities, size), "unexpected value\n");
compareSMimeCapabilities("two capabilities", &capabilities, ptr);
LocalFree(ptr);
}
+ SetLastError(0xdeadbeef);
+ ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
+ twoCapabilities, sizeof(twoCapabilities), 0, NULL, NULL, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
+ if (ptr)
+ {
+ SetLastError(0xdeadbeef);
+ ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
+ twoCapabilities, sizeof(twoCapabilities), 0, NULL, ptr, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ HeapFree(GetProcessHeap(), 0, ptr);
+ }
}
static BYTE encodedCommonNameNoNull[] = { 0x30,0x14,0x31,0x12,0x30,0x10,
{
ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */),
"CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(minimalPKCSSigner), "Unexpected size %d\n", size);
if (size == sizeof(minimalPKCSSigner))
{
ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */),
"CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %d\n",
size);
{
ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */),
"CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %d\n",
size);
else
{
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(PKCSSignerWithHashAndEncryptionAlgo),
"Unexpected size %d\n", size);
else
{
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %d\n",
size);
else
{
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(PKCSSignerWithAuthAttr), "Unexpected size %d\n",
size);
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret || broken(GetLastError() == OSS_DATA_ERROR),
"CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CMSG_SIGNER_INFO *)buf;
ok(info->dwVersion == 0, "Expected version 0, got %d\n",
ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO,
PKCSSignerWithHashAlgo, sizeof(PKCSSignerWithHashAlgo),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
info = (CMSG_SIGNER_INFO *)buf;
ok(info->dwVersion == 0, "Expected version 0, got %d\n",
PKCSSignerWithHashAndEncryptionAlgo,
sizeof(PKCSSignerWithHashAndEncryptionAlgo), CRYPT_DECODE_ALLOC_FLAG,
NULL, &buf, &size);
- if (buf)
+ if (ret)
{
info = (CMSG_SIGNER_INFO *)buf;
ok(info->dwVersion == 0, "Expected version 0, got %d\n",
ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO,
PKCSSignerWithHash, sizeof(PKCSSignerWithHash),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
info = (CMSG_SIGNER_INFO *)buf;
ok(info->dwVersion == 0, "Expected version 0, got %d\n",
ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO,
PKCSSignerWithAuthAttr, sizeof(PKCSSignerWithAuthAttr),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
- if (buf)
+ if (ret)
{
info = (CMSG_SIGNER_INFO *)buf;
ok(info->AuthAttrs.cAttr == 1, "Expected 1 attribute, got %d\n",
ok(GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
/* To be encoded, a signer must have a valid cert ID, where a valid ID may
- * be a key id or a issuer serial number with at least the issuer set, and
+ * be a key id or an issuer serial number with at least the issuer set, and
* the encoding must include PKCS_7_ASN_ENCODING.
* (That isn't enough to be decoded, see decoding tests.)
*/
else
{
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(minimalPKCSSigner), "Unexpected size %d\n", size);
ok(!memcmp(buf, minimalPKCSSigner, size), "Unexpected value\n");
else
{
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %d\n",
size);
else
{
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(CMSSignerWithKeyId), "Unexpected size %d\n",
size);
else
{
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %d\n",
size);
else
{
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(PKCSSignerWithHashAndEncryptionAlgo),
"Unexpected size %d\n", size);
else
{
ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %d\n",
size);
LPBYTE buf = NULL;
DWORD size = 0;
CMSG_CMS_SIGNER_INFO *info;
- static char oid1[] = "1.2.3", oid2[] = "1.5.6";
+ static const char oid1[] = "1.2.3", oid2[] = "1.5.6";
/* A CMS signer can't be decoded without a serial number. */
SetLastError(0xdeadbeef);
PKCSSignerWithSerial, sizeof(PKCSSignerWithSerial),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CMSG_CMS_SIGNER_INFO *)buf;
ok(info->dwVersion == 0, "Expected version 0, got %d\n",
PKCSSignerWithHashAlgo, sizeof(PKCSSignerWithHashAlgo),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CMSG_CMS_SIGNER_INFO *)buf;
ok(info->dwVersion == 0, "Expected version 0, got %d\n",
sizeof(PKCSSignerWithHashAndEncryptionAlgo), CRYPT_DECODE_ALLOC_FLAG,
NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CMSG_CMS_SIGNER_INFO *)buf;
ok(info->dwVersion == 0, "Expected version 0, got %d\n",
PKCSSignerWithHash, sizeof(PKCSSignerWithHash),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CMSG_CMS_SIGNER_INFO *)buf;
ok(info->dwVersion == 0, "Expected version 0, got %d\n",
CMSSignerWithKeyId, sizeof(CMSSignerWithKeyId),
CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
- if (buf)
+ if (ret)
{
info = (CMSG_CMS_SIGNER_INFO *)buf;
ok(info->dwVersion == 0, "Expected version 0, got %d\n",
static CERT_GENERAL_SUBTREE IPAddressWithMinMaxSubtree = {
{ CERT_ALT_NAME_IP_ADDRESS, { 0 } }, 5, TRUE, 3 };
-struct EncodedNameConstraints encodedNameConstraints[] = {
+static const struct EncodedNameConstraints encodedNameConstraints[] = {
{ { sizeof(emptySequence), (LPBYTE)emptySequence }, { 0 } },
{ { sizeof(emptyDNSPermittedConstraints), emptyDNSPermittedConstraints },
{ 1, &emptyDNSSubtree, 0, NULL } },
"unexpected qualifier value\n");
LocalFree(info);
}
+ ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES,
+ twoPolicies, sizeof(twoPolicies), 0, NULL, NULL, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
+ if (info)
+ {
+ ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES,
+ twoPolicies, sizeof(twoPolicies), 0, NULL, info, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ HeapFree(GetProcessHeap(), 0, info);
+ }
}
static const BYTE policyMappingWithOneMapping[] = {
info->rgPolicyMapping[1].pszSubjectDomainPolicy);
LocalFree(info);
}
+ ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i],
+ policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), 0,
+ NULL, NULL, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
+ if (info)
+ {
+ ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i],
+ policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), 0,
+ NULL, info, &size);
+ ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+ HeapFree(GetProcessHeap(), 0, info);
+ }
}
}
PCERT_PUBLIC_KEY_INFO info = NULL;
/* Just in case a previous run failed, delete this thing */
- CryptAcquireContextA(&csp, cspName, MS_DEF_PROV, PROV_RSA_FULL,
+ CryptAcquireContextA(&csp, cspName, MS_DEF_PROV_A, PROV_RSA_FULL,
CRYPT_DELETEKEYSET);
- ret = CryptAcquireContextA(&csp, cspName, MS_DEF_PROV, PROV_RSA_FULL,
+ ret = CryptAcquireContextA(&csp, cspName, MS_DEF_PROV_A, PROV_RSA_FULL,
CRYPT_NEWKEYSET);
ok(ret,"CryptAcquireContextA failed\n");
HeapFree(GetProcessHeap(), 0, info);
CryptReleaseContext(csp, 0);
- ret = CryptAcquireContextA(&csp, cspName, MS_DEF_PROV, PROV_RSA_FULL,
+ ret = CryptAcquireContextA(&csp, cspName, MS_DEF_PROV_A, PROV_RSA_FULL,
CRYPT_DELETEKEYSET);
ok(ret,"CryptAcquireContextA failed\n");
}