ReactOS 0.4.16-dev-1946-g52006dd
cert.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <ntstatus.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <winerror.h>
#include <wincrypt.h>
#include <bcrypt.h>
#include "wine/test.h"
Include dependency graph for cert.c:

Go to the source code of this file.

Classes

struct  IntBlobTest
 

Macros

#define WIN32_NO_STATUS
 

Functions

static void testAddCert (void)
 
static void checkHash (const BYTE *data, DWORD dataLen, ALG_ID algID, PCCERT_CONTEXT context, DWORD propID)
 
static void testCertProperties (void)
 
static void testCreateCert (void)
 
static void testDupCert (void)
 
static void testLinkCert (void)
 
static void testFindCert (void)
 
static void testGetSubjectCert (void)
 
static void testGetIssuerCert (void)
 
static void testCryptHashCert (void)
 
static void testCryptHashCert2 (void)
 
static void verifySig (HCRYPTPROV csp, const BYTE *toSign, size_t toSignLen, const BYTE *sig, unsigned int sigLen)
 
static void testSignCert (HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, LPCSTR sigOID, BYTE *sig, DWORD *sigLen)
 
static void testVerifyCertSig (HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, LPCSTR sigOID, const BYTE *sig, DWORD sigLen)
 
static void testVerifyCertSigEx (HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, LPCSTR sigOID, const BYTE *sig, DWORD sigLen)
 
static void testCertSigs (void)
 
static void testSignAndEncodeCert (void)
 
static void testCreateSelfSignCert (void)
 
static void testIntendedKeyUsage (void)
 
static void testKeyUsage (void)
 
static void testGetValidUsages (void)
 
static void testCompareCertName (void)
 
static void testIsRDNAttrsInCertificateName (void)
 
static void testCompareIntegerBlob (void)
 
static void testComparePublicKeyInfo (void)
 
static void testHashPublicKeyInfo (void)
 
static void testHashToBeSigned (void)
 
static void testCompareCert (void)
 
static void testVerifySubjectCert (void)
 
static void testVerifyRevocation (void)
 
static void testAcquireCertPrivateKey (void)
 
static void testGetPublicKeyLength (void)
 
static void testKeyProvInfo (void)
 
static void test_VerifySignature (void)
 
 START_TEST (cert)
 

Variables

static BYTE subjectName []
 
static BYTE serialNum [] = { 1 }
 
static const BYTE bigCert []
 
static BYTE bigCertHash []
 
static const BYTE bigCertWithDifferentSubject []
 
static const BYTE bigCertWithDifferentIssuer []
 
static BYTE subjectName2 []
 
static const BYTE bigCert2 []
 
static const BYTE bigCert2WithDifferentSerial []
 
static BYTE bigCert2Hash []
 
static const BYTE certWithUsage []
 
static const CHAR cspNameA [] = "WineCryptTemp"
 
static const BYTE v1CertWithPubKey []
 
static const BYTE v1CertWithSubjectKeyId []
 
static const BYTE subjectKeyId []
 
static const BYTE selfSignedCert []
 
static const BYTE selfSignedSignatureHash []
 
static BYTE subjectName3 []
 
static const BYTE iTunesCert0 []
 
static const BYTE iTunesCert1 []
 
static const BYTE iTunesCert2 []
 
static const BYTE iTunesCert3 []
 
static BYTE iTunesIssuer []
 
static BYTE iTunesSerialNum []
 
static const BYTE expiredCert []
 
static const BYTE childOfExpired []
 
static const BYTE chain10_0 []
 
static const BYTE chain10_1 []
 
static const BYTE chain7_1 []
 
static BYTE emptyCert [] = { 0x30, 0x00 }
 
static const BYTE self_signed_ecc_prime256v1 []
 
static const BYTE md5SignedEmptyCert []
 
static const BYTE md5SignedEmptyCertNoNull []
 
static const LPCSTR keyUsages []
 
static const BYTE cert2WithUsage []
 
static BYTE cn []
 
static BYTE cnWithLeadingSpace []
 
static BYTE cnWithTrailingSpace []
 
static BYTE cnWithIntermediateSpace []
 
static BYTE cnThenO []
 
static BYTE oThenCN []
 
static BYTE int1 [] = { 0x88, 0xff, 0xff, 0xff }
 
static BYTE int2 [] = { 0x88, 0xff }
 
static BYTE int3 [] = { 0x23, 0xff }
 
static BYTE int4 [] = { 0x7f, 0x00 }
 
static BYTE int5 [] = { 0x7f }
 
static BYTE int6 [] = { 0x80, 0x00, 0x00, 0x00 }
 
static BYTE int7 [] = { 0x80, 0x00 }
 
static struct IntBlobTest intBlobs []
 
static const BYTE md5SignedEmptyCertHash []
 
static const BYTE rootWithKeySignAndCRLSign []
 
static const BYTE eeCert []
 
static const BYTE rootSignedCRL []
 
static const BYTE ocsp_cert []
 
static const BYTE ocsp_cert_issuer []
 
static BYTE privKey []
 
static const BYTE exportedPublicKeyBlob []
 
static const BYTE asnEncodedPublicKey []
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 25 of file cert.c.

Function Documentation

◆ checkHash()

static void checkHash ( const BYTE data,
DWORD  dataLen,
ALG_ID  algID,
PCCERT_CONTEXT  context,
DWORD  propID 
)
static

Definition at line 284 of file cert.c.

286{
287 BYTE hash[20] = { 0 }, hashProperty[20];
288 BOOL ret;
289 DWORD size;
290 DWORD dwSizeWithNull;
291
292 memset(hash, 0, sizeof(hash));
293 memset(hashProperty, 0, sizeof(hashProperty));
294 size = sizeof(hash);
295 ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size);
296 ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
298 &dwSizeWithNull);
299 ok(ret, "algID %08x, propID %ld: CertGetCertificateContextProperty failed: %08lx\n",
300 algID, propID, GetLastError());
301 ret = CertGetCertificateContextProperty(context, propID, hashProperty,
302 &size);
303 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
304 GetLastError());
305 ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %ld\n",
306 propID);
307 ok(size == dwSizeWithNull, "Unexpected length of hash for property: received %ld instead of %ld\n",
308 dwSizeWithNull,size);
309}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: cert.c:551
BOOL WINAPI CryptHashCertificate(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash)
Definition: cert.c:2187
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
#define memset(x, y, z)
Definition: compat.h:39
Definition: http.c:7252
Definition: _hash_fun.h:40
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
unsigned char BYTE
Definition: xxhash.c:193

Referenced by testCertProperties().

◆ START_TEST()

START_TEST ( cert  )

Definition at line 4516 of file cert.c.

4517{
4518 testAddCert();
4521 testDupCert();
4522 testFindCert();
4525 testLinkCert();
4527
4530 testCertSigs();
4534 testKeyUsage();
4548}
static void testComparePublicKeyInfo(void)
Definition: cert.c:3238
static void testKeyProvInfo(void)
Definition: cert.c:4331
static void testCompareCertName(void)
Definition: cert.c:3010
static void testCryptHashCert(void)
Definition: cert.c:1703
static void testCreateCert(void)
Definition: cert.c:607
static void testVerifyRevocation(void)
Definition: cert.c:3888
static void testGetPublicKeyLength(void)
Definition: cert.c:4247
static void testSignAndEncodeCert(void)
Definition: cert.c:2132
static void testLinkCert(void)
Definition: cert.c:740
static void testCertProperties(void)
Definition: cert.c:363
static void testDupCert(void)
Definition: cert.c:649
static void testHashPublicKeyInfo(void)
Definition: cert.c:3371
static void testAcquireCertPrivateKey(void)
Definition: cert.c:4059
static void testHashToBeSigned(void)
Definition: cert.c:3413
static void testIntendedKeyUsage(void)
Definition: cert.c:2515
static void testGetIssuerCert(void)
Definition: cert.c:1513
static void testCompareIntegerBlob(void)
Definition: cert.c:3224
static void testCryptHashCert2(void)
Definition: cert.c:1738
static void testCompareCert(void)
Definition: cert.c:3459
static void testKeyUsage(void)
Definition: cert.c:2567
static void testIsRDNAttrsInCertificateName(void)
Definition: cert.c:3080
static void test_VerifySignature(void)
Definition: cert.c:4426
static void testCreateSelfSignCert(void)
Definition: cert.c:2210
static void testCertSigs(void)
Definition: cert.c:2084
static void testAddCert(void)
Definition: cert.c:115
static void testGetSubjectCert(void)
Definition: cert.c:1318
static void testGetValidUsages(void)
Definition: cert.c:2859
static void testFindCert(void)
Definition: cert.c:1095
static void testVerifySubjectCert(void)
Definition: cert.c:3492

◆ test_VerifySignature()

static void test_VerifySignature ( void  )
static

Definition at line 4426 of file cert.c.

4427{
4430 DWORD size;
4431 BOOL ret;
4432 HCRYPTPROV prov;
4433 HCRYPTKEY key;
4435#ifndef __REACTOS__
4436 BYTE hash_value[20], *sig_value;
4437 DWORD hash_len, i;
4438 BCRYPT_KEY_HANDLE bkey;
4439 BCRYPT_HASH_HANDLE bhash;
4443#endif
4444
4446 ok(cert != NULL, "CertCreateCertificateContext error %#lx\n", GetLastError());
4447
4448 /* 1. Verify certificate signature with Crypto API */
4449 ret = CryptVerifyCertificateSignature(0, cert->dwCertEncodingType,
4450 cert->pbCertEncoded, cert->cbCertEncoded, &cert->pCertInfo->SubjectPublicKeyInfo);
4451 ok(ret, "CryptVerifyCertificateSignature error %#lx\n", GetLastError());
4452
4453 /* 2. Verify certificate signature with Crypto API manually */
4455 ok(ret, "CryptAcquireContext error %#lx\n", GetLastError());
4456
4457 ret = CryptImportPublicKeyInfoEx(prov, cert->dwCertEncodingType, &cert->pCertInfo->SubjectPublicKeyInfo, 0, 0, NULL, &key);
4458 ok(ret, "CryptImportPublicKeyInfoEx error %#lx\n", GetLastError());
4459
4460 ret = CryptDecodeObjectEx(cert->dwCertEncodingType, X509_CERT,
4461 cert->pbCertEncoded, cert->cbCertEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size);
4462 ok(ret, "CryptDecodeObjectEx error %#lx\n", GetLastError());
4463
4464 ret = CryptCreateHash(prov, CALG_SHA1, 0, 0, &hash);
4465 ok(ret, "CryptCreateHash error %#lx\n", GetLastError());
4466
4467 ret = CryptHashData(hash, info->ToBeSigned.pbData, info->ToBeSigned.cbData, 0);
4468 ok(ret, "CryptHashData error %#lx\n", GetLastError());
4469
4470 ret = CryptVerifySignatureW(hash, info->Signature.pbData, info->Signature.cbData, key, NULL, 0);
4471 ok(ret, "CryptVerifySignature error %#lx\n", GetLastError());
4472
4475 CryptReleaseContext(prov, 0);
4476
4477#ifndef __REACTOS__ // FIXME: ReactOS has no implementation for CryptImportPublicKeyInfoEx2
4478 /* 3. Verify certificate signature with CNG */
4479 ret = CryptImportPublicKeyInfoEx2(cert->dwCertEncodingType, &cert->pCertInfo->SubjectPublicKeyInfo, 0, NULL, &bkey);
4480 ok(ret, "CryptImportPublicKeyInfoEx error %#lx\n", GetLastError());
4481
4483 ok(!status, "got %#lx\n", status);
4484
4485 status = BCryptCreateHash(alg, &bhash, NULL, 0, NULL, 0, 0);
4486 ok(!status, "got %#lx\n", status);
4487
4488 status = BCryptHashData(bhash, info->ToBeSigned.pbData, info->ToBeSigned.cbData, 0);
4489 ok(!status, "got %#lx\n", status);
4490
4491 status = BCryptFinishHash(bhash, hash_value, sizeof(hash_value), 0);
4492 ok(!status, "got %#lx\n", status);
4493 ok(!memcmp(hash_value, selfSignedSignatureHash, sizeof(hash_value)), "got wrong hash value\n");
4494
4495 status = BCryptGetProperty(bhash, BCRYPT_HASH_LENGTH, (BYTE *)&hash_len, sizeof(hash_len), &size, 0);
4496 ok(!status, "got %#lx\n", status);
4497 ok(hash_len == sizeof(hash_value), "got %lu\n", hash_len);
4498
4499 sig_value = malloc(info->Signature.cbData);
4500 for (i = 0; i < info->Signature.cbData; i++)
4501 sig_value[i] = info->Signature.pbData[info->Signature.cbData - i - 1];
4502
4504 status = BCryptVerifySignature(bkey, &pad, hash_value, sizeof(hash_value), sig_value, info->Signature.cbData, BCRYPT_PAD_PKCS1);
4505 ok(!status, "got %#lx\n", status);
4506
4507 free(sig_value);
4508 BCryptDestroyHash(bhash);
4510 BCryptDestroyKey(bkey);
4511 LocalFree(info);
4513#endif
4514}
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS WINAPI BCryptDestroyKey(BCRYPT_KEY_HANDLE)
NTSTATUS WINAPI BCryptVerifySignature(BCRYPT_KEY_HANDLE, void *, UCHAR *, ULONG, UCHAR *, ULONG, ULONG)
#define BCRYPT_PAD_PKCS1
Definition: bcrypt.h:153
#define BCRYPT_HASH_LENGTH
Definition: bcrypt.h:50
#define MS_PRIMITIVE_PROVIDER
Definition: bcrypt.h:69
#define BCRYPT_SHA1_ALGORITHM
Definition: bcrypt.h:74
NTSTATUS WINAPI BCryptHashData(BCRYPT_HASH_HANDLE handle, UCHAR *input, ULONG size, ULONG flags)
Definition: bcrypt_main.c:1058
NTSTATUS WINAPI BCryptGetProperty(BCRYPT_HANDLE handle, LPCWSTR prop, UCHAR *buffer, ULONG count, ULONG *res, ULONG flags)
Definition: bcrypt_main.c:978
NTSTATUS WINAPI BCryptDestroyHash(BCRYPT_HASH_HANDLE handle)
Definition: bcrypt_main.c:1047
NTSTATUS WINAPI BCryptOpenAlgorithmProvider(BCRYPT_ALG_HANDLE *handle, LPCWSTR id, LPCWSTR implementation, DWORD flags)
Definition: bcrypt_main.c:336
NTSTATUS WINAPI BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE handle, DWORD flags)
Definition: bcrypt_main.c:380
NTSTATUS WINAPI BCryptCreateHash(BCRYPT_ALG_HANDLE algorithm, BCRYPT_HASH_HANDLE *handle, UCHAR *object, ULONG objectlen, UCHAR *secret, ULONG secretlen, ULONG flags)
Definition: bcrypt_main.c:1005
NTSTATUS WINAPI BCryptFinishHash(BCRYPT_HASH_HANDLE handle, UCHAR *output, ULONG size, ULONG flags)
Definition: bcrypt_main.c:1077
BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6286
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
Definition: crypt.c:740
BOOL WINAPI CryptDestroyKey(HCRYPTKEY hKey)
Definition: crypt.c:930
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
Definition: crypt.c:890
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:648
BOOL WINAPI CryptHashData(HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
Definition: crypt.c:1771
BOOL WINAPI CryptAcquireContextA(HCRYPTPROV *phProv, LPCSTR pszContainer, LPCSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:569
BOOL WINAPI CryptVerifySignatureW(HCRYPTHASH hHash, const BYTE *pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags)
Definition: crypt.c:2238
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded)
Definition: cert.c:316
BOOL WINAPI CryptVerifyCertificateSignature(HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded, PCERT_PUBLIC_KEY_INFO pPublicKey)
Definition: cert.c:2427
BOOL WINAPI CryptImportPublicKeyInfoEx(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey)
Definition: encode.c:5044
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
static const BYTE selfSignedSignatureHash[]
Definition: cert.c:360
static const BYTE selfSignedCert[]
Definition: cert.c:336
static BYTE cert[]
Definition: msg.c:1374
Definition: copy.c:22
Definition: ps.c:97
#define PROV_RSA_FULL
Definition: wincrypt.h:2243
#define CRYPT_VERIFYCONTEXT
Definition: wincrypt.h:2273
#define CALG_SHA1
Definition: wincrypt.h:2060
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:55
#define X509_CERT
Definition: wincrypt.h:3517
WINCRYPT32API BOOL WINAPI CryptImportPublicKeyInfoEx2(DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, DWORD dwFlags, void *pvAuxInfo, BCRYPT_KEY_HANDLE *phKey)
ULONG_PTR HCRYPTHASH
Definition: wincrypt.h:59
#define X509_ASN_ENCODING
Definition: wincrypt.h:2501
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3612
ULONG_PTR HCRYPTKEY
Definition: wincrypt.h:58

Referenced by START_TEST().

◆ testAcquireCertPrivateKey()

static void testAcquireCertPrivateKey ( void  )
static

Definition at line 4059 of file cert.c.

4060{
4061 BOOL ret;
4063 HCRYPTPROV csp;
4064 DWORD size, keySpec;
4065 BOOL callerFree;
4066 CRYPT_KEY_PROV_INFO keyProvInfo;
4067 HCRYPTKEY key;
4068 WCHAR ms_def_prov_w[MAX_PATH];
4069
4070 lstrcpyW(ms_def_prov_w, MS_DEF_PROV_W);
4071
4072 keyProvInfo.pwszContainerName = (WCHAR *)L"WineCryptTemp";
4073 keyProvInfo.pwszProvName = ms_def_prov_w;
4074 keyProvInfo.dwProvType = PROV_RSA_FULL;
4075 keyProvInfo.dwFlags = 0;
4076 keyProvInfo.cProvParam = 0;
4077 keyProvInfo.rgProvParam = NULL;
4078 keyProvInfo.dwKeySpec = AT_SIGNATURE;
4079
4082
4084 sizeof(selfSignedCert));
4085
4086 /* Crash
4087 ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, NULL);
4088 ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL,
4089 &callerFree);
4090 ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, &keySpec,
4091 NULL);
4092 ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, NULL, NULL);
4093 ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, &keySpec,
4094 &callerFree);
4095 ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, NULL, NULL, NULL);
4096 */
4097
4098 /* Missing private key */
4101 "Expected CRYPT_E_NO_KEY_PROPERTY, got %08lx\n", GetLastError());
4102 ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec,
4103 &callerFree);
4105 "Expected CRYPT_E_NO_KEY_PROPERTY, got %08lx\n", GetLastError());
4107 &keyProvInfo);
4108 ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec,
4109 &callerFree);
4111 GetLastError() == NTE_BAD_KEYSET /* win8 */ ||
4112 GetLastError() == NTE_BAD_PROV_TYPE /* win10 */),
4113 "Expected CRYPT_E_NO_KEY_PROPERTY, got %08lx\n", GetLastError());
4114
4117 ret = CryptImportKey(csp, privKey, sizeof(privKey), 0, 0, &key);
4118 ok(ret, "CryptImportKey failed: %08lx\n", GetLastError());
4119 if (ret)
4120 {
4121 HCRYPTPROV certCSP;
4122 DWORD size;
4123 CERT_KEY_CONTEXT keyContext;
4124
4125 /* Don't cache provider */
4126 SetLastError(0xdeadbeef);
4128 &keySpec, &callerFree);
4129 ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError());
4130 ok(GetLastError() == ERROR_SUCCESS, "got %08lx\n", GetLastError());
4131 ok(callerFree, "Expected callerFree to be TRUE\n");
4132 CryptReleaseContext(certCSP, 0);
4133
4134 SetLastError(0xdeadbeef);
4136 NULL, NULL);
4137 ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError());
4138 ok(GetLastError() == ERROR_SUCCESS, "got %08lx\n", GetLastError());
4139 CryptReleaseContext(certCSP, 0);
4140
4141 /* Use the key prov info's caching (there shouldn't be any) */
4142 SetLastError(0xdeadbeef);
4144 CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec,
4145 &callerFree);
4146 ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError());
4147 ok(GetLastError() == ERROR_SUCCESS, "got %08lx\n", GetLastError());
4148 ok(callerFree, "Expected callerFree to be TRUE\n");
4149 CryptReleaseContext(certCSP, 0);
4150
4151 /* Cache it (and check that it's cached) */
4152 SetLastError(0xdeadbeef);
4154 CRYPT_ACQUIRE_CACHE_FLAG, NULL, &certCSP, &keySpec, &callerFree);
4155 ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError());
4156 ok(GetLastError() == ERROR_SUCCESS, "got %08lx\n", GetLastError());
4157 ok(!callerFree, "Expected callerFree to be FALSE\n");
4158 size = sizeof(keyContext);
4160 &keyContext, &size);
4161 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError());
4162
4163 /* Remove the cached provider */
4164 CryptReleaseContext(keyContext.hCryptProv, 0);
4166 NULL);
4167 /* Allow caching via the key prov info */
4170 &keyProvInfo);
4171 /* Now use the key prov info's caching */
4172 SetLastError(0xdeadbeef);
4174 CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec,
4175 &callerFree);
4176 ok(ret, "CryptAcquireCertificatePrivateKey failed: %08lx\n", GetLastError());
4177 ok(GetLastError() == ERROR_SUCCESS, "got %08lx\n", GetLastError());
4178 ok(!callerFree, "Expected callerFree to be FALSE\n");
4179 size = sizeof(keyContext);
4181 &keyContext, &size);
4182 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError());
4183 CryptReleaseContext(certCSP, 0);
4184
4186 }
4187
4188 /* Some sanity-checking on public key exporting */
4190 &cert->pCertInfo->SubjectPublicKeyInfo, &key);
4191 ok(ret, "CryptImportPublicKeyInfo failed: %08lx\n", GetLastError());
4192 if (ret)
4193 {
4195 ok(ret, "CryptExportKey failed: %08lx\n", GetLastError());
4196 if (ret)
4197 {
4198 LPBYTE buf = malloc(size), encodedKey;
4199
4201 ok(ret, "CryptExportKey failed: %08lx\n", GetLastError());
4202 ok(size == sizeof(exportedPublicKeyBlob), "Unexpected size %ld\n",
4203 size);
4204 ok(!memcmp(buf, exportedPublicKeyBlob, size), "Unexpected value\n");
4206 buf, CRYPT_ENCODE_ALLOC_FLAG, NULL, &encodedKey, &size);
4207 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
4208 if (ret)
4209 {
4210 ok(size == sizeof(asnEncodedPublicKey), "Unexpected size %ld\n",
4211 size);
4212 ok(!memcmp(encodedKey, asnEncodedPublicKey, size),
4213 "Unexpected value\n");
4214 LocalFree(encodedKey);
4215 }
4216 free(buf);
4217 }
4219 }
4221 NULL, 0, NULL, NULL, &size);
4222 ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n", GetLastError());
4223 if (ret)
4224 {
4226
4228 NULL, 0, NULL, info, &size);
4229 ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n", GetLastError());
4230 if (ret)
4231 {
4232 ok(info->PublicKey.cbData == sizeof(asnEncodedPublicKey),
4233 "Unexpected size %ld\n", info->PublicKey.cbData);
4234 ok(!memcmp(info->PublicKey.pbData, asnEncodedPublicKey,
4235 info->PublicKey.cbData), "Unexpected value\n");
4236 }
4237 free(info);
4238 }
4239
4240 CryptReleaseContext(csp, 0);
4243
4245}
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI CryptExportKey(HCRYPTKEY hKey, HCRYPTKEY hExpKey, DWORD dwBlobType, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
Definition: crypt.c:1416
BOOL WINAPI CryptImportKey(HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey)
Definition: crypt.c:1850
BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert, DWORD dwFlags, void *pvReserved, HCRYPTPROV_OR_NCRYPT_KEY_HANDLE *phCryptProv, DWORD *pdwKeySpec, BOOL *pfCallerFreeProv)
Definition: cert.c:881
BOOL WINAPI CertSetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: cert.c:799
BOOL WINAPI CryptExportPublicKeyInfoEx(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, DWORD dwFlags, void *pvAuxInfo, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)
Definition: encode.c:4934
BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, void *pvEncoded, DWORD *pcbEncoded)
Definition: encode.c:4696
BOOL WINAPI CryptImportPublicKeyInfo(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, HCRYPTKEY *phKey)
Definition: encode.c:4970
#define SetLastError(x)
Definition: compat.h:752
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
#define L(x)
Definition: resources.c:13
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static BYTE privKey[]
Definition: cert.c:4018
static const BYTE exportedPublicKeyBlob[]
Definition: cert.c:4044
static const BYTE asnEncodedPublicKey[]
Definition: cert.c:4052
static const CHAR cspNameA[]
Definition: cert.c:311
HCRYPTPROV hCryptProv
Definition: wincrypt.h:229
LPWSTR pwszContainerName
Definition: wincrypt.h:218
PCRYPT_KEY_PROV_PARAM rgProvParam
Definition: wincrypt.h:223
unsigned char * LPBYTE
Definition: typedefs.h:53
#define MS_DEF_PROV_A
Definition: wincrypt.h:2115
#define CRYPT_NEWKEYSET
Definition: wincrypt.h:2274
#define CERT_KEY_CONTEXT_PROP_ID
Definition: wincrypt.h:2837
#define CERT_KEY_PROV_INFO_PROP_ID
Definition: wincrypt.h:2833
#define CERT_SET_KEY_CONTEXT_PROP_ID
Definition: wincrypt.h:3755
#define CRYPT_DELETEKEYSET
Definition: wincrypt.h:2275
#define PUBLICKEYBLOB
Definition: wincrypt.h:2444
static const WCHAR MS_DEF_PROV_W[]
Definition: wincrypt.h:2119
#define RSA_CSP_PUBLICKEYBLOB
Definition: wincrypt.h:3536
#define CRYPT_ENCODE_ALLOC_FLAG
Definition: wincrypt.h:3599
#define AT_SIGNATURE
Definition: wincrypt.h:2240
#define CRYPT_ACQUIRE_USE_PROV_INFO_FLAG
Definition: wincrypt.h:3762
#define CRYPT_ACQUIRE_CACHE_FLAG
Definition: wincrypt.h:3761
#define NTE_BAD_PROV_TYPE
Definition: winerror.h:4267
#define CRYPT_E_NO_KEY_PROPERTY
Definition: winerror.h:4428
#define NTE_BAD_KEYSET
Definition: winerror.h:4269
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ testAddCert()

static void testAddCert ( void  )
static

Definition at line 115 of file cert.c.

116{
117 HCERTSTORE store;
120 PCCERT_CONTEXT copyContext;
121 BOOL ret;
122
125 ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
126 if (!store)
127 return;
128
130 sizeof(bigCert), 0, NULL);
133 "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n",
134 GetLastError());
136 bigCert, sizeof(bigCert), 0, NULL);
139 "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n",
140 GetLastError());
141
142 /* Weird--can add a cert to the NULL store (does this have special
143 * meaning?)
144 */
145 context = NULL;
148 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
150
153 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
154 GetLastError());
157 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
158 GetLastError());
159 /* This has the same name as bigCert, so finding isn't done by name */
162 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
163 GetLastError());
164 ok(context != NULL, "Expected a context\n");
165 if (context)
166 {
168
169 /* Duplicate (AddRef) the context so we can still use it after
170 * deleting it from the store.
171 */
174 /* Set the same hash as bigCert2, and try to readd it */
176 0, &hash);
177 ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
178 GetLastError());
181 /* The failure is a bit odd (CRYPT_E_ASN1_BADTAG), so just check
182 * that it fails.
183 */
184 ok(!ret, "Expected failure\n");
186 }
188 sizeof(bigCert2));
189 ok(context != NULL, "Expected a context\n");
190 if (context)
191 {
192 /* Try to readd bigCert2 to the store */
196 "Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError());
198 }
199
200 /* Adding a cert with the same issuer name and serial number (but
201 * different subject) as an existing cert succeeds.
202 */
203 context = NULL;
207 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
208 GetLastError());
209 if (context)
211
212 /* Adding a cert with the same subject name and serial number (but
213 * different issuer) as an existing cert succeeds.
214 */
215 context = NULL;
219 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
220 GetLastError());
221 if (context)
223
224 /* Adding a cert with the same issuer name and serial number (but
225 * different otherwise) as an existing cert succeeds.
226 */
227 context = NULL;
231 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
232 GetLastError());
233 if (context)
235
238 ok(collection != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
239 if (collection)
240 {
241 /* Add store to the collection, but disable updates */
243
245 sizeof(bigCert2));
246 ok(context != NULL, "Expected a context\n");
247 if (context)
248 {
249 /* Try to readd bigCert2 to the collection */
253 "Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError());
254 /* Replacing an existing certificate context is allowed, even
255 * though updates to the collection aren't..
256 */
259 ok(ret, "CertAddCertificateContextToStore failed: %08lx\n",
260 GetLastError());
261 /* use the existing certificate and ask for a copy of the context*/
262 copyContext = NULL;
264 CERT_STORE_ADD_USE_EXISTING, &copyContext);
265 ok(ret, "CertAddCertificateContextToStore failed: %08lx\n",
266 GetLastError());
267 ok(copyContext != NULL, "Expected on output a non NULL copyContext\n");
268 if (copyContext)
269 CertFreeCertificateContext(copyContext);
270 /* but adding a new certificate isn't allowed. */
274 "Expected E_ACCESSDENIED, got %08lx\n", GetLastError());
276 }
277
279 }
280
281 CertCloseStore(store, 0);
282}
BOOL WINAPI CertAddStoreToCollection(HCERTSTORE hCollectionStore, HCERTSTORE hSiblingStore, DWORD dwUpdateFlags, DWORD dwPriority)
#define E_INVALIDARG
Definition: ddrawi.h:101
BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition, PCCERT_CONTEXT *ppStoreContext)
Definition: cert.c:286
BOOL WINAPI CertAddEncodedCertificateToStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded, DWORD dwAddDisposition, PCCERT_CONTEXT *ppCertContext)
Definition: cert.c:58
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:360
HCERTSTORE WINAPI CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara)
Definition: store.c:815
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
BOOL WINAPI CertDeleteCertificateFromStore(PCCERT_CONTEXT pCertContext)
Definition: store.c:943
#define STATUS_ACCESS_VIOLATION
static const BYTE bigCert[]
Definition: cert.c:39
static const BYTE bigCertWithDifferentSubject[]
Definition: cert.c:52
static const BYTE bigCertWithDifferentIssuer[]
Definition: cert.c:63
static const BYTE bigCert2WithDifferentSerial[]
Definition: cert.c:88
static BYTE bigCert2Hash[]
Definition: cert.c:99
static const BYTE bigCert2[]
Definition: cert.c:78
static const BYTE certWithUsage[]
Definition: cert.c:102
static ICollection collection
Definition: typelib.c:184
#define CERT_STORE_PROV_COLLECTION
Definition: wincrypt.h:2465
#define CERT_STORE_ADD_REPLACE_EXISTING
Definition: wincrypt.h:2653
#define CERT_STORE_CREATE_NEW_FLAG
Definition: wincrypt.h:2633
#define CERT_STORE_PROV_MEMORY
Definition: wincrypt.h:2455
#define CERT_STORE_ADD_USE_EXISTING
Definition: wincrypt.h:2652
#define CERT_STORE_ADD_NEW
Definition: wincrypt.h:2651
#define CERT_HASH_PROP_ID
Definition: wincrypt.h:2835
#define CERT_STORE_ADD_ALWAYS
Definition: wincrypt.h:2654
#define E_ACCESSDENIED
Definition: winerror.h:4116
#define CRYPT_E_EXISTS
Definition: winerror.h:4422

Referenced by START_TEST().

◆ testCertProperties()

static void testCertProperties ( void  )
static

Definition at line 363 of file cert.c.

364{
366 bigCert, sizeof(bigCert));
367 DWORD propID, numProps, access, size;
368 BOOL ret;
369 BYTE hash[20] = { 0 }, hashProperty[20];
371 CERT_KEY_CONTEXT keyContext;
372 unsigned int value;
373
374 ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError());
375
376 /* This crashes
377 propID = CertEnumCertificateContextProperties(NULL, 0);
378 */
379
380 propID = 0;
381 numProps = 0;
382 do {
384 if (propID)
385 numProps++;
386 } while (propID != 0);
387 ok(numProps == 0, "Expected 0 properties, got %ld\n", numProps);
388
389 /* Tests with a NULL cert context. Prop ID 0 fails.. */
392 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
393 /* while this just crashes.
394 ret = CertSetCertificateContextProperty(NULL,
395 CERT_KEY_PROV_HANDLE_PROP_ID, 0, NULL);
396 */
397
400 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
401 /* Can't set the cert property directly, this crashes.
402 ret = CertSetCertificateContextProperty(context,
403 CERT_CERT_PROP_ID, 0, bigCert2);
404 */
405
406 /* These all crash.
407 ret = CertGetCertificateContextProperty(context,
408 CERT_ACCESS_STATE_PROP_ID, 0, NULL);
409 ret = CertGetCertificateContextProperty(context, CERT_HASH_PROP_ID,
410 NULL, NULL);
411 ret = CertGetCertificateContextProperty(context, CERT_HASH_PROP_ID,
412 hashProperty, NULL);
413 */
414 /* A missing prop */
415 size = 0;
419 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
420 /* And, an implicit property */
421 size = sizeof(access);
424 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
425 GetLastError());
427 "Didn't expect a persisted cert\n");
428 /* Trying to set this "read only" property crashes.
429 access |= CERT_ACCESS_STATE_WRITE_PERSIST_FLAG;
430 ret = CertSetCertificateContextProperty(context,
431 CERT_ACCESS_STATE_PROP_ID, 0, &access);
432 */
433
434 /* Can I set the hash to an invalid hash? */
435 blob.pbData = hash;
436 blob.cbData = sizeof(hash);
438 &blob);
439 ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
440 GetLastError());
441 size = sizeof(hashProperty);
443 hashProperty, &size);
444 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
445 GetLastError());
446 ok(!memcmp(hashProperty, hash, sizeof(hash)), "Unexpected hash\n");
447 /* Delete the (bogus) hash, and get the real one */
449 NULL);
450 ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
451 GetLastError());
454
455 /* Now that the hash property is set, we should get one property when
456 * enumerating.
457 */
458 propID = 0;
459 numProps = 0;
460 do {
462 if (propID)
463 numProps++;
464 } while (propID != 0);
465 ok(numProps == 1, "Expected 1 properties, got %ld\n", numProps);
466
467 /* Check a few other implicit properties */
470
471 /* Getting the signature hash fails with this bogus certificate */
472 size = 0;
476 "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
477
478 /* Test key contexts and handles and such */
479 size = 0;
481 NULL, &size);
483 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
484 size = sizeof(CERT_KEY_CONTEXT);
486 NULL, &size);
488 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
490 &keyContext, &size);
492 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
493 /* Key context with an invalid size */
494 keyContext.cbSize = 0;
496 0, &keyContext);
498 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
499 size = sizeof(keyContext);
501 &keyContext, &size);
503 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
504 keyContext.cbSize = sizeof(keyContext);
505 keyContext.hCryptProv = 0;
506 keyContext.dwKeySpec = AT_SIGNATURE;
508 0, &keyContext);
509 ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError());
510 /* Now that that's set, the key prov handle property is also gettable.
511 */
512 size = sizeof(keyContext.hCryptProv);
515 ok(ret, "Expected to get the CERT_KEY_PROV_HANDLE_PROP_ID, got %08lx\n",
516 GetLastError());
517 /* Remove the key prov handle property.. */
520 ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
521 GetLastError());
522 /* and the key context's CSP is set to NULL. */
523 size = sizeof(keyContext);
525 CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size);
526 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
527 GetLastError());
528 ok(keyContext.hCryptProv == 0, "Expected no hCryptProv\n");
529
530 /* According to MSDN the subject key id can be stored as a property,
531 * as a subject key extension, or as the SHA1 hash of the public key,
532 * but this cert has none of them:
533 */
537 "Expected ERROR_INVALID_DATA, got %08lx\n", GetLastError());
539 /* This cert does have a public key, but its subject key identifier still
540 * isn't available: */
546 "Expected ERROR_INVALID_DATA, got %08lx\n", GetLastError());
548 /* This cert with a subject key extension can have its key identifier
549 * property retrieved:
550 */
555 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError());
556 if (ret)
557 {
559
560 if (buf)
561 {
564 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
565 GetLastError());
566 ok(!memcmp(buf, subjectKeyId, size), "Unexpected subject key id\n");
567 free(buf);
568 }
569 }
570
572 ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "got ret %d, error %#lx.\n", ret, GetLastError());
573
574 blob.cbData = sizeof(value);
575 blob.pbData = (BYTE *)&value;
576 value = 1;
578 ok(ret, "got error %#lx.\n", GetLastError());
579 value = 0xdeadbeef;
580 size = 0xdeadbeef;
582 ok(ret, "got error %#lx.\n", GetLastError());
583 ok(size == sizeof(value), "got size %lu.\n", size);
585 ok(ret, "got error %#lx.\n", GetLastError());
586 ok(size == sizeof(value), "got size %lu.\n", size);
587 ok(value == 1, "got value %u.\n", value);
588
590
593 /* Getting the signature hash of a valid (self-signed) cert succeeds */
594 size = 0;
597 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError());
598 ok(size == sizeof(selfSignedSignatureHash), "unexpected size %ld\n", size);
600 CERT_SIGNATURE_HASH_PROP_ID, hashProperty, &size);
601 if (ret)
602 ok(!memcmp(hashProperty, selfSignedSignatureHash, size),
603 "unexpected value\n");
605}
DWORD WINAPI CertEnumCertificateContextProperties(PCCERT_CONTEXT pCertContext, DWORD dwPropId)
Definition: cert.c:380
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID, PCCERT_CONTEXT context, DWORD propID)
Definition: cert.c:284
static const BYTE subjectKeyId[]
Definition: cert.c:334
static const BYTE v1CertWithPubKey[]
Definition: cert.c:312
static const BYTE v1CertWithSubjectKeyId[]
Definition: cert.c:324
Definition: image.c:134
Definition: pdh_main.c:96
#define CERT_MD5_HASH_PROP_ID
Definition: wincrypt.h:2836
#define CERT_KEY_IDENTIFIER_PROP_ID
Definition: wincrypt.h:2853
#define CALG_MD5
Definition: wincrypt.h:2058
#define CERT_ACCESS_STATE_PROP_ID
Definition: wincrypt.h:2847
struct _CERT_KEY_CONTEXT CERT_KEY_CONTEXT
#define CERT_ACCESS_STATE_WRITE_PERSIST_FLAG
Definition: wincrypt.h:2913
#define CERT_SIGNATURE_HASH_PROP_ID
Definition: wincrypt.h:2848
#define CERT_LAST_USER_PROP_ID
Definition: wincrypt.h:2896
#define CERT_KEY_PROV_HANDLE_PROP_ID
Definition: wincrypt.h:2832
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:4421
#define CRYPT_E_ASN1_BADTAG
Definition: winerror.h:4510
#define ERROR_INVALID_DATA
Definition: winerror.h:238

Referenced by START_TEST().

◆ testCertSigs()

static void testCertSigs ( void  )
static

Definition at line 2084 of file cert.c.

2085{
2086 HCRYPTPROV csp;
2087 CRYPT_DATA_BLOB toBeSigned = { sizeof(emptyCert), emptyCert };
2088 BOOL ret;
2089 BYTE sig[64];
2090 DWORD sigSize = sizeof(sig);
2092
2093 /* Just in case a previous run failed, delete this thing */
2098 ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
2099
2100 testSignCert(csp, &toBeSigned, szOID_RSA_SHA1RSA, sig, &sigSize);
2101 testVerifyCertSig(csp, &toBeSigned, szOID_RSA_SHA1RSA, sig, sigSize);
2102 testVerifyCertSigEx(csp, &toBeSigned, szOID_RSA_SHA1RSA, sig, sigSize);
2103
2104 CryptReleaseContext(csp, 0);
2107 ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
2108
2110 ok(!!cert, "failed, error %#lx.\n", GetLastError());
2112 sizeof(self_signed_ecc_prime256v1), &cert->pCertInfo->SubjectPublicKeyInfo);
2113 ok(ret, "failed, error %#lx.\n", GetLastError());
2115}
static const BYTE self_signed_ecc_prime256v1[]
Definition: cert.c:2052
static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, LPCSTR sigOID, const BYTE *sig, DWORD sigLen)
Definition: cert.c:1958
static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, LPCSTR sigOID, const BYTE *sig, DWORD sigLen)
Definition: cert.c:1897
static BYTE emptyCert[]
Definition: cert.c:2045
static void testSignCert(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, LPCSTR sigOID, BYTE *sig, DWORD *sigLen)
Definition: cert.c:1835
#define szOID_RSA_SHA1RSA
Definition: wincrypt.h:3175

Referenced by START_TEST().

◆ testCompareCert()

static void testCompareCert ( void  )
static

Definition at line 3459 of file cert.c.

3460{
3461 CERT_INFO info1 = { 0 }, info2 = { 0 };
3462 BOOL ret;
3463
3464 /* Crashes */
3465 if (0)
3467
3468 /* Certs with the same issuer and serial number are equal, even if they
3469 * differ in other respects (like subject).
3470 */
3472 info1.SerialNumber.cbData = sizeof(serialNum);
3473 info1.Issuer.pbData = subjectName;
3474 info1.Issuer.cbData = sizeof(subjectName);
3475 info1.Subject.pbData = subjectName2;
3476 info1.Subject.cbData = sizeof(subjectName2);
3477 info2.SerialNumber.pbData = serialNum;
3478 info2.SerialNumber.cbData = sizeof(serialNum);
3479 info2.Issuer.pbData = subjectName;
3480 info2.Issuer.cbData = sizeof(subjectName);
3481 info2.Subject.pbData = subjectName;
3482 info2.Subject.cbData = sizeof(subjectName);
3483 ret = CertCompareCertificate(X509_ASN_ENCODING, &info1, &info2);
3484 ok(ret, "Expected certs to be equal\n");
3485
3486 info2.Issuer.pbData = subjectName2;
3487 info2.Issuer.cbData = sizeof(subjectName2);
3488 ret = CertCompareCertificate(X509_ASN_ENCODING, &info1, &info2);
3489 ok(!ret, "Expected certs not to be equal\n");
3490}
BOOL WINAPI CertCompareCertificate(DWORD dwCertEncodingType, PCERT_INFO pCertId1, PCERT_INFO pCertId2)
Definition: cert.c:1166
static BYTE serialNum[]
Definition: cert.c:38
static BYTE subjectName[]
Definition: cert.c:35
static BYTE subjectName2[]
Definition: cert.c:75
CERT_NAME_BLOB Subject
Definition: wincrypt.h:256
CERT_NAME_BLOB Issuer
Definition: wincrypt.h:253
CRYPT_INTEGER_BLOB SerialNumber
Definition: wincrypt.h:251
BYTE * pbData
Definition: wincrypt.h:112

Referenced by START_TEST().

◆ testCompareCertName()

static void testCompareCertName ( void  )
static

Definition at line 3010 of file cert.c.

3011{
3012 static BYTE bogus[] = { 1, 2, 3, 4 };
3013 static BYTE bogusPrime[] = { 0, 1, 2, 3, 4 };
3014 static BYTE emptyPrime[] = { 0x30, 0x00, 0x01 };
3015 BOOL ret;
3016 CERT_NAME_BLOB blob1, blob2;
3017
3018 /* crashes
3019 ret = CertCompareCertificateName(0, NULL, NULL);
3020 */
3021 /* An empty name checks against itself.. */
3022 blob1.pbData = emptyCert;
3023 blob1.cbData = sizeof(emptyCert);
3024 ret = CertCompareCertificateName(0, &blob1, &blob1);
3025 ok(ret, "CertCompareCertificateName failed: %08lx\n", GetLastError());
3026 /* It doesn't have to be a valid encoded name.. */
3027 blob1.pbData = bogus;
3028 blob1.cbData = sizeof(bogus);
3029 ret = CertCompareCertificateName(0, &blob1, &blob1);
3030 ok(ret, "CertCompareCertificateName failed: %08lx\n", GetLastError());
3031 /* Leading zeroes matter.. */
3032 blob2.pbData = bogusPrime;
3033 blob2.cbData = sizeof(bogusPrime);
3034 ret = CertCompareCertificateName(0, &blob1, &blob2);
3035 ok(!ret, "Expected failure\n");
3036 /* As do trailing extra bytes. */
3037 blob2.pbData = emptyPrime;
3038 blob2.cbData = sizeof(emptyPrime);
3039 ret = CertCompareCertificateName(0, &blob1, &blob2);
3040 ok(!ret, "Expected failure\n");
3041 /* Tests to show that CertCompareCertificateName doesn't decode the name
3042 * to remove spaces, or to do an order-independent comparison.
3043 */
3044 /* Compare CN="Juan Lang" with CN=" Juan Lang" */
3045 blob1.pbData = cn;
3046 blob1.cbData = sizeof(cn);
3047 blob2.pbData = cnWithLeadingSpace;
3048 blob2.cbData = sizeof(cnWithLeadingSpace);
3049 ret = CertCompareCertificateName(0, &blob1, &blob2);
3050 ok(!ret, "Expected failure\n");
3052 ok(!ret, "Expected failure\n");
3053 /* Compare CN="Juan Lang" with CN="Juan Lang " */
3055 blob2.cbData = sizeof(cnWithTrailingSpace);
3056 ret = CertCompareCertificateName(0, &blob1, &blob2);
3057 ok(!ret, "Expected failure\n");
3059 ok(!ret, "Expected failure\n");
3060 /* Compare CN="Juan Lang" with CN="Juan Lang" */
3062 blob2.cbData = sizeof(cnWithIntermediateSpace);
3063 ret = CertCompareCertificateName(0, &blob1, &blob2);
3064 ok(!ret, "Expected failure\n");
3066 ok(!ret, "Expected failure\n");
3067 /* Compare 'CN="Juan Lang", O="The Wine Project"' with
3068 * 'O="The Wine Project", CN="Juan Lang"'
3069 */
3070 blob1.pbData = cnThenO;
3071 blob1.cbData = sizeof(cnThenO);
3072 blob2.pbData = oThenCN;
3073 blob2.cbData = sizeof(oThenCN);
3074 ret = CertCompareCertificateName(0, &blob1, &blob2);
3075 ok(!ret, "Expected failure\n");
3077 ok(!ret, "Expected failure\n");
3078}
BOOL WINAPI CertCompareCertificateName(DWORD dwCertEncodingType, PCERT_NAME_BLOB pCertName1, PCERT_NAME_BLOB pCertName2)
Definition: cert.c:1180
static BYTE cnWithIntermediateSpace[]
Definition: cert.c:2996
static BYTE cn[]
Definition: cert.c:2987
static BYTE cnThenO[]
Definition: cert.c:2999
static BYTE oThenCN[]
Definition: cert.c:3004
static BYTE cnWithTrailingSpace[]
Definition: cert.c:2993
static BYTE cnWithLeadingSpace[]
Definition: cert.c:2990

Referenced by START_TEST().

◆ testCompareIntegerBlob()

static void testCompareIntegerBlob ( void  )
static

Definition at line 3224 of file cert.c.

3225{
3226 DWORD i;
3227 BOOL ret;
3228
3229 for (i = 0; i < ARRAY_SIZE(intBlobs); i++)
3230 {
3231 ret = CertCompareIntegerBlob(&intBlobs[i].blob1, &intBlobs[i].blob2);
3232 ok(ret == intBlobs[i].areEqual,
3233 "%ld: expected blobs %s compare\n", i, intBlobs[i].areEqual ?
3234 "to" : "not to");
3235 }
3236}
#define ARRAY_SIZE(A)
Definition: main.h:20
BOOL WINAPI CertCompareIntegerBlob(PCRYPT_INTEGER_BLOB pInt1, PCRYPT_INTEGER_BLOB pInt2)
Definition: cert.c:1221
static struct IntBlobTest intBlobs[]

Referenced by START_TEST().

◆ testComparePublicKeyInfo()

static void testComparePublicKeyInfo ( void  )
static

Definition at line 3238 of file cert.c.

3239{
3240 BOOL ret;
3241 CERT_PUBLIC_KEY_INFO info1 = { { 0 } }, info2 = { { 0 } };
3242 static CHAR oid_rsa_rsa[] = szOID_RSA_RSA;
3243 static CHAR oid_rsa_sha1rsa[] = szOID_RSA_SHA1RSA;
3244 static CHAR oid_x957_dsa[] = szOID_X957_DSA;
3245 static BYTE bits1[] = { 1, 0 };
3246 static BYTE bits2[] = { 0 };
3247 static BYTE bits3[] = { 1 };
3248 static BYTE bits4[] = { 0x30,8, 2,1,0x81, 2,3,1,0,1 }; /* ASN_SEQUENCE */
3249 static BYTE bits5[] = { 0x30,9, 2,2,0,0x81, 2,3,1,0,1 }; /* ASN_SEQUENCE */
3250 static BYTE bits6[] = { 0x30,9, 2,2,0,0x82, 2,3,1,0,1 }; /* ASN_SEQUENCE */
3251 static BYTE bits7[] = { 0x04,8, 2,1,0x81, 2,3,1,0,1 }; /* ASN_OCTETSTRING */
3252 static BYTE bits8[] = { 0x04,9, 2,2,0,0x81, 2,3,1,0,1 }; /* ASN_OCTETSTRING */
3253 static BYTE bits9[] = { 0x04,9, 2,2,0,0x82, 2,3,1,0,1 }; /* ASN_OCTETSTRING */
3254
3255 /* crashes
3256 ret = CertComparePublicKeyInfo(0, NULL, NULL);
3257 */
3258 /* Empty public keys compare */
3259 ret = CertComparePublicKeyInfo(0, &info1, &info2);
3260 ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
3262 ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
3263
3264 /* Different OIDs appear to compare */
3265 info1.Algorithm.pszObjId = oid_rsa_rsa;
3266 info2.Algorithm.pszObjId = oid_rsa_sha1rsa;
3267 ret = CertComparePublicKeyInfo(0, &info1, &info2);
3268 ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
3270 ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
3271
3272 info2.Algorithm.pszObjId = oid_x957_dsa;
3273 ret = CertComparePublicKeyInfo(0, &info1, &info2);
3274 ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
3276 ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
3277
3278 info1.PublicKey.cbData = sizeof(bits1);
3279 info1.PublicKey.pbData = bits1;
3280 info1.PublicKey.cUnusedBits = 0;
3281 info2.PublicKey.cbData = sizeof(bits1);
3282 info2.PublicKey.pbData = bits1;
3283 info2.PublicKey.cUnusedBits = 0;
3284 ret = CertComparePublicKeyInfo(0, &info1, &info2);
3285 ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
3287 ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
3288
3289 info2.Algorithm.pszObjId = oid_rsa_rsa;
3290 info1.PublicKey.cbData = sizeof(bits4);
3291 info1.PublicKey.pbData = bits4;
3292 info1.PublicKey.cUnusedBits = 0;
3293 info2.PublicKey.cbData = sizeof(bits5);
3294 info2.PublicKey.pbData = bits5;
3295 info2.PublicKey.cUnusedBits = 0;
3296 ret = CertComparePublicKeyInfo(0, &info1, &info2);
3297 ok(!ret, "CertComparePublicKeyInfo: as raw binary: keys should be unequal\n");
3299 ok(ret, "CertComparePublicKeyInfo: as ASN.1 encoded: keys should be equal\n");
3300
3301 info1.PublicKey.cUnusedBits = 1;
3302 info2.PublicKey.cUnusedBits = 5;
3304 ok(ret, "CertComparePublicKeyInfo: ASN.1 encoding should ignore cUnusedBits\n");
3305 info1.PublicKey.cUnusedBits = 0;
3306 info2.PublicKey.cUnusedBits = 0;
3307 info1.PublicKey.cbData--; /* kill one byte, make ASN.1 encoded data invalid */
3309 ok(!ret, "CertComparePublicKeyInfo: comparing bad ASN.1 encoded key should fail\n");
3310 /* Even though they compare in their used bits, these do not compare */
3311 info1.PublicKey.cbData = sizeof(bits2);
3312 info1.PublicKey.pbData = bits2;
3313 info1.PublicKey.cUnusedBits = 0;
3314 info2.PublicKey.cbData = sizeof(bits3);
3315 info2.PublicKey.pbData = bits3;
3316 info2.PublicKey.cUnusedBits = 1;
3317 ret = CertComparePublicKeyInfo(0, &info1, &info2);
3318 /* Simple (non-comparing) case */
3319 ok(!ret, "Expected keys not to compare\n");
3321 ok(!ret, "Expected keys not to compare\n");
3322
3323 info2.PublicKey.cbData = sizeof(bits1);
3324 info2.PublicKey.pbData = bits1;
3325 info2.PublicKey.cUnusedBits = 0;
3326 ret = CertComparePublicKeyInfo(0, &info1, &info2);
3327 ok(!ret, "Expected keys not to compare\n");
3329 ok(!ret, "Expected keys not to compare\n");
3330
3331 info1.PublicKey.cbData = sizeof(bits7);
3332 info1.PublicKey.pbData = bits7;
3333 info1.PublicKey.cUnusedBits = 0;
3334 info2.PublicKey.cbData = sizeof(bits8);
3335 info2.PublicKey.pbData = bits8;
3336 info2.PublicKey.cUnusedBits = 0;
3337 ret = CertComparePublicKeyInfo(0, &info1, &info2);
3338 ok(!ret, "CertComparePublicKeyInfo: as raw binary: keys should be unequal\n");
3340 ok(!ret, "CertComparePublicKeyInfo: as ASN.1 encoded: keys should be unequal\n");
3341
3342 ret = CertComparePublicKeyInfo(0, &info1, &info1);
3343 ok(ret, "CertComparePublicKeyInfo: as raw binary: keys should be equal\n");
3345 ok(ret, "CertComparePublicKeyInfo: as ASN.1 encoded: keys should be equal\n");
3346 info1.PublicKey.cbData--; /* kill one byte, make ASN.1 encoded data invalid */
3348 ok(ret, "CertComparePublicKeyInfo: as ASN.1 encoded: keys should be equal\n");
3349
3350 /* ASN.1 encoded non-comparing case */
3351 info1.PublicKey.cbData = sizeof(bits5);
3352 info1.PublicKey.pbData = bits5;
3353 info1.PublicKey.cUnusedBits = 0;
3354 info2.PublicKey.cbData = sizeof(bits6);
3355 info2.PublicKey.pbData = bits6;
3356 info2.PublicKey.cUnusedBits = 0;
3358 ok(!ret, "CertComparePublicKeyInfo: different keys should be unequal\n");
3359
3360 /* ASN.1 encoded non-comparing case */
3361 info1.PublicKey.cbData = sizeof(bits8);
3362 info1.PublicKey.pbData = bits8;
3363 info1.PublicKey.cUnusedBits = 0;
3364 info2.PublicKey.cbData = sizeof(bits9);
3365 info2.PublicKey.pbData = bits9;
3366 info2.PublicKey.cUnusedBits = 0;
3368 ok(!ret, "CertComparePublicKeyInfo: different keys should be unequal\n");
3369}
BOOL WINAPI CertComparePublicKeyInfo(DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pPublicKey1, PCERT_PUBLIC_KEY_INFO pPublicKey2)
Definition: cert.c:1244
CRYPT_BIT_BLOB PublicKey
Definition: wincrypt.h:235
CRYPT_ALGORITHM_IDENTIFIER Algorithm
Definition: wincrypt.h:234
DWORD cUnusedBits
Definition: wincrypt.h:207
BYTE * pbData
Definition: wincrypt.h:206
#define szOID_X957_DSA
Definition: wincrypt.h:3214
#define szOID_RSA_RSA
Definition: wincrypt.h:3168
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ testCreateCert()

static void testCreateCert ( void  )
static

Definition at line 607 of file cert.c.

608{
609 PCCERT_CONTEXT cert, enumCert;
611 BOOL ret;
612
613 SetLastError(0xdeadbeef);
616 "expected E_INVALIDARG, got %08lx\n", GetLastError());
617 SetLastError(0xdeadbeef);
619 sizeof(selfSignedCert));
621 "expected E_INVALIDARG, got %08lx\n", GetLastError());
622 SetLastError(0xdeadbeef);
625 "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
626
629 ok(cert != NULL, "creating cert failed: %08lx\n", GetLastError());
630 /* Even in-memory certs are expected to have a store associated with them */
631 ok(cert->hCertStore != NULL, "expected created cert to have a store\n");
632 /* The cert doesn't have the archived property set (which would imply it
633 * doesn't show up in enumerations.)
634 */
635 size = 0;
637 NULL, &size);
639 "expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
640 /* Strangely, enumerating the certs in the store finds none. */
641 enumCert = NULL;
642 count = 0;
643 while ((enumCert = CertEnumCertificatesInStore(cert->hCertStore, enumCert)))
644 count++;
645 ok(!count, "expected 0, got %ld\n", count);
647}
PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrev)
Definition: store.c:928
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define CERT_ARCHIVED_PROP_ID
Definition: wincrypt.h:2852
#define CRYPT_E_ASN1_EOD
Definition: winerror.h:4501

Referenced by START_TEST().

◆ testCreateSelfSignCert()

static void testCreateSelfSignCert ( void  )
static

Definition at line 2210 of file cert.c.

2211{
2214 HCRYPTPROV csp;
2215 BOOL ret;
2216 HCRYPTKEY key;
2217 CRYPT_KEY_PROV_INFO info, *ret_info;
2218 DWORD size;
2219
2220 /* This crashes:
2221 context = CertCreateSelfSignCertificate(0, NULL, 0, NULL, NULL, NULL, NULL, NULL); */
2222
2223 /* Test CSP created by implementation without CSP or CSP parameters provided. */
2225 ok(!!context, "failed, error %#lx.\n", GetLastError());
2226 size = 0;
2228 ok(ret, "failed, error %#lx.\n", GetLastError());
2229 ret_info = malloc(size);
2230 ok(!!ret_info, "memory allocation failed.\n");
2232 ok(ret, "failed, error %#lx.\n", GetLastError());
2234 ok(ret_info->dwKeySpec == AT_SIGNATURE, "got %#lx.\n", ret_info->dwKeySpec);
2235 ok(!ret_info->dwFlags, "got %#lx.\n", ret_info->dwFlags);
2236 ok(ret_info->pwszContainerName && *ret_info->pwszContainerName, "got %s.\n",
2237 debugstr_w(ret_info->pwszContainerName));
2238 ret = CryptAcquireContextW(&csp, ret_info->pwszContainerName, ret_info->pwszProvName, ret_info->dwProvType, 0);
2239 ok(ret, "failed, error %#lx.\n", GetLastError());
2241 ok(ret, "failed, error %#lx.\n", GetLastError());
2243 ok(ret, "failed, error %#lx.\n", GetLastError());
2245 ok(!ret && GetLastError() == NTE_NO_KEY, "got ret %d, error %#lx.\n", ret, GetLastError());
2246 CryptReleaseContext(csp, 0);
2247 csp = 0xdeadbeef;
2248 ret = CryptAcquireContextW(&csp, ret_info->pwszContainerName, ret_info->pwszProvName,
2249 ret_info->dwProvType, CRYPT_DELETEKEYSET);
2250 ok(ret, "failed, error %#lx.\n", GetLastError());
2251 ok(!csp, "got %p.\n", (void *)csp);
2252 ret = CryptAcquireContextW(&csp, ret_info->pwszContainerName, ret_info->pwszProvName, ret_info->dwProvType, 0);
2253 ok(!ret && GetLastError() == NTE_BAD_KEYSET, "got ret %d, error %#lx.\n", ret, GetLastError());
2254 free(ret_info);
2255
2256 /* Acquire a CSP */
2261 ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
2262
2264 NULL, NULL);
2266 "Expected NTE_NO_KEY, got %08lx\n", GetLastError());
2267 ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key);
2268 ok(ret, "CryptGenKey failed: %08lx\n", GetLastError());
2269 if (ret)
2270 {
2272 NULL, NULL);
2273 ok(context != NULL, "CertCreateSelfSignCertificate failed: %08lx\n",
2274 GetLastError());
2275 if (context)
2276 {
2277 DWORD size = 0;
2278
2279 /* The context must have a key provider info property */
2282 ok(ret && size, "Expected non-zero key provider info\n");
2283 if (size)
2284 {
2286
2287 if (pInfo)
2288 {
2291 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
2292 GetLastError());
2293 if (ret)
2294 {
2295 /* Sanity-check the key provider */
2296 ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"),
2297 "Unexpected key container\n");
2299 "Unexpected provider\n");
2300 ok(pInfo->dwKeySpec == AT_SIGNATURE,
2301 "Expected AT_SIGNATURE, got %ld\n", pInfo->dwKeySpec);
2302 }
2303 free(pInfo);
2304 }
2305 }
2306
2308 }
2309
2311 }
2312
2313 CryptReleaseContext(csp, 0);
2316 ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
2317
2318 /* Do the same test with a CSP, AT_KEYEXCHANGE and key info */
2323 ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
2324 ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key);
2325 ok(ret, "CryptGenKey failed: %08lx\n", GetLastError());
2326
2327 memset(&info,0,sizeof(info));
2328 info.dwProvType = PROV_RSA_FULL;
2329 info.dwKeySpec = AT_KEYEXCHANGE;
2330 info.pwszProvName = (LPWSTR) MS_DEF_PROV_W;
2331 info.pwszContainerName = (WCHAR *)L"WineCryptTemp";
2332 /* This should fail because the CSP doesn't have the specified key. */
2333 SetLastError(0xdeadbeef);
2335 NULL, NULL);
2336 ok(context == NULL, "expected failure\n");
2337 if (context != NULL)
2339 else
2340 ok(GetLastError() == NTE_NO_KEY, "expected NTE_NO_KEY, got %08lx\n",
2341 GetLastError());
2342 /* Again, with a CSP, AT_SIGNATURE and key info */
2343 info.dwKeySpec = AT_SIGNATURE;
2344 SetLastError(0xdeadbeef);
2346 NULL, NULL);
2347 ok(context != NULL,
2348 "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError());
2349 if (context)
2350 {
2351 DWORD size = 0;
2352
2353 /* The context must have a key provider info property */
2356 ok(ret && size, "Expected non-zero key provider info\n");
2357 if (size)
2358 {
2360
2361 if (pInfo)
2362 {
2365 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
2366 GetLastError());
2367 if (ret)
2368 {
2369 /* Sanity-check the key provider */
2370 ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"),
2371 "Unexpected key container\n");
2373 "Unexpected provider\n");
2374 ok(pInfo->dwKeySpec == AT_SIGNATURE,
2375 "Expected AT_SIGNATURE, got %ld\n", pInfo->dwKeySpec);
2376 }
2377 free(pInfo);
2378 }
2379 }
2380
2382 }
2384
2385 CryptReleaseContext(csp, 0);
2388 ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
2389
2390 /* Do the same test with no CSP, AT_KEYEXCHANGE and key info */
2391 info.dwKeySpec = AT_KEYEXCHANGE;
2393 NULL, NULL);
2394 ok(context != NULL, "CertCreateSelfSignCertificate failed: %08lx\n",
2395 GetLastError());
2396 if (context)
2397 {
2398 DWORD size = 0;
2399
2400 /* The context must have a key provider info property */
2403 ok(ret && size, "Expected non-zero key provider info\n");
2404 if (size)
2405 {
2407
2408 if (pInfo)
2409 {
2412 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
2413 GetLastError());
2414 if (ret)
2415 {
2416 /* Sanity-check the key provider */
2417 ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"),
2418 "Unexpected key container\n");
2420 "Unexpected provider\n");
2421 ok(pInfo->dwKeySpec == AT_KEYEXCHANGE,
2422 "Expected AT_KEYEXCHANGE, got %ld\n", pInfo->dwKeySpec);
2423 }
2424 free(pInfo);
2425 }
2426 }
2427
2429 }
2430
2433
2434 /* Acquire a CSP and generate an AT_KEYEXCHANGE key in it. */
2439 ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
2440
2442 NULL, NULL);
2444 "Expected NTE_NO_KEY, got %08lx\n", GetLastError());
2445 ret = CryptGenKey(csp, AT_KEYEXCHANGE, 0, &key);
2446 ok(ret, "CryptGenKey failed: %08lx\n", GetLastError());
2448
2449 memset(&info,0,sizeof(info));
2450 info.dwProvType = PROV_RSA_FULL;
2451 info.dwKeySpec = AT_SIGNATURE;
2452 info.pwszProvName = (LPWSTR) MS_DEF_PROV_W;
2453 info.pwszContainerName = (WCHAR *)L"WineCryptTemp";
2454 /* This should fail because the CSP doesn't have the specified key. */
2455 SetLastError(0xdeadbeef);
2457 NULL, NULL);
2458 ok(context == NULL, "expected failure\n");
2459 if (context != NULL)
2461 else
2462 ok(GetLastError() == NTE_NO_KEY, "expected NTE_NO_KEY, got %08lx\n",
2463 GetLastError());
2464 /* Again, with a CSP, AT_KEYEXCHANGE and key info. This succeeds because the
2465 * CSP has an AT_KEYEXCHANGE key in it.
2466 */
2467 info.dwKeySpec = AT_KEYEXCHANGE;
2468 SetLastError(0xdeadbeef);
2470 NULL, NULL);
2471 ok(context != NULL,
2472 "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError());
2473 if (context)
2474 {
2475 DWORD size = 0;
2476
2477 /* The context must have a key provider info property */
2480 ok(ret && size, "Expected non-zero key provider info\n");
2481 if (size)
2482 {
2484
2485 if (pInfo)
2486 {
2489 ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
2490 GetLastError());
2491 if (ret)
2492 {
2493 /* Sanity-check the key provider */
2494 ok(!lstrcmpW(pInfo->pwszContainerName, L"WineCryptTemp"),
2495 "Unexpected key container\n");
2497 "Unexpected provider\n");
2498 ok(pInfo->dwKeySpec == AT_KEYEXCHANGE,
2499 "Expected AT_KEYEXCHANGE, got %ld\n", pInfo->dwKeySpec);
2500 }
2501 free(pInfo);
2502 }
2503 }
2504
2506 }
2507
2508 CryptReleaseContext(csp, 0);
2511 ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
2512
2513}
BOOL WINAPI CryptGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKEY *phKey)
Definition: crypt.c:1451
BOOL WINAPI CryptGetUserKey(HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY *phUserKey)
Definition: crypt.c:1718
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
PCCERT_CONTEXT WINAPI CertCreateSelfSignCertificate(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hProv, PCERT_NAME_BLOB pSubjectIssuerBlob, DWORD dwFlags, PCRYPT_KEY_PROV_INFO pKeyProvInfo, PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm, PSYSTEMTIME pStartTime, PSYSTEMTIME pEndTime, PCERT_EXTENSIONS pExtensions)
Definition: cert.c:3552
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4246
#define debugstr_w
Definition: kernel32.h:32
Definition: name.c:39
#define AT_KEYEXCHANGE
Definition: wincrypt.h:2239
#define NTE_NO_KEY
Definition: winerror.h:4260
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by START_TEST().

◆ testCryptHashCert()

static void testCryptHashCert ( void  )
static

Definition at line 1703 of file cert.c.

1704{
1705 static const BYTE emptyHash[] = { 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b,
1706 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07,
1707 0x09 };
1708 static const BYTE knownHash[] = { 0xae, 0x9d, 0xbf, 0x6d, 0xf5, 0x46, 0xee,
1709 0x8b, 0xc5, 0x7a, 0x13, 0xba, 0xc2, 0xb1, 0x04, 0xf2, 0xbf, 0x52, 0xa8,
1710 0xa2 };
1711 static const BYTE toHash[] = "abcdefghijklmnopqrstuvwxyz0123456789.,;!?:";
1712 BOOL ret;
1713 BYTE hash[20];
1714 DWORD hashLen = sizeof(hash);
1715
1716 /* NULL buffer and nonzero length crashes
1717 ret = CryptHashCertificate(0, 0, 0, NULL, size, hash, &hashLen);
1718 empty hash length also crashes
1719 ret = CryptHashCertificate(0, 0, 0, buf, size, hash, NULL);
1720 */
1721 /* Test empty hash */
1722 ret = CryptHashCertificate(0, 0, 0, toHash, sizeof(toHash), NULL,
1723 &hashLen);
1724 ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
1725 ok(hashLen == sizeof(hash), "Got unexpected size of hash %ld\n", hashLen);
1726 /* Test with empty buffer */
1727 ret = CryptHashCertificate(0, 0, 0, NULL, 0, hash, &hashLen);
1728 ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
1729 ok(!memcmp(hash, emptyHash, sizeof(emptyHash)),
1730 "Unexpected hash of nothing\n");
1731 /* Test a known value */
1732 ret = CryptHashCertificate(0, 0, 0, toHash, sizeof(toHash), hash,
1733 &hashLen);
1734 ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
1735 ok(!memcmp(hash, knownHash, sizeof(knownHash)), "Unexpected hash\n");
1736}

Referenced by START_TEST().

◆ testCryptHashCert2()

static void testCryptHashCert2 ( void  )
static

Definition at line 1738 of file cert.c.

1739{
1740#ifndef __REACTOS__ // FIXME: ReactOS has no implementation for CryptHashCertificate2 (Vista+)
1741 static const BYTE emptyHash[] = { 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b,
1742 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07,
1743 0x09 };
1744 static const BYTE knownHash[] = { 0xae, 0x9d, 0xbf, 0x6d, 0xf5, 0x46, 0xee,
1745 0x8b, 0xc5, 0x7a, 0x13, 0xba, 0xc2, 0xb1, 0x04, 0xf2, 0xbf, 0x52, 0xa8,
1746 0xa2 };
1747 static const BYTE toHash[] = "abcdefghijklmnopqrstuvwxyz0123456789.,;!?:";
1748 BOOL ret;
1749 BYTE hash[20];
1750 DWORD hashLen;
1751
1752 /* Test empty hash */
1753 hashLen = sizeof(hash);
1754 ret = CryptHashCertificate2(L"SHA1", 0, NULL, NULL, 0, hash, &hashLen);
1755 ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError());
1756 ok(hashLen == sizeof(hash), "Got unexpected size of hash %ld\n", hashLen);
1757 ok(!memcmp(hash, emptyHash, sizeof(emptyHash)), "Unexpected hash of nothing\n");
1758
1759 /* Test known hash */
1760 hashLen = sizeof(hash);
1761 ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, &hashLen);
1762 ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError());
1763 ok(hashLen == sizeof(hash), "Got unexpected size of hash %ld\n", hashLen);
1764 ok(!memcmp(hash, knownHash, sizeof(knownHash)), "Unexpected hash\n");
1765
1766 /* Test null hash size pointer just sets hash size */
1767 hashLen = 0;
1768 ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), NULL, &hashLen);
1769 ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError());
1770 ok(hashLen == sizeof(hash), "Hash size not set correctly (%ld)\n", hashLen);
1771
1772 /* Null algorithm ID crashes Windows implementations */
1773 if (0) {
1774 /* Test null algorithm ID */
1775 hashLen = sizeof(hash);
1776 ret = CryptHashCertificate2(NULL, 0, NULL, toHash, sizeof(toHash), hash, &hashLen);
1777 }
1778
1779 /* Test invalid algorithm */
1780 hashLen = sizeof(hash);
1781 SetLastError(0xdeadbeef);
1782 ret = CryptHashCertificate2(L"_SHOULDNOTEXIST_", 0, NULL, toHash, sizeof(toHash), hash, &hashLen);
1784 "Expected STATUS_NOT_FOUND (0x%08lx), got 0x%08lx\n", STATUS_NOT_FOUND, GetLastError());
1785
1786 /* Test hash buffer too small */
1787 hashLen = sizeof(hash) / 2;
1788 SetLastError(0xdeadbeef);
1789 ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, &hashLen);
1791 "Expected ERROR_MORE_DATA (%d), got %ld\n", ERROR_MORE_DATA, GetLastError());
1792
1793 /* Null hash length crashes Windows implementations */
1794 if (0) {
1795 /* Test hashLen null with hash */
1796 ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), hash, NULL);
1797
1798 /* Test hashLen null with no hash */
1799 ret = CryptHashCertificate2(L"SHA1", 0, NULL, toHash, sizeof(toHash), NULL, NULL);
1800 }
1801#endif
1802}
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define STATUS_NOT_FOUND
Definition: shellext.h:72
WINCRYPT32API BOOL WINAPI CryptHashCertificate2(LPCWSTR pwszCNGHashAlgid, DWORD dwFlags, void *pvReserved, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash)

Referenced by START_TEST().

◆ testDupCert()

static void testDupCert ( void  )
static

Definition at line 649 of file cert.c.

650{
651 PCCERT_CONTEXT context, dupContext, storeContext, storeContext2, context2;
652 HCERTSTORE store, store2;
653 BOOL ret;
654
657 ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
658 if (!store)
659 return;
660
663 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
664 ok(context != NULL, "Expected a valid cert context\n");
665 if (context)
666 {
667 ok(context->cbCertEncoded == sizeof(bigCert),
668 "Wrong cert size %ld\n", context->cbCertEncoded);
669 ok(!memcmp(context->pbCertEncoded, bigCert, sizeof(bigCert)),
670 "Unexpected encoded cert in context\n");
671 ok(context->hCertStore == store, "Unexpected store\n");
672
674 ok(dupContext != NULL, "Expected valid duplicate\n");
675 /* Not only is it a duplicate, it's identical: the address is the
676 * same.
677 */
678 ok(dupContext == context, "Expected identical context addresses\n");
679 CertFreeCertificateContext(dupContext);
681 }
682 CertCloseStore(store, 0);
683
685 ok(context != NULL, "CertCreateCertificateContext failed\n");
686
688 ok(dupContext == context, "context != dupContext\n");
689
690 ret = CertFreeCertificateContext(dupContext);
691 ok(ret, "CertFreeCertificateContext failed\n");
692
694 ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
695
697 ok(ret, "CertAddCertificateContextToStore failed\n");
698 ok(storeContext != NULL && storeContext != context, "unexpected storeContext\n");
699 ok(storeContext->hCertStore == store, "unexpected hCertStore\n");
700
701 ok(storeContext->pbCertEncoded != context->pbCertEncoded, "unexpected pbCertEncoded\n");
702 ok(storeContext->cbCertEncoded == context->cbCertEncoded, "unexpected cbCertEncoded\n");
703 ok(storeContext->pCertInfo != context->pCertInfo, "unexpected pCertInfo\n");
704
706 ok(store2 != NULL, "CertOpenStore failed: %ld\n", GetLastError());
707
708 ret = CertAddCertificateContextToStore(store2, storeContext, CERT_STORE_ADD_NEW, &storeContext2);
709 ok(ret, "CertAddCertificateContextToStore failed\n");
710 ok(storeContext2 != NULL && storeContext2 != storeContext, "unexpected storeContext\n");
711 ok(storeContext2->hCertStore == store2, "unexpected hCertStore\n");
712
713 ok(storeContext2->pbCertEncoded != storeContext->pbCertEncoded, "unexpected pbCertEncoded\n");
714 ok(storeContext2->cbCertEncoded == storeContext->cbCertEncoded, "unexpected cbCertEncoded\n");
715 ok(storeContext2->pCertInfo != storeContext->pCertInfo, "unexpected pCertInfo\n");
716
717 CertFreeCertificateContext(storeContext2);
718 CertFreeCertificateContext(storeContext);
719
721 ok(context2 != NULL, "CertCreateCertificateContext failed\n");
722
723 ok(context2->hCertStore == context->hCertStore, "Unexpected hCertStore\n");
724
727 ok(ret, "CertFreeCertificateContext failed\n");
728
729 CertCloseStore(store, 0);
730 CertCloseStore(store2, 0);
731
732 SetLastError(0xdeadbeef);
734 ok(context == NULL, "Expected context to be NULL\n");
735
737 ok(ret, "CertFreeCertificateContext failed\n");
738}
HCERTSTORE hCertStore
Definition: wincrypt.h:492
PCERT_INFO pCertInfo
Definition: wincrypt.h:491
BYTE * pbCertEncoded
Definition: wincrypt.h:489
DWORD cbCertEncoded
Definition: wincrypt.h:490

Referenced by START_TEST().

◆ testFindCert()

static void testFindCert ( void  )
static

Definition at line 1095 of file cert.c.

1096{
1097 HCERTSTORE store;
1098 PCCERT_CONTEXT context = NULL, subject;
1099 BOOL ret;
1100 CERT_INFO certInfo = { 0 };
1102 BYTE otherSerialNumber[] = { 2 };
1103 DWORD count;
1104
1107 ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
1108 if (!store)
1109 return;
1110
1113 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
1114
1117 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1118 GetLastError());
1119 /* This has the same name as bigCert */
1122 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1123 GetLastError());
1124
1125 /* Crashes
1126 context = CertFindCertificateInStore(NULL, 0, 0, 0, NULL, NULL);
1127 */
1128
1129 /* Check first cert's there, by issuer */
1130 certInfo.Subject.pbData = subjectName;
1131 certInfo.Subject.cbData = sizeof(subjectName);
1132 certInfo.SerialNumber.pbData = serialNum;
1133 certInfo.SerialNumber.cbData = sizeof(serialNum);
1135 CERT_FIND_ISSUER_NAME, &certInfo.Subject, NULL);
1136 ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n",
1137 GetLastError());
1138 if (context)
1139 {
1142 ok(context != NULL, "Expected more than one cert\n");
1143 if (context)
1144 {
1146 0, CERT_FIND_ISSUER_NAME, &certInfo.Subject, context);
1147 ok(context == NULL, "Expected precisely two certs\n");
1148 }
1149 }
1150
1151 /* Check second cert's there as well, by subject name */
1152 certInfo.Subject.pbData = subjectName2;
1153 certInfo.Subject.cbData = sizeof(subjectName2);
1155 CERT_FIND_SUBJECT_NAME, &certInfo.Subject, NULL);
1156 ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n",
1157 GetLastError());
1158 if (context)
1159 {
1162 ok(context == NULL, "Expected one cert only\n");
1163 }
1164
1165 /* Strange but true: searching for the subject cert requires you to set
1166 * the issuer, not the subject
1167 */
1169 CERT_FIND_SUBJECT_CERT, &certInfo, NULL);
1170 ok(context == NULL, "Expected no certificate\n");
1171 certInfo.Subject.pbData = NULL;
1172 certInfo.Subject.cbData = 0;
1173 certInfo.Issuer.pbData = subjectName2;
1174 certInfo.Issuer.cbData = sizeof(subjectName2);
1176 CERT_FIND_SUBJECT_CERT, &certInfo, NULL);
1177 ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n",
1178 GetLastError());
1179 if (context)
1180 {
1182 CERT_FIND_SUBJECT_CERT, &certInfo, context);
1183 ok(context == NULL, "Expected one cert only\n");
1184 }
1185 /* A non-matching serial number will not match. */
1186 certInfo.SerialNumber.pbData = otherSerialNumber;
1187 certInfo.SerialNumber.cbData = sizeof(otherSerialNumber);
1189 CERT_FIND_SUBJECT_CERT, &certInfo, NULL);
1190 ok(context == NULL, "Expected no match\n");
1191 /* No serial number will not match */
1192 certInfo.SerialNumber.cbData = 0;
1194 CERT_FIND_SUBJECT_CERT, &certInfo, NULL);
1195 ok(context == NULL, "Expected no match\n");
1196 /* A serial number still won't match if the name doesn't */
1197 certInfo.SerialNumber.pbData = serialNum;
1198 certInfo.SerialNumber.cbData = sizeof(serialNum);
1199 certInfo.Issuer.pbData = subjectName3;
1200 certInfo.Issuer.cbData = sizeof(subjectName3);
1202 CERT_FIND_SUBJECT_CERT, &certInfo, NULL);
1203 ok(context == NULL, "Expected no match\n");
1204
1205 /* The nice thing about hashes, they're unique */
1206 blob.pbData = bigCertHash;
1207 blob.cbData = sizeof(bigCertHash);
1210 ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n",
1211 GetLastError());
1212 if (context)
1213 {
1215 CERT_FIND_SHA1_HASH, &certInfo.Subject, context);
1216 ok(context == NULL, "Expected one cert only\n");
1217 }
1218
1219 /* Searching for NULL string matches any context. */
1220 count = 0;
1221 context = NULL;
1222 do {
1225 if (context)
1226 count++;
1227 } while (context);
1228 ok(count == 3, "expected 3 contexts\n");
1229 count = 0;
1230 context = NULL;
1231 do {
1234 if (context)
1235 count++;
1236 } while (context);
1237 ok(count == 2, "expected 2 contexts\n");
1238 count = 0;
1239 context = NULL;
1240 do {
1243 if (context)
1244 count++;
1245 } while (context);
1246 ok(count == 3, "expected 3 contexts\n");
1247 SetLastError(0xdeadbeef);
1249 CERT_FIND_ISSUER_STR, L"malcolm", NULL);
1250 ok(!context, "expected no certs\n");
1252 "expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
1253
1254 CertCloseStore(store, 0);
1255
1256 /* Another subject cert search, using iTunes's certs */
1261 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1262 GetLastError());
1265 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1266 GetLastError());
1269 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1270 GetLastError());
1272 iTunesCert3, sizeof(iTunesCert3), CERT_STORE_ADD_NEW, &subject);
1273 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1274 GetLastError());
1275
1276 /* The certInfo's issuer does not match any subject, but the serial
1277 * number does match a cert whose issuer matches certInfo's issuer.
1278 * This yields a match.
1279 */
1280 certInfo.SerialNumber.cbData = sizeof(iTunesSerialNum);
1282 certInfo.Issuer.cbData = sizeof(iTunesIssuer);
1283 certInfo.Issuer.pbData = iTunesIssuer;
1285 CERT_FIND_SUBJECT_CERT, &certInfo, NULL);
1286 ok(context != NULL, "Expected a match\n");
1287 if (context)
1288 {
1289 ret = CertCompareCertificateName(context->dwCertEncodingType,
1290 &certInfo.Issuer, &context->pCertInfo->Subject);
1291 ok(!ret, "Expected subject name not to match\n");
1292 ret = CertCompareCertificateName(context->dwCertEncodingType,
1293 &certInfo.Issuer, &context->pCertInfo->Issuer);
1294 ok(ret, "Expected issuer name to match\n");
1296 &context->pCertInfo->SerialNumber);
1297 ok(ret, "Expected serial number to match\n");
1299 CERT_FIND_SUBJECT_CERT, &certInfo, context);
1300 ok(context == NULL, "Expected one cert only\n");
1301 }
1302
1304 CERT_FIND_ISSUER_OF, subject, NULL);
1305 ok(context != NULL, "Expected an issuer\n");
1306 if (context)
1307 {
1310
1311 ok(!none, "Expected no parent of issuer\n");
1313 }
1315 CertCloseStore(store, 0);
1316}
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, PCCERT_CONTEXT pPrevCertContext)
Definition: cert.c:1765
static BYTE iTunesSerialNum[]
Definition: cert.c:1091
static BYTE bigCertHash[]
Definition: cert.c:49
static BYTE subjectName3[]
Definition: cert.c:766
static const BYTE iTunesCert2[]
Definition: cert.c:905
static const BYTE iTunesCert3[]
Definition: cert.c:988
static BYTE iTunesIssuer[]
Definition: cert.c:1074
static const BYTE iTunesCert0[]
Definition: cert.c:769
static const BYTE iTunesCert1[]
Definition: cert.c:835
#define CERT_FIND_SUBJECT_CERT
Definition: wincrypt.h:3048
#define CERT_FIND_SUBJECT_NAME
Definition: wincrypt.h:3025
#define CERT_FIND_SHA1_HASH
Definition: wincrypt.h:3012
#define CERT_FIND_ISSUER_STR
Definition: wincrypt.h:3042
#define CERT_FIND_ISSUER_NAME
Definition: wincrypt.h:3029
#define CERT_FIND_ISSUER_OF
Definition: wincrypt.h:3050

Referenced by START_TEST().

◆ testGetIssuerCert()

static void testGetIssuerCert ( void  )
static

Definition at line 1513 of file cert.c.

1514{
1515 BOOL ret;
1517 DWORD flags = 0xffffffff, size;
1518 CERT_NAME_BLOB certsubject;
1519 BYTE *certencoded;
1522
1523 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1524
1527 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1528 GetLastError());
1529
1532 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1533 GetLastError());
1534
1535 /* These crash:
1536 parent = CertGetIssuerCertificateFromStore(NULL, NULL, NULL, NULL);
1537 parent = CertGetIssuerCertificateFromStore(store, NULL, NULL, NULL);
1538 */
1541 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1544 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1547 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1548 /* Confusing: the caller cannot set either of the
1549 * CERT_STORE_NO_*_FLAGs, as these are not checks,
1550 * they're results:
1551 */
1555 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1556 /* Perform no checks */
1557 flags = 0;
1559 ok(parent != NULL, "CertGetIssuerCertificateFromStore failed: %08lx\n",
1560 GetLastError());
1561 if (parent)
1563 /* Check revocation and signature only */
1566 ok(parent != NULL, "CertGetIssuerCertificateFromStore failed: %08lx\n",
1567 GetLastError());
1568 /* Confusing: CERT_STORE_REVOCATION_FLAG succeeds when there is no CRL by
1569 * setting CERT_STORE_NO_CRL_FLAG.
1570 */
1572 "Expected CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG, got %08lx\n",
1573 flags);
1574 if (parent)
1576 /* Checking time validity is not productive, because while most Windows
1577 * versions return 0 (time valid) because the child is not expired,
1578 * Windows 2003 SP1 returns that it is expired. Thus the range of
1579 * possibilities is covered, and a test verifies nothing.
1580 */
1581
1583 CertCloseStore(store, 0);
1584
1585 flags = 0;
1588 /* With only the child certificate, no issuer will be found */
1591 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
1593 ok(parent == NULL, "Expected no issuer\n");
1594 ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
1595 /* Adding an issuer allows one (and only one) issuer to be found */
1598 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
1600 ok(parent == cert1, "Expected cert1 to be the issuer\n");
1602 ok(parent == NULL, "Expected only one issuer\n");
1603 ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
1604 /* Adding a second issuer allows two issuers to be found - and the second
1605 * issuer is found before the first, implying certs are added to the head
1606 * of a list.
1607 */
1610 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
1612 ok(parent == cert2, "Expected cert2 to be the first issuer\n");
1614 ok(parent == cert1, "Expected cert1 to be the second issuer\n");
1616 ok(parent == NULL, "Expected no more than two issuers\n");
1617 ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
1621 CertCloseStore(store, 0);
1622
1623 /* Repeat the test, reversing the order in which issuers are added,
1624 * to show it's order-dependent.
1625 */
1628 /* With only the child certificate, no issuer will be found */
1631 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
1633 ok(parent == NULL, "Expected no issuer\n");
1634 ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
1635 /* Adding an issuer allows one (and only one) issuer to be found */
1638 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
1640 ok(parent == cert1, "Expected cert1 to be the issuer\n");
1642 ok(parent == NULL, "Expected only one issuer\n");
1643 ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
1644 /* Adding a second issuer allows two issuers to be found - and the second
1645 * issuer is found before the first, implying certs are added to the head
1646 * of a list.
1647 */
1650 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
1652 ok(parent == cert2, "Expected cert2 to be the first issuer\n");
1654 ok(parent == cert1, "Expected cert1 to be the second issuer\n");
1656 ok(parent == NULL, "Expected no more than two issuers\n");
1657 ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
1658
1659 /* Self-sign a certificate, add to the store and test getting the issuer */
1660 size = 0;
1662 "CertStrToName should have worked\n");
1663 certencoded = malloc(size);
1664 ok(CertStrToNameW(X509_ASN_ENCODING, L"CN=dummy, T=Test", CERT_X500_NAME_STR, NULL, certencoded, &size, NULL),
1665 "CertStrToName should have worked\n");
1666 certsubject.pbData = certencoded;
1667 certsubject.cbData = size;
1668 cert3 = CertCreateSelfSignCertificate(0, &certsubject, 0, NULL, NULL, NULL, NULL, NULL);
1669 ok(cert3 != NULL, "CertCreateSelfSignCertificate should have worked\n");
1671 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
1673 cert3 = CertEnumCertificatesInStore(store, NULL);
1674 ok(cert3 != NULL, "CertEnumCertificatesInStore should have worked\n");
1675 SetLastError(0xdeadbeef);
1676 flags = 0;
1678 ok(!parent, "Expected NULL\n");
1680 "Expected CRYPT_E_SELF_SIGNED, got %08lX\n", GetLastError());
1685 CertCloseStore(store, 0);
1686 free(certencoded);
1687
1688 /* Test root storage self-signed certificate */
1690 ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
1691 flags = 0;
1693 ok(cert1 != NULL, "CertEnumCertificatesInStore should have worked\n");
1694 SetLastError(0xdeadbeef);
1696 ok(!parent, "Expected NULL\n");
1698 "Expected CRYPT_E_SELF_SIGNED, got %08lX\n", GetLastError());
1700 CertCloseStore(store, 0);
1701}
PCCERT_CONTEXT WINAPI CertGetIssuerCertificateFromStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pSubjectContext, PCCERT_CONTEXT pPrevIssuerContext, DWORD *pdwFlags)
Definition: cert.c:1887
BOOL WINAPI CertStrToNameW(DWORD dwCertEncodingType, LPCWSTR pszX500, DWORD dwStrType, void *pvReserved, BYTE *pbEncoded, DWORD *pcbEncoded, LPCWSTR *ppszError)
Definition: str.c:1024
r parent
Definition: btrfs.c:3010
GLbitfield flags
Definition: glext.h:7161
static const BYTE chain10_1[]
Definition: cert.c:1454
static const BYTE childOfExpired[]
Definition: cert.c:1403
static const BYTE chain10_0[]
Definition: cert.c:1425
static const BYTE chain7_1[]
Definition: cert.c:1483
static const BYTE expiredCert[]
Definition: cert.c:1376
static const BYTE cert2[]
Definition: message.c:797
static const BYTE cert1[]
Definition: message.c:781
static HWND child
Definition: cursoricon.c:298
#define CERT_STORE_REVOCATION_FLAG
Definition: wincrypt.h:3618
#define CERT_X500_NAME_STR
Definition: wincrypt.h:3644
#define CERT_STORE_PROV_SYSTEM
Definition: wincrypt.h:2464
#define CERT_STORE_NO_ISSUER_FLAG
Definition: wincrypt.h:3620
#define CERT_STORE_NO_CRL_FLAG
Definition: wincrypt.h:3619
#define CERT_STORE_SIGNATURE_FLAG
Definition: wincrypt.h:3616
#define CERT_SYSTEM_STORE_CURRENT_USER
Definition: wincrypt.h:2528
#define CRYPT_E_SELF_SIGNED
Definition: winerror.h:4424

Referenced by START_TEST().

◆ testGetPublicKeyLength()

static void testGetPublicKeyLength ( void  )
static

Definition at line 4247 of file cert.c.

4248{
4249 static char oid_rsa_rsa[] = szOID_RSA_RSA;
4250 static char oid_rsa_dh[] = szOID_RSA_DH;
4251 static char bogusOID[] = "1.2.3";
4252 DWORD ret;
4253 CERT_PUBLIC_KEY_INFO info = { { 0 } };
4254 BYTE bogusKey[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
4255 BYTE key[] = { 0x30,0x0f,0x02,0x08,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
4256 0x02,0x03,0x01,0x00,0x01 };
4257
4258 /* Crashes
4259 ret = CertGetPublicKeyLength(0, NULL);
4260 */
4261 /* With an empty public key info */
4262 SetLastError(0xdeadbeef);
4265 "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n",
4266 ret, GetLastError());
4267 SetLastError(0xdeadbeef);
4269 ok(ret == 0 && GetLastError() == CRYPT_E_ASN1_EOD,
4270 "Expected length 0 and CRYPT_E_ASN1_EOD, got length %ld, %08lx\n",
4271 ret, GetLastError());
4272 /* With a nearly-empty public key info */
4273 info.Algorithm.pszObjId = oid_rsa_rsa;
4274 SetLastError(0xdeadbeef);
4277 "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n",
4278 ret, GetLastError());
4279 SetLastError(0xdeadbeef);
4281 ok(ret == 0 && GetLastError() == CRYPT_E_ASN1_EOD,
4282 "Expected length 0 and CRYPT_E_ASN1_EOD, got length %ld, %08lx\n",
4283 ret, GetLastError());
4284 /* With a bogus key */
4285 info.PublicKey.cbData = sizeof(bogusKey);
4286 info.PublicKey.pbData = bogusKey;
4287 SetLastError(0xdeadbeef);
4290 "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n",
4291 ret, GetLastError());
4292 SetLastError(0xdeadbeef);
4295 "Expected length 0 and CRYPT_E_ASN1_BADTAGTAG, got length %ld, %08lx\n",
4296 ret, GetLastError());
4297 /* With a believable RSA key but a bogus OID */
4298 info.Algorithm.pszObjId = bogusOID;
4299 info.PublicKey.cbData = sizeof(key);
4300 info.PublicKey.pbData = key;
4301 SetLastError(0xdeadbeef);
4304 "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n",
4305 ret, GetLastError());
4306 SetLastError(0xdeadbeef);
4308 ok(ret == 56 || broken(ret == 0 && GetLastError() == NTE_BAD_LEN) /* Win7 */,
4309 "Expected length 56, got %ld\n", ret);
4310 /* An RSA key with the DH OID */
4311 info.Algorithm.pszObjId = oid_rsa_dh;
4312 SetLastError(0xdeadbeef);
4315 "Expected length 0 and CRYPT_E_ASN1_BADTAG, got length %ld, %08lx\n",
4316 ret, GetLastError());
4317 /* With the RSA OID */
4318 info.Algorithm.pszObjId = oid_rsa_rsa;
4319 SetLastError(0xdeadbeef);
4321 ok(ret == 56 || broken(ret == 0 && GetLastError() == NTE_BAD_LEN) /* Win7 */,
4322 "Expected length 56, got %ld\n", ret);
4323 /* With the RSA OID and a message encoding */
4324 info.Algorithm.pszObjId = oid_rsa_rsa;
4325 SetLastError(0xdeadbeef);
4327 ok(ret == 56 || broken(ret == 0 && GetLastError() == NTE_BAD_LEN) /* Win7 */,
4328 "Expected length 56, got %ld\n", ret);
4329}
#define broken(x)
Definition: atltest.h:178
DWORD WINAPI CertGetPublicKeyLength(DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pPublicKey)
Definition: cert.c:1305
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define szOID_RSA_DH
Definition: wincrypt.h:3180
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2503
#define NTE_BAD_LEN
Definition: winerror.h:4251

Referenced by START_TEST().

◆ testGetSubjectCert()

static void testGetSubjectCert ( void  )
static

Definition at line 1318 of file cert.c.

1319{
1320 HCERTSTORE store;
1321 PCCERT_CONTEXT context1, context2;
1322 CERT_INFO info = { 0 };
1323 BOOL ret;
1324
1327 ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
1328 if (!store)
1329 return;
1330
1333 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
1334
1336 bigCert2, sizeof(bigCert2), CERT_STORE_ADD_NEW, &context1);
1337 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1338 GetLastError());
1339 ok(context1 != NULL, "Expected a context\n");
1342 ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
1343 GetLastError());
1344
1346 NULL);
1347 ok(!context2 && GetLastError() == E_INVALIDARG,
1348 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1350 &info);
1351 ok(!context2 && GetLastError() == CRYPT_E_NOT_FOUND,
1352 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
1353 info.SerialNumber.cbData = sizeof(serialNum);
1354 info.SerialNumber.pbData = serialNum;
1356 &info);
1357 ok(!context2 && GetLastError() == CRYPT_E_NOT_FOUND,
1358 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
1359 info.Issuer.cbData = sizeof(subjectName2);
1360 info.Issuer.pbData = subjectName2;
1362 &info);
1363 ok(context2 != NULL,
1364 "CertGetSubjectCertificateFromStore failed: %08lx\n", GetLastError());
1365 /* Not only should this find a context, but it should be the same
1366 * (same address) as context1.
1367 */
1368 ok(context1 == context2, "Expected identical context addresses\n");
1370
1372 CertCloseStore(store, 0);
1373}
PCCERT_CONTEXT WINAPI CertGetSubjectCertificateFromStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, PCERT_INFO pCertId)
Definition: cert.c:1831

Referenced by START_TEST().

◆ testGetValidUsages()

static void testGetValidUsages ( void  )
static

Definition at line 2859 of file cert.c.

2860{
2861 static const LPCSTR expectedOIDs[] = {
2862 "1.3.6.1.5.5.7.3.3",
2863 "1.3.6.1.5.5.7.3.2",
2864 "1.2.840.113549.1.1.1",
2865 };
2866 static const LPCSTR expectedOIDs2[] = {
2867 "1.3.6.1.5.5.7.3.2",
2868 "1.2.840.113549.1.1.1",
2869 };
2870 BOOL ret;
2871 int numOIDs;
2872 DWORD size;
2873 LPSTR *oids = NULL;
2874 PCCERT_CONTEXT contexts[3];
2875
2876 /* Crash
2877 ret = CertGetValidUsages(0, NULL, NULL, NULL, NULL);
2878 ret = CertGetValidUsages(0, NULL, NULL, NULL, &size);
2879 */
2880 contexts[0] = NULL;
2881 size = numOIDs = 0xdeadbeef;
2882 SetLastError(0xdeadbeef);
2883 ret = CertGetValidUsages(1, &contexts[0], &numOIDs, NULL, &size);
2884 ok(ret, "CertGetValidUsages failed: %ld\n", GetLastError());
2885 ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs);
2886 ok(size == 0, "Expected size 0, got %ld\n", size);
2888 sizeof(bigCert));
2890 sizeof(certWithUsage));
2893 size = numOIDs = 0xdeadbeef;
2894 ret = CertGetValidUsages(0, NULL, &numOIDs, NULL, &size);
2895 ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
2896 ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs);
2897 ok(size == 0, "Expected size 0, got %ld\n", size);
2898 size = numOIDs = 0xdeadbeef;
2899 ret = CertGetValidUsages(1, contexts, &numOIDs, NULL, &size);
2900 ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
2901 ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs);
2902 ok(size == 0, "Expected size 0, got %ld\n", size);
2903 ret = CertGetValidUsages(1, &contexts[1], &numOIDs, NULL, &size);
2904 ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
2905 ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs);
2906 ok(size, "Expected non-zero size\n");
2907 oids = malloc(size);
2908 if (oids)
2909 {
2910 int i;
2911 DWORD smallSize = 1;
2912
2913 SetLastError(0xdeadbeef);
2914 ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &smallSize);
2916 "Expected ERROR_MORE_DATA, got %ld\n", GetLastError());
2917 ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size);
2918 ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
2919 for (i = 0; i < numOIDs; i++)
2920 ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n",
2921 oids[i]);
2922 free(oids);
2923 }
2924 numOIDs = 0xdeadbeef;
2925 /* Oddly enough, this crashes when the number of contexts is not 1:
2926 ret = CertGetValidUsages(2, contexts, &numOIDs, NULL, &size);
2927 * but setting size to 0 allows it to succeed:
2928 */
2929 size = 0;
2930 ret = CertGetValidUsages(2, contexts, &numOIDs, NULL, &size);
2931 ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
2932 ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs);
2933 ok(size, "Expected non-zero size\n");
2934 oids = malloc(size);
2935 if (oids)
2936 {
2937 int i;
2938
2939 ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size);
2940 ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
2941 for (i = 0; i < numOIDs; i++)
2942 ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n",
2943 oids[i]);
2944 free(oids);
2945 }
2946 numOIDs = 0xdeadbeef;
2947 size = 0;
2948 ret = CertGetValidUsages(1, &contexts[2], &numOIDs, NULL, &size);
2949 ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
2950 ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs);
2951 ok(size, "Expected non-zero size\n");
2952 oids = malloc(size);
2953 if (oids)
2954 {
2955 int i;
2956
2957 ret = CertGetValidUsages(1, &contexts[2], &numOIDs, oids, &size);
2958 ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
2959 for (i = 0; i < numOIDs; i++)
2960 ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n",
2961 oids[i]);
2962 free(oids);
2963 }
2964 numOIDs = 0xdeadbeef;
2965 size = 0;
2966 ret = CertGetValidUsages(3, contexts, &numOIDs, NULL, &size);
2967 ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
2968 ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs);
2969 ok(size, "Expected non-zero size\n");
2970 oids = malloc(size);
2971 if (oids)
2972 {
2973 int i;
2974
2975 ret = CertGetValidUsages(3, contexts, &numOIDs, oids, &size);
2976 ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
2977 for (i = 0; i < numOIDs; i++)
2978 ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n",
2979 oids[i]);
2980 free(oids);
2981 }
2982 CertFreeCertificateContext(contexts[0]);
2983 CertFreeCertificateContext(contexts[1]);
2984 CertFreeCertificateContext(contexts[2]);
2985}
BOOL WINAPI CertGetValidUsages(DWORD cCerts, PCCERT_CONTEXT *rghCerts, int *cNumOIDs, LPSTR *rghOIDs, DWORD *pcbOIDs)
Definition: cert.c:3159
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4198
static const BYTE cert2WithUsage[]
Definition: cert.c:2847
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182

Referenced by START_TEST().

◆ testHashPublicKeyInfo()

static void testHashPublicKeyInfo ( void  )
static

Definition at line 3371 of file cert.c.

3372{
3373 BOOL ret;
3374 CERT_PUBLIC_KEY_INFO info = { { 0 } };
3375 DWORD len;
3376
3377 /* Crash
3378 ret = CryptHashPublicKeyInfo(0, 0, 0, 0, NULL, NULL, NULL);
3379 ret = CryptHashPublicKeyInfo(0, 0, 0, 0, &info, NULL, NULL);
3380 */
3381 ret = CryptHashPublicKeyInfo(0, 0, 0, 0, NULL, NULL, &len);
3383 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
3384
3385 if (0) /* crash */
3386 {
3389 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
3390 }
3392 ok(ret, "CryptHashPublicKeyInfo failed: %08lx\n", GetLastError());
3393 if (ret)
3394 {
3395 ok(len == 16, "Expected hash size 16, got %ld\n", len);
3396 if (len == 16)
3397 {
3398 static const BYTE emptyHash[] = { 0xb8,0x51,0x3a,0x31,0x0e,0x9f,0x40,
3399 0x36,0x9c,0x92,0x45,0x1b,0x9d,0xc8,0xf9,0xf6 };
3400 BYTE buf[16];
3401
3403 &len);
3404 ok(ret, "CryptHashPublicKeyInfo failed: %08lx\n", GetLastError());
3405 ok(!memcmp(buf, emptyHash, len), "Unexpected hash\n");
3406 }
3407 }
3408}
BOOL WINAPI CryptHashPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, BYTE *pbComputedHash, DWORD *pcbComputedHash)
Definition: cert.c:2216
GLenum GLsizei len
Definition: glext.h:6722

Referenced by START_TEST().

◆ testHashToBeSigned()

static void testHashToBeSigned ( void  )
static

Definition at line 3413 of file cert.c.

3414{
3415 BOOL ret;
3416 DWORD size;
3417 BYTE hash[16];
3418
3419 /* Crash */
3420 if (0)
3421 {
3422 CryptHashToBeSigned(0, 0, NULL, 0, NULL, NULL);
3423 }
3424 SetLastError(0xdeadbeef);
3425 ret = CryptHashToBeSigned(0, 0, NULL, 0, NULL, &size);
3427 "expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
3428 SetLastError(0xdeadbeef);
3431 "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
3432 /* Can't sign anything: has to be asn.1 encoded, at least */
3433 SetLastError(0xdeadbeef);
3435 NULL, &size);
3437 "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
3438 /* Can't be empty, either */
3439 SetLastError(0xdeadbeef);
3441 sizeof(emptyCert), NULL, &size);
3443 "expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError());
3444 /* Signing a cert works */
3446 sizeof(md5SignedEmptyCert), NULL, &size);
3447 ok(ret, "CryptHashToBeSigned failed: %08lx\n", GetLastError());
3448 if (ret)
3449 {
3450 ok(size == sizeof(md5SignedEmptyCertHash), "unexpected size %ld\n", size);
3451 }
3452
3454 sizeof(md5SignedEmptyCert), hash, &size);
3455 ok(ret, "CryptHashToBeSigned failed: %08lx\n", GetLastError());
3456 ok(!memcmp(hash, md5SignedEmptyCertHash, size), "unexpected value\n");
3457}
BOOL WINAPI CryptHashToBeSigned(HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash)
Definition: cert.c:2260
static BYTE int1[]
Definition: cert.c:3203
static const BYTE md5SignedEmptyCertHash[]
Definition: cert.c:3410
static const BYTE md5SignedEmptyCert[]
Definition: cert.c:2117
#define CRYPT_E_ASN1_CORRUPT
Definition: winerror.h:4502

Referenced by START_TEST().

◆ testIntendedKeyUsage()

static void testIntendedKeyUsage ( void  )
static

Definition at line 2515 of file cert.c.

2516{
2517 BOOL ret;
2518 CERT_INFO info = { 0 };
2519 static char oid_key_usage[] = szOID_KEY_USAGE;
2520 /* A couple "key usages". Really they're just encoded bits which aren't
2521 * necessarily restricted to the defined key usage values.
2522 */
2523 static BYTE usage1[] = { 0x03,0x03,0x00,0xff,0xff };
2524 static BYTE usage2[] = { 0x03,0x03,0x01,0xff,0xfe };
2525 static const BYTE expected_usage1[] = { 0xff,0xff,0x00,0x00 };
2526 static const BYTE expected_usage2[] = { 0xff,0xfe,0x00,0x00 };
2527 CERT_EXTENSION ext = { oid_key_usage, TRUE, { sizeof(usage1), usage1 } };
2528 BYTE usage_bytes[4];
2529
2530 if (0)
2531 {
2532 /* Crash */
2534 }
2536 ok(!ret, "expected failure\n");
2537 ret = CertGetIntendedKeyUsage(0, &info, usage_bytes, sizeof(usage_bytes));
2538 ok(!ret, "expected failure\n");
2540 ok(!ret, "expected failure\n");
2542 sizeof(usage_bytes));
2543 ok(!ret, "expected failure\n");
2544 info.cExtension = 1;
2545 info.rgExtension = &ext;
2547 ok(!ret, "expected failure\n");
2548 /* The unused bytes are filled with 0. */
2550 sizeof(usage_bytes));
2551 ok(ret, "CertGetIntendedKeyUsage failed: %08lx\n", GetLastError());
2552 ok(!memcmp(usage_bytes, expected_usage1, sizeof(expected_usage1)),
2553 "unexpected value\n");
2554 /* The usage bytes are copied in big-endian order. */
2555 ext.Value.cbData = sizeof(usage2);
2556 ext.Value.pbData = usage2;
2558 sizeof(usage_bytes));
2559 ok(ret, "CertGetIntendedKeyUsage failed: %08lx\n", GetLastError());
2560 ok(!memcmp(usage_bytes, expected_usage2, sizeof(expected_usage2)),
2561 "unexpected value\n");
2562}
#define TRUE
Definition: types.h:120
BOOL WINAPI CertGetIntendedKeyUsage(DWORD dwCertEncodingType, PCERT_INFO pCertInfo, BYTE *pbKeyUsage, DWORD cbKeyUsage)
Definition: cert.c:2810
static const WCHAR *const ext[]
Definition: module.c:53
#define szOID_KEY_USAGE
Definition: wincrypt.h:3341

Referenced by START_TEST().

◆ testIsRDNAttrsInCertificateName()

static void testIsRDNAttrsInCertificateName ( void  )
static

Definition at line 3080 of file cert.c.

3081{
3082 static char oid_1_2_3[] = "1.2.3";
3083 static char oid_common_name[] = szOID_COMMON_NAME;
3084 static char oid_organization[] = szOID_ORGANIZATION_NAME;
3085 static char juan[] = "Juan Lang";
3086 static char juan_with_leading_space[] = " Juan Lang";
3087 static char juan_with_intermediate_space[] = "Juan Lang";
3088 static char juan_with_trailing_space[] = "Juan Lang ";
3089 static char juan_lower_case[] = "juan lang";
3090 static WCHAR juanW[] = L"Juan Lang";
3091 static char the_wine_project[] = "The Wine Project";
3092 BOOL ret;
3095 CERT_RDN rdn = { 0, NULL };
3096
3097 name.cbData = sizeof(cn);
3098 name.pbData = cn;
3099 if (0)
3100 {
3101 /* Crash */
3104 }
3105 SetLastError(0xdeadbeef);
3108 "expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
3110 ok(ret, "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError());
3111 attr[0].pszObjId = oid_1_2_3;
3112 rdn.rgRDNAttr = attr;
3113 rdn.cRDNAttr = 1;
3114 SetLastError(0xdeadbeef);
3117 "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
3118 attr[0].pszObjId = oid_common_name;
3119 attr[0].dwValueType = CERT_RDN_PRINTABLE_STRING;
3120 attr[0].Value.cbData = strlen(juan);
3121 attr[0].Value.pbData = (BYTE *)juan;
3123 ok(ret, "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError());
3124 /* Again, spaces are not removed for name comparison. */
3125 attr[0].Value.cbData = strlen(juan_with_leading_space);
3126 attr[0].Value.pbData = (BYTE *)juan_with_leading_space;
3127 SetLastError(0xdeadbeef);
3130 "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
3131 attr[0].Value.cbData = strlen(juan_with_intermediate_space);
3132 attr[0].Value.pbData = (BYTE *)juan_with_intermediate_space;
3133 SetLastError(0xdeadbeef);
3136 "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
3137 attr[0].Value.cbData = strlen(juan_with_trailing_space);
3138 attr[0].Value.pbData = (BYTE *)juan_with_trailing_space;
3139 SetLastError(0xdeadbeef);
3142 "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
3143 /* The lower case name isn't matched unless a case insensitive match is
3144 * specified.
3145 */
3146 attr[0].Value.cbData = strlen(juan_lower_case);
3147 attr[0].Value.pbData = (BYTE *)juan_lower_case;
3148 SetLastError(0xdeadbeef);
3151 "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
3154 ok(ret ||
3155 broken(!ret && GetLastError() == CRYPT_E_NO_MATCH), /* Older crypt32 */
3156 "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError());
3157 /* The values don't match unless they have the same RDN type */
3158 attr[0].dwValueType = CERT_RDN_UNICODE_STRING;
3159 attr[0].Value.cbData = lstrlenW(juanW) * sizeof(WCHAR);
3160 attr[0].Value.pbData = (BYTE *)juanW;
3161 SetLastError(0xdeadbeef);
3164 "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
3165 SetLastError(0xdeadbeef);
3169 "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
3170 attr[0].dwValueType = CERT_RDN_IA5_STRING;
3171 attr[0].Value.cbData = strlen(juan);
3172 attr[0].Value.pbData = (BYTE *)juan;
3173 SetLastError(0xdeadbeef);
3176 "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
3177 /* All attributes must be present */
3178 attr[0].dwValueType = CERT_RDN_PRINTABLE_STRING;
3179 attr[0].Value.cbData = strlen(juan);
3180 attr[0].Value.pbData = (BYTE *)juan;
3181 attr[1].pszObjId = oid_organization;
3182 attr[1].dwValueType = CERT_RDN_PRINTABLE_STRING;
3183 attr[1].Value.cbData = strlen(the_wine_project);
3184 attr[1].Value.pbData = (BYTE *)the_wine_project;
3185 rdn.cRDNAttr = 2;
3186 SetLastError(0xdeadbeef);
3189 "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
3190 /* Order also matters */
3191 name.pbData = cnThenO;
3192 name.cbData = sizeof(cnThenO);
3194 ok(ret, "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError());
3195 name.pbData = oThenCN;
3196 name.cbData = sizeof(oThenCN);
3197 SetLastError(0xdeadbeef);
3200 "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
3201}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
BOOL WINAPI CertIsRDNAttrsInCertificateName(DWORD dwCertEncodingType, DWORD dwFlags, PCERT_NAME_BLOB pCertName, PCERT_RDN pRDN)
Definition: cert.c:2131
#define lstrlenW
Definition: compat.h:750
DWORD cRDNAttr
Definition: wincrypt.h:271
PCERT_RDN_ATTR rgRDNAttr
Definition: wincrypt.h:272
Definition: cookie.c:202
#define CERT_RDN_IA5_STRING
Definition: wincrypt.h:2931
#define CERT_RDN_PRINTABLE_STRING
Definition: wincrypt.h:2927
#define CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG
Definition: wincrypt.h:2954
#define CERT_UNICODE_IS_RDN_ATTRS_FLAG
Definition: wincrypt.h:2953
#define szOID_COMMON_NAME
Definition: wincrypt.h:3290
#define CERT_RDN_UNICODE_STRING
Definition: wincrypt.h:2939
#define szOID_ORGANIZATION_NAME
Definition: wincrypt.h:3297
#define CRYPT_E_NO_MATCH
Definition: winerror.h:4426

Referenced by START_TEST().

◆ testKeyProvInfo()

static void testKeyProvInfo ( void  )
static

Definition at line 4331 of file cert.c.

4332{
4333 static WCHAR containerW[] = L"Wine Test Container";
4334 static WCHAR providerW[] = L"Hello World CSP";
4335 static CRYPT_KEY_PROV_PARAM param[2] = { { 0x4444, (BYTE *)"param", 6, 0x5555 }, { 0x7777, (BYTE *)"param2", 7, 0x8888 } };
4336 HCERTSTORE store;
4337 const CERT_CONTEXT *cert;
4339 CRYPT_KEY_PROV_INFO *info, info2;
4340 BOOL ret;
4341 DWORD size;
4342
4345 ok(store != NULL, "CertOpenStore error %lu\n", GetLastError());
4346
4348 ok(cert != NULL, "CertCreateCertificateContext error %#lx\n", GetLastError());
4349
4350 info2.pwszContainerName = containerW;
4351 info2.pwszProvName = providerW;
4352 info2.dwProvType = 0x12345678;
4353 info2.dwFlags = 0x87654321;
4354 info2.cProvParam = ARRAY_SIZE(param);
4355 info2.rgProvParam = param;
4356 info2.dwKeySpec = 0x11223344;
4358 ok(ret, "CertSetCertificateContextProperty error %#lx\n", GetLastError());
4359
4361 ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
4362 info = malloc(size);
4364 ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
4365 ok(!lstrcmpW(info->pwszContainerName, containerW), "got %s\n", wine_dbgstr_w(info->pwszContainerName));
4366 ok(!lstrcmpW(info->pwszProvName, providerW), "got %s\n", wine_dbgstr_w(info->pwszProvName));
4367 ok(info->dwProvType == 0x12345678, "got %#lx\n", info->dwProvType);
4368 ok(info->dwFlags == 0x87654321, "got %#lx\n", info->dwFlags);
4369 ok(info->dwKeySpec == 0x11223344, "got %#lx\n", info->dwKeySpec);
4370 ok(info->cProvParam == 2, "got %#lx\n", info->cProvParam);
4371 ok(info->rgProvParam != NULL, "got %p\n", info->rgProvParam);
4372 ok(info->rgProvParam[0].dwParam == param[0].dwParam, "got %#lx\n", info->rgProvParam[0].dwParam);
4373 ok(info->rgProvParam[0].cbData == param[0].cbData, "got %#lx\n", info->rgProvParam[0].cbData);
4374 ok(!memcmp(info->rgProvParam[0].pbData, param[0].pbData, param[0].cbData), "param1 mismatch\n");
4375 ok(info->rgProvParam[0].dwFlags == param[0].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags);
4376 ok(info->rgProvParam[1].dwParam == param[1].dwParam, "got %#lx\n", info->rgProvParam[1].dwParam);
4377 ok(info->rgProvParam[1].cbData == param[1].cbData, "got %#lx\n", info->rgProvParam[1].cbData);
4378 ok(!memcmp(info->rgProvParam[1].pbData, param[1].pbData, param[1].cbData), "param2 mismatch\n");
4379 ok(info->rgProvParam[1].dwFlags == param[1].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags);
4380 free(info);
4381
4383 ok(ret, "CertAddCertificateContextToStore error %#lx\n", GetLastError());
4384
4386 CertCloseStore(store, 0);
4387
4390 ok(store != NULL, "CertOpenStore error %lu\n", GetLastError());
4391
4392 name.pbData = subjectName;
4393 name.cbData = sizeof(subjectName);
4395 ok(cert != NULL, "certificate should exist in My store\n");
4396
4398 ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
4399 info = malloc(size);
4401 ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
4402 ok(!lstrcmpW(info->pwszContainerName, containerW), "got %s\n", wine_dbgstr_w(info->pwszContainerName));
4403 ok(!lstrcmpW(info->pwszProvName, providerW), "got %s\n", wine_dbgstr_w(info->pwszProvName));
4404 ok(info->dwProvType == 0x12345678, "got %#lx\n", info->dwProvType);
4405 ok(info->dwFlags == 0x87654321, "got %#lx\n", info->dwFlags);
4406 ok(info->dwKeySpec == 0x11223344, "got %#lx\n", info->dwKeySpec);
4407 ok(info->cProvParam == 2, "got %#lx\n", info->cProvParam);
4408 ok(info->rgProvParam != NULL, "got %p\n", info->rgProvParam);
4409 ok(info->rgProvParam[0].dwParam == param[0].dwParam, "got %#lx\n", info->rgProvParam[0].dwParam);
4410 ok(info->rgProvParam[0].cbData == param[0].cbData, "got %#lx\n", info->rgProvParam[0].cbData);
4411 ok(!memcmp(info->rgProvParam[0].pbData, param[0].pbData, param[0].cbData), "param1 mismatch\n");
4412 ok(info->rgProvParam[0].dwFlags == param[0].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags);
4413 ok(info->rgProvParam[1].dwParam == param[1].dwParam, "got %#lx\n", info->rgProvParam[1].dwParam);
4414 ok(info->rgProvParam[1].cbData == param[1].cbData, "got %#lx\n", info->rgProvParam[1].cbData);
4415 ok(!memcmp(info->rgProvParam[1].pbData, param[1].pbData, param[1].cbData), "param2 mismatch\n");
4416 ok(info->rgProvParam[1].dwFlags == param[1].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags);
4417 free(info);
4418
4420 ok(ret, "CertDeleteCertificateFromStore error %#lx\n", GetLastError());
4421
4423 CertCloseStore(store, 0);
4424}
GLfloat param
Definition: glext.h:5796
#define wine_dbgstr_w
Definition: kernel32.h:34
#define CERT_STORE_OPEN_EXISTING_FLAG
Definition: wincrypt.h:2634
#define CERT_STORE_PROV_SYSTEM_A
Definition: wincrypt.h:2462

Referenced by START_TEST().

◆ testKeyUsage()

static void testKeyUsage ( void  )
static

Definition at line 2567 of file cert.c.

2568{
2569 BOOL ret;
2571 DWORD size;
2572
2573 /* Test base cases */
2576 "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
2577 size = 1;
2580 "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
2581 size = 0;
2584 "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
2585 /* These crash
2586 ret = CertSetEnhancedKeyUsage(NULL, NULL);
2587 usage.cUsageIdentifier = 0;
2588 ret = CertSetEnhancedKeyUsage(NULL, &usage);
2589 */
2590 /* Test with a cert with no enhanced key usage extension */
2592 sizeof(bigCert));
2593 ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
2594 GetLastError());
2595 if (context)
2596 {
2597 static const char oid[] = "1.2.3.4";
2598 BYTE buf[sizeof(CERT_ENHKEY_USAGE) + 2 * (sizeof(LPSTR) + sizeof(oid))];
2600
2603 "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
2604 size = 1;
2606 if (ret)
2607 {
2608 /* Windows 2000, ME, or later: even though it succeeded, we expect
2609 * CRYPT_E_NOT_FOUND, which indicates there is no enhanced key
2610 * usage set for this cert (which implies it's valid for all uses.)
2611 */
2613 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
2614 ok(size == sizeof(CERT_ENHKEY_USAGE), "Wrong size %ld\n", size);
2615 ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
2616 ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2617 ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %ld\n",
2618 pUsage->cUsageIdentifier);
2619 }
2620 else
2621 {
2622 /* Windows NT, 95, or 98: it fails, and the last error is
2623 * CRYPT_E_NOT_FOUND.
2624 */
2626 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
2627 }
2628 /* I can add a usage identifier when no key usage has been set */
2630 ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n",
2631 GetLastError());
2632 size = sizeof(buf);
2635 ok(ret && GetLastError() == 0,
2636 "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2637 ok(pUsage->cUsageIdentifier == 1, "Expected 1 usage, got %ld\n",
2638 pUsage->cUsageIdentifier);
2639 if (pUsage->cUsageIdentifier)
2640 ok(!strcmp(pUsage->rgpszUsageIdentifier[0], oid),
2641 "Expected %s, got %s\n", oid, pUsage->rgpszUsageIdentifier[0]);
2642 /* Now set an empty key usage */
2643 pUsage->cUsageIdentifier = 0;
2645 ok(ret, "CertSetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2646 /* Shouldn't find it in the cert */
2647 size = sizeof(buf);
2651 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
2652 /* Should find it as an extended property */
2655 ok(ret && GetLastError() == 0,
2656 "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2657 ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %ld\n",
2658 pUsage->cUsageIdentifier);
2659 /* Should find it as either */
2660 ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
2661 ok(ret && GetLastError() == 0,
2662 "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2663 ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %ld\n",
2664 pUsage->cUsageIdentifier);
2665 /* Add a usage identifier */
2667 ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n",
2668 GetLastError());
2669 size = sizeof(buf);
2670 ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
2671 ok(ret && GetLastError() == 0,
2672 "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2673 ok(pUsage->cUsageIdentifier == 1, "Expected 1 identifier, got %ld\n",
2674 pUsage->cUsageIdentifier);
2675 if (pUsage->cUsageIdentifier)
2676 ok(!strcmp(pUsage->rgpszUsageIdentifier[0], oid),
2677 "Expected %s, got %s\n", oid, pUsage->rgpszUsageIdentifier[0]);
2678 /* Re-adding the same usage identifier succeeds, though it only adds
2679 * a duplicate usage identifier on versions prior to Vista
2680 */
2682 ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n",
2683 GetLastError());
2684 size = sizeof(buf);
2685 ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
2686 ok(ret && GetLastError() == 0,
2687 "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2688 ok(pUsage->cUsageIdentifier == 1 || pUsage->cUsageIdentifier == 2,
2689 "Expected 1 or 2 identifiers, got %ld\n", pUsage->cUsageIdentifier);
2690 if (pUsage->cUsageIdentifier)
2691 ok(!strcmp(pUsage->rgpszUsageIdentifier[0], oid),
2692 "Expected %s, got %s\n", oid, pUsage->rgpszUsageIdentifier[0]);
2693 if (pUsage->cUsageIdentifier >= 2)
2694 ok(!strcmp(pUsage->rgpszUsageIdentifier[1], oid),
2695 "Expected %s, got %s\n", oid, pUsage->rgpszUsageIdentifier[1]);
2696 /* Now set a NULL extended property--this deletes the property. */
2698 ok(ret, "CertSetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2699 SetLastError(0xbaadcafe);
2700 size = sizeof(buf);
2701 ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
2702 ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2704 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
2705
2707 }
2708 /* Now test with a cert with an enhanced key usage extension */
2710 sizeof(certWithUsage));
2711 ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
2712 GetLastError());
2713 if (context)
2714 {
2715 LPBYTE buf = NULL;
2716 DWORD bufSize = 0, i;
2717
2718 /* The size may depend on what flags are used to query it, so I
2719 * realloc the buffer for each test.
2720 */
2723 ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2724 buf = malloc(bufSize);
2725 if (buf)
2726 {
2728
2729 /* Should find it in the cert */
2730 size = bufSize;
2733 ok(ret && GetLastError() == 0,
2734 "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2735 ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n",
2736 pUsage->cUsageIdentifier);
2737 for (i = 0; i < pUsage->cUsageIdentifier; i++)
2739 "Expected %s, got %s\n", keyUsages[i],
2740 pUsage->rgpszUsageIdentifier[i]);
2741 free(buf);
2742 }
2744 ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2745 buf = malloc(bufSize);
2746 if (buf)
2747 {
2749
2750 /* Should find it as either */
2751 size = bufSize;
2752 ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
2753 /* In Windows, GetLastError returns CRYPT_E_NOT_FOUND not found
2754 * here, even though the return is successful and the usage id
2755 * count is positive. I don't enforce that here.
2756 */
2757 ok(ret,
2758 "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2759 ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n",
2760 pUsage->cUsageIdentifier);
2761 for (i = 0; i < pUsage->cUsageIdentifier; i++)
2763 "Expected %s, got %s\n", keyUsages[i],
2764 pUsage->rgpszUsageIdentifier[i]);
2765 free(buf);
2766 }
2767 /* Shouldn't find it as an extended property */
2771 "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
2772 /* Adding a usage identifier overrides the cert's usage!? */
2774 ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n",
2775 GetLastError());
2777 ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2778 buf = malloc(bufSize);
2779 if (buf)
2780 {
2782
2783 /* Should find it as either */
2784 size = bufSize;
2785 ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
2786 ok(ret,
2787 "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2788 ok(pUsage->cUsageIdentifier == 1, "Expected 1 usage, got %ld\n",
2789 pUsage->cUsageIdentifier);
2791 "Expected %s, got %s\n", szOID_RSA_RSA,
2792 pUsage->rgpszUsageIdentifier[0]);
2793 free(buf);
2794 }
2795 /* But querying the cert directly returns its usage */
2798 ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2799 buf = malloc(bufSize);
2800 if (buf)
2801 {
2803
2804 size = bufSize;
2807 ok(ret,
2808 "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2809 ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n",
2810 pUsage->cUsageIdentifier);
2811 for (i = 0; i < pUsage->cUsageIdentifier; i++)
2813 "Expected %s, got %s\n", keyUsages[i],
2814 pUsage->rgpszUsageIdentifier[i]);
2815 free(buf);
2816 }
2817 /* And removing the only usage identifier in the extended property
2818 * results in the cert's key usage being found.
2819 */
2821 ok(ret, "CertRemoveEnhancedKeyUsage failed: %08lx\n", GetLastError());
2823 ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2824 buf = malloc(bufSize);
2825 if (buf)
2826 {
2828
2829 /* Should find it as either */
2830 size = bufSize;
2831 ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
2832 ok(ret,
2833 "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
2834 ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n",
2835 pUsage->cUsageIdentifier);
2836 for (i = 0; i < pUsage->cUsageIdentifier; i++)
2838 "Expected %s, got %s\n", keyUsages[i],
2839 pUsage->rgpszUsageIdentifier[i]);
2840 free(buf);
2841 }
2842
2844 }
2845}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
BOOL WINAPI CertRemoveEnhancedKeyUsageIdentifier(PCCERT_CONTEXT pCertContext, LPCSTR pszUsageIdentifier)
Definition: cert.c:3063
BOOL WINAPI CertSetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, PCERT_ENHKEY_USAGE pUsage)
Definition: cert.c:2952
BOOL WINAPI CertAddEnhancedKeyUsageIdentifier(PCCERT_CONTEXT pCertContext, LPCSTR pszUsageIdentifier)
Definition: cert.c:2978
BOOL WINAPI CertGetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, DWORD dwFlags, PCERT_ENHKEY_USAGE pUsage, DWORD *pcbUsage)
Definition: cert.c:2847
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
GLuint GLsizei bufSize
Definition: glext.h:6040
static const LPCSTR keyUsages[]
Definition: cert.c:2564
DWORD cUsageIdentifier
Definition: wincrypt.h:831
LPSTR * rgpszUsageIdentifier
Definition: wincrypt.h:832
#define CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG
Definition: wincrypt.h:3063
struct _CTL_USAGE CERT_ENHKEY_USAGE
#define CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG
Definition: wincrypt.h:3065
struct _CTL_USAGE * PCERT_ENHKEY_USAGE

Referenced by START_TEST().

◆ testLinkCert()

static void testLinkCert ( void  )
static

Definition at line 740 of file cert.c.

741{
742 const CERT_CONTEXT *context, *link;
743 HCERTSTORE store;
744 BOOL ret;
745
747 ok(context != NULL, "CertCreateCertificateContext failed\n");
748
750 ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
751
753 ok(ret, "CertAddCertificateContextToStore failed\n");
754 ok(link != NULL && link != context, "unexpected storeContext\n");
755 ok(link->hCertStore == store, "unexpected hCertStore\n");
756
757 ok(link->pbCertEncoded == context->pbCertEncoded, "unexpected pbCertEncoded\n");
758 ok(link->cbCertEncoded == context->cbCertEncoded, "unexpected cbCertEncoded\n");
759 ok(link->pCertInfo == context->pCertInfo, "unexpected pCertInfo\n");
760
763 CertCloseStore(store, 0);
764}
const WCHAR * link
Definition: db.cpp:998
BOOL WINAPI CertAddCertificateLinkToStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition, PCCERT_CONTEXT *ppCertContext)
Definition: cert.c:296

Referenced by START_TEST().

◆ testSignAndEncodeCert()

static void testSignAndEncodeCert ( void  )
static

Definition at line 2132 of file cert.c.

2133{
2134 static char oid_rsa_md5rsa[] = szOID_RSA_MD5RSA;
2135 static char oid_rsa_md5[] = szOID_RSA_MD5;
2136 BOOL ret;
2137 DWORD size;
2138 CRYPT_ALGORITHM_IDENTIFIER algID = { 0 };
2139 CERT_INFO info = { 0 };
2140
2141 /* Crash
2142 ret = CryptSignAndEncodeCertificate(0, 0, 0, NULL, NULL, NULL, NULL, NULL,
2143 NULL);
2144 ret = CryptSignAndEncodeCertificate(0, 0, 0, NULL, NULL, NULL, NULL, NULL,
2145 &size);
2146 */
2147 ret = CryptSignAndEncodeCertificate(0, 0, 0, NULL, NULL, &algID, NULL, NULL,
2148 &size);
2150 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
2152 &algID, NULL, NULL, &size);
2154 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
2156 &algID, NULL, NULL, &size);
2158 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
2162 "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
2163
2164 /* Crashes
2165 ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING,
2166 X509_CERT_TO_BE_SIGNED, &info, NULL, NULL, NULL, &size);
2167 */
2169 X509_CERT_TO_BE_SIGNED, &info, &algID, NULL, NULL, &size);
2171 "Expected NTE_BAD_ALGID, got %08lx\n", GetLastError());
2172 algID.pszObjId = oid_rsa_md5rsa;
2174 X509_CERT_TO_BE_SIGNED, &info, &algID, NULL, NULL, &size);
2176 "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08lx\n",
2177 GetLastError());
2178 algID.pszObjId = oid_rsa_md5;
2180 X509_CERT_TO_BE_SIGNED, &info, &algID, NULL, NULL, &size);
2181 /* oid_rsa_md5 not present in some win2k */
2182 if (ret)
2183 {
2184 LPBYTE buf = malloc(size);
2185
2186 if (buf)
2187 {
2189 X509_CERT_TO_BE_SIGNED, &info, &algID, NULL, buf, &size);
2190 ok(ret, "CryptSignAndEncodeCertificate failed: %08lx\n",
2191 GetLastError());
2192 /* Tricky: because the NULL parameters may either be omitted or
2193 * included as an asn.1-encoded NULL (0x05,0x00), two different
2194 * values are allowed.
2195 */
2196 ok(size == sizeof(md5SignedEmptyCert) ||
2197 size == sizeof(md5SignedEmptyCertNoNull), "Unexpected size %ld\n",
2198 size);
2199 if (size == sizeof(md5SignedEmptyCert))
2201 "Unexpected value\n");
2202 else if (size == sizeof(md5SignedEmptyCertNoNull))
2204 "Unexpected value\n");
2205 free(buf);
2206 }
2207 }
2208}
BOOL WINAPI CryptSignAndEncodeCertificate(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm, const void *pvHashAuxInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: cert.c:2364
static const BYTE md5SignedEmptyCertNoNull[]
Definition: cert.c:2124
static char oid_rsa_md5[]
Definition: msg.c:32
#define X509_CERT_TO_BE_SIGNED
Definition: wincrypt.h:3518
#define szOID_RSA_MD5RSA
Definition: wincrypt.h:3174
#define szOID_RSA_MD5
Definition: wincrypt.h:3206
#define NTE_BAD_ALGID
Definition: winerror.h:4255

Referenced by START_TEST().

◆ testSignCert()

static void testSignCert ( HCRYPTPROV  csp,
const CRYPT_DATA_BLOB toBeSigned,
LPCSTR  sigOID,
BYTE sig,
DWORD sigLen 
)
static

Definition at line 1835 of file cert.c.

1837{
1838 BOOL ret;
1839 DWORD size = 0;
1840 CRYPT_ALGORITHM_IDENTIFIER algoID = { NULL, { 0, NULL } };
1841 HCRYPTKEY key;
1842
1843 /* These all crash
1844 ret = CryptSignCertificate(0, 0, 0, NULL, 0, NULL, NULL, NULL, NULL);
1845 ret = CryptSignCertificate(0, 0, 0, NULL, 0, NULL, NULL, NULL, &size);
1846 ret = CryptSignCertificate(0, 0, 0, toBeSigned->pbData, toBeSigned->cbData,
1847 NULL, NULL, NULL, &size);
1848 */
1849 ret = CryptSignCertificate(0, 0, 0, toBeSigned->pbData, toBeSigned->cbData,
1850 &algoID, NULL, NULL, &size);
1851 ok(!ret && GetLastError() == NTE_BAD_ALGID,
1852 "Expected NTE_BAD_ALGID, got %08lx\n", GetLastError());
1853 algoID.pszObjId = (LPSTR)sigOID;
1854 ret = CryptSignCertificate(0, 0, 0, toBeSigned->pbData, toBeSigned->cbData,
1855 &algoID, NULL, NULL, &size);
1856 ok(!ret &&
1858 "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08lx\n",
1859 GetLastError());
1860 ret = CryptSignCertificate(0, AT_SIGNATURE, 0, toBeSigned->pbData,
1861 toBeSigned->cbData, &algoID, NULL, NULL, &size);
1862 ok(!ret &&
1864 "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08lx\n",
1865 GetLastError());
1866
1867 /* No keys exist in the new CSP yet.. */
1868 ret = CryptSignCertificate(csp, AT_SIGNATURE, 0, toBeSigned->pbData,
1869 toBeSigned->cbData, &algoID, NULL, NULL, &size);
1871 NTE_NO_KEY), "Expected NTE_BAD_KEYSET or NTE_NO_KEY, got %08lx\n",
1872 GetLastError());
1873 ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key);
1874 ok(ret, "CryptGenKey failed: %08lx\n", GetLastError());
1875 if (ret)
1876 {
1877 ret = CryptSignCertificate(csp, AT_SIGNATURE, 0, toBeSigned->pbData,
1878 toBeSigned->cbData, &algoID, NULL, NULL, &size);
1879 ok(ret, "CryptSignCertificate failed: %08lx\n", GetLastError());
1880 ok(size <= *sigLen, "Expected size <= %ld, got %ld\n", *sigLen, size);
1881 if (ret)
1882 {
1883 ret = CryptSignCertificate(csp, AT_SIGNATURE, 0, toBeSigned->pbData,
1884 toBeSigned->cbData, &algoID, NULL, sig, &size);
1885 ok(ret, "CryptSignCertificate failed: %08lx\n", GetLastError());
1886 if (ret)
1887 {
1888 *sigLen = size;
1889 verifySig(csp, toBeSigned->pbData, toBeSigned->cbData, sig,
1890 size);
1891 }
1892 }
1894 }
1895}
BOOL WINAPI CryptSignCertificate(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, const BYTE *pbEncodedToBeSigned, DWORD cbEncodedToBeSigned, PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm, const void *pvHashAuxInfo, BYTE *pbSignature, DWORD *pcbSignature)
Definition: cert.c:2305
static void verifySig(HCRYPTPROV csp, const BYTE *toSign, size_t toSignLen, const BYTE *sig, unsigned int sigLen)
Definition: cert.c:1804

Referenced by testCertSigs().

◆ testVerifyCertSig()

static void testVerifyCertSig ( HCRYPTPROV  csp,
const CRYPT_DATA_BLOB toBeSigned,
LPCSTR  sigOID,
const BYTE sig,
DWORD  sigLen 
)
static

Definition at line 1897 of file cert.c.

1899{
1901 LPBYTE cert = NULL;
1902 DWORD size = 0;
1903 BOOL ret;
1904
1907 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
1910 "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
1912 NULL);
1914 "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
1915 info.ToBeSigned.cbData = toBeSigned->cbData;
1916 info.ToBeSigned.pbData = toBeSigned->pbData;
1917 info.SignatureAlgorithm.pszObjId = (LPSTR)sigOID;
1918 info.SignatureAlgorithm.Parameters.cbData = 0;
1919 info.Signature.cbData = sigLen;
1920 info.Signature.pbData = (BYTE *)sig;
1921 info.Signature.cUnusedBits = 0;
1924 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
1925 if (cert)
1926 {
1927 PCERT_PUBLIC_KEY_INFO pubKeyInfo = NULL;
1928 DWORD pubKeySize;
1929
1930 if (0)
1931 {
1932 /* Crashes prior to Vista */
1934 cert, size, NULL);
1935 }
1937 (LPSTR)sigOID, 0, NULL, NULL, &pubKeySize);
1938 pubKeyInfo = malloc(pubKeySize);
1939 if (pubKeyInfo)
1940 {
1942 X509_ASN_ENCODING, (LPSTR)sigOID, 0, NULL, pubKeyInfo,
1943 &pubKeySize);
1944 ok(ret, "CryptExportKey failed: %08lx\n", GetLastError());
1945 if (ret)
1946 {
1948 cert, size, pubKeyInfo);
1949 ok(ret, "CryptVerifyCertificateSignature failed: %08lx\n",
1950 GetLastError());
1951 }
1952 free(pubKeyInfo);
1953 }
1954 LocalFree(cert);
1955 }
1956}

Referenced by testCertSigs().

◆ testVerifyCertSigEx()

static void testVerifyCertSigEx ( HCRYPTPROV  csp,
const CRYPT_DATA_BLOB toBeSigned,
LPCSTR  sigOID,
const BYTE sig,
DWORD  sigLen 
)
static

Definition at line 1958 of file cert.c.

1960{
1962 LPBYTE cert = NULL;
1963 DWORD size = 0;
1964 BOOL ret;
1965
1968 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1969 ret = CryptVerifyCertificateSignatureEx(csp, 0, 0, NULL, 0, NULL, 0, NULL);
1971 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1973 NULL, 0, NULL);
1975 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
1976 /* This crashes
1977 ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING,
1978 CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, NULL, 0, NULL, 0, NULL);
1979 */
1980 info.ToBeSigned.cbData = toBeSigned->cbData;
1981 info.ToBeSigned.pbData = toBeSigned->pbData;
1982 info.SignatureAlgorithm.pszObjId = (LPSTR)sigOID;
1983 info.SignatureAlgorithm.Parameters.cbData = 0;
1984 info.Signature.cbData = sigLen;
1985 info.Signature.pbData = (BYTE *)sig;
1986 info.Signature.cUnusedBits = 0;
1989 ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
1990 if (cert)
1991 {
1992 CRYPT_DATA_BLOB certBlob = { 0, NULL };
1993 PCERT_PUBLIC_KEY_INFO pubKeyInfo = NULL;
1994
1996 CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, 0, NULL, 0, NULL);
1998 "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
1999 certBlob.cbData = 1;
2000 certBlob.pbData = (void *)0xdeadbeef;
2002 CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, 0, NULL, 0, NULL);
2004 "Expected STATUS_ACCESS_VIOLATION, CRYPT_E_ASN1_EOD, OR CRYPT_E_ASN1_BADTAG, got %08lx\n",
2005 GetLastError());
2006
2007 certBlob.cbData = size;
2008 certBlob.pbData = cert;
2010 CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, 0, NULL, 0, NULL);
2012 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2017 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
2018 /* This crashes
2019 ret = CryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING,
2020 CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob,
2021 CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY, NULL, 0, NULL);
2022 */
2024 (LPSTR)sigOID, 0, NULL, NULL, &size);
2025 pubKeyInfo = malloc(size);
2026 if (pubKeyInfo)
2027 {
2029 X509_ASN_ENCODING, (LPSTR)sigOID, 0, NULL, pubKeyInfo, &size);
2030 ok(ret, "CryptExportKey failed: %08lx\n", GetLastError());
2031 if (ret)
2032 {
2036 ok(ret, "CryptVerifyCertificateSignatureEx failed: %08lx\n",
2037 GetLastError());
2038 }
2039 free(pubKeyInfo);
2040 }
2041 LocalFree(cert);
2042 }
2043}
BOOL WINAPI CryptVerifyCertificateSignatureEx(HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, DWORD dwSubjectType, void *pvSubject, DWORD dwIssuerType, void *pvIssuer, DWORD dwFlags, void *pvReserved)
Definition: cert.c:2717
#define CRYPT_VERIFY_CERT_SIGN_ISSUER_NULL
Definition: wincrypt.h:3634
#define CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY
Definition: wincrypt.h:3631
#define CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB
Definition: wincrypt.h:3626

Referenced by testCertSigs().

◆ testVerifyRevocation()

static void testVerifyRevocation ( void  )
static

Definition at line 3888 of file cert.c.

3889{
3890 BOOL ret;
3892 PCCERT_CONTEXT certs[2];
3893 CERT_REVOCATION_PARA revPara = { sizeof(revPara), 0 };
3894
3895 /* Crash
3896 ret = CertVerifyRevocation(0, 0, 0, NULL, 0, NULL, NULL);
3897 */
3898 SetLastError(0xdeadbeef);
3899 ret = CertVerifyRevocation(0, 0, 0, NULL, 0, NULL, &status);
3901 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
3902 status.cbSize = sizeof(status);
3903 ret = CertVerifyRevocation(0, 0, 0, NULL, 0, NULL, &status);
3904 ok(ret, "CertVerifyRevocation failed: %08lx\n", GetLastError());
3905 ret = CertVerifyRevocation(0, 2, 0, NULL, 0, NULL, &status);
3906 ok(ret, "CertVerifyRevocation failed: %08lx\n", GetLastError());
3907 ret = CertVerifyRevocation(2, 0, 0, NULL, 0, NULL, &status);
3908 ok(ret, "CertVerifyRevocation failed: %08lx\n", GetLastError());
3910 sizeof(bigCert));
3911 SetLastError(0xdeadbeef);
3912 ret = CertVerifyRevocation(0, 0, 1, (void **)certs, 0, NULL, &status);
3914 "Expected CRYPT_E_NO_REVOCATION_DLL, got %08lx\n", GetLastError());
3915 SetLastError(0xdeadbeef);
3916 ret = CertVerifyRevocation(0, 2, 1, (void **)certs, 0, NULL, &status);
3918 "Expected CRYPT_E_NO_REVOCATION_DLL, got %08lx\n", GetLastError());
3919
3921
3925 eeCert, sizeof(eeCert));
3926 /* The root cert itself can't be checked for revocation */
3927 SetLastError(0xdeadbeef);
3929 1, (void **)certs, 0, NULL, &status);
3931 "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", GetLastError());
3933 "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", status.dwError);
3934 ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
3935 /* Neither can the end cert */
3936 SetLastError(0xdeadbeef);
3938 1, (void **)&certs[1], 0, NULL, &status);
3940 "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
3941 GetLastError());
3943 "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
3944 status.dwError);
3945 ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
3946 /* Both certs together can't, either (they're not CRLs) */
3947 SetLastError(0xdeadbeef);
3949 2, (void **)certs, 0, NULL, &status);
3951 "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
3952 GetLastError());
3954 "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
3955 status.dwError);
3956 ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
3957 /* Now add a CRL to the hCrlStore */
3962 SetLastError(0xdeadbeef);
3964 2, (void **)certs, 0, &revPara, &status);
3966 "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
3967 GetLastError());
3969 "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
3970 status.dwError);
3971 ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
3972 /* Specifying CERT_VERIFY_REV_CHAIN_FLAG doesn't change things either */
3973 SetLastError(0xdeadbeef);
3975 2, (void **)certs, CERT_VERIFY_REV_CHAIN_FLAG, &revPara, &status);
3977 "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", GetLastError());
3979 "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", status.dwError);
3980 ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
3981 /* Again, specifying the issuer cert: no change */
3982 revPara.pIssuerCert = certs[0];
3983 SetLastError(0xdeadbeef);
3985 1, (void **)&certs[1], 0, &revPara, &status);
3987 "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", GetLastError());
3989 "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", status.dwError);
3990 ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
3991 CertCloseStore(revPara.hCrlStore, 0);
3994
3995 /* OCSP */
3997 memset(&revPara, 0, sizeof(revPara));
3998 revPara.cbSize = sizeof(revPara);
3999 memset(&status, 0x55, sizeof(status));
4000 status.cbSize = sizeof(status);
4001 SetLastError(0xdeadbeef);
4003 0, &revPara, &status);
4004 ok(!ret, "success\n");
4006
4008 sizeof(ocsp_cert_issuer));
4010 0, &revPara, &status);
4011 ok(ret, "got %08lx\n", GetLastError());
4012 ok(!status.dwError, "got %08lx\n", status.dwError);
4013 ok(!status.dwIndex, "got %ld\n", status.dwIndex);
4016}
BOOL WINAPI CertVerifyRevocation(DWORD dwEncodingType, DWORD dwRevType, DWORD cContext, PVOID rgpvContext[], DWORD dwFlags, PCERT_REVOCATION_PARA pRevPara, PCERT_REVOCATION_STATUS pRevStatus)
Definition: cert.c:1934
BOOL WINAPI CertAddEncodedCRLToStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, const BYTE *pbCrlEncoded, DWORD cbCrlEncoded, DWORD dwAddDisposition, PCCRL_CONTEXT *ppCrlContext)
Definition: crl.c:129
static const BYTE ocsp_cert_issuer[]
Definition: cert.c:3783
static const BYTE ocsp_cert[]
Definition: cert.c:3634
static const BYTE rootSignedCRL[]
Definition: cert.c:3612
static const BYTE rootWithKeySignAndCRLSign[]
Definition: cert.c:3547
static const BYTE eeCert[]
Definition: cert.c:3581
HCERTSTORE hCrlStore
Definition: wincrypt.h:919
PCCERT_CONTEXT pIssuerCert
Definition: wincrypt.h:916
#define CERT_CONTEXT_REVOCATION_TYPE
Definition: wincrypt.h:930
#define CERT_VERIFY_REV_CHAIN_FLAG
Definition: wincrypt.h:931
#define CRYPT_E_NO_REVOCATION_DLL
Definition: winerror.h:4434
#define CRYPT_E_NO_REVOCATION_CHECK
Definition: winerror.h:4435
#define CRYPT_E_REVOCATION_OFFLINE
Definition: winerror.h:4436

Referenced by START_TEST().

◆ testVerifySubjectCert()

static void testVerifySubjectCert ( void  )
static

Definition at line 3492 of file cert.c.

3493{
3494 BOOL ret;
3495 DWORD flags;
3496 PCCERT_CONTEXT context1, context2;
3497
3498 /* Crashes
3499 ret = CertVerifySubjectCertificateContext(NULL, NULL, NULL);
3500 */
3501 flags = 0;
3503 ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
3504 GetLastError());
3508 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
3509
3510 flags = 0;
3512 sizeof(bigCert));
3514 ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
3515 GetLastError());
3517 ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
3518 GetLastError());
3519 ret = CertVerifySubjectCertificateContext(context1, context1, &flags);
3520 ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
3521 GetLastError());
3522
3525 SetLastError(0xdeadbeef);
3526 ret = CertVerifySubjectCertificateContext(context1, context2, &flags);
3527 ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
3528 GetLastError());
3530 ret = CertVerifySubjectCertificateContext(context1, context2, &flags);
3531 ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
3532 GetLastError());
3534 "Expected CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG, got %08lx\n",
3535 flags);
3537 ret = CertVerifySubjectCertificateContext(context1, context2, &flags);
3538 ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
3539 GetLastError());
3541 "Expected CERT_STORE_SIGNATURE_FLAG, got %08lx\n", flags);
3543
3545}
BOOL WINAPI CertVerifySubjectCertificateContext(PCCERT_CONTEXT pSubject, PCCERT_CONTEXT pIssuer, DWORD *pdwFlags)
Definition: cert.c:1845

Referenced by START_TEST().

◆ verifySig()

static void verifySig ( HCRYPTPROV  csp,
const BYTE toSign,
size_t  toSignLen,
const BYTE sig,
unsigned int  sigLen 
)
static

Definition at line 1804 of file cert.c.

1806{
1808 BOOL ret = CryptCreateHash(csp, CALG_SHA1, 0, 0, &hash);
1809
1810 ok(ret, "CryptCreateHash failed: %08lx\n", GetLastError());
1811 if (ret)
1812 {
1813 BYTE mySig[64];
1814 DWORD mySigSize = sizeof(mySig);
1815
1816 ret = CryptHashData(hash, toSign, toSignLen, 0);
1817 ok(ret, "CryptHashData failed: %08lx\n", GetLastError());
1818 ret = CryptSignHashA(hash, AT_SIGNATURE, NULL, 0, mySig, &mySigSize);
1819 ok(ret, "CryptSignHash failed: %08lx\n", GetLastError());
1820 if (ret)
1821 {
1822 ok(mySigSize == sigLen, "Expected sig length %d, got %ld\n",
1823 sigLen, mySigSize);
1824 ok(!memcmp(mySig, sig, sigLen), "Unexpected signature\n");
1825 }
1827 }
1828}
BOOL WINAPI CryptSignHashA(HCRYPTHASH hHash, DWORD dwKeySpec, LPCSTR sDescription, DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen)
Definition: crypt.c:1939

Referenced by testSignCert().

Variable Documentation

◆ asnEncodedPublicKey

const BYTE asnEncodedPublicKey[]
static
Initial value:
= {
0x30,0x48,0x02,0x41,0x00,0xe2,0x54,0x3a,0xa7,0x83,0xb1,0x27,0x14,0x3e,0x59,0xbb,
0xb4,0x53,0xe6,0x1f,0xe7,0x5d,0xf1,0x21,0x68,0xad,0x85,0x53,0xdb,0x6b,0x1e,0xeb,
0x65,0x97,0x03,0x86,0x60,0xde,0xf3,0x6c,0x38,0x75,0xe0,0x4c,0x61,0xbb,0xbc,0x62,
0x17,0xa9,0xcd,0x79,0x3f,0x21,0x4e,0x96,0xcb,0x0e,0xdc,0x61,0x94,0x30,0x18,0x10,
0x6b,0xd0,0x1c,0x10,0x79,0x02,0x03,0x01,0x00,0x01 }

Definition at line 4052 of file cert.c.

Referenced by testAcquireCertPrivateKey().

◆ bigCert

const BYTE bigCert[]
static
Initial value:
= { 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06,
0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22,
0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30,
0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30,
0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20,
0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01,
0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01,
0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 }

Definition at line 39 of file cert.c.

Referenced by testAddCert(), testCertProperties(), testDupCert(), testFindCert(), testGetSubjectCert(), testGetValidUsages(), testKeyUsage(), testLinkCert(), testVerifyRevocation(), and testVerifySubjectCert().

◆ bigCert2

const BYTE bigCert2[]
static
Initial value:
= { 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06,
0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13,
0x0a, 0x41, 0x6c, 0x65, 0x78, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22,
0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30,
0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30,
0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x41, 0x6c, 0x65, 0x78, 0x20,
0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01,
0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01,
0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 }

Definition at line 78 of file cert.c.

Referenced by testAddCert(), testFindCert(), and testGetSubjectCert().

◆ bigCert2Hash

BYTE bigCert2Hash[]
static
Initial value:
= { 0x4a, 0x7f, 0x32, 0x1f, 0xcf, 0x3b, 0xc0,
0x87, 0x48, 0x2b, 0xa1, 0x86, 0x54, 0x18, 0xe4, 0x3a, 0x0e, 0x53, 0x7e, 0x2b }

Definition at line 99 of file cert.c.

Referenced by testAddCert().

◆ bigCert2WithDifferentSerial

const BYTE bigCert2WithDifferentSerial[]
static
Initial value:
= { 0x30, 0x7a, 0x02, 0x01,
0x02, 0x30, 0x02, 0x06, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
0x55, 0x04, 0x03, 0x13, 0x0a, 0x41, 0x6c, 0x65, 0x78, 0x20, 0x4c, 0x61, 0x6e,
0x67, 0x00, 0x30, 0x22, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30,
0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30,
0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30,
0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x41,
0x6c, 0x65, 0x78, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02,
0x06, 0x00, 0x03, 0x01, 0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03,
0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff,
0x02, 0x01, 0x01 }

Definition at line 88 of file cert.c.

Referenced by testAddCert().

◆ bigCertHash

BYTE bigCertHash[]
static
Initial value:
= { 0x6e, 0x30, 0x90, 0x71, 0x5f, 0xd9, 0x23,
0x56, 0xeb, 0xae, 0x25, 0x40, 0xe6, 0x22, 0xda, 0x19, 0x26, 0x02, 0xa6, 0x08 }

Definition at line 49 of file cert.c.

Referenced by testFindCert().

◆ bigCertWithDifferentIssuer

const BYTE bigCertWithDifferentIssuer[]
static
Initial value:
= { 0x30, 0x7a, 0x02, 0x01,
0x01, 0x30, 0x02, 0x06, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
0x55, 0x04, 0x03, 0x13, 0x0a, 0x41, 0x6c, 0x65, 0x78, 0x20, 0x4c, 0x61, 0x6e,
0x67, 0x00, 0x30, 0x22, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30,
0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30,
0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30,
0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a,
0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02,
0x06, 0x00, 0x03, 0x01, 0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03,
0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff,
0x02, 0x01, 0x01 }

Definition at line 63 of file cert.c.

Referenced by testAddCert().

◆ bigCertWithDifferentSubject

const BYTE bigCertWithDifferentSubject[]
static
Initial value:
= { 0x30, 0x7a, 0x02, 0x01, 0x02,
0x30, 0x02, 0x06, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55,
0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67,
0x00, 0x30, 0x22, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31,
0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15,
0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x41, 0x6c,
0x65, 0x78, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06,
0x00, 0x03, 0x01, 0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55,
0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02,
0x01, 0x01 }

Definition at line 52 of file cert.c.

Referenced by testAddCert(), and testVerifySubjectCert().

◆ cert2WithUsage

const BYTE cert2WithUsage[]
static
Initial value:
= {
0x30,0x81,0x89,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,
0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,
0x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,
0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
0x67,0x00,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,0xa3,0x25,0x30,0x23,
0x30,0x21,0x06,0x03,0x55,0x1d,0x25,0x01,0x01,0xff,0x04,0x17,0x30,0x15,0x06,
0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x03,0x02,0x06,0x09,0x2a,0x86,0x48,0x86,
0xf7,0x0d,0x01,0x01,0x01 }

Definition at line 2847 of file cert.c.

Referenced by testGetValidUsages().

◆ certWithUsage

const BYTE certWithUsage[]
static
Initial value:
= { 0x30, 0x81, 0x93, 0x02, 0x01, 0x01, 0x30,
0x02, 0x06, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04,
0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00,
0x30, 0x22, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30,
0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31,
0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61,
0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00,
0x03, 0x01, 0x00, 0xa3, 0x2f, 0x30, 0x2d, 0x30, 0x2b, 0x06, 0x03, 0x55, 0x1d,
0x25, 0x01, 0x01, 0xff, 0x04, 0x21, 0x30, 0x1f, 0x06, 0x08, 0x2b, 0x06, 0x01,
0x05, 0x05, 0x07, 0x03, 0x03, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07,
0x03, 0x02, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01 }

Definition at line 102 of file cert.c.

Referenced by testAddCert(), testDupCert(), testFindCert(), testGetSubjectCert(), testGetValidUsages(), and testKeyUsage().

◆ chain10_0

const BYTE chain10_0[]
static
Initial value:
= {
0x30,0x82,0x01,0x9b,0x30,0x82,0x01,0x08,0xa0,0x03,0x02,0x01,0x02,0x02,0x10,
0x4a,0x30,0x3a,0x42,0xa2,0x5a,0xb3,0x93,0x4d,0x94,0x06,0xad,0x6d,0x1c,0x34,
0xe6,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,0x30,0x10,0x31,
0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,0x43,0x65,0x72,0x74,0x31,
0x30,0x1e,0x17,0x0d,0x30,0x36,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,
0x30,0x5a,0x17,0x0d,0x30,0x36,0x31,0x32,0x33,0x31,0x32,0x33,0x35,0x39,0x35,
0x39,0x5a,0x30,0x10,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,
0x43,0x65,0x72,0x74,0x31,0x30,0x81,0x9f,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,
0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8d,0x00,0x30,0x81,0x89,
0x02,0x81,0x81,0x00,0xad,0x7e,0xca,0xf3,0xe5,0x99,0xc2,0x2a,0xca,0x50,0x82,
0x7c,0x2d,0xa4,0x81,0xcd,0x0d,0x0d,0x86,0xd7,0xd8,0xb2,0xde,0xc5,0xc3,0x34,
0x9e,0x07,0x78,0x08,0x11,0x12,0x2d,0x21,0x0a,0x09,0x07,0x14,0x03,0x7a,0xe7,
0x3b,0x58,0xf1,0xde,0x3e,0x01,0x25,0x93,0xab,0x8f,0xce,0x1f,0xc1,0x33,0x91,
0xfe,0x59,0xb9,0x3b,0x9e,0x95,0x12,0x89,0x8e,0xc3,0x4b,0x98,0x1b,0x99,0xc5,
0x07,0xe2,0xdf,0x15,0x4c,0x39,0x76,0x06,0xad,0xdb,0x16,0x06,0x49,0xba,0xcd,
0x0f,0x07,0xd6,0xea,0x27,0xa6,0xfe,0x3d,0x88,0xe5,0x97,0x45,0x72,0xb6,0x1c,
0xc0,0x1c,0xb1,0xa2,0x89,0xe8,0x37,0x9e,0xf6,0x2a,0xcf,0xd5,0x1f,0x2f,0x35,
0x5e,0x8f,0x3a,0x9c,0x61,0xb1,0xf1,0x6c,0xff,0x8c,0xb2,0x2f,0x02,0x03,0x01,
0x00,0x01,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,0x03,0x81,
0x81,0x00,0x85,0x6e,0x35,0x2f,0x2c,0x51,0x4f,0xd6,0x2a,0xe4,0x9e,0xd0,0x4b,
0xe6,0x90,0xfd,0xf7,0x20,0xad,0x76,0x3f,0x93,0xea,0x7f,0x0d,0x1f,0xb3,0x8e,
0xfd,0xe0,0xe1,0xd6,0xd7,0x9c,0x7d,0x46,0x6b,0x15,0x5c,0xe6,0xc9,0x62,0x3b,
0x70,0x4a,0x4b,0xb2,0x82,0xe3,0x55,0x0c,0xc4,0x90,0x44,0x06,0x6c,0x86,0x1c,
0x6d,0x47,0x12,0xda,0x33,0x95,0x5d,0x98,0x43,0xcb,0x7c,0xfa,0x2b,0xee,0xc4,
0x2d,0xc8,0x95,0x33,0x89,0x08,0x3f,0x9f,0x87,0xea,0x20,0x04,0xaf,0x58,0x4b,
0x9d,0xc0,0x7c,0x0a,0x1b,0x05,0x31,0x3b,0xbb,0x13,0x58,0x2e,0x3f,0x61,0x6b,
0x10,0xb4,0xeb,0xb9,0x1a,0x30,0xfd,0xea,0xca,0x29,0x99,0x5f,0x42,0x2b,0x00,
0xb0,0x08,0xc3,0xf0,0xb6,0xd6,0x6b,0xf9,0x35,0x95 }

Definition at line 1425 of file cert.c.

Referenced by testGetIssuerCert().

◆ chain10_1

const BYTE chain10_1[]
static
Initial value:
= {
0x30,0x82,0x01,0x9b,0x30,0x82,0x01,0x08,0xa0,0x03,0x02,0x01,0x02,0x02,0x10,
0xbf,0x99,0x4f,0x14,0x03,0x77,0x44,0xb8,0x49,0x02,0x70,0xa1,0xb8,0x9c,0xa7,
0x24,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,0x30,0x10,0x31,
0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,0x43,0x65,0x72,0x74,0x31,
0x30,0x1e,0x17,0x0d,0x30,0x37,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,
0x30,0x5a,0x17,0x0d,0x30,0x37,0x31,0x32,0x33,0x31,0x32,0x33,0x35,0x39,0x35,
0x39,0x5a,0x30,0x10,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,
0x43,0x65,0x72,0x74,0x31,0x30,0x81,0x9f,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,
0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8d,0x00,0x30,0x81,0x89,
0x02,0x81,0x81,0x00,0xad,0x7e,0xca,0xf3,0xe5,0x99,0xc2,0x2a,0xca,0x50,0x82,
0x7c,0x2d,0xa4,0x81,0xcd,0x0d,0x0d,0x86,0xd7,0xd8,0xb2,0xde,0xc5,0xc3,0x34,
0x9e,0x07,0x78,0x08,0x11,0x12,0x2d,0x21,0x0a,0x09,0x07,0x14,0x03,0x7a,0xe7,
0x3b,0x58,0xf1,0xde,0x3e,0x01,0x25,0x93,0xab,0x8f,0xce,0x1f,0xc1,0x33,0x91,
0xfe,0x59,0xb9,0x3b,0x9e,0x95,0x12,0x89,0x8e,0xc3,0x4b,0x98,0x1b,0x99,0xc5,
0x07,0xe2,0xdf,0x15,0x4c,0x39,0x76,0x06,0xad,0xdb,0x16,0x06,0x49,0xba,0xcd,
0x0f,0x07,0xd6,0xea,0x27,0xa6,0xfe,0x3d,0x88,0xe5,0x97,0x45,0x72,0xb6,0x1c,
0xc0,0x1c,0xb1,0xa2,0x89,0xe8,0x37,0x9e,0xf6,0x2a,0xcf,0xd5,0x1f,0x2f,0x35,
0x5e,0x8f,0x3a,0x9c,0x61,0xb1,0xf1,0x6c,0xff,0x8c,0xb2,0x2f,0x02,0x03,0x01,
0x00,0x01,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,0x03,0x81,
0x81,0x00,0xa8,0xec,0x8c,0x34,0xe7,0x2c,0xdf,0x75,0x87,0xc4,0xf7,0xda,0x71,
0x72,0x29,0xb2,0x48,0xa8,0x2a,0xec,0x7b,0x7d,0x19,0xb9,0x5f,0x1d,0xd9,0x91,
0x2b,0xc4,0x28,0x7e,0xd6,0xb5,0x91,0x69,0xa5,0x8a,0x1a,0x1f,0x97,0x98,0x46,
0x9d,0xdf,0x12,0xf6,0x45,0x62,0xad,0x60,0xb6,0xba,0xb0,0xfd,0xf5,0x9f,0xc6,
0x98,0x05,0x4f,0x4d,0x48,0xdc,0xee,0x69,0xbe,0xb8,0xc4,0xc4,0xd7,0x1b,0xb1,
0x1f,0x64,0xd6,0x45,0xa7,0xdb,0xb3,0x87,0x63,0x0f,0x54,0xe1,0x3a,0x6b,0x57,
0x36,0xd7,0x68,0x65,0xcf,0xda,0x57,0x8d,0xcd,0x84,0x75,0x47,0x26,0x2c,0xef,
0x1e,0x8f,0xc7,0x3b,0xee,0x5d,0x03,0xa6,0xdf,0x3a,0x20,0xb2,0xcc,0xc9,0x09,
0x2c,0xfe,0x2b,0x79,0xb0,0xca,0x2c,0x9a,0x81,0x6b }

Definition at line 1454 of file cert.c.

Referenced by testGetIssuerCert().

◆ chain7_1

const BYTE chain7_1[]
static
Initial value:
= {
0x30,0x82,0x01,0x93,0x30,0x81,0xfd,0xa0,0x03,0x02,0x01,0x02,0x02,0x01,0x01,
0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,
0x30,0x10,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,0x43,0x65,
0x72,0x74,0x31,0x30,0x1e,0x17,0x0d,0x30,0x37,0x30,0x31,0x30,0x31,0x30,0x30,
0x30,0x30,0x30,0x30,0x5a,0x17,0x0d,0x30,0x37,0x31,0x32,0x33,0x31,0x32,0x33,
0x35,0x39,0x35,0x39,0x5a,0x30,0x10,0x31,0x0e,0x30,0x0c,0x06,0x03,0x55,0x04,
0x03,0x13,0x05,0x43,0x65,0x72,0x74,0x32,0x30,0x81,0x9f,0x30,0x0d,0x06,0x09,
0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8d,0x00,
0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xb8,0x52,0xda,0xc5,0x4b,0x3f,0xe5,0x33,
0x0e,0x67,0x5f,0x48,0x21,0xdc,0x7e,0xef,0x37,0x33,0xba,0xff,0xb4,0xc6,0xdc,
0xb6,0x17,0x8e,0x20,0x55,0x07,0x12,0xd2,0x7b,0x3c,0xce,0x30,0xc5,0xa7,0x48,
0x9f,0x6e,0xfe,0xb8,0xbe,0xdb,0x9f,0x9b,0x17,0x60,0x16,0xde,0xc6,0x8b,0x47,
0xd1,0x57,0x71,0x3c,0x93,0xfc,0xbd,0xec,0x44,0x32,0x3b,0xb9,0xcf,0x6b,0x05,
0x72,0xa7,0x87,0x8e,0x7e,0xd4,0x9a,0x87,0x1c,0x2f,0xb7,0x82,0x40,0xfc,0x6a,
0x80,0x83,0x68,0x28,0xce,0x84,0xf4,0x0b,0x2e,0x44,0xcb,0x53,0xac,0x85,0x85,
0xb5,0x46,0x36,0x98,0x3c,0x10,0x02,0xaa,0x02,0xbc,0x8b,0xa2,0x23,0xb2,0xd3,
0x51,0x9a,0x22,0x4a,0xe3,0xaa,0x4e,0x7c,0xda,0x38,0xcf,0x49,0x98,0x72,0xa3,
0x02,0x03,0x01,0x00,0x01,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,
0x01,0x01,0x05,0x05,0x00,0x03,0x81,0x81,0x00,0x9f,0x69,0xfd,0x26,0xd5,0x4b,
0xe0,0xab,0x12,0x21,0xb9,0xfc,0xf7,0xe0,0x0c,0x09,0x94,0xad,0x27,0xd7,0x9d,
0xa3,0xcc,0x46,0x2a,0x25,0x9a,0x24,0xa7,0x31,0x58,0x78,0xf5,0xfc,0x30,0xe1,
0x6d,0xfd,0x59,0xab,0xbe,0x69,0xa0,0xea,0xe3,0x7d,0x7a,0x7b,0xe5,0x85,0xeb,
0x86,0x6a,0x84,0x3c,0x96,0x01,0x1a,0x70,0xa7,0xb8,0xcb,0xf2,0x11,0xe7,0x52,
0x9c,0x58,0x2d,0xac,0x63,0xce,0x72,0x4b,0xad,0x62,0xa8,0x1d,0x75,0x96,0xe2,
0x27,0xf5,0x6f,0xba,0x91,0xf8,0xf1,0xb0,0xbf,0x90,0x24,0x6d,0xba,0x5d,0xd7,
0x39,0x63,0x3b,0x7c,0x04,0x5d,0x89,0x9d,0x1c,0xf2,0xf7,0xcc,0xdf,0x6e,0x8a,
0x43,0xa9,0xdd,0x86,0x05,0xa2,0xf3,0x22,0x2d,0x1e,0x70,0xa1,0x59,0xd7,0xa5,
0x94,0x7d }

Definition at line 1483 of file cert.c.

Referenced by testGetIssuerCert().

◆ childOfExpired

const BYTE childOfExpired[]
static
Initial value:
= { 0x30, 0x81, 0xcc, 0x30, 0x78, 0xa0,
0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86,
0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x1f, 0x31, 0x1d,
0x30, 0x1b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x14, 0x61, 0x72, 0x69, 0x63,
0x40, 0x63, 0x6f, 0x64, 0x65, 0x77, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x2e,
0x63, 0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, 0x30, 0x36, 0x30, 0x35, 0x30, 0x35,
0x31, 0x37, 0x31, 0x32, 0x34, 0x39, 0x5a, 0x17, 0x0d, 0x33, 0x36, 0x30, 0x35,
0x30, 0x35, 0x31, 0x37, 0x31, 0x32, 0x34, 0x39, 0x5a, 0x30, 0x15, 0x31, 0x13,
0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e,
0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03,
0x01, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
0x01, 0x05, 0x05, 0x00, 0x03, 0x41, 0x00, 0x20, 0x3b, 0xdb, 0x4d, 0x67, 0x50,
0xec, 0x73, 0x9d, 0xf9, 0x85, 0x5d, 0x18, 0xe9, 0xb4, 0x98, 0xe3, 0x31, 0xb7,
0x03, 0x0b, 0xc0, 0x39, 0x93, 0x56, 0x81, 0x0a, 0xfc, 0x78, 0xa8, 0x29, 0x42,
0x5f, 0x69, 0xfb, 0xbc, 0x5b, 0xf2, 0xa6, 0x2a, 0xbe, 0x91, 0x2c, 0xfc, 0x89,
0x69, 0x15, 0x18, 0x58, 0xe5, 0x02, 0x75, 0xf7, 0x2a, 0xb6, 0xa9, 0xfb, 0x47,
0x6a, 0x6e, 0x0a, 0x9b, 0xe9, 0xdc }

Definition at line 1403 of file cert.c.

Referenced by testGetIssuerCert().

◆ cn

BYTE cn[]
static
Initial value:
= {
0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,
0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67 }

Definition at line 2987 of file cert.c.

Referenced by csp_qstring(), de_casteljau_surf(), horner_bezier_surf(), MimeSecurity_GetCertificateName(), run_mm(), run_mp(), test_get_inf_class(), testCompareCertName(), testIsRDNAttrsInCertificateName(), and wave_generate_tone().

◆ cnThenO

BYTE cnThenO[]
static
Initial value:
= {
0x30,0x2d,0x31,0x2b,0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,
0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x30,0x17,0x06,0x03,0x55,0x04,0x0a,0x13,
0x10,0x54,0x68,0x65,0x20,0x57,0x69,0x6e,0x65,0x20,0x50,0x72,0x6f,0x6a,0x65,
0x63,0x74 }

Definition at line 2999 of file cert.c.

Referenced by testCompareCertName(), and testIsRDNAttrsInCertificateName().

◆ cnWithIntermediateSpace

BYTE cnWithIntermediateSpace[]
static
Initial value:
= {
0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,
0x61,0x6e,0x20,0x20,0x4c,0x61,0x6e,0x67 }

Definition at line 2996 of file cert.c.

Referenced by testCompareCertName().

◆ cnWithLeadingSpace

BYTE cnWithLeadingSpace[]
static
Initial value:
= {
0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x20,0x4a,
0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67 }

Definition at line 2990 of file cert.c.

Referenced by testCompareCertName().

◆ cnWithTrailingSpace

BYTE cnWithTrailingSpace[]
static
Initial value:
= {
0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,
0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x20 }

Definition at line 2993 of file cert.c.

Referenced by testCompareCertName().

◆ cspNameA

const CHAR cspNameA[] = "WineCryptTemp"
static

Definition at line 311 of file cert.c.

Referenced by testAcquireCertPrivateKey(), testCertSigs(), and testCreateSelfSignCert().

◆ eeCert

const BYTE eeCert[]
static

Definition at line 3581 of file cert.c.

Referenced by testVerifyRevocation().

◆ emptyCert

BYTE emptyCert[] = { 0x30, 0x00 }
static

Definition at line 2045 of file cert.c.

Referenced by testCertSigs(), testCompareCertName(), and testHashToBeSigned().

◆ expiredCert

const BYTE expiredCert[]
static
Initial value:
= { 0x30, 0x82, 0x01, 0x33, 0x30, 0x81, 0xe2,
0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0xc4, 0xd7, 0x7f, 0x0e, 0x6f, 0xa6,
0x8c, 0xaa, 0x47, 0x47, 0x40, 0xe7, 0xb7, 0x0b, 0x4a, 0x7f, 0x30, 0x09, 0x06,
0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1d, 0x05, 0x00, 0x30, 0x1f, 0x31, 0x1d, 0x30,
0x1b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x14, 0x61, 0x72, 0x69, 0x63, 0x40,
0x63, 0x6f, 0x64, 0x65, 0x77, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x63,
0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, 0x36, 0x39, 0x30, 0x31, 0x30, 0x31, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x37, 0x30, 0x30, 0x31, 0x30,
0x31, 0x30, 0x36, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x1f, 0x31, 0x1d, 0x30,
0x1b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x14, 0x61, 0x72, 0x69, 0x63, 0x40,
0x63, 0x6f, 0x64, 0x65, 0x77, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x63,
0x6f, 0x6d, 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00, 0x30, 0x48, 0x02, 0x41,
0x00, 0xa1, 0xaf, 0x4a, 0xea, 0xa7, 0x83, 0x57, 0xc0, 0x37, 0x33, 0x7e, 0x29,
0x5e, 0x0d, 0xfc, 0x44, 0x74, 0x3a, 0x1d, 0xc3, 0x1b, 0x1d, 0x96, 0xed, 0x4e,
0xf4, 0x1b, 0x98, 0xec, 0x69, 0x1b, 0x04, 0xea, 0x25, 0xcf, 0xb3, 0x2a, 0xf5,
0xd9, 0x22, 0xd9, 0x8d, 0x08, 0x39, 0x81, 0xc6, 0xe0, 0x4f, 0x12, 0x37, 0x2a,
0x3f, 0x80, 0xa6, 0x6c, 0x67, 0x43, 0x3a, 0xdd, 0x95, 0x0c, 0xbb, 0x2f, 0x6b,
0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02,
0x1d, 0x05, 0x00, 0x03, 0x41, 0x00, 0x8f, 0xa2, 0x5b, 0xd6, 0xdf, 0x34, 0xd0,
0xa2, 0xa7, 0x47, 0xf1, 0x13, 0x79, 0xd3, 0xf3, 0x39, 0xbd, 0x4e, 0x2b, 0xa3,
0xf4, 0x63, 0x37, 0xac, 0x5a, 0x0c, 0x5e, 0x4d, 0x0d, 0x54, 0x87, 0x4f, 0x31,
0xfb, 0xa0, 0xce, 0x8f, 0x9a, 0x2f, 0x4d, 0x48, 0xc6, 0x84, 0x8d, 0xf5, 0x70,
0x74, 0x17, 0xa5, 0xf3, 0x66, 0x47, 0x06, 0xd6, 0x64, 0x45, 0xbc, 0x52, 0xef,
0x49, 0xe5, 0xf9, 0x65, 0xf3 }

Definition at line 1376 of file cert.c.

Referenced by testGetIssuerCert().

◆ exportedPublicKeyBlob

const BYTE exportedPublicKeyBlob[]
static
Initial value:
= {
0x06,0x02,0x00,0x00,0x00,0xa4,0x00,0x00,0x52,0x53,0x41,0x31,0x00,0x02,0x00,0x00,
0x01,0x00,0x01,0x00,0x79,0x10,0x1c,0xd0,0x6b,0x10,0x18,0x30,0x94,0x61,0xdc,0x0e,
0xcb,0x96,0x4e,0x21,0x3f,0x79,0xcd,0xa9,0x17,0x62,0xbc,0xbb,0x61,0x4c,0xe0,0x75,
0x38,0x6c,0xf3,0xde,0x60,0x86,0x03,0x97,0x65,0xeb,0x1e,0x6b,0xdb,0x53,0x85,0xad,
0x68,0x21,0xf1,0x5d,0xe7,0x1f,0xe6,0x53,0xb4,0xbb,0x59,0x3e,0x14,0x27,0xb1,0x83,
0xa7,0x3a,0x54,0xe2 }

Definition at line 4044 of file cert.c.

Referenced by testAcquireCertPrivateKey().

◆ int1

BYTE int1[] = { 0x88, 0xff, 0xff, 0xff }
static

Definition at line 3203 of file cert.c.

Referenced by IUnknownIsEqual(), test_int_widths(), and testHashToBeSigned().

◆ int2

BYTE int2[] = { 0x88, 0xff }
static

Definition at line 3204 of file cert.c.

Referenced by IUnknownIsEqual(), and test_int_widths().

◆ int3

BYTE int3[] = { 0x23, 0xff }
static

Definition at line 3205 of file cert.c.

◆ int4

BYTE int4[] = { 0x7f, 0x00 }
static

Definition at line 3206 of file cert.c.

Referenced by test_int_widths().

◆ int5

BYTE int5[] = { 0x7f }
static

Definition at line 3207 of file cert.c.

Referenced by test_int_widths().

◆ int6

BYTE int6[] = { 0x80, 0x00, 0x00, 0x00 }
static

Definition at line 3208 of file cert.c.

◆ int7

BYTE int7[] = { 0x80, 0x00 }
static

Definition at line 3209 of file cert.c.

◆ intBlobs

struct IntBlobTest intBlobs[]
static
Initial value:
= {
{ { sizeof(int1), int1 }, { sizeof(int2), int2 }, TRUE },
{ { sizeof(int3), int3 }, { sizeof(int3), int3 }, TRUE },
{ { sizeof(int4), int4 }, { sizeof(int5), int5 }, TRUE },
{ { sizeof(int6), int6 }, { sizeof(int7), int7 }, TRUE },
{ { sizeof(int1), int1 }, { sizeof(int7), int7 }, FALSE },
}
#define FALSE
Definition: types.h:117
static BYTE int7[]
Definition: cert.c:3209
static BYTE int3[]
Definition: cert.c:3205
static BYTE int6[]
Definition: cert.c:3208
static BYTE int5[]
Definition: cert.c:3207
static BYTE int4[]
Definition: cert.c:3206
static BYTE int2[]
Definition: cert.c:3204

Referenced by testCompareIntegerBlob().

◆ iTunesCert0

const BYTE iTunesCert0[]
static

Definition at line 769 of file cert.c.

Referenced by testFindCert().

◆ iTunesCert1

const BYTE iTunesCert1[]
static

Definition at line 835 of file cert.c.

Referenced by testFindCert().

◆ iTunesCert2

const BYTE iTunesCert2[]
static

Definition at line 905 of file cert.c.

Referenced by testFindCert().

◆ iTunesCert3

const BYTE iTunesCert3[]
static

Definition at line 988 of file cert.c.

Referenced by testFindCert().

◆ iTunesIssuer

BYTE iTunesIssuer[]
static
Initial value:
= {
0x30,0x81,0xb4,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,
0x13,0x02,0x55,0x53,0x31,0x17,0x30,0x15,0x06,0x03,0x55,0x04,
0x0a,0x13,0x0e,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6e,0x2c,
0x20,0x49,0x6e,0x63,0x2e,0x31,0x1f,0x30,0x1d,0x06,0x03,0x55,
0x04,0x0b,0x13,0x16,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6e,
0x20,0x54,0x72,0x75,0x73,0x74,0x20,0x4e,0x65,0x74,0x77,0x6f,
0x72,0x6b,0x31,0x3b,0x30,0x39,0x06,0x03,0x55,0x04,0x0b,0x13,
0x32,0x54,0x65,0x72,0x6d,0x73,0x20,0x6f,0x66,0x20,0x75,0x73,
0x65,0x20,0x61,0x74,0x20,0x68,0x74,0x74,0x70,0x73,0x3a,0x2f,
0x2f,0x77,0x77,0x77,0x2e,0x76,0x65,0x72,0x69,0x73,0x69,0x67,
0x6e,0x2e,0x63,0x6f,0x6d,0x2f,0x72,0x70,0x61,0x20,0x28,0x63,
0x29,0x30,0x34,0x31,0x2e,0x30,0x2c,0x06,0x03,0x55,0x04,0x03,
0x13,0x25,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6e,0x20,0x43,
0x6c,0x61,0x73,0x73,0x20,0x33,0x20,0x43,0x6f,0x64,0x65,0x20,
0x53,0x69,0x67,0x6e,0x69,0x6e,0x67,0x20,0x32,0x30,0x30,0x34,
0x20,0x43,0x41 }

Definition at line 1074 of file cert.c.

Referenced by testFindCert().

◆ iTunesSerialNum

BYTE iTunesSerialNum[]
static
Initial value:
= {
0x8d,0xf6,0x6a,0xdf,0xd2,0x40,0xfe,0xb6,0xa6,0x61,0x9b,0x9b,
0xe0,0xa0,0x1a,0x0f }

Definition at line 1091 of file cert.c.

Referenced by testFindCert().

◆ keyUsages

const LPCSTR keyUsages[]
static
Initial value:
#define szOID_PKIX_KP_CLIENT_AUTH
Definition: wincrypt.h:3451
#define szOID_PKIX_KP_CODE_SIGNING
Definition: wincrypt.h:3452

Definition at line 2564 of file cert.c.

Referenced by testKeyUsage().

◆ md5SignedEmptyCert

const BYTE md5SignedEmptyCert[]
static
Initial value:
= {
0x30,0x56,0x30,0x33,0x02,0x00,0x30,0x02,0x06,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,
0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,
0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x07,
0x30,0x02,0x06,0x00,0x03,0x01,0x00,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,
0x0d,0x02,0x05,0x05,0x00,0x03,0x11,0x00,0xfb,0x0f,0x66,0x82,0x66,0xd9,0xe5,0xf8,
0xd8,0xa2,0x55,0x2b,0xe1,0xa5,0xd9,0x04 }

Definition at line 2117 of file cert.c.

Referenced by testHashToBeSigned(), and testSignAndEncodeCert().

◆ md5SignedEmptyCertHash

const BYTE md5SignedEmptyCertHash[]
static
Initial value:
= { 0xfb,0x0f,0x66,0x82,0x66,0xd9,
0xe5,0xf8,0xd8,0xa2,0x55,0x2b,0xe1,0xa5,0xd9,0x04 }

Definition at line 3410 of file cert.c.

Referenced by testHashToBeSigned().

◆ md5SignedEmptyCertNoNull

const BYTE md5SignedEmptyCertNoNull[]
static
Initial value:
= {
0x30,0x54,0x30,0x33,0x02,0x00,0x30,0x02,0x06,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,
0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,
0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x07,
0x30,0x02,0x06,0x00,0x03,0x01,0x00,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,
0x0d,0x02,0x05,0x03,0x11,0x00,0x04,0xd9,0xa5,0xe1,0x2b,0x55,0xa2,0xd8,0xf8,0xe5,
0xd9,0x66,0x82,0x66,0x0f,0xfb }

Definition at line 2124 of file cert.c.

Referenced by testSignAndEncodeCert().

◆ ocsp_cert

const BYTE ocsp_cert[]
static

Definition at line 3634 of file cert.c.

Referenced by testVerifyRevocation().

◆ ocsp_cert_issuer

const BYTE ocsp_cert_issuer[]
static

Definition at line 3783 of file cert.c.

Referenced by testVerifyRevocation().

◆ oThenCN

BYTE oThenCN[]
static
Initial value:
= {
0x30,0x2d,0x31,0x2b,0x30,0x10,0x06,0x03,0x55,0x04,0x0a,0x13,0x09,0x4a,0x75,
0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x30,0x17,0x06,0x03,0x55,0x04,0x03,0x13,
0x10,0x54,0x68,0x65,0x20,0x57,0x69,0x6e,0x65,0x20,0x50,0x72,0x6f,0x6a,0x65,
0x63,0x74 }

Definition at line 3004 of file cert.c.

Referenced by testCompareCertName(), and testIsRDNAttrsInCertificateName().

◆ privKey

BYTE privKey[]
static
Initial value:
= {
0x07, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41, 0x32, 0x00,
0x02, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x79, 0x10, 0x1c, 0xd0, 0x6b, 0x10,
0x18, 0x30, 0x94, 0x61, 0xdc, 0x0e, 0xcb, 0x96, 0x4e, 0x21, 0x3f, 0x79, 0xcd,
0xa9, 0x17, 0x62, 0xbc, 0xbb, 0x61, 0x4c, 0xe0, 0x75, 0x38, 0x6c, 0xf3, 0xde,
0x60, 0x86, 0x03, 0x97, 0x65, 0xeb, 0x1e, 0x6b, 0xdb, 0x53, 0x85, 0xad, 0x68,
0x21, 0xf1, 0x5d, 0xe7, 0x1f, 0xe6, 0x53, 0xb4, 0xbb, 0x59, 0x3e, 0x14, 0x27,
0xb1, 0x83, 0xa7, 0x3a, 0x54, 0xe2, 0x8f, 0x65, 0x8e, 0x6a, 0x4a, 0xcf, 0x3b,
0x1f, 0x65, 0xff, 0xfe, 0xf1, 0x31, 0x3a, 0x37, 0x7a, 0x8b, 0xcb, 0xc6, 0xd4,
0x98, 0x50, 0x36, 0x67, 0xe4, 0xa1, 0xe8, 0x7e, 0x8a, 0xc5, 0x23, 0xf2, 0x77,
0xf5, 0x37, 0x61, 0x49, 0x72, 0x59, 0xe8, 0x3d, 0xf7, 0x60, 0xb2, 0x77, 0xca,
0x78, 0x54, 0x6d, 0x65, 0x9e, 0x03, 0x97, 0x1b, 0x61, 0xbd, 0x0c, 0xd8, 0x06,
0x63, 0xe2, 0xc5, 0x48, 0xef, 0xb3, 0xe2, 0x6e, 0x98, 0x7d, 0xbd, 0x4e, 0x72,
0x91, 0xdb, 0x31, 0x57, 0xe3, 0x65, 0x3a, 0x49, 0xca, 0xec, 0xd2, 0x02, 0x4e,
0x22, 0x7e, 0x72, 0x8e, 0xf9, 0x79, 0x84, 0x82, 0xdf, 0x7b, 0x92, 0x2d, 0xaf,
0xc9, 0xe4, 0x33, 0xef, 0x89, 0x5c, 0x66, 0x99, 0xd8, 0x80, 0x81, 0x47, 0x2b,
0xb1, 0x66, 0x02, 0x84, 0x59, 0x7b, 0xc3, 0xbe, 0x98, 0x45, 0x4a, 0x3d, 0xdd,
0xea, 0x2b, 0xdf, 0x4e, 0xb4, 0x24, 0x6b, 0xec, 0xe7, 0xd9, 0x0c, 0x45, 0xb8,
0xbe, 0xca, 0x69, 0x37, 0x92, 0x4c, 0x38, 0x6b, 0x96, 0x6d, 0xcd, 0x86, 0x67,
0x5c, 0xea, 0x54, 0x94, 0xa4, 0xca, 0xa4, 0x02, 0xa5, 0x21, 0x4d, 0xae, 0x40,
0x8f, 0x9d, 0x51, 0x83, 0xf2, 0x3f, 0x33, 0xc1, 0x72, 0xb4, 0x1d, 0x94, 0x6e,
0x7d, 0xe4, 0x27, 0x3f, 0xea, 0xff, 0xe5, 0x9b, 0xa7, 0x5e, 0x55, 0x8e, 0x0d,
0x69, 0x1c, 0x7a, 0xff, 0x81, 0x9d, 0x53, 0x52, 0x97, 0x9a, 0x76, 0x79, 0xda,
0x93, 0x32, 0x16, 0xec, 0x69, 0x51, 0x1a, 0x4e, 0xc3, 0xf1, 0x72, 0x80, 0x78,
0x5e, 0x66, 0x4a, 0x8d, 0x85, 0x2f, 0x3f, 0xb2, 0xa7 }

Definition at line 4018 of file cert.c.

Referenced by testAcquireCertPrivateKey().

◆ rootSignedCRL

const BYTE rootSignedCRL[]
static
Initial value:
= {
0x30,0x82,0x01,0x1f,0x30,0x81,0x89,0x02,0x01,0x01,0x30,0x0d,0x06,0x09,0x2a,
0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x10,0x31,0x0e,0x30,
0x0c,0x06,0x03,0x55,0x04,0x03,0x13,0x05,0x43,0x65,0x72,0x74,0x31,0x17,0x0d,
0x30,0x37,0x30,0x39,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x17,0x0d,
0x30,0x37,0x31,0x32,0x33,0x31,0x32,0x33,0x35,0x39,0x35,0x39,0x5a,0x30,0x14,
0x30,0x12,0x02,0x01,0x01,0x17,0x0d,0x30,0x37,0x30,0x39,0x30,0x31,0x30,0x30,
0x30,0x30,0x30,0x30,0x5a,0xa0,0x2f,0x30,0x2d,0x30,0x0a,0x06,0x03,0x55,0x1d,
0x14,0x04,0x03,0x02,0x01,0x01,0x30,0x1f,0x06,0x03,0x55,0x1d,0x23,0x04,0x18,
0x30,0x18,0x80,0x14,0x14,0x8c,0x16,0xbb,0xbe,0x70,0xa2,0x28,0x89,0xa0,0x58,
0xff,0x98,0xbd,0xa8,0x24,0x2b,0x8a,0xe9,0x9a,0x30,0x0d,0x06,0x09,0x2a,0x86,
0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x03,0x81,0x81,0x00,0xa3,0xcf,
0x17,0x5d,0x7a,0x08,0xab,0x11,0x1a,0xbd,0x5c,0xde,0x9a,0x22,0x92,0x38,0xe6,
0x96,0xcc,0xb1,0xc5,0x42,0x86,0xa6,0xae,0xad,0xa3,0x1a,0x2b,0xa0,0xb0,0x65,
0xaa,0x9c,0xd7,0x2d,0x44,0x8c,0xae,0x61,0xc7,0x30,0x17,0x89,0x84,0x3b,0x4a,
0x8f,0x17,0x08,0x06,0x37,0x1c,0xf7,0x2d,0x4e,0x47,0x07,0x61,0x50,0xd9,0x06,
0xd1,0x46,0xed,0x0a,0xbb,0xc3,0x9b,0x36,0x0b,0xa7,0x27,0x2f,0x2b,0x55,0xce,
0x2a,0xa5,0x60,0xc6,0x53,0x28,0xe8,0xee,0xad,0x0e,0x2b,0xe8,0xd7,0x5f,0xc9,
0xa5,0xed,0xf9,0x77,0xb0,0x3c,0x81,0xcf,0xcc,0x49,0xb2,0x1a,0xc3,0xfd,0x34,
0xd5,0xbc,0xb0,0xd5,0xa5,0x9c,0x1b,0x72,0xc3,0x0f,0xa3,0xe3,0x3c,0xf0,0xc3,
0x91,0xe8,0x93,0x4f,0xd4,0x2f }

Definition at line 3612 of file cert.c.

Referenced by testVerifyRevocation().

◆ rootWithKeySignAndCRLSign

const BYTE rootWithKeySignAndCRLSign[]
static

Definition at line 3547 of file cert.c.

Referenced by testVerifyRevocation().

◆ self_signed_ecc_prime256v1

const BYTE self_signed_ecc_prime256v1[]
static

Definition at line 2052 of file cert.c.

Referenced by testCertSigs().

◆ selfSignedCert

const BYTE selfSignedCert[]
static
Initial value:
= {
0x30, 0x82, 0x01, 0x1f, 0x30, 0x81, 0xce, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02,
0x10, 0xeb, 0x0d, 0x57, 0x2a, 0x9c, 0x09, 0xba, 0xa4, 0x4a, 0xb7, 0x25, 0x49,
0xd9, 0x3e, 0xb5, 0x73, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1d,
0x05, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03,
0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30,
0x1e, 0x17, 0x0d, 0x30, 0x36, 0x30, 0x36, 0x32, 0x39, 0x30, 0x35, 0x30, 0x30,
0x34, 0x36, 0x5a, 0x17, 0x0d, 0x30, 0x37, 0x30, 0x36, 0x32, 0x39, 0x31, 0x31,
0x30, 0x30, 0x34, 0x36, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e,
0x67, 0x00, 0x30, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00, 0x30, 0x48, 0x02, 0x41,
0x00, 0xe2, 0x54, 0x3a, 0xa7, 0x83, 0xb1, 0x27, 0x14, 0x3e, 0x59, 0xbb, 0xb4,
0x53, 0xe6, 0x1f, 0xe7, 0x5d, 0xf1, 0x21, 0x68, 0xad, 0x85, 0x53, 0xdb, 0x6b,
0x1e, 0xeb, 0x65, 0x97, 0x03, 0x86, 0x60, 0xde, 0xf3, 0x6c, 0x38, 0x75, 0xe0,
0x4c, 0x61, 0xbb, 0xbc, 0x62, 0x17, 0xa9, 0xcd, 0x79, 0x3f, 0x21, 0x4e, 0x96,
0xcb, 0x0e, 0xdc, 0x61, 0x94, 0x30, 0x18, 0x10, 0x6b, 0xd0, 0x1c, 0x10, 0x79,
0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02,
0x1d, 0x05, 0x00, 0x03, 0x41, 0x00, 0x25, 0x90, 0x53, 0x34, 0xd9, 0x56, 0x41,
0x5e, 0xdb, 0x7e, 0x01, 0x36, 0xec, 0x27, 0x61, 0x5e, 0xb7, 0x4d, 0x90, 0x66,
0xa2, 0xe1, 0x9d, 0x58, 0x76, 0xd4, 0x9c, 0xba, 0x2c, 0x84, 0xc6, 0x83, 0x7a,
0x22, 0x0d, 0x03, 0x69, 0x32, 0x1a, 0x6d, 0xcb, 0x0c, 0x15, 0xb3, 0x6b, 0xc7,
0x0a, 0x8c, 0xb4, 0x5c, 0x34, 0x78, 0xe0, 0x3c, 0x9c, 0xe9, 0xf3, 0x30, 0x9f,
0xa8, 0x76, 0x57, 0x92, 0x36 }

Definition at line 336 of file cert.c.

Referenced by test_VerifySignature(), testAcquireCertPrivateKey(), testCertProperties(), testCreateCert(), and testKeyProvInfo().

◆ selfSignedSignatureHash

const BYTE selfSignedSignatureHash[]
static
Initial value:
= { 0x07,0x5a,0x3e,0xfd,0x0d,0xf6,
0x88,0xeb,0x00,0x64,0xbd,0xc9,0xd6,0xea,0x0a,0x7c,0xcc,0x24,0xdb,0x5d }

Definition at line 360 of file cert.c.

Referenced by test_VerifySignature(), and testCertProperties().

◆ serialNum

BYTE serialNum[] = { 1 }
static

◆ subjectKeyId

const BYTE subjectKeyId[]
static
Initial value:
= {
0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 }

Definition at line 334 of file cert.c.

Referenced by testCertProperties().

◆ subjectName

BYTE subjectName[]
static
Initial value:
= { 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06,
0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61,
0x6e, 0x67, 0x00 }

Definition at line 35 of file cert.c.

Referenced by compare_subject_with_constraints(), compare_subject_with_email_constraints(), match_dns_to_subject_alt_name(), CDownloadManager::PerformDownloadAndInstall(), testCompareCert(), testCreateSelfSignCert(), testFindCert(), and testKeyProvInfo().

◆ subjectName2

BYTE subjectName2[]
static
Initial value:
= { 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06,
0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x41, 0x6c, 0x65, 0x78, 0x20, 0x4c, 0x61,
0x6e, 0x67, 0x00 }

Definition at line 75 of file cert.c.

Referenced by testCompareCert(), testFindCert(), and testGetSubjectCert().

◆ subjectName3

BYTE subjectName3[]
static
Initial value:
= { 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06,
0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x52, 0x6f, 0x62, 0x20, 0x20, 0x4c, 0x61,
0x6e, 0x67, 0x00 }

Definition at line 766 of file cert.c.

Referenced by testFindCert().

◆ v1CertWithPubKey

const BYTE v1CertWithPubKey[]
static
Initial value:
= {
0x30,0x81,0x95,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,
0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,
0x6e,0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,
0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,
0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,
0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
0x67,0x00,0x30,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
0x01,0x01,0x05,0x00,0x03,0x11,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0xa3,0x16,0x30,0x14,0x30,0x12,0x06,
0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,
0x01,0x01 }

Definition at line 312 of file cert.c.

Referenced by testCertProperties().

◆ v1CertWithSubjectKeyId

const BYTE v1CertWithSubjectKeyId[]
static
Initial value:
= {
0x30,0x7b,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x15,0x31,0x13,0x30,0x11,
0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,
0x67,0x00,0x30,0x22,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,
0x30,0x30,0x30,0x30,0x30,0x5a,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,
0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a,0x30,0x15,0x31,0x13,0x30,0x11,0x06,
0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,
0x00,0x30,0x07,0x30,0x02,0x06,0x00,0x03,0x01,0x00,0xa3,0x17,0x30,0x15,0x30,
0x13,0x06,0x03,0x55,0x1d,0x0e,0x04,0x0c,0x04,0x0a,0x4a,0x75,0x61,0x6e,0x20,
0x4c,0x61,0x6e,0x67,0x00 }

Definition at line 324 of file cert.c.

Referenced by testCertProperties().