ReactOS  0.4.14-dev-593-g1793dcc
cert.c File Reference
#include <assert.h>
#include <stdarg.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "wine/winternl.h"
#include "wincrypt.h"
#include "snmp.h"
#include "bcrypt.h"
#include "winnls.h"
#include "rpc.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "crypt32_private.h"
Include dependency graph for cert.c:

Go to the source code of this file.

Classes

struct  _OLD_CERT_REVOCATION_STATUS
 
struct  BitField
 

Macros

#define NONAMELESSUNION
 
#define WIN32_NO_STATUS
 
#define CRYPT_OID_INFO_HAS_EXTRA_FIELDS
 
#define BITS_PER_DWORD   (sizeof(DWORD) * 8)
 

Typedefs

typedef BOOL(* CertCompareFunc) (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
typedef PCCERT_CONTEXT(* CertFindFunc) (HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
 
typedef struct _OLD_CERT_REVOCATION_STATUS OLD_CERT_REVOCATION_STATUS
 
typedef BOOL(WINAPICertVerifyRevocationFunc) (DWORD, DWORD, DWORD, void **, DWORD, PCERT_REVOCATION_PARA, PCERT_REVOCATION_STATUS)
 
typedef RPC_STATUS(RPC_ENTRYUuidCreateFunc) (UUID *)
 
typedef RPC_STATUS(RPC_ENTRYUuidToStringFunc) (UUID *, unsigned char **)
 
typedef RPC_STATUS(RPC_ENTRYRpcStringFreeFunc) (unsigned char **)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (crypt)
 
static BOOL CertContext_GetProperty (cert_t *cert, DWORD dwPropId, void *pvData, DWORD *pcbData)
 
static BOOL CertContext_SetProperty (cert_t *cert, DWORD dwPropId, DWORD dwFlags, const void *pvData)
 
BOOL WINAPI CertAddEncodedCertificateToStore (HCERTSTORE hCertStore, DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded, DWORD dwAddDisposition, PCCERT_CONTEXT *ppCertContext)
 
BOOL WINAPI CertAddEncodedCertificateToSystemStoreA (LPCSTR pszCertStoreName, const BYTE *pbCertEncoded, DWORD cbCertEncoded)
 
BOOL WINAPI CertAddEncodedCertificateToSystemStoreW (LPCWSTR pszCertStoreName, const BYTE *pbCertEncoded, DWORD cbCertEncoded)
 
static void Cert_free (context_t *context)
 
static context_tCert_clone (context_t *context, WINECRYPT_CERTSTORE *store, BOOL use_link)
 
static BOOL add_cert_to_store (WINECRYPT_CERTSTORE *store, const CERT_CONTEXT *cert, DWORD add_disposition, BOOL use_link, PCCERT_CONTEXT *ret_context)
 
BOOL WINAPI CertAddCertificateContextToStore (HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition, PCCERT_CONTEXT *ppStoreContext)
 
BOOL WINAPI CertAddCertificateLinkToStore (HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition, PCCERT_CONTEXT *ppCertContext)
 
PCCERT_CONTEXT WINAPI CertCreateCertificateContext (DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded)
 
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext (PCCERT_CONTEXT pCertContext)
 
BOOL WINAPI CertFreeCertificateContext (PCCERT_CONTEXT pCertContext)
 
DWORD WINAPI CertEnumCertificateContextProperties (PCCERT_CONTEXT pCertContext, DWORD dwPropId)
 
static BOOL CertContext_GetHashProp (cert_t *cert, DWORD dwPropId, ALG_ID algID, const BYTE *toHash, DWORD toHashLen, void *pvData, DWORD *pcbData)
 
static BOOL CertContext_CopyParam (void *pvData, DWORD *pcbData, const void *pb, DWORD cb)
 
void CRYPT_FixKeyProvInfoPointers (PCRYPT_KEY_PROV_INFO info)
 
BOOL WINAPI CertGetCertificateContextProperty (PCCERT_CONTEXT pCertContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
 
static void CRYPT_CopyKeyProvInfo (PCRYPT_KEY_PROV_INFO to, const CRYPT_KEY_PROV_INFO *from)
 
static BOOL CertContext_SetKeyProvInfoProperty (CONTEXT_PROPERTY_LIST *properties, const CRYPT_KEY_PROV_INFO *info)
 
BOOL WINAPI CertSetCertificateContextProperty (PCCERT_CONTEXT pCertContext, DWORD dwPropId, DWORD dwFlags, const void *pvData)
 
static BOOL CRYPT_AcquirePrivateKeyFromProvInfo (PCCERT_CONTEXT pCert, PCRYPT_KEY_PROV_INFO info, HCRYPTPROV *phCryptProv, DWORD *pdwKeySpec)
 
BOOL WINAPI CryptAcquireCertificatePrivateKey (PCCERT_CONTEXT pCert, DWORD dwFlags, void *pvReserved, HCRYPTPROV_OR_NCRYPT_KEY_HANDLE *phCryptProv, DWORD *pdwKeySpec, BOOL *pfCallerFreeProv)
 
static BOOL key_prov_info_matches_cert (PCCERT_CONTEXT pCert, const CRYPT_KEY_PROV_INFO *keyProvInfo)
 
static BOOL container_matches_cert (PCCERT_CONTEXT pCert, LPCSTR container, CRYPT_KEY_PROV_INFO *keyProvInfo)
 
static BOOL find_key_prov_info_in_provider (PCCERT_CONTEXT pCert, CRYPT_KEY_PROV_INFO *keyProvInfo)
 
static BOOL find_matching_provider (PCCERT_CONTEXT pCert, DWORD dwFlags)
 
static BOOL cert_prov_info_matches_cert (PCCERT_CONTEXT pCert)
 
BOOL WINAPI CryptFindCertificateKeyProvInfo (PCCERT_CONTEXT pCert, DWORD dwFlags, void *pvReserved)
 
BOOL WINAPI CertCompareCertificate (DWORD dwCertEncodingType, PCERT_INFO pCertId1, PCERT_INFO pCertId2)
 
BOOL WINAPI CertCompareCertificateName (DWORD dwCertEncodingType, PCERT_NAME_BLOB pCertName1, PCERT_NAME_BLOB pCertName2)
 
static DWORD CRYPT_significantBytes (const CRYPT_INTEGER_BLOB *pInt)
 
BOOL WINAPI CertCompareIntegerBlob (PCRYPT_INTEGER_BLOB pInt1, PCRYPT_INTEGER_BLOB pInt2)
 
BOOL WINAPI CertComparePublicKeyInfo (DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pPublicKey1, PCERT_PUBLIC_KEY_INFO pPublicKey2)
 
DWORD WINAPI CertGetPublicKeyLength (DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pPublicKey)
 
static BOOL compare_cert_by_md5_hash (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static BOOL compare_cert_by_sha1_hash (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static BOOL compare_cert_by_name (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static BOOL compare_cert_by_public_key (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static BOOL compare_cert_by_subject_cert (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static BOOL compare_cert_by_cert_id (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static BOOL compare_existing_cert (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static BOOL compare_cert_by_signature_hash (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static PCCERT_CONTEXT cert_compare_certs_in_store (HCERTSTORE store, PCCERT_CONTEXT prev, CertCompareFunc compare, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static PCCERT_CONTEXT find_cert_any (HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
 
static PCCERT_CONTEXT find_cert_by_issuer (HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
 
static BOOL compare_cert_by_name_str (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
 
static PCCERT_CONTEXT find_cert_by_name_str_a (HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
 
static PCCERT_CONTEXT find_cert_by_name_str_w (HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
 
PCCERT_CONTEXT WINAPI CertFindCertificateInStore (HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, PCCERT_CONTEXT pPrevCertContext)
 
PCCERT_CONTEXT WINAPI CertGetSubjectCertificateFromStore (HCERTSTORE hCertStore, DWORD dwCertEncodingType, PCERT_INFO pCertId)
 
BOOL WINAPI CertVerifySubjectCertificateContext (PCCERT_CONTEXT pSubject, PCCERT_CONTEXT pIssuer, DWORD *pdwFlags)
 
PCCERT_CONTEXT WINAPI CertGetIssuerCertificateFromStore (HCERTSTORE hCertStore, PCCERT_CONTEXT pSubjectContext, PCCERT_CONTEXT pPrevIssuerContext, DWORD *pdwFlags)
 
BOOL WINAPI CertVerifyRevocation (DWORD dwEncodingType, DWORD dwRevType, DWORD cContext, PVOID rgpvContext[], DWORD dwFlags, PCERT_REVOCATION_PARA pRevPara, PCERT_REVOCATION_STATUS pRevStatus)
 
PCRYPT_ATTRIBUTE WINAPI CertFindAttribute (LPCSTR pszObjId, DWORD cAttr, CRYPT_ATTRIBUTE rgAttr[])
 
PCERT_EXTENSION WINAPI CertFindExtension (LPCSTR pszObjId, DWORD cExtensions, CERT_EXTENSION rgExtensions[])
 
PCERT_RDN_ATTR WINAPI CertFindRDNAttr (LPCSTR pszObjId, PCERT_NAME_INFO pName)
 
static BOOL find_matching_rdn_attr (DWORD dwFlags, const CERT_NAME_INFO *name, const CERT_RDN_ATTR *attr)
 
BOOL WINAPI CertIsRDNAttrsInCertificateName (DWORD dwCertEncodingType, DWORD dwFlags, PCERT_NAME_BLOB pCertName, PCERT_RDN pRDN)
 
LONG WINAPI CertVerifyTimeValidity (LPFILETIME pTimeToVerify, PCERT_INFO pCertInfo)
 
BOOL WINAPI CertVerifyValidityNesting (PCERT_INFO pSubjectInfo, PCERT_INFO pIssuerInfo)
 
BOOL WINAPI CryptHashCertificate (HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash)
 
BOOL WINAPI CryptHashPublicKeyInfo (HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, BYTE *pbComputedHash, DWORD *pcbComputedHash)
 
BOOL WINAPI CryptHashToBeSigned (HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash)
 
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)
 
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)
 
BOOL WINAPI CryptVerifyCertificateSignature (HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded, PCERT_PUBLIC_KEY_INFO pPublicKey)
 
static BOOL CRYPT_VerifySignature (HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, CERT_PUBLIC_KEY_INFO *pubKeyInfo, const CERT_SIGNED_CONTENT_INFO *signedCert, const CRYPT_OID_INFO *info)
 
static BOOL CNG_CalcHash (const WCHAR *algorithm, const CERT_SIGNED_CONTENT_INFO *signedCert, BYTE **hash_value, DWORD *hash_len)
 
static BOOL CNG_ImportECCPubKey (CERT_PUBLIC_KEY_INFO *pubKeyInfo, BCRYPT_KEY_HANDLE *key)
 
static BOOL CNG_ImportPubKey (CERT_PUBLIC_KEY_INFO *pubKeyInfo, BCRYPT_KEY_HANDLE *key)
 
static BOOL CNG_PrepareSignatureECC (BYTE *encoded_sig, DWORD encoded_size, BYTE **sig_value, DWORD *sig_len)
 
static BOOL CNG_PrepareSignature (CERT_PUBLIC_KEY_INFO *pubKeyInfo, const CERT_SIGNED_CONTENT_INFO *signedCert, BYTE **sig_value, DWORD *sig_len)
 
static BOOL CNG_VerifySignature (HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, CERT_PUBLIC_KEY_INFO *pubKeyInfo, const CERT_SIGNED_CONTENT_INFO *signedCert, const CRYPT_OID_INFO *info)
 
static BOOL CRYPT_VerifyCertSignatureFromPublicKeyInfo (HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, CERT_PUBLIC_KEY_INFO *pubKeyInfo, const CERT_SIGNED_CONTENT_INFO *signedCert)
 
BOOL WINAPI CryptVerifyCertificateSignatureEx (HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, DWORD dwSubjectType, void *pvSubject, DWORD dwIssuerType, void *pvIssuer, DWORD dwFlags, void *pvReserved)
 
BOOL WINAPI CertGetIntendedKeyUsage (DWORD dwCertEncodingType, PCERT_INFO pCertInfo, BYTE *pbKeyUsage, DWORD cbKeyUsage)
 
BOOL WINAPI CertGetEnhancedKeyUsage (PCCERT_CONTEXT pCertContext, DWORD dwFlags, PCERT_ENHKEY_USAGE pUsage, DWORD *pcbUsage)
 
BOOL WINAPI CertSetEnhancedKeyUsage (PCCERT_CONTEXT pCertContext, PCERT_ENHKEY_USAGE pUsage)
 
BOOL WINAPI CertAddEnhancedKeyUsageIdentifier (PCCERT_CONTEXT pCertContext, LPCSTR pszUsageIdentifier)
 
BOOL WINAPI CertRemoveEnhancedKeyUsageIdentifier (PCCERT_CONTEXT pCertContext, LPCSTR pszUsageIdentifier)
 
static void CRYPT_SetBitInField (struct BitField *field, DWORD bit)
 
static BOOL CRYPT_IsBitInFieldSet (const struct BitField *field, DWORD bit)
 
BOOL WINAPI CertGetValidUsages (DWORD cCerts, PCCERT_CONTEXT *rghCerts, int *cNumOIDs, LPSTR *rghOIDs, DWORD *pcbOIDs)
 
static void CertContext_SetKeyProvInfo (PCCERT_CONTEXT context, const CRYPT_KEY_PROV_INFO *pInfo, HCRYPTPROV hProv)
 
static PCCERT_CONTEXT CRYPT_CreateSignedCert (const CRYPT_DER_BLOB *blob, HCRYPTPROV hProv, DWORD dwKeySpec, PCRYPT_ALGORITHM_IDENTIFIER sigAlgo)
 
static void CRYPT_MakeCertInfo (PCERT_INFO info, const CRYPT_DATA_BLOB *pSerialNumber, const CERT_NAME_BLOB *pSubjectIssuerBlob, const CRYPT_ALGORITHM_IDENTIFIER *pSignatureAlgorithm, const SYSTEMTIME *pStartTime, const SYSTEMTIME *pEndTime, const CERT_PUBLIC_KEY_INFO *pubKey, const CERT_EXTENSIONS *pExtensions)
 
static HCRYPTPROV CRYPT_CreateKeyProv (void)
 
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)
 
BOOL WINAPI CertVerifyCTLUsage (DWORD dwEncodingType, DWORD dwSubjectType, void *pvSubject, PCTL_USAGE pSubjectUsage, DWORD dwFlags, PCTL_VERIFY_USAGE_PARA pVerifyUsagePara, PCTL_VERIFY_USAGE_STATUS pVerifyUsageStatus)
 
const void *WINAPI CertCreateContext (DWORD dwContextType, DWORD dwEncodingType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCERT_CREATE_CONTEXT_PARA pCreatePara)
 
BOOL WINAPI CryptSetKeyIdentifierProperty (const CRYPT_HASH_BLOB *pKeyIdentifier, DWORD dwPropId, DWORD dwFlags, LPCWSTR pwszComputerName, void *pvReserved, const void *pvData)
 

Variables

static const context_vtbl_t cert_vtbl
 

Macro Definition Documentation

◆ BITS_PER_DWORD

#define BITS_PER_DWORD   (sizeof(DWORD) * 8)

Definition at line 3126 of file cert.c.

◆ CRYPT_OID_INFO_HAS_EXTRA_FIELDS

#define CRYPT_OID_INFO_HAS_EXTRA_FIELDS

Definition at line 29 of file cert.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 23 of file cert.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 25 of file cert.c.

Typedef Documentation

◆ CertCompareFunc

typedef BOOL(* CertCompareFunc) (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)

Definition at line 1364 of file cert.c.

◆ CertFindFunc

typedef PCCERT_CONTEXT(* CertFindFunc) (HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)

Definition at line 1562 of file cert.c.

◆ CertVerifyRevocationFunc

typedef BOOL(WINAPI * CertVerifyRevocationFunc) (DWORD, DWORD, DWORD, void **, DWORD, PCERT_REVOCATION_PARA, PCERT_REVOCATION_STATUS)

Definition at line 1931 of file cert.c.

◆ OLD_CERT_REVOCATION_STATUS

◆ RpcStringFreeFunc

typedef RPC_STATUS(RPC_ENTRY * RpcStringFreeFunc) (unsigned char **)

Definition at line 3504 of file cert.c.

◆ UuidCreateFunc

typedef RPC_STATUS(RPC_ENTRY * UuidCreateFunc) (UUID *)

Definition at line 3502 of file cert.c.

◆ UuidToStringFunc

typedef RPC_STATUS(RPC_ENTRY * UuidToStringFunc) (UUID *, unsigned char **)

Definition at line 3503 of file cert.c.

Function Documentation

◆ add_cert_to_store()

static BOOL add_cert_to_store ( WINECRYPT_CERTSTORE store,
const CERT_CONTEXT cert,
DWORD  add_disposition,
BOOL  use_link,
PCCERT_CONTEXT ret_context 
)
static

Definition at line 171 of file cert.c.

173 {
174  const CERT_CONTEXT *existing = NULL;
175  BOOL ret = TRUE, inherit_props = FALSE;
176  context_t *new_context = NULL;
177 
178  switch (add_disposition)
179  {
181  break;
182  case CERT_STORE_ADD_NEW:
188  {
189  BYTE hashToAdd[20];
190  DWORD size = sizeof(hashToAdd);
191 
193  hashToAdd, &size);
194  if (ret)
195  {
196  CRYPT_HASH_BLOB blob = { sizeof(hashToAdd), hashToAdd };
197 
198  existing = CertFindCertificateInStore(store, cert->dwCertEncodingType, 0,
200  }
201  break;
202  }
203  default:
204  FIXME("Unimplemented add disposition %d\n", add_disposition);
206  return FALSE;
207  }
208 
209  switch (add_disposition)
210  {
212  break;
213  case CERT_STORE_ADD_NEW:
214  if (existing)
215  {
216  TRACE("found matching certificate, not adding\n");
218  return FALSE;
219  }
220  break;
222  break;
224  if (use_link)
225  FIXME("CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES: semi-stub for links\n");
226  if (existing)
227  inherit_props = TRUE;
228  break;
230  if(use_link)
231  FIXME("CERT_STORE_ADD_USE_EXISTING: semi-stub for links\n");
232  if (existing)
233  {
234  Context_CopyProperties(existing, cert);
235  if (ret_context)
236  *ret_context = CertDuplicateCertificateContext(existing);
237  return TRUE;
238  }
239  break;
241  if (existing && CompareFileTime(&existing->pCertInfo->NotBefore, &cert->pCertInfo->NotBefore) >= 0)
242  {
243  TRACE("existing certificate is newer, not adding\n");
245  return FALSE;
246  }
247  break;
249  if (existing)
250  {
251  if (CompareFileTime(&existing->pCertInfo->NotBefore, &cert->pCertInfo->NotBefore) >= 0)
252  {
253  TRACE("existing certificate is newer, not adding\n");
255  return FALSE;
256  }
257  inherit_props = TRUE;
258  }
259  break;
260  }
261 
262  /* FIXME: We have tests that this works, but what should we really do in this case? */
263  if(!store) {
264  if(ret_context)
265  *ret_context = CertDuplicateCertificateContext(cert);
266  return TRUE;
267  }
268 
269  ret = store->vtbl->certs.addContext(store, context_from_ptr(cert), existing ? context_from_ptr(existing) : NULL,
270  (ret_context || inherit_props) ? &new_context : NULL, use_link);
271  if(!ret)
272  return FALSE;
273 
274  if(inherit_props)
275  Context_CopyProperties(context_ptr(new_context), existing);
276 
277  if(ret_context)
278  *ret_context = context_ptr(new_context);
279  else if(new_context)
280  Context_Release(new_context);
281 
282  TRACE("returning %d\n", ret);
283  return ret;
284 }
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, PCCERT_CONTEXT pPrevCertContext)
Definition: cert.c:1765
void Context_CopyProperties(const void *to, const void *from)
Definition: context.c:123
static context_t * context_from_ptr(const void *ptr)
#define TRUE
Definition: types.h:120
#define CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
Definition: wincrypt.h:2486
#define CERT_FIND_SHA1_HASH
Definition: wincrypt.h:2865
Definition: image.c:133
#define CRYPT_E_EXISTS
Definition: winerror.h:3008
#define CERT_STORE_ADD_NEW
Definition: wincrypt.h:2482
#define CERT_STORE_ADD_NEWER
Definition: wincrypt.h:2487
static void * context_ptr(context_t *context)
void Context_Release(context_t *context)
Definition: context.c:106
BOOL(* addContext)(struct WINE_CRYPTCERTSTORE *, context_t *, context_t *, context_t **, BOOL)
BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: cert.c:551
unsigned int BOOL
Definition: ntddk_ex.h:94
CONTEXT_FUNCS certs
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define CERT_STORE_ADD_REPLACE_EXISTING
Definition: wincrypt.h:2484
static BYTE cert[]
Definition: msg.c:1437
#define CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES
Definition: wincrypt.h:2488
#define TRACE(s)
Definition: solgame.cpp:4
PCERT_INFO pCertInfo
Definition: wincrypt.h:482
GLsizeiptr size
Definition: glext.h:5919
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
const store_vtbl_t * vtbl
#define CERT_STORE_ADD_USE_EXISTING
Definition: wincrypt.h:2483
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
#define CERT_HASH_PROP_ID
Definition: wincrypt.h:2688
int ret
unsigned char BYTE
Definition: mem.h:68
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:360
FILETIME NotBefore
Definition: wincrypt.h:245
#define CERT_STORE_ADD_ALWAYS
Definition: wincrypt.h:2485

Referenced by CertAddCertificateContextToStore(), and CertAddCertificateLinkToStore().

◆ Cert_clone()

static context_t* Cert_clone ( context_t context,
WINECRYPT_CERTSTORE store,
BOOL  use_link 
)
static

Definition at line 128 of file cert.c.

129 {
130  cert_t *cert;
131 
132  if(use_link) {
134  if(!cert)
135  return NULL;
136  }else {
137  const cert_t *cloned = (const cert_t*)context;
138  DWORD size = 0;
139  BOOL res;
140 
142  if(!cert)
143  return NULL;
144 
145  Context_CopyProperties(&cert->ctx, &cloned->ctx);
146 
147  cert->ctx.dwCertEncodingType = cloned->ctx.dwCertEncodingType;
148  cert->ctx.pbCertEncoded = CryptMemAlloc(cloned->ctx.cbCertEncoded);
149  memcpy(cert->ctx.pbCertEncoded, cloned->ctx.pbCertEncoded, cloned->ctx.cbCertEncoded);
150  cert->ctx.cbCertEncoded = cloned->ctx.cbCertEncoded;
151 
152  /* FIXME: We don't need to decode the object here, we could just clone cert info. */
153  res = CryptDecodeObjectEx(cert->ctx.dwCertEncodingType, X509_CERT_TO_BE_SIGNED,
154  cert->ctx.pbCertEncoded, cert->ctx.cbCertEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL,
155  &cert->ctx.pCertInfo, &size);
156  if(!res) {
158  return NULL;
159  }
160  }
161 
162  cert->ctx.hCertStore = store;
163  return &cert->base;
164 }
void Context_CopyProperties(const void *to, const void *from)
Definition: context.c:123
CERT_CONTEXT ctx
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
BYTE * pbCertEncoded
Definition: wincrypt.h:480
Definition: http.c:7098
static const context_vtbl_t cert_vtbl
Definition: cert.c:118
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
DWORD dwCertEncodingType
Definition: wincrypt.h:479
context_t * Context_CreateDataContext(size_t contextSize, const context_vtbl_t *vtbl, WINECRYPT_CERTSTORE *store)
Definition: context.c:28
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static BYTE cert[]
Definition: msg.c:1437
DWORD cbCertEncoded
Definition: wincrypt.h:481
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define X509_CERT_TO_BE_SIGNED
Definition: wincrypt.h:3366
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLuint res
Definition: glext.h:9613
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454
context_t * Context_CreateLinkContext(unsigned int contextSize, context_t *linked, WINECRYPT_CERTSTORE *store)
Definition: context.c:54

◆ cert_compare_certs_in_store()

static PCCERT_CONTEXT cert_compare_certs_in_store ( HCERTSTORE  store,
PCCERT_CONTEXT  prev,
CertCompareFunc  compare,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
inlinestatic

Definition at line 1546 of file cert.c.

1549 {
1550  BOOL matches = FALSE;
1552 
1553  ret = prev;
1554  do {
1556  if (ret)
1557  matches = compare(ret, dwType, dwFlags, pvPara);
1558  } while (ret != NULL && !matches);
1559  return ret;
1560 }
#define matches(FN)
Definition: match.h:70
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrev)
Definition: store.c:928
#define compare
_In_ void * pvPara
Definition: wincrypt.h:6081

Referenced by CertFindCertificateInStore(), find_cert_by_issuer(), find_cert_by_name_str_a(), and find_cert_by_name_str_w().

◆ Cert_free()

static void Cert_free ( context_t context)
static

Definition at line 120 of file cert.c.

121 {
122  cert_t *cert = (cert_t*)context;
123 
124  CryptMemFree(cert->ctx.pbCertEncoded);
125  LocalFree(cert->ctx.pCertInfo);
126 }
Definition: http.c:7098
static BYTE cert[]
Definition: msg.c:1437
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141

◆ cert_prov_info_matches_cert()

static BOOL cert_prov_info_matches_cert ( PCCERT_CONTEXT  pCert)
static

Definition at line 1132 of file cert.c.

1133 {
1134  BOOL matches = FALSE;
1135  DWORD size;
1136 
1138  NULL, &size))
1139  {
1140  CRYPT_KEY_PROV_INFO *keyProvInfo = CryptMemAlloc(size);
1141 
1142  if (keyProvInfo)
1143  {
1145  CERT_KEY_PROV_INFO_PROP_ID, keyProvInfo, &size))
1146  matches = key_prov_info_matches_cert(pCert, keyProvInfo);
1147  CryptMemFree(keyProvInfo);
1148  }
1149  }
1150  return matches;
1151 }
#define matches(FN)
Definition: match.h:70
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: cert.c:551
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL key_prov_info_matches_cert(PCCERT_CONTEXT pCert, const CRYPT_KEY_PROV_INFO *keyProvInfo)
Definition: cert.c:955
#define CERT_KEY_PROV_INFO_PROP_ID
Definition: wincrypt.h:2686
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141

Referenced by CryptFindCertificateKeyProvInfo().

◆ CertAddCertificateContextToStore()

BOOL WINAPI CertAddCertificateContextToStore ( HCERTSTORE  hCertStore,
PCCERT_CONTEXT  pCertContext,
DWORD  dwAddDisposition,
PCCERT_CONTEXT ppStoreContext 
)

Definition at line 286 of file cert.c.

288 {
289  WINECRYPT_CERTSTORE *store = hCertStore;
290 
291  TRACE("(%p, %p, %08x, %p)\n", hCertStore, pCertContext, dwAddDisposition, ppStoreContext);
292 
294 }
_In_ PCCERT_CONTEXT _In_ DWORD dwAddDisposition
Definition: wincrypt.h:4987
_In_ PCCERT_CONTEXT _In_ DWORD _Outptr_opt_ PCCERT_CONTEXT * ppStoreContext
Definition: wincrypt.h:4987
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL add_cert_to_store(WINECRYPT_CERTSTORE *store, const CERT_CONTEXT *cert, DWORD add_disposition, BOOL use_link, PCCERT_CONTEXT *ret_context)
Definition: cert.c:171
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

Referenced by cert_mgr_do_export(), CertAddEncodedCertificateToStore(), check_and_store_certs(), CRYPT_CreateAny(), CRYPT_CreateCert(), CRYPT_FindIssuer(), import_cert(), save_cert_as_cms(), save_pfx(), testAddCert(), testCertRegisterSystemStore(), testDupCert(), testEmptyStore(), testGetIssuerCert(), testRegStoreSavedCerts(), and testStoresInCollection().

◆ CertAddCertificateLinkToStore()

BOOL WINAPI CertAddCertificateLinkToStore ( HCERTSTORE  hCertStore,
PCCERT_CONTEXT  pCertContext,
DWORD  dwAddDisposition,
PCCERT_CONTEXT ppCertContext 
)

Definition at line 296 of file cert.c.

299 {
300  static int calls;
301  WINECRYPT_CERTSTORE *store = (WINECRYPT_CERTSTORE*)hCertStore;
302 
303  if (!(calls++))
304  FIXME("(%p, %p, %08x, %p): semi-stub\n", hCertStore, pCertContext,
306  if (store->dwMagic != WINE_CRYPTCERTSTORE_MAGIC)
307  return FALSE;
308  if (store->type == StoreTypeCollection)
309  {
311  return FALSE;
312  }
314 }
#define TRUE
Definition: types.h:120
_In_ PCCERT_CONTEXT _In_ DWORD dwAddDisposition
Definition: wincrypt.h:4987
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
#define WINE_CRYPTCERTSTORE_MAGIC
#define SetLastError(x)
Definition: compat.h:417
static BOOL add_cert_to_store(WINECRYPT_CERTSTORE *store, const CERT_CONTEXT *cert, DWORD add_disposition, BOOL use_link, PCCERT_CONTEXT *ret_context)
Definition: cert.c:171
_In_ DWORD _In_ DWORD _In_ DWORD _Outptr_opt_ PCCERT_CONTEXT * ppCertContext
Definition: wincrypt.h:5043
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

Referenced by testAddCertificateLink(), and testLinkCert().

◆ CertAddEncodedCertificateToStore()

BOOL WINAPI CertAddEncodedCertificateToStore ( HCERTSTORE  hCertStore,
DWORD  dwCertEncodingType,
const BYTE pbCertEncoded,
DWORD  cbCertEncoded,
DWORD  dwAddDisposition,
PCCERT_CONTEXT ppCertContext 
)

Definition at line 58 of file cert.c.

61 {
63  pbCertEncoded, cbCertEncoded);
64  BOOL ret;
65 
66  TRACE("(%p, %08x, %p, %d, %08x, %p)\n", hCertStore, dwCertEncodingType,
68 
69  if (cert)
70  {
74  }
75  else
76  ret = FALSE;
77  return ret;
78 }
BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pCertContext, DWORD dwAddDisposition, PCCERT_CONTEXT *ppStoreContext)
Definition: cert.c:286
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
_In_ PCCERT_CONTEXT _In_ DWORD dwAddDisposition
Definition: wincrypt.h:4987
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ DWORD _In_ DWORD cbCertEncoded
Definition: wincrypt.h:5043
static BYTE cert[]
Definition: msg.c:1437
#define TRACE(s)
Definition: solgame.cpp:4
int ret
PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded)
Definition: cert.c:316
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5041
_In_ DWORD _In_ DWORD _In_ DWORD _Outptr_opt_ PCCERT_CONTEXT * ppCertContext
Definition: wincrypt.h:5043

Referenced by add_ms_root_certs(), CertAddEncodedCertificateToSystemStoreA(), CertAddEncodedCertificateToSystemStoreW(), check_ssl_policy(), CRYPT_MsgOpenStore(), getChain(), import_base64_certs_from_fp(), read_trusted_roots_from_known_locations(), test_CERT_CHAIN_PARA_cbSize(), test_crypt_ui_wiz_import(), test_I_UpdateStore(), test_msg_get_and_verify_signer(), testAddCert(), testAddCertificateLink(), testCloseStore(), testCollectionStore(), testCreateCertChainEngine(), testDupCert(), testFileNameStore(), testFileStore(), testFindCert(), testGetCertChain(), testGetIssuerCert(), testGetSubjectCert(), testMemStore(), testMessageStore(), and testRegStore().

◆ CertAddEncodedCertificateToSystemStoreA()

BOOL WINAPI CertAddEncodedCertificateToSystemStoreA ( LPCSTR  pszCertStoreName,
const BYTE pbCertEncoded,
DWORD  cbCertEncoded 
)

Definition at line 80 of file cert.c.

82 {
83  HCERTSTORE store;
84  BOOL ret = FALSE;
85 
86  TRACE("(%s, %p, %d)\n", debugstr_a(pszCertStoreName), pbCertEncoded,
88 
89  store = CertOpenSystemStoreA(0, pszCertStoreName);
90  if (store)
91  {
94  CertCloseStore(store, 0);
95  }
96  return ret;
97 }
BOOL WINAPI CertAddEncodedCertificateToStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded, DWORD dwAddDisposition, PCCERT_CONTEXT *ppCertContext)
Definition: cert.c:58
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ DWORD _In_ DWORD cbCertEncoded
Definition: wincrypt.h:5043
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define CERT_STORE_ADD_USE_EXISTING
Definition: wincrypt.h:2483
int ret
HCERTSTORE WINAPI CertOpenSystemStoreA(HCRYPTPROV_LEGACY hProv, LPCSTR szSubSystemProtocol)
Definition: store.c:904

◆ CertAddEncodedCertificateToSystemStoreW()

BOOL WINAPI CertAddEncodedCertificateToSystemStoreW ( LPCWSTR  pszCertStoreName,
const BYTE pbCertEncoded,
DWORD  cbCertEncoded 
)

Definition at line 99 of file cert.c.

101 {
102  HCERTSTORE store;
103  BOOL ret = FALSE;
104 
105  TRACE("(%s, %p, %d)\n", debugstr_w(pszCertStoreName), pbCertEncoded,
106  cbCertEncoded);
107 
108  store = CertOpenSystemStoreW(0, pszCertStoreName);
109  if (store)
110  {
113  CertCloseStore(store, 0);
114  }
115  return ret;
116 }
BOOL WINAPI CertAddEncodedCertificateToStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded, DWORD dwAddDisposition, PCCERT_CONTEXT *ppCertContext)
Definition: cert.c:58
HCERTSTORE WINAPI CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv, LPCWSTR szSubSystemProtocol)
Definition: store.c:916
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
_In_ DWORD _In_ DWORD cbCertEncoded
Definition: wincrypt.h:5043
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
#define TRACE(s)
Definition: solgame.cpp:4
#define CERT_STORE_ADD_USE_EXISTING
Definition: wincrypt.h:2483
int ret

◆ CertAddEnhancedKeyUsageIdentifier()

BOOL WINAPI CertAddEnhancedKeyUsageIdentifier ( PCCERT_CONTEXT  pCertContext,
LPCSTR  pszUsageIdentifier 
)

Definition at line 2978 of file cert.c.

2980 {
2981  BOOL ret;
2982  DWORD size;
2983 
2984  TRACE("(%p, %s)\n", pCertContext, debugstr_a(pszUsageIdentifier));
2985 
2988  {
2990 
2991  if (usage)
2992  {
2995  if (ret)
2996  {
2997  DWORD i;
2998  BOOL exists = FALSE;
2999 
3000  /* Make sure usage doesn't already exist */
3001  for (i = 0; !exists && i < usage->cUsageIdentifier; i++)
3002  {
3003  if (!strcmp(usage->rgpszUsageIdentifier[i],
3004  pszUsageIdentifier))
3005  exists = TRUE;
3006  }
3007  if (!exists)
3008  {
3010  sizeof(LPSTR) + strlen(pszUsageIdentifier) + 1);
3011 
3012  if (newUsage)
3013  {
3014  LPSTR nextOID;
3015 
3016  newUsage->rgpszUsageIdentifier = (LPSTR *)
3017  ((LPBYTE)newUsage + sizeof(CERT_ENHKEY_USAGE));
3018  nextOID = (LPSTR)((LPBYTE)newUsage->rgpszUsageIdentifier
3019  + (usage->cUsageIdentifier + 1) * sizeof(LPSTR));
3020  for (i = 0; i < usage->cUsageIdentifier; i++)
3021  {
3022  newUsage->rgpszUsageIdentifier[i] = nextOID;
3023  strcpy(nextOID, usage->rgpszUsageIdentifier[i]);
3024  nextOID += strlen(nextOID) + 1;
3025  }
3026  newUsage->rgpszUsageIdentifier[i] = nextOID;
3027  strcpy(nextOID, pszUsageIdentifier);
3028  newUsage->cUsageIdentifier = i + 1;
3030  CryptMemFree(newUsage);
3031  }
3032  else
3033  ret = FALSE;
3034  }
3035  }
3037  }
3038  else
3039  ret = FALSE;
3040  }
3041  else
3042  {
3044  sizeof(LPSTR) + strlen(pszUsageIdentifier) + 1);
3045 
3046  if (usage)
3047  {
3048  usage->rgpszUsageIdentifier =
3049  (LPSTR *)((LPBYTE)usage + sizeof(CERT_ENHKEY_USAGE));
3050  usage->rgpszUsageIdentifier[0] = (LPSTR)((LPBYTE)usage +
3051  sizeof(CERT_ENHKEY_USAGE) + sizeof(LPSTR));
3052  strcpy(usage->rgpszUsageIdentifier[0], pszUsageIdentifier);
3053  usage->cUsageIdentifier = 1;
3056  }
3057  else
3058  ret = FALSE;
3059  }
3060  return ret;
3061 }
struct _CTL_USAGE CERT_ENHKEY_USAGE
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * LPSTR
Definition: xmlstorage.h:182
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
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
BOOL WINAPI CertSetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, PCERT_ENHKEY_USAGE pUsage)
Definition: cert.c:2952
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
DWORD cUsageIdentifier
Definition: wincrypt.h:719
#define CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG
Definition: wincrypt.h:2918
BOOL WINAPI CertGetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, DWORD dwFlags, PCERT_ENHKEY_USAGE pUsage, DWORD *pcbUsage)
Definition: cert.c:2847
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
LPSTR * rgpszUsageIdentifier
Definition: wincrypt.h:720
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

Referenced by testKeyUsage().

◆ CertCompareCertificate()

BOOL WINAPI CertCompareCertificate ( DWORD  dwCertEncodingType,
PCERT_INFO  pCertId1,
PCERT_INFO  pCertId2 
)

Definition at line 1166 of file cert.c.

1168 {
1169  BOOL ret;
1170 
1171  TRACE("(%08x, %p, %p)\n", dwCertEncodingType, pCertId1, pCertId2);
1172 
1174  &pCertId2->Issuer) && CertCompareIntegerBlob(&pCertId1->SerialNumber,
1175  &pCertId2->SerialNumber);
1176  TRACE("returning %d\n", ret);
1177  return ret;
1178 }
CRYPT_INTEGER_BLOB SerialNumber
Definition: wincrypt.h:242
BOOL WINAPI CertCompareCertificateName(DWORD dwCertEncodingType, PCERT_NAME_BLOB pCertName1, PCERT_NAME_BLOB pCertName2)
Definition: cert.c:1180
unsigned int BOOL
Definition: ntddk_ex.h:94
CERT_NAME_BLOB Issuer
Definition: wincrypt.h:244
BOOL WINAPI CertCompareIntegerBlob(PCRYPT_INTEGER_BLOB pInt1, PCRYPT_INTEGER_BLOB pInt2)
Definition: cert.c:1221
#define TRACE(s)
Definition: solgame.cpp:4
int ret
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5041

Referenced by compare_existing_cert(), CRYPT_CheckSimpleChainForCycles(), and testCompareCert().

◆ CertCompareCertificateName()

BOOL WINAPI CertCompareCertificateName ( DWORD  dwCertEncodingType,
PCERT_NAME_BLOB  pCertName1,
PCERT_NAME_BLOB  pCertName2 
)

Definition at line 1180 of file cert.c.

1182 {
1183  BOOL ret;
1184 
1185  TRACE("(%08x, %p, %p)\n", dwCertEncodingType, pCertName1, pCertName2);
1186 
1187  if (pCertName1->cbData == pCertName2->cbData)
1188  {
1189  if (pCertName1->cbData)
1190  ret = !memcmp(pCertName1->pbData, pCertName2->pbData,
1191  pCertName1->cbData);
1192  else
1193  ret = TRUE;
1194  }
1195  else
1196  ret = FALSE;
1197  TRACE("returning %d\n", ret);
1198  return ret;
1199 }
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
int ret
BYTE * pbData
Definition: wincrypt.h:103
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5041

Referenced by CDecodeSignedMsg_VerifySignature(), CertCompareCertificate(), compare_cert_by_cert_id(), compare_cert_by_name(), compare_cert_by_subject_cert(), compare_crl_existing(), compare_crl_issued_by(), compare_crl_issued_for(), CRYPT_IsCertificateSelfSigned(), testCompareCertName(), testFindCert(), and TrustIsCertificateSelfSigned().

◆ CertCompareIntegerBlob()

BOOL WINAPI CertCompareIntegerBlob ( PCRYPT_INTEGER_BLOB  pInt1,
PCRYPT_INTEGER_BLOB  pInt2 
)

Definition at line 1221 of file cert.c.

1223 {
1224  BOOL ret;
1225  DWORD cb1, cb2;
1226 
1227  TRACE("(%p, %p)\n", pInt1, pInt2);
1228 
1229  cb1 = CRYPT_significantBytes(pInt1);
1230  cb2 = CRYPT_significantBytes(pInt2);
1231  if (cb1 == cb2)
1232  {
1233  if (cb1)
1234  ret = !memcmp(pInt1->pbData, pInt2->pbData, cb1);
1235  else
1236  ret = TRUE;
1237  }
1238  else
1239  ret = FALSE;
1240  TRACE("returning %d\n", ret);
1241  return ret;
1242 }
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static DWORD CRYPT_significantBytes(const CRYPT_INTEGER_BLOB *pInt)
Definition: cert.c:1205
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
BYTE * pbData
Definition: wincrypt.h:103

Referenced by CDecodeSignedMsg_VerifySignature(), CertCompareCertificate(), compare_cert_by_cert_id(), compare_cert_by_subject_cert(), compare_crl_issued_by(), CRYPT_FindCertificateInCRL(), CRYPT_IsCertificateSelfSigned(), testCompareIntegerBlob(), testFindCert(), and TrustIsCertificateSelfSigned().

◆ CertComparePublicKeyInfo()

BOOL WINAPI CertComparePublicKeyInfo ( DWORD  dwCertEncodingType,
PCERT_PUBLIC_KEY_INFO  pPublicKey1,
PCERT_PUBLIC_KEY_INFO  pPublicKey2 
)

Definition at line 1244 of file cert.c.

1246 {
1247  BOOL ret;
1248 
1249  TRACE("(%08x, %p, %p)\n", dwCertEncodingType, pPublicKey1, pPublicKey2);
1250 
1251  /* RSA public key data should start with ASN_SEQUENCE,
1252  * otherwise it's not a RSA_CSP_PUBLICKEYBLOB.
1253  */
1254  if (!pPublicKey1->PublicKey.cbData || pPublicKey1->PublicKey.pbData[0] != ASN_SEQUENCE)
1255  dwCertEncodingType = 0;
1256 
1258  {
1259  case 0: /* Seems to mean "raw binary bits" */
1260  if (pPublicKey1->PublicKey.cbData == pPublicKey2->PublicKey.cbData &&
1261  pPublicKey1->PublicKey.cUnusedBits == pPublicKey2->PublicKey.cUnusedBits)
1262  {
1263  if (pPublicKey2->PublicKey.cbData)
1264  ret = !memcmp(pPublicKey1->PublicKey.pbData,
1265  pPublicKey2->PublicKey.pbData, pPublicKey1->PublicKey.cbData);
1266  else
1267  ret = TRUE;
1268  }
1269  else
1270  ret = FALSE;
1271  break;
1272  default:
1273  WARN("Unknown encoding type %08x\n", dwCertEncodingType);
1274  /* FALLTHROUGH */
1275  case X509_ASN_ENCODING:
1276  {
1277  BLOBHEADER *pblob1, *pblob2;
1278  DWORD length;
1279  ret = FALSE;
1281  pPublicKey1->PublicKey.pbData, pPublicKey1->PublicKey.cbData,
1282  CRYPT_DECODE_ALLOC_FLAG, &pblob1, &length))
1283  {
1285  pPublicKey2->PublicKey.pbData, pPublicKey2->PublicKey.cbData,
1286  CRYPT_DECODE_ALLOC_FLAG, &pblob2, &length))
1287  {
1288  /* The RSAPUBKEY structure directly follows the BLOBHEADER */
1289  RSAPUBKEY *pk1 = (LPVOID)(pblob1 + 1),
1290  *pk2 = (LPVOID)(pblob2 + 1);
1291  ret = (pk1->bitlen == pk2->bitlen) && (pk1->pubexp == pk2->pubexp)
1292  && !memcmp(pk1 + 1, pk2 + 1, pk1->bitlen/8);
1293 
1294  LocalFree(pblob2);
1295  }
1296  LocalFree(pblob1);
1297  }
1298 
1299  break;
1300  }
1301  }
1302  return ret;
1303 }
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6278
#define WARN(fmt,...)
Definition: debug.h:111
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
DWORD pubexp
Definition: wincrypt.h:145
DWORD cUnusedBits
Definition: wincrypt.h:198
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define GET_CERT_ENCODING_TYPE(x)
Definition: wincrypt.h:2292
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LPVOID
Definition: nt_native.h:45
int ret
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5041
DWORD bitlen
Definition: wincrypt.h:144
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
CRYPT_BIT_BLOB PublicKey
Definition: wincrypt.h:226
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454
#define RSA_CSP_PUBLICKEYBLOB
Definition: wincrypt.h:3384
#define ASN_SEQUENCE
Definition: snmp.h:110
BYTE * pbData
Definition: wincrypt.h:197

Referenced by compare_cert_by_public_key(), testComparePublicKeyInfo(), verify_authenticode_policy(), and verify_ms_root_policy().

◆ CertContext_CopyParam()

static BOOL CertContext_CopyParam ( void pvData,
DWORD pcbData,
const void pb,
DWORD  cb 
)
static

Definition at line 410 of file cert.c.

412 {
413  BOOL ret = TRUE;
414 
415  if (!pvData)
416  *pcbData = cb;
417  else if (*pcbData < cb)
418  {
420  *pcbData = cb;
421  ret = FALSE;
422  }
423  else
424  {
425  memcpy(pvData, pb, cb);
426  *pcbData = cb;
427  }
428  return ret;
429 }
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
#define SetLastError(x)
Definition: compat.h:417
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERROR_MORE_DATA
Definition: dderror.h:13
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953

Referenced by CertContext_GetProperty(), and CertGetCertificateContextProperty().

◆ CertContext_GetHashProp()

static BOOL CertContext_GetHashProp ( cert_t cert,
DWORD  dwPropId,
ALG_ID  algID,
const BYTE toHash,
DWORD  toHashLen,
void pvData,
DWORD pcbData 
)
static

Definition at line 395 of file cert.c.

398 {
399  BOOL ret = CryptHashCertificate(0, algID, 0, toHash, toHashLen, pvData,
400  pcbData);
401  if (ret && pvData)
402  {
404 
406  }
407  return ret;
408 }
static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: cert.c:678
Definition: image.c:133
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
static BYTE cert[]
Definition: msg.c:1437
int ret
_In_ DWORD dwPropId
Definition: wincrypt.h:4952
BOOL WINAPI CryptHashCertificate(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash)
Definition: cert.c:2187
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953

Referenced by CertContext_GetProperty().

◆ CertContext_GetProperty()

static BOOL CertContext_GetProperty ( cert_t cert,
DWORD  dwPropId,
void pvData,
DWORD pcbData 
)
static

Definition at line 431 of file cert.c.

433 {
434  BOOL ret;
436 
437  TRACE("(%p, %d, %p, %p)\n", cert, dwPropId, pvData, pcbData);
438 
439  if (cert->base.properties)
440  ret = ContextPropertyList_FindProperty(cert->base.properties, dwPropId, &blob);
441  else
442  ret = FALSE;
443  if (ret)
444  ret = CertContext_CopyParam(pvData, pcbData, blob.pbData, blob.cbData);
445  else
446  {
447  /* Implicit properties */
448  switch (dwPropId)
449  {
452  cert->ctx.pbCertEncoded, cert->ctx.cbCertEncoded, pvData,
453  pcbData);
454  break;
457  cert->ctx.pbCertEncoded, cert->ctx.cbCertEncoded, pvData,
458  pcbData);
459  break;
462  cert->ctx.pCertInfo->Subject.pbData,
463  cert->ctx.pCertInfo->Subject.cbData,
464  pvData, pcbData);
465  break;
468  cert->ctx.pCertInfo->SubjectPublicKeyInfo.PublicKey.pbData,
469  cert->ctx.pCertInfo->SubjectPublicKeyInfo.PublicKey.cbData,
470  pvData, pcbData);
471  break;
474  cert->ctx.pCertInfo->SerialNumber.pbData,
475  cert->ctx.pCertInfo->SerialNumber.cbData,
476  pvData, pcbData);
477  break;
479  ret = CryptHashToBeSigned(0, cert->ctx.dwCertEncodingType,
480  cert->ctx.pbCertEncoded, cert->ctx.cbCertEncoded, pvData,
481  pcbData);
482  if (ret && pvData)
483  {
485 
487  }
488  break;
490  {
492  szOID_SUBJECT_KEY_IDENTIFIER, cert->ctx.pCertInfo->cExtension,
493  cert->ctx.pCertInfo->rgExtension);
494 
495  if (ext)
496  {
498  DWORD size = sizeof(value);
499 
501  szOID_SUBJECT_KEY_IDENTIFIER, ext->Value.pbData,
502  ext->Value.cbData, CRYPT_DECODE_NOCOPY_FLAG, NULL, &value,
503  &size);
504  if (ret)
505  {
507  value.cbData);
509  }
510  }
511  else
513  break;
514  }
515  default:
517  }
518  }
519  TRACE("returning %d\n", ret);
520  return ret;
521 }
#define CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID
Definition: wincrypt.h:2711
static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: cert.c:678
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
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
Definition: image.c:133
BOOL ContextPropertyList_FindProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, PCRYPT_DATA_BLOB blob) DECLSPEC_HIDDEN
Definition: proplist.c:72
#define CERT_KEY_IDENTIFIER_PROP_ID
Definition: wincrypt.h:2706
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
static BYTE cert[]
Definition: msg.c:1437
#define CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID
Definition: wincrypt.h:2714
#define TRACE(s)
Definition: solgame.cpp:4
#define CERT_MD5_HASH_PROP_ID
Definition: wincrypt.h:2689
GLsizeiptr size
Definition: glext.h:5919
#define CERT_SIGNATURE_HASH_PROP_ID
Definition: wincrypt.h:2701
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
PCERT_EXTENSION WINAPI CertFindExtension(LPCSTR pszObjId, DWORD cExtensions, CERT_EXTENSION rgExtensions[])
Definition: cert.c:2028
static BOOL CertContext_CopyParam(void *pvData, DWORD *pcbData, const void *pb, DWORD cb)
Definition: cert.c:410
int ret
#define CALG_MD5
Definition: wincrypt.h:1805
#define szOID_SUBJECT_KEY_IDENTIFIER
Definition: wincrypt.h:3184
GLsizei const GLfloat * value
Definition: glext.h:6069
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define CRYPT_DECODE_NOCOPY_FLAG
Definition: wincrypt.h:3450
#define CALG_SHA1
Definition: wincrypt.h:1807
_In_ DWORD dwPropId
Definition: wincrypt.h:4952
#define CERT_SHA1_HASH_PROP_ID
Definition: wincrypt.h:2687
#define CERT_SUBJECT_NAME_MD5_HASH_PROP_ID
Definition: wincrypt.h:2715
BOOL WINAPI CryptHashToBeSigned(HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash)
Definition: cert.c:2260
static BOOL CertContext_GetHashProp(cert_t *cert, DWORD dwPropId, ALG_ID algID, const BYTE *toHash, DWORD toHashLen, void *pvData, DWORD *pcbData)
Definition: cert.c:395
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953

Referenced by CertContext_SetProperty(), and CertGetCertificateContextProperty().

◆ CertContext_SetKeyProvInfo()

static void CertContext_SetKeyProvInfo ( PCCERT_CONTEXT  context,
const CRYPT_KEY_PROV_INFO pInfo,
HCRYPTPROV  hProv 
)
static

Definition at line 3304 of file cert.c.

3306 {
3307  CRYPT_KEY_PROV_INFO info = { 0 };
3308  BOOL ret;
3309 
3310  if (!pInfo)
3311  {
3312  DWORD size;
3313  int len;
3314 
3316  if (ret)
3317  {
3319 
3320  if (szContainer)
3321  {
3323  (BYTE *)szContainer, &size, 0);
3324  if (ret)
3325  {
3327  NULL, 0);
3328  if (len)
3329  {
3330  info.pwszContainerName = CryptMemAlloc(len *
3331  sizeof(WCHAR));
3333  info.pwszContainerName, len);
3334  }
3335  }
3337  }
3338  }
3340  if (ret)
3341  {
3343 
3344  if (szProvider)
3345  {
3347  &size, 0);
3348  if (ret)
3349  {
3351  NULL, 0);
3352  if (len)
3353  {
3354  info.pwszProvName = CryptMemAlloc(len *
3355  sizeof(WCHAR));
3357  info.pwszProvName, len);
3358  }
3359  }
3361  }
3362  }
3363  /* in case no CRYPT_KEY_PROV_INFO given,
3364  * we always use AT_SIGNATURE key spec
3365  */
3366  info.dwKeySpec = AT_SIGNATURE;
3367  size = sizeof(info.dwProvType);
3368  ret = CryptGetProvParam(hProv, PP_PROVTYPE, (LPBYTE)&info.dwProvType,
3369  &size, 0);
3370  if (!ret)
3371  info.dwProvType = PROV_RSA_FULL;
3372  pInfo = &info;
3373  }
3374 
3376  0, pInfo);
3377 
3378  if (pInfo == &info)
3379  {
3380  CryptMemFree(info.pwszContainerName);
3381  CryptMemFree(info.pwszProvName);
3382  }
3383 }
static const char * szProvider
Definition: rsaenh.c:36
#define PP_PROVTYPE
Definition: wincrypt.h:2096
#define PP_CONTAINER
Definition: wincrypt.h:2087
Definition: http.c:7098
#define CP_ACP
Definition: compat.h:99
char * LPSTR
Definition: xmlstorage.h:182
static HCRYPTPROV hProv
Definition: rsaenh.c:32
struct _test_info info[]
Definition: SetCursorPos.c:19
static const char szContainer[]
Definition: rsaenh.c:35
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define CERT_KEY_PROV_INFO_PROP_ID
Definition: wincrypt.h:2686
#define PP_NAME
Definition: wincrypt.h:2085
BOOL WINAPI CryptGetProvParam(HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1693
#define MultiByteToWideChar
Definition: compat.h:100
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
#define AT_SIGNATURE
Definition: wincrypt.h:2036
BOOL WINAPI CertSetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: cert.c:799
#define PROV_RSA_FULL
Definition: wincrypt.h:2039

Referenced by CertCreateSelfSignCertificate().

◆ CertContext_SetKeyProvInfoProperty()

static BOOL CertContext_SetKeyProvInfoProperty ( CONTEXT_PROPERTY_LIST properties,
const CRYPT_KEY_PROV_INFO info 
)
static

Definition at line 647 of file cert.c.

649 {
650  BOOL ret;
651  LPBYTE buf = NULL;
652  DWORD size = sizeof(CRYPT_KEY_PROV_INFO), i, containerSize, provNameSize;
653 
654  if (info->pwszContainerName)
655  containerSize = (lstrlenW(info->pwszContainerName) + 1) * sizeof(WCHAR);
656  else
657  containerSize = 0;
658  if (info->pwszProvName)
659  provNameSize = (lstrlenW(info->pwszProvName) + 1) * sizeof(WCHAR);
660  else
661  provNameSize = 0;
662  size += containerSize + provNameSize;
663  for (i = 0; i < info->cProvParam; i++)
664  size += sizeof(CRYPT_KEY_PROV_PARAM) + info->rgProvParam[i].cbData;
666  if (buf)
667  {
671  CryptMemFree(buf);
672  }
673  else
674  ret = FALSE;
675  return ret;
676 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
BOOL ContextPropertyList_SetProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, const BYTE *pbData, size_t cbData) DECLSPEC_HIDDEN
Definition: proplist.c:95
#define lstrlenW
Definition: compat.h:415
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
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
static void CRYPT_CopyKeyProvInfo(PCRYPT_KEY_PROV_INFO to, const CRYPT_KEY_PROV_INFO *from)
Definition: cert.c:608
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define CERT_KEY_PROV_INFO_PROP_ID
Definition: wincrypt.h:2686
struct _CRYPT_KEY_PROV_INFO CRYPT_KEY_PROV_INFO
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141

Referenced by CertContext_SetProperty().

◆ CertContext_SetProperty()

static BOOL CertContext_SetProperty ( cert_t cert,
DWORD  dwPropId,
DWORD  dwFlags,
const void pvData 
)
static

Definition at line 678 of file cert.c.

680 {
681  BOOL ret;
682 
683  TRACE("(%p, %d, %08x, %p)\n", cert, dwPropId, dwFlags, pvData);
684 
685  if (!cert->base.properties)
686  ret = FALSE;
687  else
688  {
689  switch (dwPropId)
690  {
692  case CERT_CTL_USAGE_PROP_ID: /* same as CERT_ENHKEY_USAGE_PROP_ID */
695  case CERT_HASH_PROP_ID:
710  {
711  if (pvData)
712  {
713  const CRYPT_DATA_BLOB *blob = pvData;
714 
715  ret = ContextPropertyList_SetProperty(cert->base.properties, dwPropId,
716  blob->pbData, blob->cbData);
717  }
718  else
719  {
721  ret = TRUE;
722  }
723  break;
724  }
726  if (pvData)
727  ret = ContextPropertyList_SetProperty(cert->base.properties, dwPropId,
728  pvData, sizeof(FILETIME));
729  else
730  {
732  ret = TRUE;
733  }
734  break;
736  {
737  if (pvData)
738  {
739  const CERT_KEY_CONTEXT *keyContext = pvData;
740 
741  if (keyContext->cbSize != sizeof(CERT_KEY_CONTEXT))
742  {
744  ret = FALSE;
745  }
746  else
747  ret = ContextPropertyList_SetProperty(cert->base.properties, dwPropId,
748  (const BYTE *)keyContext, keyContext->cbSize);
749  }
750  else
751  {
753  ret = TRUE;
754  }
755  break;
756  }
758  if (pvData)
759  ret = CertContext_SetKeyProvInfoProperty(cert->base.properties, pvData);
760  else
761  {
763  ret = TRUE;
764  }
765  break;
767  {
768  CERT_KEY_CONTEXT keyContext;
769  DWORD size = sizeof(keyContext);
770 
772  &keyContext, &size);
773  if (ret)
774  {
776  CryptReleaseContext(keyContext.hCryptProv, 0);
777  }
778  keyContext.cbSize = sizeof(keyContext);
779  if (pvData)
780  keyContext.hCryptProv = *(const HCRYPTPROV *)pvData;
781  else
782  {
783  keyContext.hCryptProv = 0;
784  keyContext.dwKeySpec = AT_SIGNATURE;
785  }
787  0, &keyContext);
788  break;
789  }
790  default:
791  FIXME("%d: stub\n", dwPropId);
792  ret = FALSE;
793  }
794  }
795  TRACE("returning %d\n", ret);
796  return ret;
797 }
void ContextPropertyList_RemoveProperty(CONTEXT_PROPERTY_LIST *list, DWORD id) DECLSPEC_HIDDEN
Definition: proplist.c:149
#define CERT_ENROLLMENT_PROP_ID
Definition: wincrypt.h:2712
#define CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID
Definition: wincrypt.h:2711
#define TRUE
Definition: types.h:120
static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: cert.c:678
Definition: image.c:133
static BOOL CertContext_GetProperty(cert_t *cert, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: cert.c:431
BOOL ContextPropertyList_SetProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, const BYTE *pbData, size_t cbData) DECLSPEC_HIDDEN
Definition: proplist.c:95
#define CERT_DATE_STAMP_PROP_ID
Definition: wincrypt.h:2713
#define CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID
Definition: wincrypt.h:2710
#define CERT_AUTO_ENROLL_PROP_ID
Definition: wincrypt.h:2707
#define CERT_KEY_IDENTIFIER_PROP_ID
Definition: wincrypt.h:2706
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
#define CERT_PVK_FILE_PROP_ID
Definition: wincrypt.h:2698
static BYTE cert[]
Definition: msg.c:1437
#define CERT_FRIENDLY_NAME_PROP_ID
Definition: wincrypt.h:2697
#define TRACE(s)
Definition: solgame.cpp:4
#define CERT_MD5_HASH_PROP_ID
Definition: wincrypt.h:2689
GLsizeiptr size
Definition: glext.h:5919
static BOOL CertContext_SetKeyProvInfoProperty(CONTEXT_PROPERTY_LIST *properties, const CRYPT_KEY_PROV_INFO *info)
Definition: cert.c:647
#define CERT_SIGNATURE_HASH_PROP_ID
Definition: wincrypt.h:2701
HCRYPTPROV hCryptProv
Definition: wincrypt.h:220
#define CERT_CROSS_CERT_DIST_POINTS_PROP_ID
Definition: wincrypt.h:2709
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
#define CERT_HASH_PROP_ID
Definition: wincrypt.h:2688
int ret
#define CERT_KEY_CONTEXT_PROP_ID
Definition: wincrypt.h:2690
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
unsigned char BYTE
Definition: mem.h:68
#define CERT_NEXT_UPDATE_LOCATION_PROP_ID
Definition: wincrypt.h:2696
#define CERT_RENEWAL_PROP_ID
Definition: wincrypt.h:2724
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
#define CERT_KEY_PROV_INFO_PROP_ID
Definition: wincrypt.h:2686
_In_ DWORD dwPropId
Definition: wincrypt.h:4952
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, ULONG_PTR dwFlags)
Definition: crypt.c:651
#define CERT_EXTENDED_ERROR_INFO_PROP_ID
Definition: wincrypt.h:2716
#define CERT_STORE_NO_CRYPT_RELEASE_FLAG
Definition: wincrypt.h:2452
#define AT_SIGNATURE
Definition: wincrypt.h:2036
#define CERT_SUBJECT_NAME_MD5_HASH_PROP_ID
Definition: wincrypt.h:2715
#define CERT_DESCRIPTION_PROP_ID
Definition: wincrypt.h:2699
#define CERT_CTL_USAGE_PROP_ID
Definition: wincrypt.h:2695
#define CERT_OCSP_RESPONSE_PROP_ID
Definition: wincrypt.h:2730
#define CERT_PUBKEY_ALG_PARA_PROP_ID
Definition: wincrypt.h:2708
#define CERT_KEY_PROV_HANDLE_PROP_ID
Definition: wincrypt.h:2685

Referenced by CertContext_GetHashProp(), CertContext_GetProperty(), and CertSetCertificateContextProperty().

◆ CertCreateCertificateContext()

PCCERT_CONTEXT WINAPI CertCreateCertificateContext ( DWORD  dwCertEncodingType,
const BYTE pbCertEncoded,
DWORD  cbCertEncoded 
)

Definition at line 316 of file cert.c.

318 {
319  cert_t *cert = NULL;
320  BYTE *data = NULL;
321  BOOL ret;
322  PCERT_INFO certInfo = NULL;
323  DWORD size = 0;
324 
325  TRACE("(%08x, %p, %d)\n", dwCertEncodingType, pbCertEncoded,
326  cbCertEncoded);
327 
329  {
331  return NULL;
332  }
333 
335  pbCertEncoded, cbCertEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL,
336  &certInfo, &size);
337  if (!ret)
338  return NULL;
339 
341  if (!cert)
342  return NULL;
344  if (!data)
345  {
346  Context_Release(&cert->base);
347  return NULL;
348  }
349 
350  memcpy(data, pbCertEncoded, cbCertEncoded);
351  cert->ctx.dwCertEncodingType = dwCertEncodingType;
352  cert->ctx.pbCertEncoded = data;
353  cert->ctx.cbCertEncoded = cbCertEncoded;
354  cert->ctx.pCertInfo = certInfo;
355  cert->ctx.hCertStore = &empty_store;
356 
357  return &cert->ctx;
358 }
WINECRYPT_CERTSTORE empty_store
Definition: store.c:1509
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
static const context_vtbl_t cert_vtbl
Definition: cert.c:118
#define CERT_ENCODING_TYPE_MASK
Definition: wincrypt.h:2290
void Context_Release(context_t *context)
Definition: context.c:106
context_t * Context_CreateDataContext(size_t contextSize, const context_vtbl_t *vtbl, WINECRYPT_CERTSTORE *store)
Definition: context.c:28
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ DWORD _In_ DWORD cbCertEncoded
Definition: wincrypt.h:5043
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
static BYTE cert[]
Definition: msg.c:1437
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define X509_CERT_TO_BE_SIGNED
Definition: wincrypt.h:3366
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5041
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454

Referenced by CertAddEncodedCertificateToStore(), CertCreateContext(), CertCreateSelfSignCertificate(), CRYPT_CreateSignedCert(), msg_get_signer_callback(), rdssl_cert_read(), ShowX509EncodedCertificate(), test_CertGetNameStringA(), test_CertNameToStrA(), test_CertNameToStrW(), test_crypt_ui_wiz_import(), test_encrypt_message(), test_enveloped_msg_open(), test_getObjectUrl(), test_sign_message(), test_utils(), test_verifyRevocation(), testAcquireCertPrivateKey(), testAcquireSecurityContext(), testAddCert(), testAddCertificateLink(), testCertProperties(), testCertRegisterSystemStore(), testCertTrust(), testCreateCert(), testDupCert(), testEmptyStore(), testFindCertInCRL(), testFindCRL(), testGetCertChain(), testGetCRLFromStore(), testGetValidUsages(), testImportPublicKey(), testIsValidCRLForCert(), testKeyUsage(), testLinkCert(), testObjTrust(), testRegStoreSavedCerts(), testStoresInCollection(), testVerifyCertChainPolicy(), testVerifyCRLRevocation(), testVerifyRevocation(), and testVerifySubjectCert().

◆ CertCreateContext()

const void* WINAPI CertCreateContext ( DWORD  dwContextType,
DWORD  dwEncodingType,
const BYTE pbEncoded,
DWORD  cbEncoded,
DWORD  dwFlags,
PCERT_CREATE_CONTEXT_PARA  pCreatePara 
)

Definition at line 3679 of file cert.c.

3682 {
3683  TRACE("(0x%x, 0x%x, %p, %d, 0x%08x, %p)\n", dwContextType, dwEncodingType,
3684  pbEncoded, cbEncoded, dwFlags, pCreatePara);
3685 
3686  if (dwFlags)
3687  {
3688  FIXME("dwFlags 0x%08x not handled\n", dwFlags);
3689  return NULL;
3690  }
3691  if (pCreatePara)
3692  {
3693  FIXME("pCreatePara not handled\n");
3694  return NULL;
3695  }
3696 
3697  switch (dwContextType)
3698  {
3702  return CertCreateCRLContext(dwEncodingType, pbEncoded, cbEncoded);
3704  return CertCreateCTLContext(dwEncodingType, pbEncoded, cbEncoded);
3705  default:
3706  WARN("unknown context type: 0x%x\n", dwContextType);
3707  return NULL;
3708  }
3709 }
#define WARN(fmt,...)
Definition: debug.h:111
PCCTL_CONTEXT WINAPI CertCreateCTLContext(DWORD dwMsgAndCertEncodingType, const BYTE *pbCtlEncoded, DWORD cbCtlEncoded)
Definition: ctl.c:363
_In_ DWORD dwEncodingType
Definition: wincrypt.h:4629
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define CERT_STORE_CERTIFICATE_CONTEXT
Definition: wincrypt.h:2974
#define TRACE(s)
Definition: solgame.cpp:4
static LPCSTR DWORD void BYTE * pbEncoded
Definition: str.c:196
PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType, const BYTE *pbCrlEncoded, DWORD cbCrlEncoded)
Definition: crl.c:85
PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded)
Definition: cert.c:316
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CERT_STORE_CTL_CONTEXT
Definition: wincrypt.h:2976
#define CERT_STORE_CRL_CONTEXT
Definition: wincrypt.h:2975

◆ CertCreateSelfSignCertificate()

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 at line 3552 of file cert.c.

3557 {
3559  BOOL ret, releaseContext = FALSE;
3561  DWORD pubKeySize = 0, dwKeySpec;
3562 
3563  TRACE("(%08lx, %p, %08x, %p, %p, %p, %p, %p)\n", hProv,
3564  pSubjectIssuerBlob, dwFlags, pKeyProvInfo, pSignatureAlgorithm, pStartTime,
3565  pExtensions, pExtensions);
3566 
3567  if(!pSubjectIssuerBlob)
3568  {
3570  return NULL;
3571  }
3572 
3573  dwKeySpec = pKeyProvInfo ? pKeyProvInfo->dwKeySpec : AT_SIGNATURE;
3574  if (!hProv)
3575  {
3576  if (!pKeyProvInfo)
3577  {
3579  releaseContext = TRUE;
3580  }
3581  else if (pKeyProvInfo->dwFlags & CERT_SET_KEY_PROV_HANDLE_PROP_ID)
3582  {
3584  return NULL;
3585  }
3586  else
3587  {
3588  HCRYPTKEY hKey = 0;
3589  /* acquire the context using the given information*/
3591  pKeyProvInfo->pwszProvName,pKeyProvInfo->dwProvType,
3592  pKeyProvInfo->dwFlags);
3593  if (!ret)
3594  {
3595  if(GetLastError() != NTE_BAD_KEYSET)
3596  return NULL;
3597  /* create the key set */
3599  pKeyProvInfo->pwszProvName,pKeyProvInfo->dwProvType,
3600  pKeyProvInfo->dwFlags|CRYPT_NEWKEYSET);
3601  if (!ret)
3602  return NULL;
3603  }
3604  /* check if the key is here */
3605  ret = CryptGetUserKey(hProv,dwKeySpec,&hKey);
3606  if(!ret)
3607  {
3608  if (NTE_NO_KEY == GetLastError())
3609  { /* generate the key */
3610  ret = CryptGenKey(hProv,dwKeySpec,0,&hKey);
3611  }
3612  if (!ret)
3613  {
3616  return NULL;
3617  }
3618  }
3619  CryptDestroyKey(hKey);
3620  releaseContext = TRUE;
3621  }
3622  }
3623 
3625  &pubKeySize);
3626  if (!ret)
3627  goto end;
3628  pubKey = CryptMemAlloc(pubKeySize);
3629  if (pubKey)
3630  {
3632  pubKey, &pubKeySize);
3633  if (ret)
3634  {
3635  CERT_INFO info = { 0 };
3636  CRYPT_DER_BLOB blob = { 0, NULL };
3637  BYTE serial[16];
3638  CRYPT_DATA_BLOB serialBlob = { sizeof(serial), serial };
3639 
3640  CryptGenRandom(hProv, sizeof(serial), serial);
3641  CRYPT_MakeCertInfo(&info, &serialBlob, pSubjectIssuerBlob,
3642  pSignatureAlgorithm, pStartTime, pEndTime, pubKey, pExtensions);
3644  &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &blob.pbData,
3645  &blob.cbData);
3646  if (ret)
3647  {
3649  context = CRYPT_CreateSignedCert(&blob, hProv,dwKeySpec,
3650  &info.SignatureAlgorithm);
3651  else
3653  blob.pbData, blob.cbData);
3655  CertContext_SetKeyProvInfo(context, pKeyProvInfo, hProv);
3656  LocalFree(blob.pbData);
3657  }
3658  }
3660  }
3661 end:
3662  if (releaseContext)
3664  return context;
3665 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
LPWSTR pwszContainerName
Definition: wincrypt.h:209
#define CRYPT_NEWKEYSET
Definition: wincrypt.h:2070
#define TRUE
Definition: types.h:120
static HCRYPTPROV CRYPT_CreateKeyProv(void)
Definition: cert.c:3506
#define NTE_NO_KEY
Definition: winerror.h:2881
Definition: image.c:133
Definition: http.c:7098
static PCCERT_CONTEXT CRYPT_CreateSignedCert(const CRYPT_DER_BLOB *blob, HCRYPTPROV hProv, DWORD dwKeySpec, PCRYPT_ALGORITHM_IDENTIFIER sigAlgo)
Definition: cert.c:3388
BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, void *pvEncoded, DWORD *pcbEncoded)
Definition: encode.c:4696
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint GLuint end
Definition: gl.h:1545
static HCRYPTPROV hProv
Definition: rsaenh.c:32
BOOL WINAPI CryptGenRandom(HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer)
Definition: crypt.c:705
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CryptGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKEY *phKey)
Definition: crypt.c:1456
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI CryptDestroyKey(HCRYPTKEY hKey)
Definition: crypt.c:935
#define CERT_CREATE_SELFSIGN_NO_SIGN
Definition: wincrypt.h:3597
#define TRACE(s)
Definition: solgame.cpp:4
static BYTE pubKey[]
Definition: msg.c:1214
#define NTE_BAD_KEYSET
Definition: winerror.h:2890
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
#define X509_CERT_TO_BE_SIGNED
Definition: wincrypt.h:3366
int ret
PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded)
Definition: cert.c:316
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
unsigned char BYTE
Definition: mem.h:68
BOOL WINAPI CryptExportPublicKeyInfo(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)
Definition: encode.c:4775
static void CRYPT_MakeCertInfo(PCERT_INFO info, const CRYPT_DATA_BLOB *pSerialNumber, const CERT_NAME_BLOB *pSubjectIssuerBlob, const CRYPT_ALGORITHM_IDENTIFIER *pSignatureAlgorithm, const SYSTEMTIME *pStartTime, const SYSTEMTIME *pEndTime, const CERT_PUBLIC_KEY_INFO *pubKey, const CERT_EXTENSIONS *pExtensions)
Definition: cert.c:3442
uint32_t serial
Definition: fsck.fat.h:64
static void CertContext_SetKeyProvInfo(PCCERT_CONTEXT context, const CRYPT_KEY_PROV_INFO *pInfo, HCRYPTPROV hProv)
Definition: cert.c:3304
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define NTE_BAD_FLAGS
Definition: winerror.h:2877
ULONG_PTR HCRYPTKEY
Definition: wincrypt.h:49
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, ULONG_PTR dwFlags)
Definition: crypt.c:651
#define CRYPT_ENCODE_ALLOC_FLAG
Definition: wincrypt.h:3441
#define AT_SIGNATURE
Definition: wincrypt.h:2036
#define CERT_CREATE_SELFSIGN_NO_KEY_INFO
Definition: wincrypt.h:3598
#define CERT_SET_KEY_PROV_HANDLE_PROP_ID
Definition: wincrypt.h:3594
BOOL WINAPI CryptGetUserKey(HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY *phUserKey)
Definition: crypt.c:1723

Referenced by init_function_pointers(), and testGetIssuerCert().

◆ CertDuplicateCertificateContext()

PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext ( PCCERT_CONTEXT  pCertContext)

Definition at line 360 of file cert.c.

361 {
362  TRACE("(%p)\n", pCertContext);
363 
364  if (!pCertContext)
365  return NULL;
366 
368  return pCertContext;
369 }
void Context_AddRef(context_t *context)
Definition: context.c:78
smooth NULL
Definition: ftsmooth.c:416
static cert_t * cert_from_ptr(const CERT_CONTEXT *ptr)
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

Referenced by add_cert_to_list(), add_cert_to_store(), add_cert_to_view(), CRYPT_AddCertToSimpleChain(), CRYPT_BuildAlternateContextFromChain(), CRYPT_CopySimpleChainToElement(), CryptMsgGetAndVerifySigner(), MsiGetFileSignatureInformationW(), request_query_option(), request_set_option(), select_cert_dlg_proc(), testAddCert(), testDupCert(), testMemStore(), and WINTRUST_AddCert().

◆ CertEnumCertificateContextProperties()

DWORD WINAPI CertEnumCertificateContextProperties ( PCCERT_CONTEXT  pCertContext,
DWORD  dwPropId 
)

Definition at line 380 of file cert.c.

382 {
384  DWORD ret;
385 
386  TRACE("(%p, %d)\n", pCertContext, dwPropId);
387 
388  if (cert->base.properties)
389  ret = ContextPropertyList_EnumPropIDs(cert->base.properties, dwPropId);
390  else
391  ret = 0;
392  return ret;
393 }
static BYTE cert[]
Definition: msg.c:1437
static cert_t * cert_from_ptr(const CERT_CONTEXT *ptr)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
_In_ DWORD dwPropId
Definition: wincrypt.h:4952
DWORD ContextPropertyList_EnumPropIDs(CONTEXT_PROPERTY_LIST *list, DWORD id) DECLSPEC_HIDDEN
Definition: proplist.c:170
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

Referenced by testCertProperties().

◆ CertFindAttribute()

PCRYPT_ATTRIBUTE WINAPI CertFindAttribute ( LPCSTR  pszObjId,
DWORD  cAttr,
CRYPT_ATTRIBUTE  rgAttr[] 
)

Definition at line 2006 of file cert.c.

2008 {
2010  DWORD i;
2011 
2012  TRACE("%s %d %p\n", debugstr_a(pszObjId), cAttr, rgAttr);
2013 
2014  if (!cAttr)
2015  return NULL;
2016  if (!pszObjId)
2017  {
2019  return NULL;
2020  }
2021 
2022  for (i = 0; !ret && i < cAttr; i++)
2023  if (rgAttr[i].pszObjId && !strcmp(pszObjId, rgAttr[i].pszObjId))
2024  ret = &rgAttr[i];
2025  return ret;
2026 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
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
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by test_findAttribute().

◆ CertFindCertificateInStore()

PCCERT_CONTEXT WINAPI CertFindCertificateInStore ( HCERTSTORE  hCertStore,
DWORD  dwCertEncodingType,
DWORD  dwFlags,
DWORD  dwType,
const void pvPara,
PCCERT_CONTEXT  pPrevCertContext 
)

Definition at line 1765 of file cert.c.

1768 {
1772 
1773  TRACE("(%p, %08x, %08x, %08x, %p, %p)\n", hCertStore, dwCertEncodingType,
1774  dwFlags, dwType, pvPara, pPrevCertContext);
1775 
1776  switch (dwType >> CERT_COMPARE_SHIFT)
1777  {
1778  case CERT_COMPARE_ANY:
1779  find = find_cert_any;
1780  break;
1781  case CERT_COMPARE_MD5_HASH:
1783  break;
1786  break;
1787  case CERT_COMPARE_NAME:
1789  break;
1792  break;
1795  break;
1798  break;
1801  break;
1802  case CERT_COMPARE_CERT_ID:
1804  break;
1807  break;
1808  case CERT_COMPARE_EXISTING:
1810  break;
1813  break;
1814  default:
1815  FIXME("find type %08x unimplemented\n", dwType);
1816  }
1817 
1818  if (find)
1819  ret = find(hCertStore, dwType, dwFlags, pvPara, pPrevCertContext);
1820  else if (compare)
1822  compare, dwType, dwFlags, pvPara);
1823  else
1824  ret = NULL;
1825  if (!ret)
1827  TRACE("returning %p\n", ret);
1828  return ret;
1829 }
Definition: bug.cpp:7
PCCERT_CONTEXT(* CertFindFunc)(HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
Definition: cert.c:1562
#define CERT_COMPARE_NAME
Definition: wincrypt.h:2843
BOOL(* CertCompareFunc)(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1364
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
static BOOL compare_existing_cert(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1510
#define CERT_COMPARE_ISSUER_OF
Definition: wincrypt.h:2854
#define CERT_COMPARE_SHIFT
Definition: wincrypt.h:2839
#define CERT_COMPARE_CERT_ID
Definition: wincrypt.h:2858
static PCCERT_CONTEXT find_cert_by_name_str_a(HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
Definition: cert.c:1706
#define CERT_COMPARE_SHA1_HASH
Definition: wincrypt.h:2841
static BOOL compare_cert_by_sha1_hash(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1388
static PCCERT_CONTEXT find_cert_by_issuer(HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
Definition: cert.c:1571
_In_ PCCERT_STORE_PROV_FIND_INFO _In_ PCCERT_CONTEXT pPrevCertContext
Definition: wincrypt.h:1279
static PCCERT_CONTEXT find_cert_any(HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
Definition: cert.c:1565
#define CERT_COMPARE_SIGNATURE_HASH
Definition: wincrypt.h:2856
static BOOL compare_cert_by_public_key(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1424
#define FIXME(fmt,...)
Definition: debug.h:110
static PCCERT_CONTEXT cert_compare_certs_in_store(HCERTSTORE store, PCCERT_CONTEXT prev, CertCompareFunc compare, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1546
smooth NULL
Definition: ftsmooth.c:416
#define CERT_COMPARE_MD5_HASH
Definition: wincrypt.h:2845
#define CERT_COMPARE_PUBLIC_KEY
Definition: wincrypt.h:2847
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL compare_cert_by_name(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1409
static BOOL compare_cert_by_md5_hash(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1367
#define SetLastError(x)
Definition: compat.h:417
#define CERT_COMPARE_NAME_STR_A
Definition: wincrypt.h:2848
int ret
#define CERT_COMPARE_NAME_STR_W
Definition: wincrypt.h:2849
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5041
static BOOL compare_cert_by_signature_hash(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1518
#define CERT_COMPARE_EXISTING
Definition: wincrypt.h:2855
#define CERT_COMPARE_SUBJECT_CERT
Definition: wincrypt.h:2853
static TAGID TAGID find
Definition: db.cpp:153
_In_ void * pvPara
Definition: wincrypt.h:6081
static PCCERT_CONTEXT find_cert_by_name_str_w(HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
Definition: cert.c:1735
#define CERT_COMPARE_ANY
Definition: wincrypt.h:2840
static BOOL compare_cert_by_cert_id(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1460
static BOOL compare_cert_by_subject_cert(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1435

Referenced by add_cert_to_store(), CertGetIssuerCertificateFromStore(), CertGetSubjectCertificateFromStore(), CRYPT_CheckBasicConstraintsForCA(), CRYPT_DefaultGetSignerCertificate(), CRYPT_FindCertInStore(), CRYPT_FindIssuer(), CRYPTDLG_IsCertAllowed(), CryptMsgGetAndVerifySigner(), find_and_delete_cert_in_store(), SoftpubAuthenticode(), testFindCert(), and testRegStoreSavedCerts().

◆ CertFindExtension()

PCERT_EXTENSION WINAPI CertFindExtension ( LPCSTR  pszObjId,
DWORD  cExtensions,
CERT_EXTENSION  rgExtensions[] 
)

Definition at line 2028 of file cert.c.

2030 {
2032  DWORD i;
2033 
2034  TRACE("%s %d %p\n", debugstr_a(pszObjId), cExtensions, rgExtensions);
2035 
2036  if (!cExtensions)
2037  return NULL;
2038  if (!pszObjId)
2039  {
2041  return NULL;
2042  }
2043 
2044  for (i = 0; !ret && i < cExtensions; i++)
2045  if (rgExtensions[i].pszObjId && !strcmp(pszObjId,
2046  rgExtensions[i].pszObjId))
2047  ret = &rgExtensions[i];
2048  return ret;
2049 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
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
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by cert_find_alt_name_entry(), CertContext_GetProperty(), CertGetEnhancedKeyUsage(), CertGetIntendedKeyUsage(), CertIsValidCRLForCertificate(), compare_crl_issued_by(), CRYPT_CheckUsages(), CRYPT_DecodeBasicConstraints(), CRYPT_GetIssuer(), CRYPT_GetNameConstraints(), CRYPT_GetPolicies(), CRYPT_GetUrlFromCertificateCRLDistPoint(), CRYPT_GetUrlFromCertificateIssuer(), CRYPT_IsCertificateSelfSigned(), CRYPT_KeyUsageValid(), display_app_usages(), find_cert_by_issuer(), get_subject_alt_name_ext(), is_ca_cert(), set_issuer_statement(), test_findExtension(), TrustIsCertificateSelfSigned(), and verify_cert_revocation().

◆ CertFindRDNAttr()

PCERT_RDN_ATTR WINAPI CertFindRDNAttr ( LPCSTR  pszObjId,
PCERT_NAME_INFO  pName 
)

Definition at line 2051 of file cert.c.

2052 {
2054  DWORD i, j;
2055 
2056  TRACE("%s %p\n", debugstr_a(pszObjId), pName);
2057 
2058  if (!pszObjId)
2059  {
2061  return NULL;
2062  }
2063 
2064  for (i = 0; !ret && i < pName->cRDN; i++)
2065  for (j = 0; !ret && j < pName->rgRDN[i].cRDNAttr; j++)
2066  if (pName->rgRDN[i].rgRDNAttr[j].pszObjId && !strcmp(pszObjId,
2067  pName->rgRDN[i].rgRDNAttr[j].pszObjId))
2068  ret = &pName->rgRDN[i].rgRDNAttr[j];
2069  return ret;
2070 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
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
smooth NULL
Definition: ftsmooth.c:416
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 GLint GLint j
Definition: glfuncs.h:250
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by cert_get_name_from_rdn_attr(), CertGetNameStringW(), get_cert_common_name(), match_dns_to_subject_dn(), and test_findRDNAttr().

◆ CertFreeCertificateContext()

BOOL WINAPI CertFreeCertificateContext ( PCCERT_CONTEXT  pCertContext)

Definition at line 371 of file cert.c.

372 {
373  TRACE("(%p)\n", pCertContext);
374 
375  if (pCertContext)
377  return TRUE;
378 }
#define TRUE
Definition: types.h:120
void Context_Release(context_t *context)
Definition: context.c:106
static cert_t * cert_from_ptr(const CERT_CONTEXT *ptr)
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

Referenced by Cert_clone(), CertAddEncodedCertificateToStore(), CertGetIssuerCertificateFromStore(), check_store_context_type(), CRYPT_BuildAlternateContextFromChain(), CRYPT_BuildSimpleChain(), CRYPT_CheckBasicConstraintsForCA(), CRYPT_CheckRestrictedRoot(), CRYPT_CheckTrustedStatus(), CRYPT_CreateAny(), CRYPT_FindIssuer(), CRYPT_FreeChainElement(), CRYPTDLG_IsCertAllowed(), CryptExtOpenCERW(), CryptMsgGetAndVerifySigner(), CryptVerifyDetachedMessageSignature(), CryptVerifyMessageSignature(), free_certs(), getChain(), HTTPREQ_QueryOption(), netcon_secure_connect_setup(), netconn_secure_connect(), open_connection(), rdssl_cert_free(), request_destroy(), request_set_option(), save_pfx(), ShowX509EncodedCertificate(), SoftpubAuthenticode(), SoftpubCleanup(), test_CERT_CHAIN_PARA_cbSize(), test_CertGetNameStringA(), test_CertNameToStrA(), test_CertNameToStrW(), test_communication(), test_crypt_ui_wiz_import(), test_encrypt_message(), test_enveloped_msg_open(), test_getObjectUrl(), test_msg_get_and_verify_signer(), test_retrieveObjectByUrl(), test_secure_connection(), test_sign_message(), test_utils(), test_verifyRevocation(), testAcquireCertPrivateKey(), testAcquireSecurityContext(), testAddCert(), testAddCertificateLink(), testAddSerialized(), testCertProperties(), testCertRegisterSystemStore(), testCertTrust(), testCloseStore(), testCollectionStore(), testCreateCert(), testCreateSelfSignCert(), testDupCert(), testEmptyStore(), testFileStore(), testFindCert(), testFindCertInCRL(), testFindCRL(), testGetCertChain(), testGetCRLFromStore(), testGetIssuerCert(), testGetSubjectCert(), testGetValidUsages(), testImportPublicKey(), testIsValidCRLForCert(), testKeyUsage(), testLinkCert(), testMemStore(), testObjTrust(), testRegStoreSavedCerts(), testStoresInCollection(), testVerifyCertChainPolicy(), testVerifyCRLRevocation(), testVerifyRevocation(), testVerifySubjectCert(), and WINTRUST_VerifySigner().

◆ CertGetCertificateContextProperty()

BOOL WINAPI CertGetCertificateContextProperty ( PCCERT_CONTEXT  pCertContext,
DWORD  dwPropId,
void pvData,
DWORD pcbData 
)

Definition at line 551 of file cert.c.

553 {
555  BOOL ret;
556 
557  TRACE("(%p, %d, %p, %p)\n", pCertContext, dwPropId, pvData, pcbData);
558 
559  switch (dwPropId)
560  {
561  case 0:
562  case CERT_CERT_PROP_ID:
563  case CERT_CRL_PROP_ID:
564  case CERT_CTL_PROP_ID:
566  ret = FALSE;
567  break;
569  ret = CertGetStoreProperty(cert->ctx.hCertStore, dwPropId, pvData, pcbData);
570  break;
572  {
573  CERT_KEY_CONTEXT keyContext;
574  DWORD size = sizeof(keyContext);
575 
577  CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size);
578  if (ret)
580  sizeof(keyContext.hCryptProv));
581  break;
582  }
585  pcbData);
586  if (ret && pvData)
588  break;
589  default:
591  pcbData);
592  }
593 
594  TRACE("returning %d\n", ret);
595  return ret;
596 }
BOOL WINAPI CertGetStoreProperty(HCERTSTORE hCertStore, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: store.c:1172
#define CERT_CERT_PROP_ID
static BOOL CertContext_GetProperty(cert_t *cert, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: cert.c:431
#define CERT_CTL_PROP_ID
#define CERT_ACCESS_STATE_PROP_ID
Definition: wincrypt.h:2700
unsigned int BOOL
Definition: ntddk_ex.h:94
#define E_INVALIDARG
Definition: ddrawi.h:101
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
static BYTE cert[]
Definition: msg.c:1437
static cert_t * cert_from_ptr(const CERT_CONTEXT *ptr)
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
HCRYPTPROV hCryptProv
Definition: wincrypt.h:220
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
static BOOL CertContext_CopyParam(void *pvData, DWORD *pcbData, const void *pb, DWORD cb)
Definition: cert.c:410
int ret
#define CERT_KEY_CONTEXT_PROP_ID
Definition: wincrypt.h:2690
void CRYPT_FixKeyProvInfoPointers(PCRYPT_KEY_PROV_INFO info)
Definition: cert.c:523
#define CERT_KEY_PROV_INFO_PROP_ID
Definition: wincrypt.h:2686
_In_ DWORD dwPropId
Definition: wincrypt.h:4952
#define CERT_CRL_PROP_ID
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4953
#define CERT_KEY_PROV_HANDLE_PROP_ID
Definition: wincrypt.h:2685
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

Referenced by add_cert_to_list(), add_cert_to_store(), add_cert_to_view(), add_properties(), cert_prov_info_matches_cert(), CertGetEnhancedKeyUsage(), CertGetNameStringW(), checkHash(), compare_cert_by_cert_id(), compare_cert_by_md5_hash(), compare_cert_by_sha1_hash(), compare_cert_by_signature_hash(), compare_crl_issued_by(), CRYPT_AcquirePrivateKeyFromProvInfo(), CRYPT_CheckBasicConstraintsForCA(), CRYPT_FindCertInStore(), CRYPT_IsCertificateSelfSigned(), CryptAcquireCertificatePrivateKey(), CRYPTDLG_IsCertAllowed(), export_get_private_key_info(), export_info_has_private_key(), get_cert_property_as_string(), SoftpubAuthenticode(), testAcquireCertPrivateKey(), testAddCertificateLink(), testAddSerialized(), testCertProperties(), testCreateCert(), testCreateSelfSignCert(), and TrustIsCertificateSelfSigned().

◆ CertGetEnhancedKeyUsage()

BOOL WINAPI CertGetEnhancedKeyUsage ( PCCERT_CONTEXT  pCertContext,
DWORD  dwFlags,
PCERT_ENHKEY_USAGE  pUsage,
DWORD pcbUsage 
)

Definition at line 2847 of file cert.c.

2849 {
2851  DWORD bytesNeeded;
2852  BOOL ret = TRUE;
2853 
2854  if (!pCertContext || !pcbUsage)
2855  {
2857  return FALSE;
2858  }
2859 
2860  TRACE("(%p, %08x, %p, %d)\n", pCertContext, dwFlags, pUsage, *pcbUsage);
2861 
2863  {
2864  DWORD propSize = 0;
2865 
2867  CERT_ENHKEY_USAGE_PROP_ID, NULL, &propSize))
2868  {
2869  LPBYTE buf = CryptMemAlloc(propSize);
2870 
2871  if (buf)
2872  {
2874  CERT_ENHKEY_USAGE_PROP_ID, buf, &propSize))
2875  {
2877  X509_ENHANCED_KEY_USAGE, buf, propSize,
2878  CRYPT_ENCODE_ALLOC_FLAG, NULL, &usage, &bytesNeeded);
2879  }
2880  CryptMemFree(buf);
2881  }
2882  }
2883  }
2885  {
2889 
2890  if (ext)
2891  {
2893  X509_ENHANCED_KEY_USAGE, ext->Value.pbData, ext->Value.cbData,
2894  CRYPT_ENCODE_ALLOC_FLAG, NULL, &usage, &bytesNeeded);
2895  }
2896  }
2897  if (!usage)
2898  {
2899  /* If a particular location is specified, this should fail. Otherwise
2900  * it should succeed with an empty usage. (This is true on Win2k and
2901  * later, which we emulate.)
2902  */
2903  if (dwFlags)
2904  {
2906  ret = FALSE;
2907  }
2908  else
2909  bytesNeeded = sizeof(CERT_ENHKEY_USAGE);
2910  }
2911 
2912  if (ret)
2913  {
2914  if (!pUsage)
2915  *pcbUsage = bytesNeeded;
2916  else if (*pcbUsage < bytesNeeded)
2917  {
2919  *pcbUsage = bytesNeeded;
2920  ret = FALSE;
2921  }
2922  else
2923  {
2924  *pcbUsage = bytesNeeded;
2925  if (usage)
2926  {
2927  DWORD i;
2928  LPSTR nextOID = (LPSTR)((LPBYTE)pUsage +
2929  sizeof(CERT_ENHKEY_USAGE) +
2930  usage->cUsageIdentifier * sizeof(LPSTR));
2931 
2932  pUsage->cUsageIdentifier = usage->cUsageIdentifier;
2933  pUsage->rgpszUsageIdentifier = (LPSTR *)((LPBYTE)pUsage +
2934  sizeof(CERT_ENHKEY_USAGE));
2935  for (i = 0; i < usage->cUsageIdentifier; i++)
2936  {
2937  pUsage->rgpszUsageIdentifier[i] = nextOID;
2938  strcpy(nextOID, usage->rgpszUsageIdentifier[i]);
2939  nextOID += strlen(nextOID) + 1;
2940  }
2941  }
2942  else
2943  pUsage->cUsageIdentifier = 0;
2944  }
2945  }
2946  if (usage)
2947  LocalFree(usage);
2948  TRACE("returning %d\n", ret);
2949  return ret;
2950 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
struct _CTL_USAGE CERT_ENHKEY_USAGE
#define TRUE
Definition: types.h:120
#define X509_ENHANCED_KEY_USAGE
Definition: wincrypt.h:3403
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
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
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
DWORD dwCertEncodingType
Definition: wincrypt.h:479
char * LPSTR
Definition: xmlstorage.h:182
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
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: cert.c:551
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
PCERT_EXTENSION rgExtension
Definition: wincrypt.h:252
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
#define TRACE(s)
Definition: solgame.cpp:4
PCERT_INFO pCertInfo
Definition: wincrypt.h:482
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
PCERT_EXTENSION WINAPI CertFindExtension(LPCSTR pszObjId, DWORD cExtensions, CERT_EXTENSION rgExtensions[])
Definition: cert.c:2028
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG
Definition: wincrypt.h:2916
DWORD cUsageIdentifier
Definition: wincrypt.h:719
#define CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG
Definition: wincrypt.h:2918
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define szOID_ENHANCED_KEY_USAGE
Definition: wincrypt.h:3202
DWORD cExtension
Definition: wincrypt.h:251
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
#define CRYPT_ENCODE_ALLOC_FLAG
Definition: wincrypt.h:3441
LPSTR * rgpszUsageIdentifier
Definition: wincrypt.h:720
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define CERT_ENHKEY_USAGE_PROP_ID
Definition: wincrypt.h:2694
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

Referenced by CertAddEnhancedKeyUsageIdentifier(), CertGetValidUsages(), CertRemoveEnhancedKeyUsageIdentifier(), display_cert_usages(), get_cert_usages(), show_cert_usages(), and testKeyUsage().

◆ CertGetIntendedKeyUsage()

BOOL WINAPI CertGetIntendedKeyUsage ( DWORD  dwCertEncodingType,
PCERT_INFO  pCertInfo,
BYTE pbKeyUsage,
DWORD  cbKeyUsage 
)

Definition at line 2810 of file cert.c.

2812 {
2814  BOOL ret = FALSE;
2815 
2816  TRACE("(%08x, %p, %p, %d)\n", dwCertEncodingType, pCertInfo, pbKeyUsage,
2817  cbKeyUsage);
2818 
2820  pCertInfo->rgExtension);
2821  if (ext)
2822  {
2824  DWORD size = sizeof(usage);
2825 
2827  ext->Value.pbData, ext->Value.cbData, CRYPT_DECODE_NOCOPY_FLAG, NULL,
2828  &usage, &size);
2829  if (ret)
2830  {
2831  if (cbKeyUsage < usage.cbData)
2832  ret = FALSE;
2833  else
2834  {
2835  memcpy(pbKeyUsage, usage.pbData, usage.cbData);
2836  if (cbKeyUsage > usage.cbData)
2837  memset(pbKeyUsage + usage.cbData, 0,
2838  cbKeyUsage - usage.cbData);
2839  }
2840  }
2841  }
2842  else
2843  SetLastError(0);
2844  return ret;
2845 }
#define szOID_KEY_USAGE
Definition: wincrypt.h:3185
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
unsigned int BOOL
Definition: ntddk_ex.h:94
PCERT_EXTENSION rgExtension
Definition: wincrypt.h:252
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
PCERT_EXTENSION WINAPI CertFindExtension(LPCSTR pszObjId, DWORD cExtensions, CERT_EXTENSION rgExtensions[])
Definition: cert.c:2028
int ret
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5041
#define CRYPT_DECODE_NOCOPY_FLAG
Definition: wincrypt.h:3450
DWORD cExtension
Definition: wincrypt.h:251
#define memset(x, y, z)
Definition: compat.h:39
#define X509_BITS
Definition: wincrypt.h:3392

Referenced by testIntendedKeyUsage().

◆ CertGetIssuerCertificateFromStore()

PCCERT_CONTEXT WINAPI CertGetIssuerCertificateFromStore ( HCERTSTORE  hCertStore,
PCCERT_CONTEXT  pSubjectContext,
PCCERT_CONTEXT  pPrevIssuerContext,
DWORD pdwFlags 
)

Definition at line 1887 of file cert.c.

1890 {
1892 
1893  TRACE("(%p, %p, %p, %08x)\n", hCertStore, pSubjectContext,
1894  pPrevIssuerContext, *pdwFlags);
1895 
1896  if (!pSubjectContext)
1897  {
1899  return NULL;
1900  }
1901 
1902  ret = CertFindCertificateInStore(hCertStore,
1903  pSubjectContext->dwCertEncodingType, 0, CERT_FIND_ISSUER_OF,
1904  pSubjectContext, pPrevIssuerContext);
1905  if (ret)
1906  {
1907  if (!CertVerifySubjectCertificateContext(pSubjectContext, ret,
1908  pdwFlags))
1909  {
1911  ret = NULL;
1912  }
1913  if (CRYPT_IsCertificateSelfSigned(pSubjectContext))
1914  {
1916  ret = NULL;
1918  }
1919  }
1920  TRACE("returning %p\n", ret);
1921  return ret;
1922 }
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, PCCERT_CONTEXT pPrevCertContext)
Definition: cert.c:1765
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
#define CERT_FIND_ISSUER_OF
Definition: wincrypt.h:2903
DWORD dwCertEncodingType
Definition: wincrypt.h:479
#define CRYPT_E_SELF_SIGNED
Definition: winerror.h:3010
DWORD CRYPT_IsCertificateSelfSigned(const CERT_CONTEXT *cert)
Definition: chain.c:268
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:417
int ret
BOOL WINAPI CertVerifySubjectCertificateContext(PCCERT_CONTEXT pSubject, PCCERT_CONTEXT pIssuer, DWORD *pdwFlags)
Definition: cert.c:1845

Referenced by testGetIssuerCert().

◆ CertGetPublicKeyLength()

DWORD WINAPI CertGetPublicKeyLength ( DWORD  dwCertEncodingType,
PCERT_PUBLIC_KEY_INFO  pPublicKey 
)

Definition at line 1305 of file cert.c.

1307 {
1308  DWORD len = 0;
1309 
1310  TRACE("(%08x, %p)\n", dwCertEncodingType, pPublicKey);
1311 
1313  {
1315  return 0;
1316  }
1317  if (pPublicKey->Algorithm.pszObjId &&
1318  !strcmp(pPublicKey->Algorithm.pszObjId, szOID_RSA_DH))
1319  {
1320  FIXME("unimplemented for DH public keys\n");
1322  }
1323  else
1324  {
1326  DWORD size;
1327  PBYTE buf;
1328  BOOL ret;
1329 
1331  if (info)
1332  {
1333  HCRYPTKEY key;
1334 
1335  TRACE("public key algid %#x (%s)\n", info->u.Algid, debugstr_a(pPublicKey->Algorithm.pszObjId));
1336 
1338  if (ret)
1339  {
1340  size = sizeof(len);
1341  ret = CryptGetKeyParam(key, KP_KEYLEN, (BYTE *)&len, &size, 0);
1343  return len;
1344  }
1345  /* fallback to RSA */
1346  }
1347 
1349  RSA_CSP_PUBLICKEYBLOB, pPublicKey->PublicKey.pbData,
1351  &size);
1352 
1353  if (ret)
1354  {
1355  RSAPUBKEY *rsaPubKey = (RSAPUBKEY *)(buf + sizeof(BLOBHEADER));
1356 
1357  len = rsaPubKey->bitlen;
1358  LocalFree(buf);
1359  }
1360  }
1361  return len;
1362 }
#define CRYPT_E_ASN1_BADTAG
Definition: winerror.h:3095
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
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
BOOL WINAPI CryptGetKeyParam(HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1654
struct _test_info info[]
Definition: SetCursorPos.c:19
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define KP_KEYLEN
Definition: wincrypt.h:2136
BOOL WINAPI CryptImportPublicKeyInfo(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, HCRYPTKEY *phKey)
Definition: encode.c:4970
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI CryptDestroyKey(HCRYPTKEY hKey)
Definition: crypt.c:935
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_a
Definition: kernel32.h:31
HCRYPTPROV WINAPI I_CryptGetDefaultCryptProv(ALG_ID)
Definition: main.c:210
#define GET_CERT_ENCODING_TYPE(x)
Definition: wincrypt.h:2292
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define CRYPT_OID_INFO_OID_KEY
Definition: wincrypt.h:1702
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5041
DWORD bitlen
Definition: wincrypt.h:144
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
CRYPT_BIT_BLOB PublicKey
Definition: wincrypt.h:226
ULONG_PTR HCRYPTKEY
Definition: wincrypt.h:49
#define szOID_RSA_DH
Definition: wincrypt.h:3027
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define RSA_CSP_PUBLICKEYBLOB
Definition: wincrypt.h:3384
PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey, DWORD dwGroupId)
Definition: oid.c:1799
BYTE * PBYTE
Definition: pedump.c:66
BYTE * pbData
Definition: wincrypt.h:197
CRYPT_ALGORITHM_IDENTIFIER Algorithm
Definition: wincrypt.h:225
Definition: path.c:41

Referenced by field_format_public_key(), and testGetPublicKeyLength().

◆ CertGetSubjectCertificateFromStore()

PCCERT_CONTEXT WINAPI CertGetSubjectCertificateFromStore ( HCERTSTORE  hCertStore,
DWORD  dwCertEncodingType,
PCERT_INFO  pCertId 
)

Definition at line 1831 of file cert.c.

1833 {
1834  TRACE("(%p, %08x, %p)\n", hCertStore, dwCertEncodingType, pCertId);
1835 
1836  if (!pCertId)
1837  {
1839  return NULL;
1840  }
1841  return CertFindCertificateInStore(hCertStore, dwCertEncodingType, 0,
1842  CERT_FIND_SUBJECT_CERT, pCertId, NULL);
1843 }
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, PCCERT_CONTEXT pPrevCertContext)
Definition: cert.c:1765
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:417
#define CERT_FIND_SUBJECT_CERT
Definition: wincrypt.h:2901
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5041

Referenced by testGetSubjectCert(), and WINTRUST_VerifySigner().

◆ CertGetValidUsages()

BOOL WINAPI CertGetValidUsages ( DWORD  cCerts,
PCCERT_CONTEXT rghCerts,
int cNumOIDs,
LPSTR rghOIDs,
DWORD pcbOIDs 
)

Definition at line 3159 of file cert.c.

3161 {
3162  BOOL ret = TRUE;
3163  DWORD i, cbOIDs = 0;
3164  BOOL allUsagesValid = TRUE;
3165  CERT_ENHKEY_USAGE validUsages = { 0, NULL };
3166 
3167  TRACE("(%d, %p, %d, %p, %d)\n", cCerts, rghCerts, *cNumOIDs,
3168  rghOIDs, *pcbOIDs);
3169 
3170  for (i = 0; i < cCerts; i++)
3171  {
3173  DWORD size = sizeof(usage);
3174 
3175  ret = CertGetEnhancedKeyUsage(rghCerts[i], 0, &usage, &size);
3176  /* Success is deliberately ignored: it implies all usages are valid */
3177  if (!ret && GetLastError() == ERROR_MORE_DATA)
3178  {
3180 
3181  allUsagesValid = FALSE;
3182  if (pUsage)
3183  {
3184  ret = CertGetEnhancedKeyUsage(rghCerts[i], 0, pUsage, &size);
3185  if (ret)
3186  {
3187  if (!validUsages.cUsageIdentifier)
3188  {
3189  DWORD j;
3190 
3191  cbOIDs = pUsage->cUsageIdentifier * sizeof(LPSTR);
3192  validUsages.cUsageIdentifier = pUsage->cUsageIdentifier;
3193  for (j = 0; j < validUsages.cUsageIdentifier; j++)
3194  cbOIDs += lstrlenA(pUsage->rgpszUsageIdentifier[j])
3195  + 1;
3196  validUsages.rgpszUsageIdentifier =
3197  CryptMemAlloc(cbOIDs);
3198  if (validUsages.rgpszUsageIdentifier)
3199  {
3200  LPSTR nextOID = (LPSTR)
3201  ((LPBYTE)validUsages.rgpszUsageIdentifier +
3202  validUsages.cUsageIdentifier * sizeof(LPSTR));
3203 
3204  for (j = 0; j < validUsages.cUsageIdentifier; j++)
3205  {
3206  validUsages.rgpszUsageIdentifier[j] = nextOID;
3207  lstrcpyA(validUsages.rgpszUsageIdentifier[j],
3208  pUsage->rgpszUsageIdentifier[j]);
3209  nextOID += lstrlenA(nextOID) + 1;
3210  }
3211  }
3212  }
3213  else
3214  {
3215  struct BitField validIndexes = { 0, NULL };
3216  DWORD j, k, numRemoved = 0;
3217 
3218  /* Merge: build a bitmap of all the indexes of
3219  * validUsages.rgpszUsageIdentifier that are in pUsage.
3220  */
3221  for (j = 0; j < pUsage->cUsageIdentifier; j++)
3222  {
3223  for (k = 0; k < validUsages.cUsageIdentifier; k++)
3224  {
3225  if (!strcmp(pUsage->rgpszUsageIdentifier[j],
3226  validUsages.rgpszUsageIdentifier[k]))
3227  {
3228  CRYPT_SetBitInField(&validIndexes, k);
3229  break;
3230  }
3231  }
3232  }
3233  /* Merge by removing from validUsages those that are
3234  * not in the bitmap.
3235  */
3236  for (j = 0; j < validUsages.cUsageIdentifier; j++)
3237  {
3238  if (!CRYPT_IsBitInFieldSet(&validIndexes, j))
3239  {
3240  if (j < validUsages.cUsageIdentifier - 1)
3241  {
3242  memmove(&validUsages.rgpszUsageIdentifier[j],
3243  &validUsages.rgpszUsageIdentifier[j +
3244  numRemoved + 1],
3245  (validUsages.cUsageIdentifier - numRemoved
3246  - j - 1) * sizeof(LPSTR));
3247  cbOIDs -= lstrlenA(
3248  validUsages.rgpszUsageIdentifier[j]) + 1 +
3249  sizeof(LPSTR);
3250  validUsages.cUsageIdentifier--;
3251  numRemoved++;
3252  }
3253  else
3254  validUsages.cUsageIdentifier--;
3255  }
3256  }
3257  CryptMemFree(validIndexes.indexes);
3258  }
3259  }
3260  CryptMemFree(pUsage);
3261  }
3262  }
3263  }
3264  ret = TRUE;
3265  if (allUsagesValid)
3266  {
3267  *cNumOIDs = -1;
3268  *pcbOIDs = 0;
3269  }
3270  else
3271  {
3272  *cNumOIDs = validUsages.cUsageIdentifier;
3273  if (!rghOIDs)
3274  *pcbOIDs = cbOIDs;
3275  else if (*pcbOIDs < cbOIDs)
3276  {
3277  *pcbOIDs = cbOIDs;
3279  ret = FALSE;
3280  }
3281  else
3282  {
3283  LPSTR nextOID = (LPSTR)((LPBYTE)rghOIDs +
3284  validUsages.cUsageIdentifier * sizeof(LPSTR));
3285 
3286  *pcbOIDs = cbOIDs;
3287  for (i = 0; i < validUsages.cUsageIdentifier; i++)
3288  {
3289  rghOIDs[i] = nextOID;
3290  lstrcpyA(nextOID, validUsages.rgpszUsageIdentifier[i]);
3291  nextOID += lstrlenA(nextOID) + 1;
3292  }
3293  }
3294  }
3295  CryptMemFree(validUsages.rgpszUsageIdentifier);
3296  TRACE("cNumOIDs: %d\n", *cNumOIDs);
3297  TRACE("returning %d\n", ret);
3298  return ret;
3299 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void CRYPT_SetBitInField(struct BitField *field, DWORD bit)
Definition: cert.c:3128
static BOOL CRYPT_IsBitInFieldSet(const struct BitField *field, DWORD bit)
Definition: cert.c:3149
char * LPSTR
Definition: xmlstorage.h:182
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
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_Out_ int _Out_writes_bytes_to_opt_ pcbOIDs LPSTR _Inout_ DWORD * pcbOIDs
Definition: wincrypt.h:5308
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 GLint GLint j
Definition: glfuncs.h:250
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
_Out_ int _Out_writes_bytes_to_opt_ pcbOIDs LPSTR * rghOIDs
Definition: wincrypt.h:5308
DWORD * indexes
Definition: cert.c:3123
unsigned long DWORD
Definition: ntddk_ex.h:95
_Out_ int * cNumOIDs
Definition: wincrypt.h:5307
#define SetLastError(x)
Definition: compat.h:417
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int ret
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
#define ERROR_MORE_DATA
Definition: dderror.h:13
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
DWORD cUsageIdentifier
Definition: wincrypt.h:719
BOOL WINAPI CertGetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, DWORD dwFlags, PCERT_ENHKEY_USAGE pUsage, DWORD *pcbUsage)
Definition: cert.c:2847
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
LPSTR * rgpszUsageIdentifier
Definition: wincrypt.h:720
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int k
Definition: mpi.c:3369

Referenced by init_function_pointers(), and show_store_certs().

◆ CertIsRDNAttrsInCertificateName()

BOOL WINAPI CertIsRDNAttrsInCertificateName ( DWORD  dwCertEncodingType,
DWORD  dwFlags,
PCERT_NAME_BLOB  pCertName,
PCERT_RDN  pRDN 
)

Definition at line 2131 of file cert.c.

2133 {
2135  LPCSTR type;
2136  DWORD size;
2137  BOOL ret;
2138 
2139  TRACE("(%08x, %08x, %p, %p)\n", dwCertEncodingType, dwFlags, pCertName,
2140  pRDN);
2141 
2143  X509_NAME;
2145  pCertName->cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &name, &size)))
2146  {
2147  DWORD i;
2148 
2149  for (i = 0; ret && i < pRDN->cRDNAttr; i++)
2151  if (!ret)
2153  LocalFree(name);
2154  }
2155  return ret;
2156 }
PCERT_RDN_ATTR rgRDNAttr
Definition: wincrypt.h:263
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
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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
static BOOL find_matching_rdn_attr(DWORD dwFlags, const CERT_NAME_INFO *name, const CERT_RDN_ATTR *attr)
Definition: cert.c:2072
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define X509_NAME
Definition: wincrypt.h:3372
#define TRACE(s)
Definition: solgame.cpp:4
#define CERT_UNICODE_IS_RDN_ATTRS_FLAG
Definition: wincrypt.h:2806
GLsizeiptr size
Definition: glext.h:5919
DWORD cRDNAttr
Definition: wincrypt.h:262
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
BYTE * pbData
Definition: wincrypt.h:103
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5041
#define CRYPT_E_NO_MATCH
Definition: winerror.h:3012
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define X509_UNICODE_NAME
Definition: wincrypt.h:3385
Definition: name.c:38
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by directory_name_matches(), and testIsRDNAttrsInCertificateName().

◆ CertRemoveEnhancedKeyUsageIdentifier()

BOOL WINAPI CertRemoveEnhancedKeyUsageIdentifier ( PCCERT_CONTEXT  pCertContext,
LPCSTR  pszUsageIdentifier 
)

Definition at line 3063 of file cert.c.

3065 {
3066  BOOL ret;
3067  DWORD size;
3069 
3070  TRACE("(%p, %s)\n", pCertContext, debugstr_a(pszUsageIdentifier));
3071 
3072  size = sizeof(usage);
3075  if (!ret && GetLastError() == ERROR_MORE_DATA)
3076  {
3078 
3079  if (pUsage)
3080  {
3083  if (ret)
3084  {
3085  if (pUsage->cUsageIdentifier)
3086  {
3087  DWORD i;
3088  BOOL found = FALSE;
3089 
3090  for (i = 0; i < pUsage->cUsageIdentifier; i++)
3091  {
3092  if (!strcmp(pUsage->rgpszUsageIdentifier[i],
3093  pszUsageIdentifier))
3094  found = TRUE;
3095  if (found && i < pUsage->cUsageIdentifier - 1)
3096  pUsage->rgpszUsageIdentifier[i] =
3097  pUsage->rgpszUsageIdentifier[i + 1];
3098  }
3099  pUsage->cUsageIdentifier--;
3100  /* Remove the usage if it's empty */
3101  if (pUsage->cUsageIdentifier)
3103  else
3105  }
3106  }
3107  CryptMemFree(pUsage);
3108  }
3109  else
3110  ret = FALSE;
3111  }
3112  else
3113  {
3114  /* it fit in an empty usage, therefore there's nothing to remove */
3115  ret = TRUE;
3116  }
3117  return ret;
3118 }
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
BOOL WINAPI CertSetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, PCERT_ENHKEY_USAGE pUsage)
Definition: cert.c:2952
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
#define ERROR_MORE_DATA
Definition: dderror.h:13
DWORD cUsageIdentifier
Definition: wincrypt.h:719
#define CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG
Definition: wincrypt.h:2918
BOOL WINAPI CertGetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, DWORD dwFlags, PCERT_ENHKEY_USAGE pUsage, DWORD *pcbUsage)
Definition: cert.c:2847
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
LPSTR * rgpszUsageIdentifier
Definition: wincrypt.h:720
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

Referenced by testKeyUsage().

◆ CertSetCertificateContextProperty()

BOOL WINAPI CertSetCertificateContextProperty ( PCCERT_CONTEXT  pCertContext,
DWORD  dwPropId,
DWORD  dwFlags,
const void pvData 
)

Definition at line 799 of file cert.c.

801 {
802  BOOL ret;
803 
804  TRACE("(%p, %d, %08x, %p)\n", pCertContext, dwPropId, dwFlags, pvData);
805 
806  /* Handle special cases for "read-only"/invalid prop IDs. Windows just
807  * crashes on most of these, I'll be safer.
808  */
809  switch (dwPropId)
810  {
811  case 0:
813  case CERT_CERT_PROP_ID:
814  case CERT_CRL_PROP_ID:
815  case CERT_CTL_PROP_ID:
817  return FALSE;
818  }
820  pvData);
821  TRACE("returning %d\n", ret);
822  return ret;
823 }
static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: cert.c:678
#define CERT_CERT_PROP_ID
#define CERT_CTL_PROP_ID
#define CERT_ACCESS_STATE_PROP_ID
Definition: wincrypt.h:2700
unsigned int BOOL
Definition: ntddk_ex.h:94
#define E_INVALIDARG
Definition: ddrawi.h:101
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3748
static cert_t * cert_from_ptr(const CERT_CONTEXT *ptr)
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:417
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_In_ DWORD dwPropId
Definition: wincrypt.h:4952
#define CERT_CRL_PROP_ID
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

Referenced by CertContext_SetKeyProvInfo(), CertSetEnhancedKeyUsage(), CryptAcquireCertificatePrivateKey(), find_matching_provider(), save_pfx(), set_cert_string_property(), test_sign_message(), testAcquireCertPrivateKey(), testAcquireSecurityContext(), testAddCert(), testAddCertificateLink(), and testCertProperties().

◆ CertSetEnhancedKeyUsage()

BOOL WINAPI CertSetEnhancedKeyUsage ( PCCERT_CONTEXT  pCertContext,
PCERT_ENHKEY_USAGE  pUsage 
)

Definition at line 2952 of file cert.c.

2954 {
2955  BOOL ret;
2956 
2957  TRACE("(%p, %p)\n", pCertContext, pUsage);
2958 
2959  if (pUsage)
2960  {
2961  CRYPT_DATA_BLOB blob = { 0, NULL };
2962 
2964  pUsage, CRYPT_ENCODE_ALLOC_FLAG, NULL, &blob.pbData, &blob.cbData);
2965  if (ret)
2966  {
2969  LocalFree(blob.pbData);
2970  }
2971  }
2972  else
2975  return ret;
2976 }
#define X509_ENHANCED_KEY_USAGE
Definition: wincrypt.h:3403
Definition: image.c:133
BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, void *pvEncoded, DWORD *pcbEncoded)
Definition: encode.c:4696
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
int ret
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define CRYPT_ENCODE_ALLOC_FLAG
Definition: wincrypt.h:3441
#define CERT_ENHKEY_USAGE_PROP_ID
Definition: wincrypt.h:2694
BOOL WINAPI CertSetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: cert.c:799
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4840

Referenced by apply_general_changes(), CertAddEnhancedKeyUsageIdentifier(), CertRemoveEnhancedKeyUsageIdentifier(), and testKeyUsage().

◆ CertVerifyCTLUsage()

BOOL WINAPI CertVerifyCTLUsage ( DWORD  dwEncodingType,
DWORD  dwSubjectType,
void pvSubject,
PCTL_USAGE  pSubjectUsage,
DWORD  dwFlags,
PCTL_VERIFY_USAGE_PARA  pVerifyUsagePara,
PCTL_VERIFY_USAGE_STATUS  pVerifyUsageStatus 
)

Definition at line 3667 of file cert.c.

3671 {
3672  FIXME("(0x%x, %d, %p, %p, 0x%x, %p, %p): stub\n", dwEncodingType,
3673  dwSubjectType, pvSubject, pSubjectUsage, dwFlags, pVerifyUsagePara,
3674  pVerifyUsageStatus);
3676  return FALSE;
3677 }
_In_ DWORD dwEncodingType
Definition: wincrypt.h:4629
#define FIXME(fmt,...)
Definition: debug.h:110
#define SetLastError(x)
Definition: compat.h:417
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ CertVerifyRevocation()

BOOL WINAPI CertVerifyRevocation ( DWORD  dwEncodingType,
DWORD  dwRevType,
DWORD  cContext,
PVOID  rgpvContext[],
DWORD  dwFlags,
PCERT_REVOCATION_PARA  pRevPara,
PCERT_REVOCATION_STATUS  pRevStatus 
)

Definition at line 1934 of file cert.c.

1937 {
1938  BOOL ret;
1939 
1940  TRACE("(%08x, %d, %d, %p, %08x, %p, %p)\n", dwEncodingType, dwRevType,
1941  cContext, rgpvContext, dwFlags, pRevPara, pRevStatus);
1942 
1943  if (pRevStatus->cbSize != sizeof(OLD_CERT_REVOCATION_STATUS) &&
1944  pRevStatus->cbSize != sizeof(CERT_REVOCATION_STATUS))
1945  {
1947  return FALSE;
1948  }
1949  if (cContext)
1950  {
1951  static HCRYPTOIDFUNCSET set = NULL;
1952  DWORD size;
1953 
1954  if (!set)
1957