ReactOS 0.4.15-dev-8408-g466a198
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;
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;
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)
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}
#define FIXME(fmt,...)
Definition: precomp.h:53
static void * context_ptr(context_t *context)
static context_t * context_from_ptr(const void *ptr)
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, PCCERT_CONTEXT pPrevCertContext)
Definition: cert.c:1765
BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: cert.c:551
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:360
void Context_Release(context_t *context)
Definition: context.c:106
void Context_CopyProperties(const void *to, const void *from)
Definition: context.c:123
#define SetLastError(x)
Definition: compat.h:752
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
static BYTE cert[]
Definition: msg.c:1437
#define TRACE(s)
Definition: solgame.cpp:4
const store_vtbl_t * vtbl
PCERT_INFO pCertInfo
Definition: wincrypt.h:482
FILETIME NotBefore
Definition: wincrypt.h:245
BOOL(* addContext)(struct WINE_CRYPTCERTSTORE *, context_t *, context_t *, context_t **, BOOL)
Definition: image.c:134
CONTEXT_FUNCS certs
int ret
#define CERT_STORE_ADD_REPLACE_EXISTING
Definition: wincrypt.h:2484
#define CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES
Definition: wincrypt.h:2488
#define CERT_STORE_ADD_NEWER
Definition: wincrypt.h:2487
#define CERT_STORE_ADD_USE_EXISTING
Definition: wincrypt.h:2483
#define CERT_STORE_ADD_NEW
Definition: wincrypt.h:2482
#define CERT_HASH_PROP_ID
Definition: wincrypt.h:2688
#define CERT_STORE_ADD_ALWAYS
Definition: wincrypt.h:2485
#define CERT_FIND_SHA1_HASH
Definition: wincrypt.h:2865
#define CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES
Definition: wincrypt.h:2486
#define CRYPT_E_EXISTS
Definition: winerror.h:3008
unsigned char BYTE
Definition: xxhash.c:193

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}
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
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
static const context_vtbl_t cert_vtbl
Definition: cert.c:118
context_t * Context_CreateLinkContext(unsigned int contextSize, context_t *linked, WINECRYPT_CERTSTORE *store)
Definition: context.c:54
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
GLuint res
Definition: glext.h:9613
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD dwCertEncodingType
Definition: wincrypt.h:479
BYTE * pbCertEncoded
Definition: wincrypt.h:480
DWORD cbCertEncoded
Definition: wincrypt.h:481
CERT_CONTEXT ctx
Definition: http.c:7252
#define X509_CERT_TO_BE_SIGNED
Definition: wincrypt.h:3366
#define CRYPT_DECODE_ALLOC_FLAG
Definition: wincrypt.h:3454

◆ 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 compare
PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrev)
Definition: store.c:928
#define matches(FN)
Definition: match.h:70
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ void * pvPara
Definition: wincrypt.h:6077

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{
123
124 CryptMemFree(cert->ctx.pbCertEncoded);
125 LocalFree(cert->ctx.pCertInfo);
126}
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594

◆ 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}
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

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}
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 _In_ DWORD dwAddDisposition
Definition: wincrypt.h:4984
_In_ PCCERT_CONTEXT _In_ DWORD _Outptr_opt_ PCCERT_CONTEXT * ppStoreContext
Definition: wincrypt.h:4985
_In_ PCCERT_CONTEXT pCertContext
Definition: wincrypt.h:4836

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,
307 return FALSE;
308 if (store->type == StoreTypeCollection)
309 {
311 return FALSE;
312 }
314}
#define WINE_CRYPTCERTSTORE_MAGIC
@ StoreTypeCollection
_In_ DWORD _In_ DWORD _In_ DWORD _Outptr_opt_ PCCERT_CONTEXT * ppCertContext
Definition: wincrypt.h:5041

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
PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded)
Definition: cert.c:316
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5037
_In_ DWORD _In_ DWORD cbCertEncoded
Definition: wincrypt.h:5039

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
HCERTSTORE WINAPI CertOpenSystemStoreA(HCRYPTPROV_LEGACY hProv, LPCSTR szSubSystemProtocol)
Definition: store.c:904
BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
Definition: store.c:1127
#define debugstr_a
Definition: kernel32.h:31
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297

◆ 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,
107
108 store = CertOpenSystemStoreW(0, pszCertStoreName);
109 if (store)
110 {
113 CertCloseStore(store, 0);
114 }
115 return ret;
116}
HCERTSTORE WINAPI CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv, LPCWSTR szSubSystemProtocol)
Definition: store.c:916
#define debugstr_w
Definition: kernel32.h:32

◆ 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}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
BOOL WINAPI CertSetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, PCERT_ENHKEY_USAGE pUsage)
Definition: cert.c:2952
BOOL WINAPI CertGetEnhancedKeyUsage(PCCERT_CONTEXT pCertContext, DWORD dwFlags, PCERT_ENHKEY_USAGE pUsage, DWORD *pcbUsage)
Definition: cert.c:2847
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
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
DWORD cUsageIdentifier
Definition: wincrypt.h:719
LPSTR * rgpszUsageIdentifier
Definition: wincrypt.h:720
unsigned char * LPBYTE
Definition: typedefs.h:53
struct _CTL_USAGE CERT_ENHKEY_USAGE
#define CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG
Definition: wincrypt.h:2918
char * LPSTR
Definition: xmlstorage.h:182

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}
BOOL WINAPI CertCompareCertificateName(DWORD dwCertEncodingType, PCERT_NAME_BLOB pCertName1, PCERT_NAME_BLOB pCertName2)
Definition: cert.c:1180
BOOL WINAPI CertCompareIntegerBlob(PCRYPT_INTEGER_BLOB pInt1, PCRYPT_INTEGER_BLOB pInt2)
Definition: cert.c:1221
CERT_NAME_BLOB Issuer
Definition: wincrypt.h:244
CRYPT_INTEGER_BLOB SerialNumber
Definition: wincrypt.h:242

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}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
BYTE * pbData
Definition: wincrypt.h:103

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}
static DWORD CRYPT_significantBytes(const CRYPT_INTEGER_BLOB *pInt)
Definition: cert.c:1205

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)
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 WARN(fmt,...)
Definition: precomp.h:61
BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6278
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define LPVOID
Definition: nt_native.h:45
#define ASN_SEQUENCE
Definition: snmp.h:110
CRYPT_BIT_BLOB PublicKey
Definition: wincrypt.h:226
DWORD cUnusedBits
Definition: wincrypt.h:198
BYTE * pbData
Definition: wincrypt.h:197
DWORD pubexp
Definition: wincrypt.h:145
DWORD bitlen
Definition: wincrypt.h:144
#define GET_CERT_ENCODING_TYPE(x)
Definition: wincrypt.h:2292
#define RSA_CSP_PUBLICKEYBLOB
Definition: wincrypt.h:3384

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 ERROR_MORE_DATA
Definition: dderror.h:13
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4950
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749

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}
BOOL WINAPI CryptHashCertificate(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash)
Definition: cert.c:2187
static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: cert.c:678
_In_ DWORD dwPropId
Definition: wincrypt.h:4948

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)
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}
BOOL ContextPropertyList_FindProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, PCRYPT_DATA_BLOB blob) DECLSPEC_HIDDEN
Definition: proplist.c:72
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
static BOOL CertContext_CopyParam(void *pvData, DWORD *pcbData, const void *pb, DWORD cb)
Definition: cert.c:410
PCERT_EXTENSION WINAPI CertFindExtension(LPCSTR pszObjId, DWORD cExtensions, CERT_EXTENSION rgExtensions[])
Definition: cert.c:2028
BOOL WINAPI CryptHashToBeSigned(HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash)
Definition: cert.c:2260
static const WCHAR *const ext[]
Definition: module.c:53
Definition: pdh_main.c:94
#define CERT_MD5_HASH_PROP_ID
Definition: wincrypt.h:2689
#define CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID
Definition: wincrypt.h:2711
#define CRYPT_DECODE_NOCOPY_FLAG
Definition: wincrypt.h:3450
#define CALG_SHA1
Definition: wincrypt.h:1807
#define CERT_KEY_IDENTIFIER_PROP_ID
Definition: wincrypt.h:2706
#define CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID
Definition: wincrypt.h:2714
#define CALG_MD5
Definition: wincrypt.h:1805
#define szOID_SUBJECT_KEY_IDENTIFIER
Definition: wincrypt.h:3184
#define CERT_SHA1_HASH_PROP_ID
Definition: wincrypt.h:2687
#define CERT_SIGNATURE_HASH_PROP_ID
Definition: wincrypt.h:2701
#define CERT_SUBJECT_NAME_MD5_HASH_PROP_ID
Definition: wincrypt.h:2715
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
#define ERROR_INVALID_DATA
Definition: winerror.h:116

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);
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}
BOOL WINAPI CryptGetProvParam(HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1688
BOOL WINAPI CertSetCertificateContextProperty(PCCERT_CONTEXT pCertContext, DWORD dwPropId, DWORD dwFlags, const void *pvData)
Definition: cert.c:799
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
static const char szContainer[]
Definition: rsaenh.c:35
static HCRYPTPROV hProv
Definition: rsaenh.c:32
static const char * szProvider
Definition: rsaenh.c:36
#define PROV_RSA_FULL
Definition: wincrypt.h:2039
#define PP_NAME
Definition: wincrypt.h:2085
#define PP_CONTAINER
Definition: wincrypt.h:2087
#define PP_PROVTYPE
Definition: wincrypt.h:2096
#define AT_SIGNATURE
Definition: wincrypt.h:2036
__wchar_t WCHAR
Definition: xmlstorage.h:180

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 {
672 }
673 else
674 ret = FALSE;
675 return ret;
676}
BOOL ContextPropertyList_SetProperty(CONTEXT_PROPERTY_LIST *list, DWORD id, const BYTE *pbData, size_t cbData) DECLSPEC_HIDDEN
Definition: proplist.c:95
static void CRYPT_CopyKeyProvInfo(PCRYPT_KEY_PROV_INFO to, const CRYPT_KEY_PROV_INFO *from)
Definition: cert.c:608
#define lstrlenW
Definition: compat.h:750
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
struct _CRYPT_KEY_PROV_INFO CRYPT_KEY_PROV_INFO

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 */
710 {
711 if (pvData)
712 {
713 const CRYPT_DATA_BLOB *blob = pvData;
714
716 blob->pbData, blob->cbData);
717 }
718 else
719 {
721 ret = TRUE;
722 }
723 break;
724 }
726 if (pvData)
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
748 (const BYTE *)keyContext, keyContext->cbSize);
749 }
750 else
751 {
753 ret = TRUE;
754 }
755 break;
756 }
758 if (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
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:648
static BOOL CertContext_SetKeyProvInfoProperty(CONTEXT_PROPERTY_LIST *properties, const CRYPT_KEY_PROV_INFO *info)
Definition: cert.c:647
static BOOL CertContext_GetProperty(cert_t *cert, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: cert.c:431
HCRYPTPROV hCryptProv
Definition: wincrypt.h:220
#define CERT_PVK_FILE_PROP_ID
Definition: wincrypt.h:2698
#define CERT_CROSS_CERT_DIST_POINTS_PROP_ID
Definition: wincrypt.h:2709
#define CERT_ENROLLMENT_PROP_ID
Definition: wincrypt.h:2712
#define CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID
Definition: wincrypt.h:2710
#define CERT_KEY_CONTEXT_PROP_ID
Definition: wincrypt.h:2690
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
#define CERT_DESCRIPTION_PROP_ID
Definition: wincrypt.h:2699
#define CERT_OCSP_RESPONSE_PROP_ID
Definition: wincrypt.h:2730
#define CERT_EXTENDED_ERROR_INFO_PROP_ID
Definition: wincrypt.h:2716
#define CERT_NEXT_UPDATE_LOCATION_PROP_ID
Definition: wincrypt.h:2696
#define CERT_PUBKEY_ALG_PARA_PROP_ID
Definition: wincrypt.h:2708
#define CERT_AUTO_ENROLL_PROP_ID
Definition: wincrypt.h:2707
#define CERT_FRIENDLY_NAME_PROP_ID
Definition: wincrypt.h:2697
#define CERT_CTL_USAGE_PROP_ID
Definition: wincrypt.h:2695
#define CERT_RENEWAL_PROP_ID
Definition: wincrypt.h:2724
#define CERT_STORE_NO_CRYPT_RELEASE_FLAG
Definition: wincrypt.h:2452
#define CERT_KEY_PROV_HANDLE_PROP_ID
Definition: wincrypt.h:2685
#define CERT_DATE_STAMP_PROP_ID
Definition: wincrypt.h:2713

Referenced by CertContext_GetHashProp(), CertContext_GetProperty(), CertContext_SetProperty(), 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,
327
329 {
331 return NULL;
332 }
333
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
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define CERT_ENCODING_TYPE_MASK
Definition: wincrypt.h:2290

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}
PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType, const BYTE *pbCrlEncoded, DWORD cbCrlEncoded)
Definition: crl.c:85
PCCTL_CONTEXT WINAPI CertCreateCTLContext(DWORD dwMsgAndCertEncodingType, const BYTE *pbCtlEncoded, DWORD cbCtlEncoded)
Definition: ctl.c:363
static LPCSTR DWORD void BYTE * pbEncoded
Definition: str.c:196
_In_ DWORD dwEncodingType
Definition: wincrypt.h:4625
#define CERT_STORE_CERTIFICATE_CONTEXT
Definition: wincrypt.h:2974
#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 {
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 }
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);
3645 &blob.cbData);
3646 if (ret)
3647 {
3650 &info.SignatureAlgorithm);
3651 else
3653 blob.pbData, blob.cbData);
3656 LocalFree(blob.pbData);
3657 }
3658 }
3660 }
3661end:
3662 if (releaseContext)
3664 return context;
3665}
BOOL WINAPI CryptGenRandom(HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer)
Definition: crypt.c:700
BOOL WINAPI CryptDestroyKey(HCRYPTKEY hKey)
Definition: crypt.c:930
BOOL WINAPI CryptGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKEY *phKey)
Definition: crypt.c:1451
BOOL WINAPI CryptGetUserKey(HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY *phUserKey)
Definition: crypt.c:1718
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
static HCRYPTPROV CRYPT_CreateKeyProv(void)
Definition: cert.c:3506
static void CertContext_SetKeyProvInfo(PCCERT_CONTEXT context, const CRYPT_KEY_PROV_INFO *pInfo, HCRYPTPROV hProv)
Definition: cert.c:3304
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
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
BOOL WINAPI CryptExportPublicKeyInfo(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)
Definition: encode.c:4775
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
uint32_t serial
Definition: fsck.fat.h:29
FxAutoRegKey hKey
GLuint GLuint end
Definition: gl.h:1545
static BYTE pubKey[]
Definition: msg.c:1214
LPWSTR pwszContainerName
Definition: wincrypt.h:209
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CERT_SET_KEY_PROV_HANDLE_PROP_ID
Definition: wincrypt.h:3594
#define CRYPT_NEWKEYSET
Definition: wincrypt.h:2070
#define CERT_CREATE_SELFSIGN_NO_KEY_INFO
Definition: wincrypt.h:3598
#define CERT_CREATE_SELFSIGN_NO_SIGN
Definition: wincrypt.h:3597
#define CRYPT_ENCODE_ALLOC_FLAG
Definition: wincrypt.h:3441
ULONG_PTR HCRYPTKEY
Definition: wincrypt.h:49
#define NTE_NO_KEY
Definition: winerror.h:2881
#define NTE_BAD_KEYSET
Definition: winerror.h:2890
#define NTE_BAD_FLAGS
Definition: winerror.h:2877

Referenced by init_function_pointers(), and testGetIssuerCert().

◆ CertDuplicateCertificateContext()

◆ 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)
390 else
391 ret = 0;
392 return ret;
393}
DWORD ContextPropertyList_EnumPropIDs(CONTEXT_PROPERTY_LIST *list, DWORD id) DECLSPEC_HIDDEN
Definition: proplist.c:170

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}

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:
1780 break;
1783 break;
1786 break;
1787 case CERT_COMPARE_NAME:
1789 break;
1792 break;
1795 break;
1798 break;
1801 break;
1804 break;
1807 break;
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}
static TAGID TAGID find
Definition: db.cpp:155
static BOOL compare_existing_cert(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1510
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
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
static BOOL compare_cert_by_sha1_hash(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1388
static BOOL compare_cert_by_md5_hash(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1367
static PCCERT_CONTEXT find_cert_any(HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
Definition: cert.c:1565
static PCCERT_CONTEXT find_cert_by_issuer(HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
Definition: cert.c:1571
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
static BOOL compare_cert_by_name(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1409
BOOL(* CertCompareFunc)(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1364
static BOOL compare_cert_by_signature_hash(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1518
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
static BOOL compare_cert_by_public_key(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, const void *pvPara)
Definition: cert.c:1424
PCCERT_CONTEXT(* CertFindFunc)(HCERTSTORE store, DWORD dwType, DWORD dwFlags, const void *pvPara, PCCERT_CONTEXT prev)
Definition: cert.c:1562
Definition: bug.cpp:8
#define CERT_COMPARE_MD5_HASH
Definition: wincrypt.h:2845
#define CERT_COMPARE_NAME_STR_W
Definition: wincrypt.h:2849
#define CERT_COMPARE_ISSUER_OF
Definition: wincrypt.h:2854
#define CERT_COMPARE_PUBLIC_KEY
Definition: wincrypt.h:2847
#define CERT_COMPARE_SUBJECT_CERT
Definition: wincrypt.h:2853
#define CERT_COMPARE_CERT_ID
Definition: wincrypt.h:2858
#define CERT_COMPARE_ANY
Definition: wincrypt.h:2840
#define CERT_COMPARE_NAME_STR_A
Definition: wincrypt.h:2848
#define CERT_COMPARE_NAME
Definition: wincrypt.h:2843
#define CERT_COMPARE_SHIFT
Definition: wincrypt.h:2839
#define CERT_COMPARE_SHA1_HASH
Definition: wincrypt.h:2841
#define CERT_COMPARE_SIGNATURE_HASH
Definition: wincrypt.h:2856
_In_ PCCERT_STORE_PROV_FIND_INFO _In_ PCCERT_CONTEXT pPrevCertContext
Definition: wincrypt.h:1280
#define CERT_COMPARE_EXISTING
Definition: wincrypt.h:2855

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[] 
)

◆ 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}
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
static LPSTR pName
Definition: security.c:75

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}

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(), get_security_cert_struct(), getChain(), 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:
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}
#define CERT_CTL_PROP_ID
#define CERT_CRL_PROP_ID
#define CERT_CERT_PROP_ID
void CRYPT_FixKeyProvInfoPointers(PCRYPT_KEY_PROV_INFO info)
Definition: cert.c:523
BOOL WINAPI CertGetStoreProperty(HCERTSTORE hCertStore, DWORD dwPropId, void *pvData, DWORD *pcbData)
Definition: store.c:1172
#define CERT_ACCESS_STATE_PROP_ID
Definition: wincrypt.h:2700

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 }
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)
2948 TRACE("returning %d\n", ret);
2949 return ret;
2950}
PCERT_EXTENSION rgExtension
Definition: wincrypt.h:252
DWORD cExtension
Definition: wincrypt.h:251
#define CERT_ENHKEY_USAGE_PROP_ID
Definition: wincrypt.h:2694
#define CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG
Definition: wincrypt.h:2916
#define szOID_ENHANCED_KEY_USAGE
Definition: wincrypt.h:3202
#define X509_ENHANCED_KEY_USAGE
Definition: wincrypt.h:3403

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 memset(x, y, z)
Definition: compat.h:39
#define szOID_KEY_USAGE
Definition: wincrypt.h:3185
#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}
BOOL WINAPI CertVerifySubjectCertificateContext(PCCERT_CONTEXT pSubject, PCCERT_CONTEXT pIssuer, DWORD *pdwFlags)
Definition: cert.c:1845
DWORD CRYPT_IsCertificateSelfSigned(const CERT_CONTEXT *cert)
Definition: chain.c:268
#define CERT_FIND_ISSUER_OF
Definition: wincrypt.h:2903
#define CRYPT_E_SELF_SIGNED
Definition: winerror.h:3010

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);
1343 return len;
1344 }
1345 /* fallback to RSA */
1346 }
1347
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}
HCRYPTPROV WINAPI I_CryptGetDefaultCryptProv(ALG_ID)
Definition: main.c:210
BOOL WINAPI CryptGetKeyParam(HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1649
BOOL WINAPI CryptImportPublicKeyInfo(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, HCRYPTKEY *phKey)
Definition: encode.c:4970
PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey, DWORD dwGroupId)
Definition: oid.c:1799
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
BYTE * PBYTE
Definition: pedump.c:66
CRYPT_ALGORITHM_IDENTIFIER Algorithm
Definition: wincrypt.h:225
Definition: copy.c:22
#define szOID_RSA_DH
Definition: wincrypt.h:3027
#define CRYPT_OID_INFO_OID_KEY
Definition: wincrypt.h:1702
#define KP_KEYLEN
Definition: wincrypt.h:2136
#define CRYPT_E_ASN1_BADTAG
Definition: winerror.h:3095

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}
#define CERT_FIND_SUBJECT_CERT
Definition: wincrypt.h:2901

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 }
3296 TRACE("cNumOIDs: %d\n", *cNumOIDs);
3297 TRACE("returning %d\n", ret);
3298 return ret;
3299}
static BOOL CRYPT_IsBitInFieldSet(const struct BitField *field, DWORD bit)
Definition: cert.c:3149
static void CRYPT_SetBitInField(struct BitField *field, DWORD bit)
Definition: cert.c:3128
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
int k
Definition: mpi.c:3369
DWORD * indexes
Definition: cert.c:3123
_Out_ int _Out_writes_bytes_to_opt_ pcbOIDs LPSTR _Inout_ DWORD * pcbOIDs
Definition: wincrypt.h:5305
_Out_ int * cNumOIDs
Definition: wincrypt.h:5303
_Out_ int _Out_writes_bytes_to_opt_ pcbOIDs LPSTR * rghOIDs
Definition: wincrypt.h:5304

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}
static BOOL find_matching_rdn_attr(DWORD dwFlags, const CERT_NAME_INFO *name, const CERT_RDN_ATTR *attr)
Definition: cert.c:2072
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD cRDNAttr
Definition: wincrypt.h:262
PCERT_RDN_ATTR rgRDNAttr
Definition: wincrypt.h:263
Definition: name.c:39
#define X509_NAME
Definition: wincrypt.h:3372
#define X509_UNICODE_NAME
Definition: wincrypt.h:3385
#define CERT_UNICODE_IS_RDN_ATTRS_FLAG
Definition: wincrypt.h:2806
#define CRYPT_E_NO_MATCH
Definition: winerror.h:3012
const char * LPCSTR
Definition: xmlstorage.h:183

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}

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:
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}

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}

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}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102

◆ 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 if (ret)
1958 {
1959 if (size == 1)
1960 {
1961 /* empty list */
1963 ret = FALSE;
1964 }
1965 else
1966 {
1967 LPWSTR dllList = CryptMemAlloc(size * sizeof(WCHAR)), ptr;
1968
1969 if (dllList)
1970 {
1972 dllList, &size);
1973 if (ret)
1974 {
1975 for (ptr = dllList; ret && *ptr;
1976 ptr += lstrlenW(ptr) + 1)
1977 {
1979 HCRYPTOIDFUNCADDR hFunc;
1980
1982 dwEncodingType, ptr, 0, (void **)&func, &hFunc);
1983 if (ret)
1984 {
1985 ret = func(dwEncodingType, dwRevType, cContext,
1986 rgpvContext, dwFlags, pRevPara, pRevStatus);
1988 }
1989 }
1990 }
1991 CryptMemFree(dllList);
1992 }
1993 else
1994 {
1996 ret = FALSE;
1997 }
1998 }
1999 }
2000 }
2001 else
2002 ret = TRUE;
2003 return ret;
2004}
Definition: _set.h:50
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
BOOL(WINAPI * CertVerifyRevocationFunc)(DWORD, DWORD, DWORD, void **, DWORD, PCERT_REVOCATION_PARA, PCERT_REVOCATION_STATUS)
Definition: cert.c:1931
HCRYPTOIDFUNCSET WINAPI CryptInitOIDFunctionSet(LPCSTR pszFuncName, DWORD dwFlags)
Definition: oid.c:114
BOOL WINAPI CryptGetDefaultOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet, DWORD dwEncodingType, LPCWSTR pwszDll, DWORD dwFlags, void **ppvFuncAddr, HCRYPTOIDFUNCADDR *phFuncAddr)
Definition: oid.c:511
BOOL WINAPI CryptGetDefaultOIDDllList(HCRYPTOIDFUNCSET hFuncSet, DWORD dwEncodingType, LPWSTR pwszDllList, DWORD *pcchDllList)
Definition: oid.c:193
BOOL WINAPI CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr, DWORD dwFlags)
Definition: oid.c:468
GLenum func
Definition: glext.h:6028
static PVOID ptr
Definition: dispmode.c:27
#define CRYPT_OID_VERIFY_REVOCATION_FUNC
Definition: wincrypt.h:2497
#define CRYPT_E_NO_REVOCATION_DLL
Definition: winerror.h:3020
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CRYPT_VerifyChainRevocation(), test_verifyRevocation(), and testVerifyRevocation().

◆ CertVerifySubjectCertificateContext()

BOOL WINAPI CertVerifySubjectCertificateContext ( PCCERT_CONTEXT  pSubject,
PCCERT_CONTEXT  pIssuer,
DWORD pdwFlags 
)

Definition at line 1845 of file cert.c.

1847{
1848 static const DWORD supportedFlags = CERT_STORE_REVOCATION_FLAG |
1850
1851 if (*pdwFlags & ~supportedFlags)
1852 {
1854 return FALSE;
1855 }
1856 if (*pdwFlags & CERT_STORE_REVOCATION_FLAG)
1857 {
1858 DWORD flags = 0;
1859 PCCRL_CONTEXT crl = CertGetCRLFromStore(pSubject->hCertStore, pSubject,
1860 NULL, &flags);
1861
1862 /* FIXME: what if the CRL has expired? */
1863 if (crl)
1864 {
1866 pSubject->pCertInfo, 1, (PCRL_INFO *)&crl->pCrlInfo))
1867 *pdwFlags &= CERT_STORE_REVOCATION_FLAG;
1868 }
1869 else
1870 *pdwFlags |= CERT_STORE_NO_CRL_FLAG;
1871 }
1872 if (*pdwFlags & CERT_STORE_TIME_VALIDITY_FLAG)
1873 {
1874 if (0 == CertVerifyTimeValidity(NULL, pSubject->pCertInfo))
1875 *pdwFlags &= ~CERT_STORE_TIME_VALIDITY_FLAG;
1876 }
1877 if (*pdwFlags & CERT_STORE_SIGNATURE_FLAG)
1878 {
1880 CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT, (void *)pSubject,
1882 *pdwFlags &= ~CERT_STORE_SIGNATURE_FLAG;
1883 }
1884 return TRUE;
1885}
BOOL WINAPI CryptVerifyCertificateSignatureEx(HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, DWORD dwSubjectType, void *pvSubject, DWORD dwIssuerType, void *pvIssuer, DWORD dwFlags, void *pvReserved)
Definition: cert.c:2717
LONG WINAPI CertVerifyTimeValidity(LPFILETIME pTimeToVerify, PCERT_INFO pCertInfo)
Definition: cert.c:2158
PCCRL_CONTEXT WINAPI CertGetCRLFromStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pIssuerContext, PCCRL_CONTEXT pPrevCrlContext, DWORD *pdwFlags)
Definition: crl.c:337
BOOL WINAPI CertVerifyCRLRevocation(DWORD dwCertEncodingType, PCERT_INFO pCertId, DWORD cCrlInfo, PCRL_INFO rgpCrlInfo[])
Definition: crl.c:762
GLbitfield flags
Definition: glext.h:7161
static const BYTE crl[]
Definition: message.c:864
HCERTSTORE hCertStore
Definition: wincrypt.h:483
#define CERT_STORE_REVOCATION_FLAG
Definition: wincrypt.h:3460
_In_ void _In_ PCCERT_CONTEXT pIssuer
Definition: wincrypt.h:6078
#define CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT
Definition: wincrypt.h:3474
#define CRYPT_VERIFY_CERT_SIGN_SUBJECT_CERT
Definition: wincrypt.h:3469
#define CERT_STORE_NO_CRL_FLAG
Definition: wincrypt.h:3461
#define CERT_STORE_SIGNATURE_FLAG
Definition: wincrypt.h:3458
#define CERT_STORE_TIME_VALIDITY_FLAG
Definition: wincrypt.h:3459

Referenced by CertGetIssuerCertificateFromStore(), rdssl_certs_ok(), and testVerifySubjectCert().

◆ CertVerifyTimeValidity()

LONG WINAPI CertVerifyTimeValidity ( LPFILETIME  pTimeToVerify,
PCERT_INFO  pCertInfo 
)

Definition at line 2158 of file cert.c.

2160{
2161 FILETIME fileTime;
2162 LONG ret;
2163
2164 if (!pTimeToVerify)
2165 {
2166 GetSystemTimeAsFileTime(&fileTime);
2167 pTimeToVerify = &fileTime;
2168 }
2169 if ((ret = CompareFileTime(pTimeToVerify, &pCertInfo->NotBefore)) >= 0)
2170 {
2171 ret = CompareFileTime(pTimeToVerify, &pCertInfo->NotAfter);
2172 if (ret < 0)
2173 ret = 0;
2174 }
2175 return ret;
2176}
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
long LONG
Definition: pedump.c:60
FILETIME NotAfter
Definition: wincrypt.h:246

Referenced by CertTrustFinalPolicy(), CertVerifySubjectCertificateContext(), CertVerifyValidityNesting(), CRYPT_CheckSimpleChain(), and test_verifyTimeValidity().

◆ CertVerifyValidityNesting()

BOOL WINAPI CertVerifyValidityNesting ( PCERT_INFO  pSubjectInfo,
PCERT_INFO  pIssuerInfo 
)

Definition at line 2178 of file cert.c.

2180{
2181 TRACE("(%p, %p)\n", pSubjectInfo, pIssuerInfo);
2182
2183 return CertVerifyTimeValidity(&pSubjectInfo->NotBefore, pIssuerInfo) == 0
2184 && CertVerifyTimeValidity(&pSubjectInfo->NotAfter, pIssuerInfo) == 0;
2185}

◆ CNG_CalcHash()

static BOOL CNG_CalcHash ( const WCHAR algorithm,
const CERT_SIGNED_CONTENT_INFO signedCert,
BYTE **  hash_value,
DWORD hash_len 
)
static

Definition at line 2474 of file cert.c.

2476{
2478 BCRYPT_ALG_HANDLE alg = NULL;
2480 DWORD size;
2481
2483 goto done;
2484
2485 if ((status = BCryptCreateHash(alg, &hash, NULL, 0, NULL, 0, 0)))
2486 goto done;
2487
2488 if ((status = BCryptHashData(hash, signedCert->ToBeSigned.pbData, signedCert->ToBeSigned.cbData, 0)))
2489 goto done;
2490
2491 if ((status = BCryptGetProperty(hash, BCRYPT_HASH_LENGTH, (BYTE *)hash_len, sizeof(*hash_len), &size, 0)))
2492 goto done;
2493
2494 if (!(*hash_value = CryptMemAlloc(*hash_len)))
2495 {
2497 goto done;
2498 }
2499
2500 if ((status = BCryptFinishHash(hash, *hash_value, *hash_len, 0)))
2501 {
2502 CryptMemFree(*hash_value);
2503 goto done;
2504 }
2505
2506done:
2508 if (alg) BCryptCloseAlgorithmProvider(alg, 0);
2510 return status == 0;
2511}
LONG NTSTATUS
Definition: precomp.h:26
#define BCRYPT_HASH_LENGTH
Definition: bcrypt.h:50
NTSTATUS WINAPI BCryptHashData(BCRYPT_HASH_HANDLE handle, UCHAR *input, ULONG size, ULONG flags)
Definition: bcrypt_main.c:1058
NTSTATUS WINAPI BCryptGetProperty(BCRYPT_HANDLE handle, LPCWSTR prop, UCHAR *buffer, ULONG count, ULONG *res, ULONG flags)
Definition: bcrypt_main.c:978
NTSTATUS WINAPI BCryptDestroyHash(BCRYPT_HASH_HANDLE handle)
Definition: bcrypt_main.c:1047
NTSTATUS WINAPI BCryptOpenAlgorithmProvider(BCRYPT_ALG_HANDLE *handle, LPCWSTR id, LPCWSTR implementation, DWORD flags)
Definition: bcrypt_main.c:336
NTSTATUS WINAPI BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE handle, DWORD flags)
Definition: bcrypt_main.c:380
NTSTATUS WINAPI BCryptCreateHash(BCRYPT_ALG_HANDLE algorithm, BCRYPT_HASH_HANDLE *handle, UCHAR *object, ULONG objectlen, UCHAR *secret, ULONG secretlen, ULONG flags)
Definition: bcrypt_main.c:1005
NTSTATUS WINAPI BCryptFinishHash(BCRYPT_HASH_HANDLE handle, UCHAR *output, ULONG size, ULONG flags)
Definition: bcrypt_main.c:1077
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
CRYPT_DER_BLOB ToBeSigned
Definition: wincrypt.h:613
Definition: _hash_fun.h:40
Definition: ps.c:97

Referenced by CNG_VerifySignature().

◆ CNG_ImportECCPubKey()

static BOOL CNG_ImportECCPubKey ( CERT_PUBLIC_KEY_INFO pubKeyInfo,
BCRYPT_KEY_HANDLE key 
)
static

Definition at line 2513 of file cert.c.

2514{
2515 DWORD blob_magic, ecckey_len, size;
2516 BCRYPT_ALG_HANDLE alg = NULL;
2517 BCRYPT_ECCKEY_BLOB *ecckey;
2518 const WCHAR *sign_algo;
2519 char **ecc_curve;
2521
2522 if (!pubKeyInfo->PublicKey.cbData)
2523 {
2525 return FALSE;
2526 }
2527
2528 if (pubKeyInfo->PublicKey.pbData[0] != 0x4)
2529 {
2530 FIXME("Compressed ECC curves (%02x) not yet supported\n", pubKeyInfo->PublicKey.pbData[0]);
2532 return FALSE;
2533 }
2534
2536 pubKeyInfo->Algorithm.Parameters.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &ecc_curve, &size))
2537 return FALSE;
2538
2539 if (!strcmp(*ecc_curve, szOID_ECC_CURVE_P256))
2540 {
2541 sign_algo = BCRYPT_ECDSA_P256_ALGORITHM;
2542 blob_magic = BCRYPT_ECDSA_PUBLIC_P256_MAGIC;
2543 }
2544 else if (!strcmp(*ecc_curve, szOID_ECC_CURVE_P384))
2545 {
2546 sign_algo = BCRYPT_ECDSA_P384_ALGORITHM;
2547 blob_magic = BCRYPT_ECDSA_PUBLIC_P384_MAGIC;
2548 }
2549 else
2550 {
2551 FIXME("Unsupported ecc curve type: %s\n", *ecc_curve);
2552 sign_algo = NULL;
2553 blob_magic = 0;
2554 }
2555 LocalFree(ecc_curve);
2556
2557 if (!sign_algo)
2558 {
2560 return FALSE;
2561 }
2562
2563 if ((status = BCryptOpenAlgorithmProvider(&alg, sign_algo, NULL, 0)))
2564 goto done;
2565
2566 ecckey_len = sizeof(BCRYPT_ECCKEY_BLOB) + pubKeyInfo->PublicKey.cbData - 1;
2567 if (!(ecckey = CryptMemAlloc(ecckey_len)))
2568 {
2570 goto done;
2571 }
2572
2573 ecckey->dwMagic = blob_magic;
2574 ecckey->cbKey = (pubKeyInfo->PublicKey.cbData - 1) / 2;
2575 memcpy(ecckey + 1, pubKeyInfo->PublicKey.pbData + 1, pubKeyInfo->PublicKey.cbData - 1);
2576
2577 status = BCryptImportKeyPair(alg, NULL, BCRYPT_ECCPUBLIC_BLOB, key, (BYTE*)ecckey, ecckey_len, 0);
2578 CryptMemFree(ecckey);
2579
2580done:
2581 if (alg) BCryptCloseAlgorithmProvider(alg, 0);
2583 return !status;
2584}
#define BCRYPT_ECDSA_PUBLIC_P256_MAGIC
Definition: bcrypt.h:82
#define BCRYPT_ECDSA_P384_ALGORITHM
Definition: bcrypt.h:79
#define BCRYPT_ECCPUBLIC_BLOB
Definition: bcrypt.h:64
#define BCRYPT_ECDSA_PUBLIC_P384_MAGIC
Definition: bcrypt.h:84
struct _BCRYPT_ECCKEY_BLOB BCRYPT_ECCKEY_BLOB
#define BCRYPT_ECDSA_P256_ALGORITHM
Definition: bcrypt.h:78
NTSTATUS WINAPI BCryptImportKeyPair(BCRYPT_ALG_HANDLE, BCRYPT_KEY_HANDLE, LPCWSTR, BCRYPT_KEY_HANDLE *, UCHAR *, ULONG, ULONG)
if(dx< 0)
Definition: linetemp.h:194
CRYPT_OBJID_BLOB Parameters
Definition: wincrypt.h:127
#define X509_OBJECT_IDENTIFIER
Definition: wincrypt.h:3435
#define szOID_ECC_CURVE_P256
Definition: wincrypt.h:3064
#define szOID_ECC_CURVE_P384
Definition: wincrypt.h:3110
#define NTE_BAD_ALGID
Definition: winerror.h:2876

Referenced by CNG_ImportPubKey().

◆ CNG_ImportPubKey()

static BOOL CNG_ImportPubKey ( CERT_PUBLIC_KEY_INFO pubKeyInfo,
BCRYPT_KEY_HANDLE key 
)
static

Definition at line 2586 of file cert.c.

2587{
2588 if (!strcmp(pubKeyInfo->Algorithm.pszObjId, szOID_ECC_PUBLIC_KEY))
2589 return CNG_ImportECCPubKey(pubKeyInfo, key);
2590
2591 FIXME("Unsupported public key type: %s\n", debugstr_a(pubKeyInfo->Algorithm.pszObjId));
2593 return FALSE;
2594}
static BOOL CNG_ImportECCPubKey(CERT_PUBLIC_KEY_INFO *pubKeyInfo, BCRYPT_KEY_HANDLE *key)
Definition: cert.c:2513
#define szOID_ECC_PUBLIC_KEY
Definition: wincrypt.h:3063

Referenced by CNG_VerifySignature().

◆ CNG_PrepareSignature()

static BOOL CNG_PrepareSignature ( CERT_PUBLIC_KEY_INFO pubKeyInfo,
const CERT_SIGNED_CONTENT_INFO signedCert,
BYTE **  sig_value,
DWORD sig_len 
)
static

Definition at line 2630 of file cert.c.

2632{
2633 BYTE *encoded_sig;
2634 BOOL ret = FALSE;
2635 int i;
2636
2637 if (!signedCert->Signature.cbData)
2638 {
2640 return FALSE;
2641 }
2642
2643 if (!(encoded_sig = CryptMemAlloc(signedCert->Signature.cbData)))
2644 {
2646 return FALSE;
2647 }
2648
2649 for (i = 0; i < signedCert->Signature.cbData; i++)
2650 encoded_sig[i] = signedCert->Signature.pbData[signedCert->Signature.cbData - i - 1];
2651
2653 ret = CNG_PrepareSignatureECC(encoded_sig, signedCert->Signature.cbData, sig_value, sig_len);
2654 else
2655 {
2656 FIXME("Unsupported public key type: %s\n", debugstr_a(pubKeyInfo->Algorithm.pszObjId));
2658 }
2659
2660 CryptMemFree(encoded_sig);
2661 return ret;
2662}
static BOOL CNG_PrepareSignatureECC(BYTE *encoded_sig, DWORD encoded_size, BYTE **sig_value, DWORD *sig_len)
Definition: cert.c:2596
CRYPT_BIT_BLOB Signature
Definition: wincrypt.h:615

Referenced by CNG_VerifySignature().

◆ CNG_PrepareSignatureECC()

static BOOL CNG_PrepareSignatureECC ( BYTE encoded_sig,
DWORD  encoded_size,
BYTE **  sig_value,
DWORD sig_len 
)
static

Definition at line 2596 of file cert.c.

2597{
2598 CERT_ECC_SIGNATURE *ecc_sig;
2599 DWORD size;
2600 int i;
2601
2602 if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_ECC_SIGNATURE, encoded_sig, encoded_size,
2603 CRYPT_DECODE_ALLOC_FLAG, NULL, &ecc_sig, &size))
2604 return FALSE;
2605
2606 if (!ecc_sig->r.cbData || !ecc_sig->s.cbData)
2607 {
2608 LocalFree(ecc_sig);
2610 return FALSE;
2611 }
2612
2613 *sig_len = ecc_sig->r.cbData + ecc_sig->s.cbData;
2614 if (!(*sig_value = CryptMemAlloc(*sig_len)))
2615 {
2616 LocalFree(ecc_sig);
2618 return FALSE;
2619 }
2620
2621 for (i = 0; i < ecc_sig->r.cbData; i++)
2622 (*sig_value)[i] = ecc_sig->r.pbData[ecc_sig->r.cbData - i - 1];
2623 for (i = 0; i < ecc_sig->s.cbData; i++)
2624 (*sig_value)[ecc_sig->r.cbData + i] = ecc_sig->s.pbData[ecc_sig->s.cbData - i - 1];
2625
2626 LocalFree(ecc_sig);
2627 return TRUE;
2628}
CRYPT_UINT_BLOB s
Definition: wincrypt.h:300
CRYPT_UINT_BLOB r
Definition: wincrypt.h:299
#define X509_ECC_SIGNATURE
Definition: wincrypt.h:3417

Referenced by CNG_PrepareSignature().

◆ CNG_VerifySignature()

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

Definition at line 2664 of file cert.c.

2666{
2668 BYTE *hash_value = NULL, *sig_value;
2669 DWORD hash_len, sig_len;
2671 BOOL ret;
2672
2673 ret = CNG_ImportPubKey(pubKeyInfo, &key);
2674 if (ret)
2675 {
2676 ret = CNG_CalcHash(info->pwszCNGAlgid, signedCert, &hash_value, &hash_len);
2677 if (ret)
2678 {
2679 ret = CNG_PrepareSignature(pubKeyInfo, signedCert, &sig_value, &sig_len);
2680 if (ret)
2681 {
2682 status = BCryptVerifySignature(key, NULL, hash_value, hash_len, sig_value, sig_len, 0);
2683 if (status)
2684 {
2685 FIXME("Failed to verify signature: %08x\n", status);
2687 ret = FALSE;
2688 }
2689 CryptMemFree(sig_value);
2690 }
2691 CryptMemFree(hash_value);
2692 }
2694 }
2695
2696 return ret;
2697}
NTSTATUS WINAPI BCryptDestroyKey(BCRYPT_KEY_HANDLE)
NTSTATUS WINAPI BCryptVerifySignature(BCRYPT_KEY_HANDLE, void *, UCHAR *, ULONG, UCHAR *, ULONG, ULONG)
static BOOL CNG_ImportPubKey(CERT_PUBLIC_KEY_INFO *pubKeyInfo, BCRYPT_KEY_HANDLE *key)
Definition: cert.c:2586
static BOOL CNG_CalcHash(const WCHAR *algorithm, const CERT_SIGNED_CONTENT_INFO *signedCert, BYTE **hash_value, DWORD *hash_len)
Definition: cert.c:2474
static BOOL CNG_PrepareSignature(CERT_PUBLIC_KEY_INFO *pubKeyInfo, const CERT_SIGNED_CONTENT_INFO *signedCert, BYTE **sig_value, DWORD *sig_len)
Definition: cert.c:2630

Referenced by CRYPT_VerifyCertSignatureFromPublicKeyInfo().

◆ compare_cert_by_cert_id()

static BOOL compare_cert_by_cert_id ( PCCERT_CONTEXT  pCertContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 1460 of file cert.c.

1462{
1463 CERT_ID *id = (CERT_ID *)pvPara;
1464 BOOL ret;
1465
1466 switch (id->dwIdChoice)
1467 {
1470 &pCertContext->pCertInfo->Issuer, &id->u.IssuerSerialNumber.Issuer);
1471 if (ret)
1473 &id->u.IssuerSerialNumber.SerialNumber);
1474 break;
1475 case CERT_ID_SHA1_HASH:
1477 &id->u.HashId);
1478 break;
1480 {
1481 DWORD size = 0;
1482
1485 if (ret && size == id->u.KeyId.cbData)
1486 {
1488
1489 if (buf)
1490 {
1493 ret = !memcmp(buf, id->u.KeyId.pbData, size);
1495 }
1496 else
1497 ret = FALSE;
1498 }
1499 else
1500 ret = FALSE;
1501 break;
1502 }
1503 default:
1504 ret = FALSE;
1505 break;
1506 }
1507 return ret;
1508}
GLuint id
Definition: glext.h:5910
#define CERT_ID_ISSUER_SERIAL_NUMBER
Definition: wincrypt.h:3673
#define CERT_ID_KEY_IDENTIFIER
Definition: wincrypt.h:3674
#define CERT_ID_SHA1_HASH
Definition: wincrypt.h:3675

Referenced by CertFindCertificateInStore(), and find_cert_by_issuer().

◆ compare_cert_by_md5_hash()

static BOOL compare_cert_by_md5_hash ( PCCERT_CONTEXT  pCertContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 1367 of file cert.c.

1369{
1370 BOOL ret;
1371 BYTE hash[16];
1372 DWORD size = sizeof(hash);
1373
1376 if (ret)
1377 {
1378 const CRYPT_HASH_BLOB *pHash = pvPara;
1379
1380 if (size == pHash->cbData)
1381 ret = !memcmp(pHash->pbData, hash, size);
1382 else
1383 ret = FALSE;
1384 }
1385 return ret;
1386}

Referenced by CertFindCertificateInStore().

◆ compare_cert_by_name()

static BOOL compare_cert_by_name ( PCCERT_CONTEXT  pCertContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 1409 of file cert.c.

1411{
1412 CERT_NAME_BLOB *blob = (CERT_NAME_BLOB *)pvPara, *toCompare;
1413 BOOL ret;
1414
1415 if (dwType & CERT_INFO_SUBJECT_FLAG)
1416 toCompare = &pCertContext->pCertInfo->Subject;
1417 else
1418 toCompare = &pCertContext->pCertInfo->Issuer;
1420 toCompare, blob);
1421 return ret;
1422}
CERT_NAME_BLOB Subject
Definition: wincrypt.h:247
#define CERT_INFO_SUBJECT_FLAG
Definition: wincrypt.h:2665

Referenced by CertFindCertificateInStore(), and find_cert_by_issuer().

◆ compare_cert_by_name_str()

static BOOL compare_cert_by_name_str ( PCCERT_CONTEXT  pCertContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 1673 of file cert.c.

1675{
1677 DWORD len;
1678 BOOL ret = FALSE;
1679
1680 if (dwType & CERT_INFO_SUBJECT_FLAG)
1682 else
1686 if (len)
1687 {
1688 LPWSTR str = CryptMemAlloc(len * sizeof(WCHAR));
1689
1690 if (str)
1691 {
1692 LPWSTR ptr;
1693
1696 for (ptr = str; *ptr; ptr++)
1697 *ptr = tolowerW(*ptr);
1698 if (strstrW(str, pvPara))
1699 ret = TRUE;
1701 }
1702 }
1703 return ret;
1704}
DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName, DWORD dwStrType, LPWSTR psz, DWORD csz)
Definition: str.c:702
#define strstrW(d, s)
Definition: unicode.h:38
#define tolowerW(n)
Definition: unicode.h:50
const WCHAR * str
#define CERT_SIMPLE_NAME_STR
Definition: wincrypt.h:3484

Referenced by find_cert_by_name_str_a(), and find_cert_by_name_str_w().

◆ compare_cert_by_public_key()

static BOOL compare_cert_by_public_key ( PCCERT_CONTEXT  pCertContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 1424 of file cert.c.

1426{
1428 BOOL ret;
1429
1432 return ret;
1433}
BOOL WINAPI CertComparePublicKeyInfo(DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pPublicKey1, PCERT_PUBLIC_KEY_INFO pPublicKey2)
Definition: cert.c:1244
CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo
Definition: wincrypt.h:248

Referenced by CertFindCertificateInStore().

◆ compare_cert_by_sha1_hash()

static BOOL compare_cert_by_sha1_hash ( PCCERT_CONTEXT  pCertContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 1388 of file cert.c.

1390{
1391 BOOL ret;
1392 BYTE hash[20];
1393 DWORD size = sizeof(hash);
1394
1397 if (ret)
1398 {
1399 const CRYPT_HASH_BLOB *pHash = pvPara;
1400
1401 if (size == pHash->cbData)
1402 ret = !memcmp(pHash->pbData, hash, size);
1403 else
1404 ret = FALSE;
1405 }
1406 return ret;
1407}

Referenced by CertFindCertificateInStore(), and compare_cert_by_cert_id().

◆ compare_cert_by_signature_hash()

static BOOL compare_cert_by_signature_hash ( PCCERT_CONTEXT  pCertContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 1518 of file cert.c.

1520{
1521 const CRYPT_HASH_BLOB *hash = pvPara;
1522 DWORD size = 0;
1523 BOOL ret;
1524
1527 if (ret && size == hash->cbData)
1528 {
1530
1531 if (buf)
1532 {
1535 ret = !memcmp(buf, hash->pbData, size);
1537 }
1538 else
1539 ret = FALSE;
1540 }
1541 else
1542 ret = FALSE;
1543 return ret;
1544}

Referenced by CertFindCertificateInStore().

◆ compare_cert_by_subject_cert()

static BOOL compare_cert_by_subject_cert ( PCCERT_CONTEXT  pCertContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 1435 of file cert.c.

1437{
1438 CERT_INFO *pCertInfo = (CERT_INFO *)pvPara;
1439 BOOL ret;
1440
1441 /* Matching serial number and subject match.. */
1443 &pCertContext->pCertInfo->Subject, &pCertInfo->Issuer);
1444 if (ret)
1446 &pCertInfo->SerialNumber);
1447 else
1448 {
1449 /* failing that, if the serial number and issuer match, we match */
1451 &pCertInfo->SerialNumber);
1452 if (ret)
1454 &pCertContext->pCertInfo->Issuer, &pCertInfo->Issuer);
1455 }
1456 TRACE("returning %d\n", ret);
1457 return ret;
1458}

Referenced by CertFindCertificateInStore().

◆ compare_existing_cert()

static BOOL compare_existing_cert ( PCCERT_CONTEXT  pCertContext,
DWORD  dwType,
DWORD  dwFlags,
const void pvPara 
)
static

Definition at line 1510 of file cert.c.

1512{
1513 PCCERT_CONTEXT toCompare = pvPara;
1515 pCertContext->pCertInfo, toCompare->pCertInfo);
1516}
BOOL WINAPI CertCompareCertificate(DWORD dwCertEncodingType, PCERT_INFO pCertId1, PCERT_INFO pCertId2)
Definition: cert.c:1166

Referenced by CertFindCertificateInStore().

◆ container_matches_cert()

static BOOL container_matches_cert ( PCCERT_CONTEXT  pCert,
LPCSTR  container,
CRYPT_KEY_PROV_INFO keyProvInfo 
)
static

Definition at line 994 of file cert.c.

996{
998 WCHAR containerW[MAX_PATH];
1000
1001 MultiByteToWideChar(CP_ACP, 0, container, -1, containerW, ARRAY_SIZE(containerW));
1002 /* We make a copy of the CRYPT_KEY_PROV_INFO because the caller expects
1003 * keyProvInfo->pwszContainerName to be NULL or a heap-allocated container
1004 * name.
1005 */
1006 copy = *keyProvInfo;
1007 copy.pwszContainerName = containerW;
1009 if (matches)
1010 {
1011 keyProvInfo->pwszContainerName =
1012 CryptMemAlloc((strlenW(containerW) + 1) * sizeof(WCHAR));
1013 if (keyProvInfo->pwszContainerName)
1014 {
1015 strcpyW(keyProvInfo->pwszContainerName, containerW);
1016 keyProvInfo->dwKeySpec = AT_SIGNATURE;
1017 }
1018 else
1019 matches = FALSE;
1020 }
1021 return matches;
1022}
#define ARRAY_SIZE(A)
Definition: main.h:33
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define MAX_PATH
Definition: compat.h:34
#define strlenW(s)
Definition: unicode.h:34
#define strcpyW(d, s)
Definition: unicode.h:35

Referenced by find_key_prov_info_in_provider().

◆ CRYPT_AcquirePrivateKeyFromProvInfo()

static BOOL CRYPT_AcquirePrivateKeyFromProvInfo ( PCCERT_CONTEXT  pCert,
PCRYPT_KEY_PROV_INFO  info,
HCRYPTPROV phCryptProv,
DWORD pdwKeySpec 
)
static

Definition at line 829 of file cert.c.

831{
832 DWORD size = 0;
833 BOOL allocated = FALSE, ret = TRUE;
834
835 if (!info)
836 {
839 if (ret)
840 {
842 if (info)
843 {
846 allocated = TRUE;
847 }
848 else
849 {
851 ret = FALSE;
852 }
853 }
854 else
856 }
857 if (ret)
858 {
859 ret = CryptAcquireContextW(phCryptProv, info->pwszContainerName,
860 info->pwszProvName, info->dwProvType, 0);
861 if (ret)
862 {
863 DWORD i;
864
865 for (i = 0; i < info->cProvParam; i++)
866 {
867 CryptSetProvParam(*phCryptProv,
868 info->rgProvParam[i].dwParam, info->rgProvParam[i].pbData,
869 info->rgProvParam[i].dwFlags);
870 }
871 *pdwKeySpec = info->dwKeySpec;
872 }
873 else
875 }
876 if (allocated)
878 return ret;
879}
BOOL WINAPI CryptSetProvParam(HCRYPTPROV hProv, DWORD dwParam, const BYTE *pbData, DWORD dwFlags)
Definition: crypt.c:2179
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CRYPT_E_NO_KEY_PROPERTY
Definition: winerror.h:3014

Referenced by CryptAcquireCertificatePrivateKey().

◆ CRYPT_CopyKeyProvInfo()

static void CRYPT_CopyKeyProvInfo ( PCRYPT_KEY_PROV_INFO  to,
const CRYPT_KEY_PROV_INFO from 
)
static

Definition at line 608 of file cert.c.

610{
611 DWORD i;
612 LPBYTE nextData = (LPBYTE)to + sizeof(CRYPT_KEY_PROV_INFO);
613
614 if (from->pwszContainerName)
615 {
616 to->pwszContainerName = (LPWSTR)nextData;
617 lstrcpyW(to->pwszContainerName, from->pwszContainerName);
618 nextData += (lstrlenW(from->pwszContainerName) + 1) * sizeof(WCHAR);
619 }
620 else
622 if (from->pwszProvName)
623 {
624 to->pwszProvName = (LPWSTR)nextData;
625 lstrcpyW(to->pwszProvName, from->pwszProvName);
626 nextData += (lstrlenW(from->pwszProvName) + 1) * sizeof(WCHAR);
627 }
628 else
629 to-&