ReactOS 0.4.16-dev-197-g92996da
encode.c File Reference
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "wincrypt.h"
#include "snmp.h"
#include "wine/debug.h"
#include "wine/exception.h"
#include "wine/unicode.h"
#include "crypt32_private.h"
Include dependency graph for encode.c:

Go to the source code of this file.

Classes

struct  AsnEncodeTagSwappedItem
 
struct  DERSetDescriptor
 
struct  CTLEntries
 

Macros

#define NONAMELESSUNION
 

Typedefs

typedef BOOL(WINAPICryptEncodeObjectFunc) (DWORD, LPCSTR, const void *, BYTE *, DWORD *)
 
typedef BOOL(WINAPIEncodePublicKeyAndParametersFunc) (DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, BYTE *pbPubKey, DWORD cbPubKey, DWORD dwFlags, void *pvAuxInfo, BYTE **ppPublicKey, DWORD *pcbPublicKey, BYTE **ppbParams, DWORD *pcbParams)
 
typedef BOOL(WINAPIExportPublicKeyInfoExFunc) (HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, DWORD dwFlags, void *pvAuxInfo, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)
 
typedef BOOL(WINAPIConvertPublicKeyInfoFunc) (DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, BYTE **ppbData, DWORD *dwDataLen)
 
typedef BOOL(WINAPIImportPublicKeyInfoExFunc) (HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (cryptasn)
 
 WINE_DECLARE_DEBUG_CHANNEL (crypt)
 
BOOL WINAPI CRYPT_AsnEncodeOid (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeExtensions (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeSequenceOfAny (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeBool (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodePubKeyInfo (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeBits (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeBitsSwapBytes (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeInt (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeInteger (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeUnsignedInteger (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeChoiceOfTime (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeEnhancedKeyUsage (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodePKCSAttributes (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
BOOL CRYPT_EncodeEnsureSpace (DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded, DWORD bytesNeeded)
 
static void CRYPT_FreeSpace (const CRYPT_ENCODE_PARA *pEncodePara, LPVOID pv)
 
BOOL CRYPT_EncodeLen (DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded)
 
BOOL WINAPI CRYPT_AsnEncodeSequence (DWORD dwCertEncodingType, struct AsnEncodeSequenceItem items[], DWORD cItem, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
BOOL WINAPI CRYPT_AsnEncodeConstructed (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeSwapTag (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCertVersion (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_CopyEncodedBlob (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeValidity (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeAlgorithmIdWithNullParams (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeAlgorithmId (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCert (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCertInfo (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeCRLEntry (const CRL_ENTRY *entry, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCRLEntries (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCRLVersion (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCRLInfo (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeExtension (CERT_EXTENSION *ext, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeStringCoerce (const CERT_NAME_VALUE *value, BYTE tag, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeBMPString (const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeUTF8String (const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeNameValue (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeRdnAttr (DWORD dwCertEncodingType, const CERT_RDN_ATTR *attr, CryptEncodeObjectExFunc nameValueEncodeFunc, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static int BLOBComp (const void *l, const void *r)
 
static BOOL WINAPI CRYPT_DEREncodeSet (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_DEREncodeItemsAsSet (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeRdn (DWORD dwCertEncodingType, const CERT_RDN *rdn, CryptEncodeObjectExFunc nameValueEncodeFunc, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeUnicodeNameValue (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeOrCopyUnicodeNameValue (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeUnicodeName (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCTLVersion (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCTLSubjectAlgorithm (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeCTLEntry (const CTL_ENTRY *entry, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCTLEntries (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCTL (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeSMIMECapability (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeSMIMECapabilities (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeNoticeNumbers (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeNoticeReference (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodePolicyQualifierUserNotice (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodePKCSAttribute (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodePKCSContentInfoInternal (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
BOOL CRYPT_AsnEncodePKCSDigestedData (const CRYPT_DIGESTED_DATA *digestedData, void *pvData, DWORD *pcbData)
 
static BOOL WINAPI CRYPT_AsnEncodePKCSContentInfo (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeUnicodeStringCoerce (const CERT_NAME_VALUE *value, BYTE tag, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeNumericString (const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL isprintableW (WCHAR wc)
 
static BOOL CRYPT_AsnEncodePrintableString (const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeIA5String (const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeUniversalString (const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeName (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeAltNameEntry (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeAuthorityKeyId (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeAltName (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeAuthorityKeyId2 (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeAccessDescription (const CERT_ACCESS_DESCRIPTION *descr, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeAuthorityInfoAccess (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeBasicConstraints (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeBasicConstraints2 (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCertPolicyQualifiers (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeCertPolicy (DWORD dwCertEncodingType, const CERT_POLICY_INFO *info, DWORD dwFlags, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCertPolicies (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeCertPolicyMapping (DWORD dwCertEncodingType, const CERT_POLICY_MAPPING *mapping, DWORD dwFlags, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCertPolicyMappings (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCertPolicyConstraints (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeRsaPubKey (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
BOOL WINAPI CRYPT_AsnEncodeOctets (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeEnumerated (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeUtcTime (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeGeneralizedTime (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeDistPoint (const CRL_DIST_POINT *distPoint, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCRLDistPoints (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeIssuingDistPoint (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL CRYPT_AsnEncodeGeneralSubtree (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeNameConstraints (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeIssuerSerialNumber (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodePKCSSignerInfo (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeCMSSignerInfo (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
BOOL CRYPT_AsnEncodeCMSSignedInfo (CRYPT_SIGNED_INFO *signedInfo, void *pvData, DWORD *pcbData)
 
static BOOL WINAPI CRYPT_AsnEncodeRecipientInfo (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
static BOOL WINAPI CRYPT_AsnEncodeEncryptedContentInfo (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
 
BOOL CRYPT_AsnEncodePKCSEnvelopedData (const CRYPT_ENVELOPED_DATA *envelopedData, void *pvData, DWORD *pcbData)
 
static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder (DWORD dwCertEncodingType, LPCSTR lpszStructType)
 
static CryptEncodeObjectFunc CRYPT_LoadEncoderFunc (DWORD dwCertEncodingType, LPCSTR lpszStructType, HCRYPTOIDFUNCADDR *hFunc)
 
static CryptEncodeObjectExFunc CRYPT_LoadEncoderExFunc (DWORD dwCertEncodingType, LPCSTR lpszStructType, HCRYPTOIDFUNCADDR *hFunc)
 
BOOL WINAPI CryptEncodeObject (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
 
BOOL WINAPI CryptEncodeObjectEx (DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, void *pvEncoded, DWORD *pcbEncoded)
 
BOOL WINAPI PFXExportCertStore (HCERTSTORE hStore, CRYPT_DATA_BLOB *pPFX, LPCWSTR szPassword, DWORD dwFlags)
 
BOOL WINAPI PFXExportCertStoreEx (HCERTSTORE hStore, CRYPT_DATA_BLOB *pPFX, LPCWSTR szPassword, void *pvReserved, DWORD dwFlags)
 
BOOL WINAPI CryptExportPublicKeyInfo (HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)
 
static BOOL WINAPI CRYPT_ExportPublicKeyInfoEx (HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, DWORD dwFlags, void *pvAuxInfo, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)
 
BOOL WINAPI CryptExportPublicKeyInfoEx (HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, DWORD dwFlags, void *pvAuxInfo, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)
 
BOOL WINAPI CryptImportPublicKeyInfo (HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, HCRYPTKEY *phKey)
 
static BOOL WINAPI CRYPT_ImportPublicKeyInfoEx (HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey)
 
BOOL WINAPI CryptImportPublicKeyInfoEx (HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey)
 

Macro Definition Documentation

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 41 of file encode.c.

Typedef Documentation

◆ ConvertPublicKeyInfoFunc

typedef BOOL(WINAPI * ConvertPublicKeyInfoFunc) (DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, BYTE **ppbData, DWORD *dwDataLen)

Definition at line 4977 of file encode.c.

◆ CryptEncodeObjectFunc

typedef BOOL(WINAPI * CryptEncodeObjectFunc) (DWORD, LPCSTR, const void *, BYTE *, DWORD *)

Definition at line 55 of file encode.c.

◆ EncodePublicKeyAndParametersFunc

typedef BOOL(WINAPI * EncodePublicKeyAndParametersFunc) (DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, BYTE *pbPubKey, DWORD cbPubKey, DWORD dwFlags, void *pvAuxInfo, BYTE **ppPublicKey, DWORD *pcbPublicKey, BYTE **ppbParams, DWORD *pcbParams)

Definition at line 4782 of file encode.c.

◆ ExportPublicKeyInfoExFunc

typedef BOOL(WINAPI * ExportPublicKeyInfoExFunc) (HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, DWORD dwFlags, void *pvAuxInfo, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)

Definition at line 4930 of file encode.c.

◆ ImportPublicKeyInfoExFunc

typedef BOOL(WINAPI * ImportPublicKeyInfoExFunc) (HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey)

Definition at line 5040 of file encode.c.

Function Documentation

◆ BLOBComp()

static int BLOBComp ( const void l,
const void r 
)
static

Definition at line 1189 of file encode.c.

1190{
1191 const CRYPT_DER_BLOB *a = l, *b = r;
1192 int ret;
1193
1194 if (!(ret = memcmp(a->pbData, b->pbData, min(a->cbData, b->cbData))))
1195 ret = a->cbData - b->cbData;
1196 return ret;
1197}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
r l[0]
Definition: byte_order.h:168
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define min(a, b)
Definition: monoChain.cc:55
int ret

Referenced by CRYPT_DEREncodeItemsAsSet(), and CRYPT_DEREncodeSet().

◆ CRYPT_AsnEncodeAccessDescription()

static BOOL CRYPT_AsnEncodeAccessDescription ( const CERT_ACCESS_DESCRIPTION descr,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2697 of file encode.c.

2699{
2700 struct AsnEncodeSequenceItem items[] = {
2701 { descr->pszAccessMethod, CRYPT_AsnEncodeOid, 0 },
2702 { &descr->AccessLocation, CRYPT_AsnEncodeAltNameEntry, 0 },
2703 };
2704
2705 if (!descr->pszAccessMethod)
2706 {
2708 return FALSE;
2709 }
2711}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
BOOL WINAPI CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType, struct AsnEncodeSequenceItem items[], DWORD cItem, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:180
BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:820
static BOOL WINAPI CRYPT_AsnEncodeAltNameEntry(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2400
#define SetLastError(x)
Definition: compat.h:752
static LPCSTR DWORD void BYTE * pbEncoded
Definition: str.c:196
static LPCSTR DWORD void BYTE DWORD * pcbEncoded
Definition: str.c:197
static TCHAR * items[]
Definition: page1.c:45
const char * descr
Definition: boot.c:45
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297

Referenced by CRYPT_AsnEncodeAuthorityInfoAccess().

◆ CRYPT_AsnEncodeAlgorithmId()

static BOOL WINAPI CRYPT_AsnEncodeAlgorithmId ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 408 of file encode.c.

411{
412 const CRYPT_ALGORITHM_IDENTIFIER *algo = pvStructInfo;
413 BOOL ret;
414 struct AsnEncodeSequenceItem items[] = {
415 { algo->pszObjId, CRYPT_AsnEncodeOid, 0 },
416 { &algo->Parameters, CRYPT_CopyEncodedBlob, 0 },
417 };
418
420 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
421 pcbEncoded);
422 return ret;
423}
static BOOL WINAPI CRYPT_CopyEncodedBlob(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:335
unsigned int BOOL
Definition: ntddk_ex.h:94
CRYPT_OBJID_BLOB Parameters
Definition: wincrypt.h:127
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ DWORD dwCertEncodingType
Definition: wincrypt.h:5037

Referenced by CRYPT_AsnEncodeCert(), CRYPT_AsnEncodeCertInfo(), CRYPT_AsnEncodeCRLInfo(), and CRYPT_AsnEncodePubKeyInfoNoNull().

◆ CRYPT_AsnEncodeAlgorithmIdWithNullParams()

static BOOL WINAPI CRYPT_AsnEncodeAlgorithmIdWithNullParams ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 383 of file encode.c.

387{
388 const CRYPT_ALGORITHM_IDENTIFIER *algo = pvStructInfo;
389 static const BYTE asn1Null[] = { ASN_NULL, 0 };
390 static const CRYPT_DATA_BLOB nullBlob = { sizeof(asn1Null),
391 (LPBYTE)asn1Null };
392 BOOL ret;
393 struct AsnEncodeSequenceItem items[2] = {
394 { algo->pszObjId, CRYPT_AsnEncodeOid, 0 },
396 };
397
398 if (algo->Parameters.cbData)
399 items[1].pvStructInfo = &algo->Parameters;
400 else
401 items[1].pvStructInfo = &nullBlob;
403 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
404 pcbEncoded);
405 return ret;
406}
#define ASN_NULL
Definition: snmp.h:106
unsigned char * LPBYTE
Definition: typedefs.h:53
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CRYPT_AsnEncodeCMSSignedInfo(), CRYPT_AsnEncodeCMSSignerInfo(), CRYPT_AsnEncodeEncryptedContentInfo(), CRYPT_AsnEncodePKCSDigestedData(), CRYPT_AsnEncodePKCSSignerInfo(), CRYPT_AsnEncodePubKeyInfo(), and CRYPT_AsnEncodeRecipientInfo().

◆ CRYPT_AsnEncodeAltName()

static BOOL WINAPI CRYPT_AsnEncodeAltName ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2560 of file encode.c.

2563{
2564 BOOL ret;
2565
2566 __TRY
2567 {
2568 const CERT_ALT_NAME_INFO *info = pvStructInfo;
2569 DWORD bytesNeeded, dataLen, lenBytes, i;
2570
2571 ret = TRUE;
2572 /* FIXME: should check that cAltEntry is not bigger than 0xff, since we
2573 * can't encode an erroneous entry index if it's bigger than this.
2574 */
2575 for (i = 0, dataLen = 0; ret && i < info->cAltEntry; i++)
2576 {
2577 DWORD len;
2578
2580 &info->rgAltEntry[i], 0, NULL, NULL, &len);
2581 if (ret)
2582 dataLen += len;
2584 {
2585 /* CRYPT_AsnEncodeAltNameEntry encoded the index of
2586 * the bad character, now set the index of the bad
2587 * entry
2588 */
2589 *pcbEncoded = (BYTE)i <<
2591 }
2592 }
2593 if (ret)
2594 {
2595 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
2596 bytesNeeded = 1 + lenBytes + dataLen;
2597 if (!pbEncoded)
2598 {
2599 *pcbEncoded = bytesNeeded;
2600 ret = TRUE;
2601 }
2602 else
2603 {
2604 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
2605 pbEncoded, pcbEncoded, bytesNeeded)))
2606 {
2607 BYTE *out;
2608
2610 pbEncoded = *(BYTE **)pbEncoded;
2611 out = pbEncoded;
2612 *out++ = ASN_SEQUENCEOF;
2613 CRYPT_EncodeLen(dataLen, out, &lenBytes);
2614 out += lenBytes;
2615 for (i = 0; ret && i < info->cAltEntry; i++)
2616 {
2617 DWORD len = dataLen;
2618
2620 NULL, &info->rgAltEntry[i], 0, NULL, out, &len);
2621 if (ret)
2622 {
2623 out += len;
2624 dataLen -= len;
2625 }
2626 }
2628 CRYPT_FreeSpace(pEncodePara, pbEncoded);
2629 }
2630 }
2631 }
2632 }
2634 {
2636 ret = FALSE;
2637 }
2638 __ENDTRY
2639 return ret;
2640}
#define TRUE
Definition: types.h:120
static void CRYPT_FreeSpace(const CRYPT_ENCODE_PARA *pEncodePara, LPVOID pv)
Definition: encode.c:130
BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:138
BOOL CRYPT_EncodeEnsureSpace(DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded, DWORD bytesNeeded)
Definition: encode.c:103
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
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
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
static FILE * out
Definition: regtests2xml.c:44
#define ASN_SEQUENCEOF
Definition: snmp.h:111
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CERT_ALT_NAME_ENTRY_ERR_INDEX_SHIFT
Definition: wincrypt.h:361
#define CRYPT_ENCODE_ALLOC_FLAG
Definition: wincrypt.h:3441
#define CRYPT_E_INVALID_IA5_STRING
Definition: winerror.h:3026

Referenced by CRYPT_AsnEncodeAuthorityKeyId2(), CRYPT_AsnEncodeDistPoint(), CRYPT_AsnEncodeIssuingDistPoint(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeAltNameEntry()

static BOOL WINAPI CRYPT_AsnEncodeAltNameEntry ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2400 of file encode.c.

2403{
2404 const CERT_ALT_NAME_ENTRY *entry = pvStructInfo;
2405 BOOL ret;
2406 DWORD dataLen;
2407 BYTE tag;
2408
2409 ret = TRUE;
2410 switch (entry->dwAltNameChoice)
2411 {
2414 case CERT_ALT_NAME_URL:
2415 tag = ASN_CONTEXT | (entry->dwAltNameChoice - 1);
2416 if (entry->u.pwszURL)
2417 {
2418 DWORD i;
2419
2420 /* Not + 1: don't encode the NULL-terminator */
2421 dataLen = lstrlenW(entry->u.pwszURL);
2422 for (i = 0; ret && i < dataLen; i++)
2423 {
2424 if (entry->u.pwszURL[i] > 0x7f)
2425 {
2427 ret = FALSE;
2428 *pcbEncoded = i;
2429 }
2430 }
2431 }
2432 else
2433 dataLen = 0;
2434 break;
2436 tag = ASN_CONTEXT | ASN_CONSTRUCTOR | (entry->dwAltNameChoice - 1);
2437 dataLen = entry->u.DirectoryName.cbData;
2438 break;
2440 tag = ASN_CONTEXT | (entry->dwAltNameChoice - 1);
2441 dataLen = entry->u.IPAddress.cbData;
2442 break;
2444 {
2445 struct AsnEncodeTagSwappedItem swapped =
2446 { ASN_CONTEXT | (entry->dwAltNameChoice - 1), entry->u.pszRegisteredID,
2448
2449 return CRYPT_AsnEncodeSwapTag(0, NULL, &swapped, 0, NULL, pbEncoded,
2450 pcbEncoded);
2451 }
2453 FIXME("name type %d unimplemented\n", entry->dwAltNameChoice);
2454 return FALSE;
2455 default:
2457 return FALSE;
2458 }
2459 if (ret)
2460 {
2461 DWORD bytesNeeded, lenBytes;
2462
2463 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
2464 bytesNeeded = 1 + dataLen + lenBytes;
2465 if (!pbEncoded)
2466 *pcbEncoded = bytesNeeded;
2467 else if (*pcbEncoded < bytesNeeded)
2468 {
2470 *pcbEncoded = bytesNeeded;
2471 ret = FALSE;
2472 }
2473 else
2474 {
2475 *pbEncoded++ = tag;
2476 CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes);
2477 pbEncoded += lenBytes;
2478 switch (entry->dwAltNameChoice)
2479 {
2482 case CERT_ALT_NAME_URL:
2483 {
2484 DWORD i;
2485
2486 for (i = 0; i < dataLen; i++)
2487 *pbEncoded++ = (BYTE)entry->u.pwszURL[i];
2488 break;
2489 }
2491 memcpy(pbEncoded, entry->u.DirectoryName.pbData, dataLen);
2492 break;
2494 memcpy(pbEncoded, entry->u.IPAddress.pbData, dataLen);
2495 break;
2496 }
2497 if (ret)
2498 *pcbEncoded = bytesNeeded;
2499 }
2500 }
2501 TRACE("returning %d (%08x)\n", ret, GetLastError());
2502 return ret;
2503}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERROR_MORE_DATA
Definition: dderror.h:13
static BOOL WINAPI CRYPT_AsnEncodeSwapTag(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:298
#define lstrlenW
Definition: compat.h:750
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ASN_CONSTRUCTOR
Definition: snmp.h:92
#define ASN_CONTEXT
Definition: snmp.h:89
#define TRACE(s)
Definition: solgame.cpp:4
Definition: wincrypt.h:332
Definition: ecma_167.h:138
#define CERT_ALT_NAME_URL
Definition: wincrypt.h:351
#define CERT_ALT_NAME_DIRECTORY_NAME
Definition: wincrypt.h:349
#define CERT_ALT_NAME_IP_ADDRESS
Definition: wincrypt.h:352
#define CERT_ALT_NAME_RFC822_NAME
Definition: wincrypt.h:346
#define CERT_ALT_NAME_OTHER_NAME
Definition: wincrypt.h:345
#define CERT_ALT_NAME_DNS_NAME
Definition: wincrypt.h:347
#define CERT_ALT_NAME_REGISTERED_ID
Definition: wincrypt.h:353

Referenced by CRYPT_AsnEncodeAccessDescription(), CRYPT_AsnEncodeAltName(), and CRYPT_AsnEncodeGeneralSubtree().

◆ CRYPT_AsnEncodeAuthorityInfoAccess()

static BOOL WINAPI CRYPT_AsnEncodeAuthorityInfoAccess ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2713 of file encode.c.

2716{
2717 BOOL ret;
2718
2719 __TRY
2720 {
2721 DWORD bytesNeeded, dataLen, lenBytes, i;
2722 const CERT_AUTHORITY_INFO_ACCESS *info = pvStructInfo;
2723
2724 ret = TRUE;
2725 for (i = 0, dataLen = 0; ret && i < info->cAccDescr; i++)
2726 {
2727 DWORD size;
2728
2730 &size);
2731 if (ret)
2732 dataLen += size;
2733 }
2734 if (ret)
2735 {
2736 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
2737 bytesNeeded = 1 + lenBytes + dataLen;
2738 if (!pbEncoded)
2739 *pcbEncoded = bytesNeeded;
2740 else
2741 {
2742 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
2743 pbEncoded, pcbEncoded, bytesNeeded)))
2744 {
2745 BYTE *out;
2746
2748 pbEncoded = *(BYTE **)pbEncoded;
2749 out = pbEncoded;
2750 *out++ = ASN_SEQUENCEOF;
2751 CRYPT_EncodeLen(dataLen, out, &lenBytes);
2752 out += lenBytes;
2753 for (i = 0; i < info->cAccDescr; i++)
2754 {
2755 DWORD size = dataLen;
2756
2758 &info->rgAccDescr[i], out, &size);
2759 out += size;
2760 dataLen -= size;
2761 }
2763 CRYPT_FreeSpace(pEncodePara, pbEncoded);
2764 }
2765 }
2766 }
2767 }
2769 {
2771 ret = FALSE;
2772 }
2773 __ENDTRY
2774 return ret;
2775}
static BOOL CRYPT_AsnEncodeAccessDescription(const CERT_ACCESS_DESCRIPTION *descr, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2697
GLsizeiptr size
Definition: glext.h:5919

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeAuthorityKeyId()

static BOOL WINAPI CRYPT_AsnEncodeAuthorityKeyId ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2505 of file encode.c.

2508{
2509 BOOL ret;
2510
2511 __TRY
2512 {
2513 const CERT_AUTHORITY_KEY_ID_INFO *info = pvStructInfo;
2514 struct AsnEncodeSequenceItem items[3] = { { 0 } };
2515 struct AsnEncodeTagSwappedItem swapped[3] = { { 0 } };
2516 struct AsnConstructedItem constructed = { 0 };
2517 DWORD cItem = 0, cSwapped = 0;
2518
2519 if (info->KeyId.cbData)
2520 {
2521 swapped[cSwapped].tag = ASN_CONTEXT | 0;
2522 swapped[cSwapped].pvStructInfo = &info->KeyId;
2523 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeOctets;
2524 items[cItem].pvStructInfo = &swapped[cSwapped];
2525 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
2526 cSwapped++;
2527 cItem++;
2528 }
2529 if (info->CertIssuer.cbData)
2530 {
2531 constructed.tag = 1;
2532 constructed.pvStructInfo = &info->CertIssuer;
2533 constructed.encodeFunc = CRYPT_CopyEncodedBlob;
2534 items[cItem].pvStructInfo = &constructed;
2535 items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
2536 cItem++;
2537 }
2538 if (info->CertSerialNumber.cbData)
2539 {
2540 swapped[cSwapped].tag = ASN_CONTEXT | 2;
2541 swapped[cSwapped].pvStructInfo = &info->CertSerialNumber;
2542 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeInteger;
2543 items[cItem].pvStructInfo = &swapped[cSwapped];
2544 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
2545 cSwapped++;
2546 cItem++;
2547 }
2549 pEncodePara, pbEncoded, pcbEncoded);
2550 }
2552 {
2554 ret = FALSE;
2555 }
2556 __ENDTRY
2557 return ret;
2558}
BOOL WINAPI CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:239
BOOL WINAPI CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3178
static BOOL WINAPI CRYPT_AsnEncodeInteger(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3343
const void * pvStructInfo
CryptEncodeObjectExFunc encodeFunc
const void * pvStructInfo
Definition: encode.c:290
CryptEncodeObjectExFunc encodeFunc
Definition: encode.c:291

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeAuthorityKeyId2()

static BOOL WINAPI CRYPT_AsnEncodeAuthorityKeyId2 ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2642 of file encode.c.

2645{
2646 BOOL ret;
2647
2648 __TRY
2649 {
2650 const CERT_AUTHORITY_KEY_ID2_INFO *info = pvStructInfo;
2651 struct AsnEncodeSequenceItem items[3] = { { 0 } };
2652 struct AsnEncodeTagSwappedItem swapped[3] = { { 0 } };
2653 DWORD cItem = 0, cSwapped = 0;
2654
2655 if (info->KeyId.cbData)
2656 {
2657 swapped[cSwapped].tag = ASN_CONTEXT | 0;
2658 swapped[cSwapped].pvStructInfo = &info->KeyId;
2659 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeOctets;
2660 items[cItem].pvStructInfo = &swapped[cSwapped];
2661 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
2662 cSwapped++;
2663 cItem++;
2664 }
2665 if (info->AuthorityCertIssuer.cAltEntry)
2666 {
2667 swapped[cSwapped].tag = ASN_CONTEXT | ASN_CONSTRUCTOR | 1;
2668 swapped[cSwapped].pvStructInfo = &info->AuthorityCertIssuer;
2669 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeAltName;
2670 items[cItem].pvStructInfo = &swapped[cSwapped];
2671 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
2672 cSwapped++;
2673 cItem++;
2674 }
2675 if (info->AuthorityCertSerialNumber.cbData)
2676 {
2677 swapped[cSwapped].tag = ASN_CONTEXT | 2;
2678 swapped[cSwapped].pvStructInfo = &info->AuthorityCertSerialNumber;
2679 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeInteger;
2680 items[cItem].pvStructInfo = &swapped[cSwapped];
2681 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
2682 cSwapped++;
2683 cItem++;
2684 }
2686 pEncodePara, pbEncoded, pcbEncoded);
2687 }
2689 {
2691 ret = FALSE;
2692 }
2693 __ENDTRY
2694 return ret;
2695}
static BOOL WINAPI CRYPT_AsnEncodeAltName(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2560

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeBasicConstraints()

static BOOL WINAPI CRYPT_AsnEncodeBasicConstraints ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2777 of file encode.c.

2780{
2781 BOOL ret;
2782
2783 __TRY
2784 {
2785 const CERT_BASIC_CONSTRAINTS_INFO *info = pvStructInfo;
2786 struct AsnEncodeSequenceItem items[3] = {
2787 { &info->SubjectType, CRYPT_AsnEncodeBits, 0 },
2788 { 0 }
2789 };
2790 DWORD cItem = 1;
2791
2792 if (info->fPathLenConstraint)
2793 {
2794 items[cItem].pvStructInfo = &info->dwPathLenConstraint;
2795 items[cItem].encodeFunc = CRYPT_AsnEncodeInt;
2796 cItem++;
2797 }
2798 if (info->cSubtreesConstraint)
2799 {
2800 items[cItem].pvStructInfo = &info->cSubtreesConstraint;
2801 items[cItem].encodeFunc = CRYPT_AsnEncodeSequenceOfAny;
2802 cItem++;
2803 }
2805 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
2806 }
2808 {
2810 ret = FALSE;
2811 }
2812 __ENDTRY
2813 return ret;
2814}
static BOOL WINAPI CRYPT_AsnEncodeBits(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3224
static BOOL WINAPI CRYPT_AsnEncodeInt(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3333
static BOOL WINAPI CRYPT_AsnEncodeSequenceOfAny(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3656

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeBasicConstraints2()

static BOOL WINAPI CRYPT_AsnEncodeBasicConstraints2 ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2816 of file encode.c.

2819{
2820 BOOL ret;
2821
2822 __TRY
2823 {
2824 const CERT_BASIC_CONSTRAINTS2_INFO *info = pvStructInfo;
2825 struct AsnEncodeSequenceItem items[2] = { { 0 } };
2826 DWORD cItem = 0;
2827
2828 if (info->fCA)
2829 {
2830 items[cItem].pvStructInfo = &info->fCA;
2831 items[cItem].encodeFunc = CRYPT_AsnEncodeBool;
2832 cItem++;
2833 }
2834 if (info->fPathLenConstraint)
2835 {
2836 items[cItem].pvStructInfo = &info->dwPathLenConstraint;
2837 items[cItem].encodeFunc = CRYPT_AsnEncodeInt;
2838 cItem++;
2839 }
2841 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
2842 }
2844 {
2846 ret = FALSE;
2847 }
2848 __ENDTRY
2849 return ret;
2850}
static BOOL WINAPI CRYPT_AsnEncodeBool(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2369

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeBits()

static BOOL WINAPI CRYPT_AsnEncodeBits ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3224 of file encode.c.

3227{
3228 BOOL ret;
3229
3230 __TRY
3231 {
3232 const CRYPT_BIT_BLOB *blob = pvStructInfo;
3233 DWORD bytesNeeded, lenBytes, dataBytes;
3234 BYTE unusedBits;
3235
3236 /* yep, MS allows cUnusedBits to be >= 8 */
3237 if (!blob->cUnusedBits)
3238 {
3239 dataBytes = blob->cbData;
3240 unusedBits = 0;
3241 }
3242 else if (blob->cbData * 8 > blob->cUnusedBits)
3243 {
3244 dataBytes = (blob->cbData * 8 - blob->cUnusedBits) / 8 + 1;
3245 unusedBits = blob->cUnusedBits >= 8 ? blob->cUnusedBits / 8 :
3246 blob->cUnusedBits;
3247 }
3248 else
3249 {
3250 dataBytes = 0;
3251 unusedBits = 0;
3252 }
3253 CRYPT_EncodeLen(dataBytes + 1, NULL, &lenBytes);
3254 bytesNeeded = 1 + lenBytes + dataBytes + 1;
3255 if (!pbEncoded)
3256 {
3257 *pcbEncoded = bytesNeeded;
3258 ret = TRUE;
3259 }
3260 else
3261 {
3262 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded,
3263 pcbEncoded, bytesNeeded)))
3264 {
3266 pbEncoded = *(BYTE **)pbEncoded;
3268 CRYPT_EncodeLen(dataBytes + 1, pbEncoded, &lenBytes);
3269 pbEncoded += lenBytes;
3270 *pbEncoded++ = unusedBits;
3271 if (dataBytes)
3272 {
3273 BYTE mask = 0xff << unusedBits;
3274
3275 if (dataBytes > 1)
3276 {
3277 memcpy(pbEncoded, blob->pbData, dataBytes - 1);
3278 pbEncoded += dataBytes - 1;
3279 }
3280 *pbEncoded = *(blob->pbData + dataBytes - 1) & mask;
3281 }
3282 }
3283 }
3284 }
3286 {
3288 ret = FALSE;
3289 }
3290 __ENDTRY
3291 return ret;
3292}
#define ASN_BITSTRING
GLenum GLint GLuint mask
Definition: glext.h:6028
Definition: image.c:134

Referenced by CRYPT_AsnEncodeBasicConstraints(), CRYPT_AsnEncodeBitsSwapBytes(), CRYPT_AsnEncodeCert(), CRYPT_AsnEncodeCertInfo(), CRYPT_AsnEncodeDistPoint(), CRYPT_AsnEncodeIssuingDistPoint(), CRYPT_AsnEncodePubKeyInfo(), CRYPT_AsnEncodePubKeyInfoNoNull(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeBitsSwapBytes()

static BOOL WINAPI CRYPT_AsnEncodeBitsSwapBytes ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3294 of file encode.c.

3297{
3298 BOOL ret;
3299
3300 __TRY
3301 {
3302 const CRYPT_BIT_BLOB *blob = pvStructInfo;
3303 CRYPT_BIT_BLOB newBlob = { blob->cbData, NULL, blob->cUnusedBits };
3304
3305 ret = TRUE;
3306 if (newBlob.cbData)
3307 {
3308 newBlob.pbData = CryptMemAlloc(newBlob.cbData);
3309 if (newBlob.pbData)
3310 {
3311 DWORD i;
3312
3313 for (i = 0; i < newBlob.cbData; i++)
3314 newBlob.pbData[newBlob.cbData - i - 1] = blob->pbData[i];
3315 }
3316 else
3317 ret = FALSE;
3318 }
3319 if (ret)
3320 ret = CRYPT_AsnEncodeBits(dwCertEncodingType, lpszStructType,
3321 &newBlob, dwFlags, pEncodePara, pbEncoded, pcbEncoded);
3322 CryptMemFree(newBlob.pbData);
3323 }
3325 {
3327 ret = FALSE;
3328 }
3329 __ENDTRY
3330 return ret;
3331}
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
BYTE * pbData
Definition: wincrypt.h:197

Referenced by CRYPT_AsnEncodeCert().

◆ CRYPT_AsnEncodeBMPString()

static BOOL CRYPT_AsnEncodeBMPString ( const CERT_NAME_VALUE value,
DWORD  dwFlags,
const CRYPT_ENCODE_PARA pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 967 of file encode.c.

970{
971 BOOL ret = TRUE;
972 LPCWSTR str = (LPCWSTR)value->Value.pbData;
973 DWORD bytesNeeded, lenBytes, strLen;
974
975 if (value->Value.cbData)
976 strLen = value->Value.cbData / sizeof(WCHAR);
977 else if (value->Value.pbData)
978 strLen = lstrlenW(str);
979 else
980 strLen = 0;
981 CRYPT_EncodeLen(strLen * 2, NULL, &lenBytes);
982 bytesNeeded = 1 + lenBytes + strLen * 2;
983 if (!pbEncoded)
984 *pcbEncoded = bytesNeeded;
985 else
986 {
987 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
988 pbEncoded, pcbEncoded, bytesNeeded)))
989 {
990 DWORD i;
991
993 pbEncoded = *(BYTE **)pbEncoded;
995 CRYPT_EncodeLen(strLen * 2, pbEncoded, &lenBytes);
996 pbEncoded += lenBytes;
997 for (i = 0; i < strLen; i++)
998 {
999 *pbEncoded++ = (str[i] & 0xff00) >> 8;
1000 *pbEncoded++ = str[i] & 0x00ff;
1001 }
1002 }
1003 }
1004 return ret;
1005}
#define ASN_BMPSTRING
if(dx< 0)
Definition: linetemp.h:194
const WCHAR * str
Definition: pdh_main.c:94
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by CRYPT_AsnEncodeNameValue(), and CRYPT_AsnEncodeUnicodeNameValue().

◆ CRYPT_AsnEncodeBool()

static BOOL WINAPI CRYPT_AsnEncodeBool ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2369 of file encode.c.

2372{
2373 BOOL val = *(const BOOL *)pvStructInfo, ret;
2374
2375 TRACE("%d\n", val);
2376
2377 if (!pbEncoded)
2378 {
2379 *pcbEncoded = 3;
2380 ret = TRUE;
2381 }
2382 else if (*pcbEncoded < 3)
2383 {
2384 *pcbEncoded = 3;
2386 ret = FALSE;
2387 }
2388 else
2389 {
2390 *pcbEncoded = 3;
2391 *pbEncoded++ = ASN_BOOL;
2392 *pbEncoded++ = 1;
2393 *pbEncoded++ = val ? 0xff : 0;
2394 ret = TRUE;
2395 }
2396 TRACE("returning %d (%08x)\n", ret, GetLastError());
2397 return ret;
2398}
#define ASN_BOOL
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by CRYPT_AsnEncodeBasicConstraints2(), CRYPT_AsnEncodeExtension(), and CRYPT_AsnEncodeIssuingDistPoint().

◆ CRYPT_AsnEncodeCert()

static BOOL WINAPI CRYPT_AsnEncodeCert ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 454 of file encode.c.

457{
458 BOOL ret;
459
460 __TRY
461 {
462 const CERT_SIGNED_CONTENT_INFO *info = pvStructInfo;
463 struct AsnEncodeSequenceItem items[] = {
464 { &info->ToBeSigned, CRYPT_CopyEncodedBlob, 0 },
465 { &info->SignatureAlgorithm, CRYPT_AsnEncodeAlgorithmId, 0 },
466 { &info->Signature, CRYPT_AsnEncodeBitsSwapBytes, 0 },
467 };
468
470 items[2].encodeFunc = CRYPT_AsnEncodeBits;
472 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
473 pcbEncoded);
474 }
476 {
478 ret = FALSE;
479 }
481 return ret;
482}
static BOOL WINAPI CRYPT_AsnEncodeAlgorithmId(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:408
static BOOL WINAPI CRYPT_AsnEncodeBitsSwapBytes(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3294
#define CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG
Definition: wincrypt.h:3440

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeCertInfo()

static BOOL WINAPI CRYPT_AsnEncodeCertInfo ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 507 of file encode.c.

510{
511 BOOL ret;
512
513 __TRY
514 {
515 const CERT_INFO *info = pvStructInfo;
516 struct AsnEncodeSequenceItem items[10] = {
517 { &info->dwVersion, CRYPT_AsnEncodeCertVersion, 0 },
518 { &info->SerialNumber, CRYPT_AsnEncodeInteger, 0 },
519 { &info->SignatureAlgorithm, CRYPT_AsnEncodeAlgorithmId, 0 },
520 { &info->Issuer, CRYPT_CopyEncodedBlob, 0 },
521 { &info->NotBefore, CRYPT_AsnEncodeValidity, 0 },
522 { &info->Subject, CRYPT_CopyEncodedBlob, 0 },
523 { &info->SubjectPublicKeyInfo, CRYPT_AsnEncodePubKeyInfoNoNull, 0 },
524 { 0 }
525 };
526 struct AsnConstructedItem constructed = { 0 };
527 struct AsnEncodeTagSwappedItem swapped[2] = { { 0 } };
528 DWORD cItem = 7, cSwapped = 0;
529
530 if (info->IssuerUniqueId.cbData)
531 {
532 swapped[cSwapped].tag = ASN_CONTEXT | 1;
533 swapped[cSwapped].pvStructInfo = &info->IssuerUniqueId;
534 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeBits;
535 items[cItem].pvStructInfo = &swapped[cSwapped];
536 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
537 cSwapped++;
538 cItem++;
539 }
540 if (info->SubjectUniqueId.cbData)
541 {
542 swapped[cSwapped].tag = ASN_CONTEXT | 2;
543 swapped[cSwapped].pvStructInfo = &info->SubjectUniqueId;
544 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeBits;
545 items[cItem].pvStructInfo = &swapped[cSwapped];
546 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
547 cSwapped++;
548 cItem++;
549 }
550 if (info->cExtension)
551 {
552 constructed.tag = 3;
553 constructed.pvStructInfo = &info->cExtension;
555 items[cItem].pvStructInfo = &constructed;
556 items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
557 cItem++;
558 }
559
561 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
562 }
564 {
566 ret = FALSE;
567 }
569 return ret;
570}
BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:484
static BOOL WINAPI CRYPT_AsnEncodeExtensions(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:757
static BOOL WINAPI CRYPT_AsnEncodeValidity(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:362
static BOOL WINAPI CRYPT_AsnEncodeCertVersion(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:312

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeCertPolicies()

static BOOL WINAPI CRYPT_AsnEncodeCertPolicies ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2945 of file encode.c.

2948{
2949 BOOL ret = FALSE;
2950
2951 __TRY
2952 {
2953 const CERT_POLICIES_INFO *info = pvStructInfo;
2954 DWORD bytesNeeded = 0, lenBytes, size, i;
2955
2956 ret = TRUE;
2957 for (i = 0; ret && i < info->cPolicyInfo; i++)
2958 {
2960 &info->rgPolicyInfo[i], dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL,
2961 &size);
2962 if (ret)
2963 bytesNeeded += size;
2964 }
2965 CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes);
2966 bytesNeeded += 1 + lenBytes;
2967 if (ret)
2968 {
2969 if (!pbEncoded)
2970 *pcbEncoded = bytesNeeded;
2971 else
2972 {
2973 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
2974 pbEncoded, pcbEncoded, bytesNeeded)))
2975 {
2976 BYTE *out;
2977
2979 pbEncoded = *(BYTE **)pbEncoded;
2980 out = pbEncoded;
2981 *out++ = ASN_SEQUENCEOF;
2982 CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, out, &lenBytes);
2983 out += lenBytes;
2984 for (i = 0; ret && i < info->cPolicyInfo; i++)
2985 {
2986 size = bytesNeeded;
2988 &info->rgPolicyInfo[i],
2990 if (ret)
2991 {
2992 out += size;
2993 bytesNeeded -= size;
2994 }
2995 }
2997 CRYPT_FreeSpace(pEncodePara, pbEncoded);
2998 }
2999 }
3000 }
3001 }
3003 {
3005 }
3006 __ENDTRY
3007 return ret;
3008}
static BOOL CRYPT_AsnEncodeCertPolicy(DWORD dwCertEncodingType, const CERT_POLICY_INFO *info, DWORD dwFlags, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2926

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeCertPolicy()

static BOOL CRYPT_AsnEncodeCertPolicy ( DWORD  dwCertEncodingType,
const CERT_POLICY_INFO info,
DWORD  dwFlags,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2926 of file encode.c.

2929{
2930 struct AsnEncodeSequenceItem items[2] = {
2931 { info->pszPolicyIdentifier, CRYPT_AsnEncodeOid, 0 },
2933 };
2934 BOOL ret;
2935
2936 if (!info->pszPolicyIdentifier)
2937 {
2939 return FALSE;
2940 }
2942 return ret;
2943}
static BOOL WINAPI CRYPT_AsnEncodeCertPolicyQualifiers(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2852

Referenced by CRYPT_AsnEncodeCertPolicies().

◆ CRYPT_AsnEncodeCertPolicyConstraints()

static BOOL WINAPI CRYPT_AsnEncodeCertPolicyConstraints ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3092 of file encode.c.

3096{
3097 BOOL ret = FALSE;
3098
3099 __TRY
3100 {
3101 const CERT_POLICY_CONSTRAINTS_INFO *info = pvStructInfo;
3102 struct AsnEncodeSequenceItem items[2];
3103 struct AsnEncodeTagSwappedItem swapped[2];
3104 DWORD cItem = 0, cSwapped = 0;
3105
3106 if (info->fRequireExplicitPolicy)
3107 {
3108 swapped[cSwapped].tag = ASN_CONTEXT | 0;
3109 swapped[cSwapped].pvStructInfo =
3110 &info->dwRequireExplicitPolicySkipCerts;
3111 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeInt;
3112 items[cItem].pvStructInfo = &swapped[cSwapped];
3113 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
3114 cSwapped++;
3115 cItem++;
3116 }
3117 if (info->fInhibitPolicyMapping)
3118 {
3119 swapped[cSwapped].tag = ASN_CONTEXT | 1;
3120 swapped[cSwapped].pvStructInfo =
3121 &info->dwInhibitPolicyMappingSkipCerts;
3122 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeInt;
3123 items[cItem].pvStructInfo = &swapped[cSwapped];
3124 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
3125 cSwapped++;
3126 cItem++;
3127 }
3130 }
3132 {
3134 }
3135 __ENDTRY
3136 return ret;
3137}

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeCertPolicyMapping()

static BOOL CRYPT_AsnEncodeCertPolicyMapping ( DWORD  dwCertEncodingType,
const CERT_POLICY_MAPPING mapping,
DWORD  dwFlags,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3010 of file encode.c.

3013{
3014 struct AsnEncodeSequenceItem items[] = {
3015 { mapping->pszIssuerDomainPolicy, CRYPT_AsnEncodeOid, 0 },
3016 { mapping->pszSubjectDomainPolicy, CRYPT_AsnEncodeOid, 0 },
3017 };
3018
3019 if (!mapping->pszIssuerDomainPolicy || !mapping->pszSubjectDomainPolicy)
3020 {
3022 return FALSE;
3023 }
3025}
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031

Referenced by CRYPT_AsnEncodeCertPolicyMappings().

◆ CRYPT_AsnEncodeCertPolicyMappings()

static BOOL WINAPI CRYPT_AsnEncodeCertPolicyMappings ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3027 of file encode.c.

3030{
3031 BOOL ret = FALSE;
3032
3033 __TRY
3034 {
3035 const CERT_POLICY_MAPPINGS_INFO *info = pvStructInfo;
3036 DWORD bytesNeeded = 0, lenBytes, size, i;
3037
3038 ret = TRUE;
3039 for (i = 0; ret && i < info->cPolicyMapping; i++)
3040 {
3042 &info->rgPolicyMapping[i], dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG,
3043 NULL, &size);
3044 if (ret)
3045 bytesNeeded += size;
3046 }
3047 CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes);
3048 bytesNeeded += 1 + lenBytes;
3049 if (ret)
3050 {
3051 if (!pbEncoded)
3052 *pcbEncoded = bytesNeeded;
3053 else
3054 {
3055 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
3056 pbEncoded, pcbEncoded, bytesNeeded)))
3057 {
3058 BYTE *out;
3059
3061 pbEncoded = *(BYTE **)pbEncoded;
3062 out = pbEncoded;
3063 *out++ = ASN_SEQUENCEOF;
3064 CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, out, &lenBytes);
3065 out += lenBytes;
3066 for (i = 0; ret && i < info->cPolicyMapping; i++)
3067 {
3068 size = bytesNeeded;
3070 dwCertEncodingType, &info->rgPolicyMapping[i],
3072 if (ret)
3073 {
3074 out += size;
3075 bytesNeeded -= size;
3076 }
3077 }
3079 CRYPT_FreeSpace(pEncodePara, pbEncoded);
3080 }
3081 }
3082 }
3083 }
3085 {
3087 }
3088 __ENDTRY
3089 return ret;
3090}
static BOOL CRYPT_AsnEncodeCertPolicyMapping(DWORD dwCertEncodingType, const CERT_POLICY_MAPPING *mapping, DWORD dwFlags, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3010

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeCertPolicyQualifiers()

static BOOL WINAPI CRYPT_AsnEncodeCertPolicyQualifiers ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2852 of file encode.c.

2855{
2856 const CERT_POLICY_INFO *info = pvStructInfo;
2857 BOOL ret;
2858
2859 if (!info->cPolicyQualifier)
2860 {
2861 *pcbEncoded = 0;
2862 ret = TRUE;
2863 }
2864 else
2865 {
2866 struct AsnEncodeSequenceItem items[2] = {
2867 { NULL, CRYPT_AsnEncodeOid, 0 },
2869 };
2870 DWORD bytesNeeded = 0, lenBytes, size, i;
2871
2872 ret = TRUE;
2873 for (i = 0; ret && i < info->cPolicyQualifier; i++)
2874 {
2875 items[0].pvStructInfo =
2876 info->rgPolicyQualifier[i].pszPolicyQualifierId;
2877 items[1].pvStructInfo = &info->rgPolicyQualifier[i].Qualifier;
2880 if (ret)
2881 bytesNeeded += size;
2882 }
2883 CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes);
2884 bytesNeeded += 1 + lenBytes;
2885 if (ret)
2886 {
2887 if (!pbEncoded)
2888 *pcbEncoded = bytesNeeded;
2889 else
2890 {
2891 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
2892 pbEncoded, pcbEncoded, bytesNeeded)))
2893 {
2894 BYTE *out;
2895
2897 pbEncoded = *(BYTE **)pbEncoded;
2898 out = pbEncoded;
2899 *out++ = ASN_SEQUENCEOF;
2900 CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, out, &lenBytes);
2901 out += lenBytes;
2902 for (i = 0; ret && i < info->cPolicyQualifier; i++)
2903 {
2904 items[0].pvStructInfo =
2905 info->rgPolicyQualifier[i].pszPolicyQualifierId;
2906 items[1].pvStructInfo =
2907 &info->rgPolicyQualifier[i].Qualifier;
2908 size = bytesNeeded;
2911 if (ret)
2912 {
2913 out += size;
2914 bytesNeeded -= size;
2915 }
2916 }
2918 CRYPT_FreeSpace(pEncodePara, pbEncoded);
2919 }
2920 }
2921 }
2922 }
2923 return ret;
2924}

Referenced by CRYPT_AsnEncodeCertPolicy().

◆ CRYPT_AsnEncodeCertVersion()

static BOOL WINAPI CRYPT_AsnEncodeCertVersion ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 312 of file encode.c.

315{
316 const DWORD *ver = pvStructInfo;
317 BOOL ret;
318
319 /* CERT_V1 is not encoded */
320 if (*ver == CERT_V1)
321 {
322 *pcbEncoded = 0;
323 ret = TRUE;
324 }
325 else
326 {
327 struct AsnConstructedItem item = { 0, ver, CRYPT_AsnEncodeInt };
328
330 &item, dwFlags, pEncodePara, pbEncoded, pcbEncoded);
331 }
332 return ret;
333}
static ATOM item
Definition: dde.c:856
#define X509_INTEGER
Definition: wincrypt.h:3393
#define CERT_V1
Definition: wincrypt.h:2656

Referenced by CRYPT_AsnEncodeCertInfo().

◆ CRYPT_AsnEncodeChoiceOfTime()

static BOOL WINAPI CRYPT_AsnEncodeChoiceOfTime ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3626 of file encode.c.

3629{
3630 BOOL ret;
3631
3632 __TRY
3633 {
3634 SYSTEMTIME sysTime;
3635
3636 /* Check the year, if it's in the UTCTime range call that encode func */
3637 if (!FileTimeToSystemTime(pvStructInfo, &sysTime))
3638 return FALSE;
3639 if (sysTime.wYear >= 1950 && sysTime.wYear <= 2050)
3641 pvStructInfo, dwFlags, pEncodePara, pbEncoded, pcbEncoded);
3642 else
3644 lpszStructType, pvStructInfo, dwFlags, pEncodePara, pbEncoded,
3645 pcbEncoded);
3646 }
3648 {
3650 ret = FALSE;
3651 }
3652 __ENDTRY
3653 return ret;
3654}
static BOOL WINAPI CRYPT_AsnEncodeUtcTime(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3521
static BOOL CRYPT_AsnEncodeGeneralizedTime(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3578
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
WORD wYear
Definition: winbase.h:929

Referenced by CRYPT_AsnEncodeCRLEntry(), CRYPT_AsnEncodeCRLInfo(), CRYPT_AsnEncodeCTL(), CRYPT_AsnEncodeValidity(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeCMSSignedInfo()

BOOL CRYPT_AsnEncodeCMSSignedInfo ( CRYPT_SIGNED_INFO signedInfo,
void pvData,
DWORD pcbData 
)

Definition at line 4307 of file encode.c.

4309{
4310 struct AsnEncodeSequenceItem items[7] = {
4311 { &signedInfo->version, CRYPT_AsnEncodeInt, 0 },
4312 };
4313 struct DERSetDescriptor digestAlgorithmsSet = { 0 }, certSet = { 0 };
4314 struct DERSetDescriptor crlSet = { 0 }, signerSet = { 0 };
4315 struct AsnEncodeTagSwappedItem swapped[2] = { { 0 } };
4316 DWORD cItem = 1, cSwapped = 0;
4317 BOOL ret = TRUE;
4318
4319 if (signedInfo->cSignerInfo)
4320 {
4321 digestAlgorithmsSet.cItems = signedInfo->cSignerInfo;
4322 digestAlgorithmsSet.items = signedInfo->rgSignerInfo;
4323 digestAlgorithmsSet.itemSize = sizeof(CMSG_CMS_SIGNER_INFO);
4324 digestAlgorithmsSet.itemOffset =
4327 items[cItem].pvStructInfo = &digestAlgorithmsSet;
4328 items[cItem].encodeFunc = CRYPT_DEREncodeItemsAsSet;
4329 cItem++;
4330 }
4331 items[cItem].pvStructInfo = &signedInfo->content;
4333 cItem++;
4334 if (signedInfo->cCertEncoded)
4335 {
4336 certSet.cItems = signedInfo->cCertEncoded;
4337 certSet.items = signedInfo->rgCertEncoded;
4338 certSet.itemSize = sizeof(CERT_BLOB);
4339 certSet.itemOffset = 0;
4340 certSet.encode = CRYPT_CopyEncodedBlob;
4341 swapped[cSwapped].tag = ASN_CONSTRUCTOR | ASN_CONTEXT | 0;
4342 swapped[cSwapped].pvStructInfo = &certSet;
4343 swapped[cSwapped].encodeFunc = CRYPT_DEREncodeItemsAsSet;
4344 items[cItem].pvStructInfo = &swapped[cSwapped];
4345 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
4346 cSwapped++;
4347 cItem++;
4348 }
4349 if (signedInfo->cCrlEncoded)
4350 {
4351 crlSet.cItems = signedInfo->cCrlEncoded;
4352 crlSet.items = signedInfo->rgCrlEncoded;
4353 crlSet.itemSize = sizeof(CRL_BLOB);
4354 crlSet.itemOffset = 0;
4356 swapped[cSwapped].tag = ASN_CONSTRUCTOR | ASN_CONTEXT | 1;
4357 swapped[cSwapped].pvStructInfo = &crlSet;
4358 swapped[cSwapped].encodeFunc = CRYPT_DEREncodeItemsAsSet;
4359 items[cItem].pvStructInfo = &swapped[cSwapped];
4360 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
4361 cSwapped++;
4362 cItem++;
4363 }
4364 if (ret && signedInfo->cSignerInfo)
4365 {
4366 signerSet.cItems = signedInfo->cSignerInfo;
4367 signerSet.items = signedInfo->rgSignerInfo;
4368 signerSet.itemSize = sizeof(CMSG_CMS_SIGNER_INFO);
4369 signerSet.itemOffset = 0;
4370 signerSet.encode = CRYPT_AsnEncodeCMSSignerInfo;
4371 items[cItem].pvStructInfo = &signerSet;
4372 items[cItem].encodeFunc = CRYPT_DEREncodeItemsAsSet;
4373 cItem++;
4374 }
4375 if (ret)
4377 items, cItem, 0, NULL, pvData, pcbData);
4378
4379 return ret;
4380}
static BOOL WINAPI CRYPT_AsnEncodeAlgorithmIdWithNullParams(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:383
static BOOL WINAPI CRYPT_AsnEncodeCMSSignerInfo(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:4218
static BOOL WINAPI CRYPT_AsnEncodePKCSContentInfoInternal(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1926
static BOOL WINAPI CRYPT_DEREncodeItemsAsSet(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1245
#define offsetof(TYPE, MEMBER)
size_t itemOffset
Definition: encode.c:1241
CryptEncodeObjectExFunc encode
Definition: encode.c:1242
size_t itemSize
Definition: encode.c:1240
const void * items
Definition: encode.c:1239
PCERT_BLOB rgCertEncoded
CRYPT_CONTENT_INFO content
PCMSG_CMS_SIGNER_INFO rgSignerInfo
struct _CRYPTOAPI_BLOB CRL_BLOB
struct _CMSG_CMS_SIGNER_INFO CMSG_CMS_SIGNER_INFO
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4950
struct _CRYPTOAPI_BLOB CERT_BLOB
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749
_In_ BOOLEAN _In_ ULONG HashAlgorithm
Definition: rtlfuncs.h:2052

Referenced by CRYPT_SavePKCSToMem(), and CSignedEncodeMsg_GetParam().

◆ CRYPT_AsnEncodeCMSSignerInfo()

static BOOL WINAPI CRYPT_AsnEncodeCMSSignerInfo ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 4218 of file encode.c.

4221{
4222 BOOL ret = FALSE;
4223
4225 {
4227 return FALSE;
4228 }
4229
4230 __TRY
4231 {
4232 const CMSG_CMS_SIGNER_INFO *info = pvStructInfo;
4233
4234 if (info->SignerId.dwIdChoice != CERT_ID_ISSUER_SERIAL_NUMBER &&
4235 info->SignerId.dwIdChoice != CERT_ID_KEY_IDENTIFIER)
4237 else if (info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER &&
4238 !info->SignerId.u.IssuerSerialNumber.Issuer.cbData)
4240 else
4241 {
4242 struct AsnEncodeSequenceItem items[7] = {
4243 { &info->dwVersion, CRYPT_AsnEncodeInt, 0 },
4244 };
4245 struct AsnEncodeTagSwappedItem swapped[3] = { { 0 } };
4246 DWORD cItem = 1, cSwapped = 0;
4247
4248 if (info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER)
4249 {
4250 items[cItem].pvStructInfo =
4251 &info->SignerId.u.IssuerSerialNumber.Issuer;
4252 items[cItem].encodeFunc =
4254 cItem++;
4255 }
4256 else
4257 {
4258 swapped[cSwapped].tag = ASN_CONTEXT | 0;
4259 swapped[cSwapped].pvStructInfo = &info->SignerId.u.KeyId;
4260 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeOctets;
4261 items[cItem].pvStructInfo = &swapped[cSwapped];
4262 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
4263 cSwapped++;
4264 cItem++;
4265 }
4266 items[cItem].pvStructInfo = &info->HashAlgorithm;
4268 cItem++;
4269 if (info->AuthAttrs.cAttr)
4270 {
4271 swapped[cSwapped].tag = ASN_CONTEXT | ASN_CONSTRUCTOR | 0;
4272 swapped[cSwapped].pvStructInfo = &info->AuthAttrs;
4273 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodePKCSAttributes;
4274 items[cItem].pvStructInfo = &swapped[cSwapped];
4275 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
4276 cSwapped++;
4277 cItem++;
4278 }
4279 items[cItem].pvStructInfo = &info->HashEncryptionAlgorithm;
4281 cItem++;
4282 items[cItem].pvStructInfo = &info->EncryptedHash;
4283 items[cItem].encodeFunc = CRYPT_AsnEncodeOctets;
4284 cItem++;
4285 if (info->UnauthAttrs.cAttr)
4286 {
4287 swapped[cSwapped].tag = ASN_CONTEXT | ASN_CONSTRUCTOR | 1;
4288 swapped[cSwapped].pvStructInfo = &info->UnauthAttrs;
4289 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodePKCSAttributes;
4290 items[cItem].pvStructInfo = &swapped[cSwapped];
4291 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
4292 cSwapped++;
4293 cItem++;
4294 }
4296 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
4297 }
4298 }
4300 {
4302 }
4303 __ENDTRY
4304 return ret;
4305}
static BOOL WINAPI CRYPT_AsnEncodePKCSAttributes(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1902
static BOOL WINAPI CRYPT_AsnEncodeIssuerSerialNumber(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:4134
#define CERT_ID_ISSUER_SERIAL_NUMBER
Definition: wincrypt.h:3673
#define CERT_ID_KEY_IDENTIFIER
Definition: wincrypt.h:3674

Referenced by CRYPT_AsnEncodeCMSSignedInfo(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeConstructed()

BOOL WINAPI CRYPT_AsnEncodeConstructed ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)

Definition at line 239 of file encode.c.

242{
243 BOOL ret;
244 const struct AsnConstructedItem *item = pvStructInfo;
245 DWORD len;
246
247 if ((ret = item->encodeFunc(dwCertEncodingType, lpszStructType,
248 item->pvStructInfo, dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, NULL, &len)))
249 {
250 DWORD dataLen, bytesNeeded;
251
252 CRYPT_EncodeLen(len, NULL, &dataLen);
253 bytesNeeded = 1 + dataLen + len;
254 if (!pbEncoded)
255 *pcbEncoded = bytesNeeded;
256 else if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
257 pbEncoded, pcbEncoded, bytesNeeded)))
258 {
259 BYTE *out;
260
262 pbEncoded = *(BYTE **)pbEncoded;
263 out = pbEncoded;
264 *out++ = ASN_CONTEXT | ASN_CONSTRUCTOR | item->tag;
265 CRYPT_EncodeLen(len, out, &dataLen);
266 out += dataLen;
267 ret = item->encodeFunc(dwCertEncodingType, lpszStructType,
268 item->pvStructInfo, dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL,
269 out, &len);
270 if (!ret)
271 {
272 /* Some functions propagate their errors through the size */
273 *pcbEncoded = len;
275 CRYPT_FreeSpace(pEncodePara, pbEncoded);
276 }
277 }
278 }
279 else
280 {
281 /* Some functions propagate their errors through the size */
282 *pcbEncoded = len;
283 }
284 return ret;
285}

Referenced by CRYPT_AsnEncodeAuthorityKeyId(), CRYPT_AsnEncodeCertInfo(), CRYPT_AsnEncodeCertVersion(), CRYPT_AsnEncodeCRLInfo(), CRYPT_AsnEncodeCTL(), CRYPT_AsnEncodeDistPoint(), CRYPT_AsnEncodeIssuingDistPoint(), CRYPT_AsnEncodePKCSContentInfoInternal(), and CRYPT_EncodeDataContentInfoHeader().

◆ CRYPT_AsnEncodeCRLDistPoints()

static BOOL WINAPI CRYPT_AsnEncodeCRLDistPoints ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3763 of file encode.c.

3766{
3767 BOOL ret;
3768
3769 __TRY
3770 {
3771 const CRL_DIST_POINTS_INFO *info = pvStructInfo;
3772
3773 if (!info->cDistPoint)
3774 {
3776 ret = FALSE;
3777 }
3778 else
3779 {
3780 DWORD bytesNeeded, dataLen, lenBytes, i;
3781
3782 ret = TRUE;
3783 for (i = 0, dataLen = 0; ret && i < info->cDistPoint; i++)
3784 {
3785 DWORD len;
3786
3787 ret = CRYPT_AsnEncodeDistPoint(&info->rgDistPoint[i], NULL,
3788 &len);
3789 if (ret)
3790 dataLen += len;
3792 {
3793 /* Have to propagate index of failing character */
3794 *pcbEncoded = len;
3795 }
3796 }
3797 if (ret)
3798 {
3799 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
3800 bytesNeeded = 1 + lenBytes + dataLen;
3801 if (!pbEncoded)
3802 {
3803 *pcbEncoded = bytesNeeded;
3804 ret = TRUE;
3805 }
3806 else
3807 {
3808 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
3809 pbEncoded, pcbEncoded, bytesNeeded)))
3810 {
3811 BYTE *out;
3812
3814 pbEncoded = *(BYTE **)pbEncoded;
3815 out = pbEncoded;
3816 *out++ = ASN_SEQUENCEOF;
3817 CRYPT_EncodeLen(dataLen, out, &lenBytes);
3818 out += lenBytes;
3819 for (i = 0; ret && i < info->cDistPoint; i++)
3820 {
3821 DWORD len = dataLen;
3822
3824 &info->rgDistPoint[i], out, &len);
3825 if (ret)
3826 {
3827 out += len;
3828 dataLen -= len;
3829 }
3830 }
3832 CRYPT_FreeSpace(pEncodePara, pbEncoded);
3833 }
3834 }
3835 }
3836 }
3837 }
3839 {
3841 ret = FALSE;
3842 }
3843 __ENDTRY
3844 return ret;
3845}
static BOOL CRYPT_AsnEncodeDistPoint(const CRL_DIST_POINT *distPoint, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3704

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeCRLEntries()

static BOOL WINAPI CRYPT_AsnEncodeCRLEntries ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 599 of file encode.c.

602{
603 DWORD bytesNeeded, dataLen, lenBytes, i;
604 const CRL_INFO *info = pvStructInfo;
605 const CRL_ENTRY *rgCRLEntry = info->rgCRLEntry;
606 BOOL ret = TRUE;
607
608 for (i = 0, dataLen = 0; ret && i < info->cCRLEntry; i++)
609 {
610 DWORD size;
611
612 ret = CRYPT_AsnEncodeCRLEntry(&rgCRLEntry[i], NULL, &size);
613 if (ret)
614 dataLen += size;
615 }
616 if (ret)
617 {
618 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
619 bytesNeeded = 1 + lenBytes + dataLen;
620 if (!pbEncoded)
621 *pcbEncoded = bytesNeeded;
622 else
623 {
624 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded,
625 pcbEncoded, bytesNeeded)))
626 {
627 BYTE *out;
628
630 pbEncoded = *(BYTE **)pbEncoded;
631 out = pbEncoded;
632 *out++ = ASN_SEQUENCEOF;
633 CRYPT_EncodeLen(dataLen, out, &lenBytes);
634 out += lenBytes;
635 for (i = 0; i < info->cCRLEntry; i++)
636 {
637 DWORD size = dataLen;
638
639 ret = CRYPT_AsnEncodeCRLEntry(&rgCRLEntry[i], out, &size);
640 out += size;
641 dataLen -= size;
642 }
644 CRYPT_FreeSpace(pEncodePara, pbEncoded);
645 }
646 }
647 }
648 return ret;
649}
static BOOL CRYPT_AsnEncodeCRLEntry(const CRL_ENTRY *entry, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:572
Definition: wincrypt.h:487

Referenced by CRYPT_AsnEncodeCRLInfo().

◆ CRYPT_AsnEncodeCRLEntry()

static BOOL CRYPT_AsnEncodeCRLEntry ( const CRL_ENTRY entry,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 572 of file encode.c.

574{
575 struct AsnEncodeSequenceItem items[3] = {
576 { &entry->SerialNumber, CRYPT_AsnEncodeInteger, 0 },
577 { &entry->RevocationDate, CRYPT_AsnEncodeChoiceOfTime, 0 },
578 { 0 }
579 };
580 DWORD cItem = 2;
581 BOOL ret;
582
583 TRACE("%p, %p, %d\n", entry, pbEncoded, pbEncoded ? *pcbEncoded : 0);
584
585 if (entry->cExtension)
586 {
587 items[cItem].pvStructInfo = &entry->cExtension;
588 items[cItem].encodeFunc = CRYPT_AsnEncodeExtensions;
589 cItem++;
590 }
591
594
595 TRACE("returning %d (%08x)\n", ret, GetLastError());
596 return ret;
597}
static BOOL WINAPI CRYPT_AsnEncodeChoiceOfTime(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3626

Referenced by CRYPT_AsnEncodeCRLEntries().

◆ CRYPT_AsnEncodeCRLInfo()

static BOOL WINAPI CRYPT_AsnEncodeCRLInfo ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 674 of file encode.c.

677{
678 BOOL ret;
679
680 __TRY
681 {
682 const CRL_INFO *info = pvStructInfo;
683 struct AsnEncodeSequenceItem items[7] = {
684 { &info->dwVersion, CRYPT_AsnEncodeCRLVersion, 0 },
685 { &info->SignatureAlgorithm, CRYPT_AsnEncodeAlgorithmId, 0 },
686 { &info->Issuer, CRYPT_CopyEncodedBlob, 0 },
687 { &info->ThisUpdate, CRYPT_AsnEncodeChoiceOfTime, 0 },
688 { 0 }
689 };
690 struct AsnConstructedItem constructed[1] = { { 0 } };
691 DWORD cItem = 4, cConstructed = 0;
692
693 if (info->NextUpdate.dwLowDateTime || info->NextUpdate.dwHighDateTime)
694 {
695 items[cItem].pvStructInfo = &info->NextUpdate;
696 items[cItem].encodeFunc = CRYPT_AsnEncodeChoiceOfTime;
697 cItem++;
698 }
699 if (info->cCRLEntry)
700 {
701 items[cItem].pvStructInfo = info;
702 items[cItem].encodeFunc = CRYPT_AsnEncodeCRLEntries;
703 cItem++;
704 }
705 if (info->cExtension)
706 {
707 constructed[cConstructed].tag = 0;
708 constructed[cConstructed].pvStructInfo = &info->cExtension;
709 constructed[cConstructed].encodeFunc = CRYPT_AsnEncodeExtensions;
710 items[cItem].pvStructInfo = &constructed[cConstructed];
711 items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
712 cConstructed++;
713 cItem++;
714 }
715
717 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
718 }
720 {
722 ret = FALSE;
723 }
725 return ret;
726}
static BOOL WINAPI CRYPT_AsnEncodeCRLVersion(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:651
static BOOL WINAPI CRYPT_AsnEncodeCRLEntries(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:599

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeCRLVersion()

static BOOL WINAPI CRYPT_AsnEncodeCRLVersion ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 651 of file encode.c.

654{
655 const DWORD *ver = pvStructInfo;
656 BOOL ret;
657
658 /* CRL_V1 is not encoded */
659 if (*ver == CRL_V1)
660 {
661 *pcbEncoded = 0;
662 ret = TRUE;
663 }
664 else
666 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
667 return ret;
668}
#define CRL_V1
Definition: wincrypt.h:2678

Referenced by CRYPT_AsnEncodeCRLInfo().

◆ CRYPT_AsnEncodeCTL()

static BOOL WINAPI CRYPT_AsnEncodeCTL ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1596 of file encode.c.

1599{
1600 BOOL ret = FALSE;
1601
1602 __TRY
1603 {
1604 const CTL_INFO *info = pvStructInfo;
1605 struct AsnEncodeSequenceItem items[9] = {
1606 { &info->dwVersion, CRYPT_AsnEncodeCTLVersion, 0 },
1607 { &info->SubjectUsage, CRYPT_AsnEncodeEnhancedKeyUsage, 0 },
1608 };
1609 struct AsnConstructedItem constructed = { 0 };
1610 DWORD cItem = 2;
1611
1612 if (info->ListIdentifier.cbData)
1613 {
1614 items[cItem].pvStructInfo = &info->ListIdentifier;
1615 items[cItem].encodeFunc = CRYPT_AsnEncodeOctets;
1616 cItem++;
1617 }
1618 if (info->SequenceNumber.cbData)
1619 {
1620 items[cItem].pvStructInfo = &info->SequenceNumber;
1621 items[cItem].encodeFunc = CRYPT_AsnEncodeInteger;
1622 cItem++;
1623 }
1624 items[cItem].pvStructInfo = &info->ThisUpdate;
1625 items[cItem].encodeFunc = CRYPT_AsnEncodeChoiceOfTime;
1626 cItem++;
1627 if (info->NextUpdate.dwLowDateTime || info->NextUpdate.dwHighDateTime)
1628 {
1629 items[cItem].pvStructInfo = &info->NextUpdate;
1630 items[cItem].encodeFunc = CRYPT_AsnEncodeChoiceOfTime;
1631 cItem++;
1632 }
1633 items[cItem].pvStructInfo = &info->SubjectAlgorithm;
1634 items[cItem].encodeFunc = CRYPT_AsnEncodeCTLSubjectAlgorithm;
1635 cItem++;
1636 if (info->cCTLEntry)
1637 {
1638 items[cItem].pvStructInfo = &info->cCTLEntry;
1639 items[cItem].encodeFunc = CRYPT_AsnEncodeCTLEntries;
1640 cItem++;
1641 }
1642 if (info->cExtension)
1643 {
1644 constructed.tag = 0;
1645 constructed.pvStructInfo = &info->cExtension;
1647 items[cItem].pvStructInfo = &constructed;
1648 items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
1649 cItem++;
1650 }
1652 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1653 }
1655 {
1657 }
1658 __ENDTRY
1659 return ret;
1660}
static BOOL WINAPI CRYPT_AsnEncodeCTLSubjectAlgorithm(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1493
static BOOL WINAPI CRYPT_AsnEncodeCTLVersion(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1471
static BOOL WINAPI CRYPT_AsnEncodeEnhancedKeyUsage(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3847
static BOOL WINAPI CRYPT_AsnEncodeCTLEntries(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1543

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeCTLEntries()

static BOOL WINAPI CRYPT_AsnEncodeCTLEntries ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1543 of file encode.c.

1546{
1547 BOOL ret;
1548 DWORD bytesNeeded, dataLen, lenBytes, i;
1549 const struct CTLEntries *entries = pvStructInfo;
1550
1551 ret = TRUE;
1552 for (i = 0, dataLen = 0; ret && i < entries->cEntry; i++)
1553 {
1554 DWORD size;
1555
1556 ret = CRYPT_AsnEncodeCTLEntry(&entries->rgEntry[i], NULL, &size);
1557 if (ret)
1558 dataLen += size;
1559 }
1560 if (ret)
1561 {
1562 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
1563 bytesNeeded = 1 + lenBytes + dataLen;
1564 if (!pbEncoded)
1565 *pcbEncoded = bytesNeeded;
1566 else
1567 {
1568 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
1569 pbEncoded, pcbEncoded, bytesNeeded)))
1570 {
1571 BYTE *out;
1572
1574 pbEncoded = *(BYTE **)pbEncoded;
1575 out = pbEncoded;
1576 *out++ = ASN_SEQUENCEOF;
1577 CRYPT_EncodeLen(dataLen, out, &lenBytes);
1578 out += lenBytes;
1579 for (i = 0; ret && i < entries->cEntry; i++)
1580 {
1581 DWORD size = dataLen;
1582
1583 ret = CRYPT_AsnEncodeCTLEntry(&entries->rgEntry[i],
1584 out, &size);
1585 out += size;
1586 dataLen -= size;
1587 }
1589 CRYPT_FreeSpace(pEncodePara, pbEncoded);
1590 }
1591 }
1592 }
1593 return ret;
1594}
static BOOL CRYPT_AsnEncodeCTLEntry(const CTL_ENTRY *entry, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1523
DWORD cEntry
Definition: encode.c:1539
CTL_ENTRY * rgEntry
Definition: encode.c:1540

Referenced by CRYPT_AsnEncodeCTL().

◆ CRYPT_AsnEncodeCTLEntry()

static BOOL CRYPT_AsnEncodeCTLEntry ( const CTL_ENTRY entry,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1523 of file encode.c.

1525{
1526 struct AsnEncodeSequenceItem items[2] = {
1527 { &entry->SubjectIdentifier, CRYPT_AsnEncodeOctets, 0 },
1528 { &entry->cAttribute, CRYPT_AsnEncodePKCSAttributes, 0 },
1529 };
1530 BOOL ret;
1531
1534 return ret;
1535}

Referenced by CRYPT_AsnEncodeCTLEntries().

◆ CRYPT_AsnEncodeCTLSubjectAlgorithm()

static BOOL WINAPI CRYPT_AsnEncodeCTLSubjectAlgorithm ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1493 of file encode.c.

1497{
1498 const CRYPT_ALGORITHM_IDENTIFIER *algo = pvStructInfo;
1499 BOOL ret;
1500 struct AsnEncodeSequenceItem items[2] = {
1501 { algo->pszObjId, CRYPT_AsnEncodeOid, 0 },
1502 };
1503 DWORD cItem = 1;
1504
1505 if (algo->pszObjId)
1506 {
1507 static const BYTE asn1Null[] = { ASN_NULL, 0 };
1508 static const CRYPT_DATA_BLOB nullBlob = { sizeof(asn1Null),
1509 (LPBYTE)asn1Null };
1510
1511 if (algo->Parameters.cbData)
1512 items[cItem].pvStructInfo = &algo->Parameters;
1513 else
1514 items[cItem].pvStructInfo = &nullBlob;
1515 items[cItem].encodeFunc = CRYPT_CopyEncodedBlob;
1516 cItem++;
1517 }
1519 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1520 return ret;
1521}

Referenced by CRYPT_AsnEncodeCTL().

◆ CRYPT_AsnEncodeCTLVersion()

static BOOL WINAPI CRYPT_AsnEncodeCTLVersion ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1471 of file encode.c.

1474{
1475 const DWORD *ver = pvStructInfo;
1476 BOOL ret;
1477
1478 /* CTL_V1 is not encoded */
1479 if (*ver == CTL_V1)
1480 {
1481 *pcbEncoded = 0;
1482 ret = TRUE;
1483 }
1484 else
1486 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1487 return ret;
1488}
#define CTL_V1
Definition: wincrypt.h:2682

Referenced by CRYPT_AsnEncodeCTL().

◆ CRYPT_AsnEncodeDistPoint()

static BOOL CRYPT_AsnEncodeDistPoint ( const CRL_DIST_POINT distPoint,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3704 of file encode.c.

3706{
3707 BOOL ret = TRUE;
3708 struct AsnEncodeSequenceItem items[3] = { { 0 } };
3709 struct AsnConstructedItem constructed = { 0 };
3710 struct AsnEncodeTagSwappedItem swapped[3] = { { 0 } };
3711 DWORD cItem = 0, cSwapped = 0;
3712
3713 switch (distPoint->DistPointName.dwDistPointNameChoice)
3714 {
3716 /* do nothing */
3717 break;
3719 swapped[cSwapped].tag = ASN_CONTEXT | ASN_CONSTRUCTOR | 0;
3720 swapped[cSwapped].pvStructInfo = &distPoint->DistPointName.u.FullName;
3721 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeAltName;
3722 constructed.tag = 0;
3723 constructed.pvStructInfo = &swapped[cSwapped];
3724 constructed.encodeFunc = CRYPT_AsnEncodeSwapTag;
3725 items[cItem].pvStructInfo = &constructed;
3726 items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
3727 cSwapped++;
3728 cItem++;
3729 break;
3731 FIXME("unimplemented for CRL_DIST_POINT_ISSUER_RDN_NAME\n");
3732 ret = FALSE;
3733 break;
3734 default:
3735 ret = FALSE;
3736 }
3737 if (ret && distPoint->ReasonFlags.cbData)
3738 {
3739 swapped[cSwapped].tag = ASN_CONTEXT | 1;
3740 swapped[cSwapped].pvStructInfo = &distPoint->ReasonFlags;
3741 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeBits;
3742 items[cItem].pvStructInfo = &swapped[cSwapped];
3743 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
3744 cSwapped++;
3745 cItem++;
3746 }
3747 if (ret && distPoint->CRLIssuer.cAltEntry)
3748 {
3749 swapped[cSwapped].tag = ASN_CONTEXT | ASN_CONSTRUCTOR | 2;
3750 swapped[cSwapped].pvStructInfo = &distPoint->CRLIssuer;
3751 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeAltName;
3752 items[cItem].pvStructInfo = &swapped[cSwapped];
3753 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
3754 cSwapped++;
3755 cItem++;
3756 }
3757 if (ret)
3760 return ret;
3761}
CERT_ALT_NAME_INFO FullName
Definition: wincrypt.h:509
DWORD dwDistPointNameChoice
Definition: wincrypt.h:507
CRYPT_BIT_BLOB ReasonFlags
Definition: wincrypt.h:519
CERT_ALT_NAME_INFO CRLIssuer
Definition: wincrypt.h:520
CRL_DIST_POINT_NAME DistPointName
Definition: wincrypt.h:518
#define CRL_DIST_POINT_ISSUER_RDN_NAME
Definition: wincrypt.h:515
#define CRL_DIST_POINT_NO_NAME
Definition: wincrypt.h:513
#define CRL_DIST_POINT_FULL_NAME
Definition: wincrypt.h:514

Referenced by CRYPT_AsnEncodeCRLDistPoints().

◆ CRYPT_AsnEncodeEncryptedContentInfo()

static BOOL WINAPI CRYPT_AsnEncodeEncryptedContentInfo ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 4400 of file encode.c.

4403{
4404 const CRYPT_ENCRYPTED_CONTENT_INFO *info = pvStructInfo;
4405 struct AsnEncodeTagSwappedItem swapped = { ASN_CONTEXT | 0,
4406 &info->encryptedContent, CRYPT_AsnEncodeOctets };
4407 struct AsnEncodeSequenceItem items[] = {
4408 { info->contentType, CRYPT_AsnEncodeOid, 0 },
4409 { &info->contentEncryptionAlgorithm,
4411 { &swapped, CRYPT_AsnEncodeSwapTag, 0 },
4412 };
4413
4415 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
4416}

Referenced by CRYPT_AsnEncodePKCSEnvelopedData().

◆ CRYPT_AsnEncodeEnhancedKeyUsage()

static BOOL WINAPI CRYPT_AsnEncodeEnhancedKeyUsage ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3847 of file encode.c.

3850{
3851 BOOL ret;
3852
3853 __TRY
3854 {
3855 const CERT_ENHKEY_USAGE *usage = pvStructInfo;
3856 DWORD bytesNeeded = 0, lenBytes, size, i;
3857
3858 ret = TRUE;
3859 for (i = 0; ret && i < usage->cUsageIdentifier; i++)
3860 {
3862 usage->rgpszUsageIdentifier[i],
3864 if (ret)
3865 bytesNeeded += size;
3866 }
3867 CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes);
3868 bytesNeeded += 1 + lenBytes;
3869 if (ret)
3870 {
3871 if (!pbEncoded)
3872 *pcbEncoded = bytesNeeded;
3873 else
3874 {
3875 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
3876 pbEncoded, pcbEncoded, bytesNeeded)))
3877 {
3878 BYTE *out;
3879
3881 pbEncoded = *(BYTE **)pbEncoded;
3882 out = pbEncoded;
3883 *out++ = ASN_SEQUENCEOF;
3884 CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, out, &lenBytes);
3885 out += lenBytes;
3886 for (i = 0; ret && i < usage->cUsageIdentifier; i++)
3887 {
3888 size = bytesNeeded;
3890 usage->rgpszUsageIdentifier[i],
3892 if (ret)
3893 {
3894 out += size;
3895 bytesNeeded -= size;
3896 }
3897 }
3899 CRYPT_FreeSpace(pEncodePara, pbEncoded);
3900 }
3901 }
3902 }
3903 }
3905 {
3907 ret = FALSE;
3908 }
3909 __ENDTRY
3910 return ret;
3911}
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919

Referenced by CRYPT_AsnEncodeCTL(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeEnumerated()

static BOOL WINAPI CRYPT_AsnEncodeEnumerated ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3500 of file encode.c.

3503{
3505 BOOL ret;
3506
3507 /* Encode as an unsigned integer, then change the tag to enumerated */
3508 blob.cbData = sizeof(DWORD);
3509 blob.pbData = (BYTE *)pvStructInfo;
3512 if (ret && pbEncoded)
3513 {
3515 pbEncoded = *(BYTE **)pbEncoded;
3517 }
3518 return ret;
3519}
#define ASN_ENUMERATED
static BOOL WINAPI CRYPT_AsnEncodeUnsignedInteger(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3431
#define DWORD
Definition: nt_native.h:44
#define X509_MULTI_BYTE_UINT
Definition: wincrypt.h:3405

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeExtension()

static BOOL CRYPT_AsnEncodeExtension ( CERT_EXTENSION ext,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 728 of file encode.c.

730{
731 BOOL ret;
732 struct AsnEncodeSequenceItem items[3] = {
733 { ext->pszObjId, CRYPT_AsnEncodeOid, 0 },
734 { NULL, NULL, 0 },
735 { NULL, NULL, 0 },
736 };
737 DWORD cItem = 1;
738
739 TRACE("%p, %p, %d\n", ext, pbEncoded, pbEncoded ? *pcbEncoded : 0);
740
741 if (ext->fCritical)
742 {
743 items[cItem].pvStructInfo = &ext->fCritical;
744 items[cItem].encodeFunc = CRYPT_AsnEncodeBool;
745 cItem++;
746 }
747 items[cItem].pvStructInfo = &ext->Value;
748 items[cItem].encodeFunc = CRYPT_AsnEncodeOctets;
749 cItem++;
750
753 TRACE("returning %d (%08x)\n", ret, GetLastError());
754 return ret;
755}
static const WCHAR *const ext[]
Definition: module.c:53

Referenced by CRYPT_AsnEncodeExtensions().

◆ CRYPT_AsnEncodeExtensions()

static BOOL WINAPI CRYPT_AsnEncodeExtensions ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 757 of file encode.c.

760{
761 BOOL ret;
762
763 __TRY
764 {
765 DWORD bytesNeeded, dataLen, lenBytes, i;
766 const CERT_EXTENSIONS *exts = pvStructInfo;
767
768 ret = TRUE;
769 for (i = 0, dataLen = 0; ret && i < exts->cExtension; i++)
770 {
771 DWORD size;
772
773 ret = CRYPT_AsnEncodeExtension(&exts->rgExtension[i], NULL, &size);
774 if (ret)
775 dataLen += size;
776 }
777 if (ret)
778 {
779 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
780 bytesNeeded = 1 + lenBytes + dataLen;
781 if (!pbEncoded)
782 *pcbEncoded = bytesNeeded;
783 else
784 {
785 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
786 pbEncoded, pcbEncoded, bytesNeeded)))
787 {
788 BYTE *out;
789
791 pbEncoded = *(BYTE **)pbEncoded;
792 out = pbEncoded;
793 *out++ = ASN_SEQUENCEOF;
794 CRYPT_EncodeLen(dataLen, out, &lenBytes);
795 out += lenBytes;
796 for (i = 0; i < exts->cExtension; i++)
797 {
798 DWORD size = dataLen;
799
800 ret = CRYPT_AsnEncodeExtension(&exts->rgExtension[i],
801 out, &size);
802 out += size;
803 dataLen -= size;
804 }
806 CRYPT_FreeSpace(pEncodePara, pbEncoded);
807 }
808 }
809 }
810 }
812 {
814 ret = FALSE;
815 }
817 return ret;
818}
static BOOL CRYPT_AsnEncodeExtension(CERT_EXTENSION *ext, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:728
static const struct encodedExtensions exts[]
Definition: encode.c:2703

Referenced by CRYPT_AsnEncodeCertInfo(), CRYPT_AsnEncodeCRLEntry(), CRYPT_AsnEncodeCRLInfo(), CRYPT_AsnEncodeCTL(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeGeneralizedTime()

static BOOL CRYPT_AsnEncodeGeneralizedTime ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3578 of file encode.c.

3581{
3582 BOOL ret;
3583
3584 __TRY
3585 {
3586 SYSTEMTIME sysTime;
3587 /* sorry, magic number: enough for tag, len, YYYYMMDDHHMMSSZ. I use a
3588 * temporary buffer because the output buffer is not NULL-terminated.
3589 */
3590 static const DWORD bytesNeeded = 17;
3591 char buf[40];
3592
3593 if (!pbEncoded)
3594 {
3595 *pcbEncoded = bytesNeeded;
3596 ret = TRUE;
3597 }
3598 else
3599 {
3600 ret = FileTimeToSystemTime(pvStructInfo, &sysTime);
3601 if (ret)
3603 pcbEncoded, bytesNeeded);
3604 if (ret)
3605 {
3607 pbEncoded = *(BYTE **)pbEncoded;
3608 buf[0] = ASN_GENERALTIME;
3609 buf[1] = bytesNeeded - 2;
3610 snprintf(buf + 2, sizeof(buf) - 2, "%04d%02d%02d%02d%02d%02dZ",
3611 sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour,
3612 sysTime.wMinute, sysTime.wSecond);
3613 memcpy(pbEncoded, buf, bytesNeeded);
3614 }
3615 }
3616 }
3618 {
3620 ret = FALSE;
3621 }
3622 __ENDTRY
3623 return ret;
3624}
#define ASN_GENERALTIME
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
WORD wMonth
Definition: winbase.h:930
WORD wHour
Definition: winbase.h:933
WORD wSecond
Definition: winbase.h:935
WORD wMinute
Definition: winbase.h:934
WORD wDay
Definition: winbase.h:932
#define snprintf
Definition: wintirpc.h:48

Referenced by CRYPT_AsnEncodeChoiceOfTime().

◆ CRYPT_AsnEncodeGeneralSubtree()

static BOOL CRYPT_AsnEncodeGeneralSubtree ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 4002 of file encode.c.

4005{
4006 BOOL ret;
4007 const CERT_GENERAL_SUBTREE *subtree = pvStructInfo;
4008 struct AsnEncodeSequenceItem items[3] = {
4009 { &subtree->Base, CRYPT_AsnEncodeAltNameEntry, 0 },
4010 { 0 }
4011 };
4012 struct AsnEncodeTagSwappedItem swapped[2] = { { 0 } };
4013 DWORD cItem = 1, cSwapped = 0;
4014
4015 if (subtree->dwMinimum)
4016 {
4017 swapped[cSwapped].tag = ASN_CONTEXT | 0;
4018 swapped[cSwapped].pvStructInfo = &subtree->dwMinimum;
4019 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeInt;
4020 items[cItem].pvStructInfo = &swapped[cSwapped];
4021 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
4022 cSwapped++;
4023 cItem++;
4024 }
4025 if (subtree->fMaximum)
4026 {
4027 swapped[cSwapped].tag = ASN_CONTEXT | 1;
4028 swapped[cSwapped].pvStructInfo = &subtree->dwMaximum;
4029 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeInt;
4030 items[cItem].pvStructInfo = &swapped[cSwapped];
4031 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
4032 cSwapped++;
4033 cItem++;
4034 }
4036 pEncodePara, pbEncoded, pcbEncoded);
4037 return ret;
4038}
CERT_ALT_NAME_ENTRY Base
Definition: wincrypt.h:571

Referenced by CRYPT_AsnEncodeNameConstraints().

◆ CRYPT_AsnEncodeIA5String()

static BOOL CRYPT_AsnEncodeIA5String ( const CERT_NAME_VALUE value,
DWORD  dwFlags,
const CRYPT_ENCODE_PARA pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2137 of file encode.c.

2140{
2141 BOOL ret = TRUE;
2142 LPCWSTR str = (LPCWSTR)value->Value.pbData;
2143 DWORD bytesNeeded, lenBytes, encodedLen;
2144
2145 if (value->Value.cbData)
2146 encodedLen = value->Value.cbData / sizeof(WCHAR);
2147 else if (str)
2148 encodedLen = strlenW(str);
2149 else
2150 encodedLen = 0;
2151 CRYPT_EncodeLen(encodedLen, NULL, &lenBytes);
2152 bytesNeeded = 1 + lenBytes + encodedLen;
2153 if (!pbEncoded)
2154 *pcbEncoded = bytesNeeded;
2155 else
2156 {
2157 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
2158 pbEncoded, pcbEncoded, bytesNeeded)))
2159 {
2160 DWORD i;
2161 BYTE *ptr;
2162
2164 ptr = *(BYTE **)pbEncoded;
2165 else
2166 ptr = pbEncoded;
2167 *ptr++ = ASN_IA5STRING;
2168 CRYPT_EncodeLen(encodedLen, ptr, &lenBytes);
2169 ptr += lenBytes;
2170 for (i = 0; ret && i < encodedLen; i++)
2171 {
2172 if (str[i] <= 0x7f)
2173 *ptr++ = (BYTE)str[i];
2174 else
2175 {
2176 *pcbEncoded = i;
2178 ret = FALSE;
2179 }
2180 }
2182 CRYPT_FreeSpace(pEncodePara, *(BYTE **)pbEncoded);
2183 }
2184 }
2185 return ret;
2186}
#define ASN_IA5STRING
static PVOID ptr
Definition: dispmode.c:27
#define strlenW(s)
Definition: unicode.h:34

Referenced by CRYPT_AsnEncodeUnicodeNameValue().

◆ CRYPT_AsnEncodeInt()

◆ CRYPT_AsnEncodeInteger()

static BOOL WINAPI CRYPT_AsnEncodeInteger ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3343 of file encode.c.

3346{
3347 BOOL ret;
3348
3349 __TRY
3350 {
3351 DWORD significantBytes, lenBytes, bytesNeeded;
3352 BYTE padByte = 0;
3353 BOOL pad = FALSE;
3354 const CRYPT_INTEGER_BLOB *blob = pvStructInfo;
3355
3356 significantBytes = blob->cbData;
3357 if (significantBytes)
3358 {
3359 if (blob->pbData[significantBytes - 1] & 0x80)
3360 {
3361 /* negative, lop off leading (little-endian) 0xffs */
3362 for (; significantBytes > 0 &&
3363 blob->pbData[significantBytes - 1] == 0xff; significantBytes--)
3364 ;
3365 if (blob->pbData[significantBytes - 1] < 0x80)
3366 {
3367 padByte = 0xff;
3368 pad = TRUE;
3369 }
3370 }
3371 else
3372 {
3373 /* positive, lop off leading (little-endian) zeroes */
3374 for (; significantBytes > 0 &&
3375 !blob->pbData[significantBytes - 1]; significantBytes--)
3376 ;
3377 if (significantBytes == 0)
3378 significantBytes = 1;
3379 if (blob->pbData[significantBytes - 1] > 0x7f)
3380 {
3381 padByte = 0;
3382 pad = TRUE;
3383 }
3384 }
3385 }
3386 if (pad)
3387 CRYPT_EncodeLen(significantBytes + 1, NULL, &lenBytes);
3388 else
3389 CRYPT_EncodeLen(significantBytes, NULL, &lenBytes);
3390 bytesNeeded = 1 + lenBytes + significantBytes;
3391 if (pad)
3392 bytesNeeded++;
3393 if (!pbEncoded)
3394 {
3395 *pcbEncoded = bytesNeeded;
3396 ret = TRUE;
3397 }
3398 else
3399 {
3400 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded,
3401 pcbEncoded, bytesNeeded)))
3402 {
3404 pbEncoded = *(BYTE **)pbEncoded;
3406 if (pad)
3407 {
3408 CRYPT_EncodeLen(significantBytes + 1, pbEncoded, &lenBytes);
3409 pbEncoded += lenBytes;
3410 *pbEncoded++ = padByte;
3411 }
3412 else
3413 {
3414 CRYPT_EncodeLen(significantBytes, pbEncoded, &lenBytes);
3415 pbEncoded += lenBytes;
3416 }
3417 for (; significantBytes > 0; significantBytes--)
3418 *(pbEncoded++) = blob->pbData[significantBytes - 1];
3419 }
3420 }
3421 }
3423 {
3425 ret = FALSE;
3426 }
3427 __ENDTRY
3428 return ret;
3429}
#define ASN_INTEGER
Definition: snmp.h:103

Referenced by CRYPT_AsnEncodeAuthorityKeyId(), CRYPT_AsnEncodeAuthorityKeyId2(), CRYPT_AsnEncodeCertInfo(), CRYPT_AsnEncodeCRLEntry(), CRYPT_AsnEncodeCTL(), CRYPT_AsnEncodeInt(), CRYPT_AsnEncodeIssuerSerialNumber(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeIssuerSerialNumber()

static BOOL WINAPI CRYPT_AsnEncodeIssuerSerialNumber ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 4134 of file encode.c.

4138{
4139 BOOL ret;
4140 const CERT_ISSUER_SERIAL_NUMBER *issuerSerial = pvStructInfo;
4141 struct AsnEncodeSequenceItem items[] = {
4142 { &issuerSerial->Issuer, CRYPT_CopyEncodedBlob, 0 },
4143 { &issuerSerial->SerialNumber, CRYPT_AsnEncodeInteger, 0 },
4144 };
4145
4147 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
4148 return ret;
4149}
CERT_NAME_BLOB Issuer
Definition: wincrypt.h:3659
CRYPT_INTEGER_BLOB SerialNumber
Definition: wincrypt.h:3660

Referenced by CRYPT_AsnEncodeCMSSignerInfo(), CRYPT_AsnEncodePKCSSignerInfo(), and CRYPT_AsnEncodeRecipientInfo().

◆ CRYPT_AsnEncodeIssuingDistPoint()

static BOOL WINAPI CRYPT_AsnEncodeIssuingDistPoint ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3913 of file encode.c.

3916{
3917 BOOL ret;
3918
3919 __TRY
3920 {
3921 const CRL_ISSUING_DIST_POINT *point = pvStructInfo;
3922 struct AsnEncodeSequenceItem items[6] = { { 0 } };
3923 struct AsnConstructedItem constructed = { 0 };
3924 struct AsnEncodeTagSwappedItem swapped[5] = { { 0 } };
3925 DWORD cItem = 0, cSwapped = 0;
3926
3927 ret = TRUE;
3928 switch (point->DistPointName.dwDistPointNameChoice)
3929 {
3931 /* do nothing */
3932 break;
3934 swapped[cSwapped].tag = ASN_CONTEXT | ASN_CONSTRUCTOR | 0;
3935 swapped[cSwapped].pvStructInfo = &point->DistPointName.u.FullName;
3936 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeAltName;
3937 constructed.tag = 0;
3938 constructed.pvStructInfo = &swapped[cSwapped];
3939 constructed.encodeFunc = CRYPT_AsnEncodeSwapTag;
3940 items[cItem].pvStructInfo = &constructed;
3941 items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
3942 cSwapped++;
3943 cItem++;
3944 break;
3945 default:
3947 ret = FALSE;
3948 }
3949 if (ret && point->fOnlyContainsUserCerts)
3950 {
3951 swapped[cSwapped].tag = ASN_CONTEXT | 1;
3952 swapped[cSwapped].pvStructInfo = &point->fOnlyContainsUserCerts;
3953 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeBool;
3954 items[cItem].pvStructInfo = &swapped[cSwapped];
3955 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
3956 cSwapped++;
3957 cItem++;
3958 }
3959 if (ret && point->fOnlyContainsCACerts)
3960 {
3961 swapped[cSwapped].tag = ASN_CONTEXT | 2;
3962 swapped[cSwapped].pvStructInfo = &point->fOnlyContainsCACerts;
3963 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeBool;
3964 items[cItem].pvStructInfo = &swapped[cSwapped];
3965 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
3966 cSwapped++;
3967 cItem++;
3968 }
3969 if (ret && point->OnlySomeReasonFlags.cbData)
3970 {
3971 swapped[cSwapped].tag = ASN_CONTEXT | 3;
3972 swapped[cSwapped].pvStructInfo = &point->OnlySomeReasonFlags;
3973 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeBits;
3974 items[cItem].pvStructInfo = &swapped[cSwapped];
3975 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
3976 cSwapped++;
3977 cItem++;
3978 }
3979 if (ret && point->fIndirectCRL)
3980 {
3981 swapped[cSwapped].tag = ASN_CONTEXT | 4;
3982 swapped[cSwapped].pvStructInfo = &point->fIndirectCRL;
3983 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodeBool;
3984 items[cItem].pvStructInfo = &swapped[cSwapped];
3985 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
3986 cSwapped++;
3987 cItem++;
3988 }
3989 if (ret)
3991 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
3992 }
3994 {
3996 ret = FALSE;
3997 }
3998 __ENDTRY
3999 return ret;
4000}
POINTL point
Definition: edittest.c:50

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeName()

static BOOL WINAPI CRYPT_AsnEncodeName ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2304 of file encode.c.

2307{
2308 BOOL ret;
2309
2310 __TRY
2311 {
2312 const CERT_NAME_INFO *info = pvStructInfo;
2313 DWORD bytesNeeded = 0, lenBytes, size, i;
2314
2315 TRACE("encoding name with %d RDNs\n", info->cRDN);
2316 ret = TRUE;
2317 for (i = 0; ret && i < info->cRDN; i++)
2318 {
2321 if (ret)
2322 bytesNeeded += size;
2323 }
2324 CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes);
2325 bytesNeeded += 1 + lenBytes;
2326 if (ret)
2327 {
2328 if (!pbEncoded)
2329 *pcbEncoded = bytesNeeded;
2330 else
2331 {
2332 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
2333 pbEncoded, pcbEncoded, bytesNeeded)))
2334 {
2335 BYTE *out;
2336
2338 pbEncoded = *(BYTE **)pbEncoded;
2339 out = pbEncoded;
2340 *out++ = ASN_SEQUENCEOF;
2341 CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, out, &lenBytes);
2342 out += lenBytes;
2343 for (i = 0; ret && i < info->cRDN; i++)
2344 {
2345 size = bytesNeeded;
2347 &info->rgRDN[i], CRYPT_AsnEncodeNameValue, out, &size);
2348 if (ret)
2349 {
2350 out += size;
2351 bytesNeeded -= size;
2352 }
2353 }
2355 CRYPT_FreeSpace(pEncodePara, pbEncoded);
2356 }
2357 }
2358 }
2359 }
2361 {
2363 ret = FALSE;
2364 }
2365 __ENDTRY
2366 return ret;
2367}
static BOOL CRYPT_AsnEncodeRdn(DWORD dwCertEncodingType, const CERT_RDN *rdn, CryptEncodeObjectExFunc nameValueEncodeFunc, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1319
static BOOL WINAPI CRYPT_AsnEncodeNameValue(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1044

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeNameConstraints()

static BOOL WINAPI CRYPT_AsnEncodeNameConstraints ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 4040 of file encode.c.

4043{
4044 BOOL ret = FALSE;
4045 CRYPT_BLOB_ARRAY permitted = { 0, NULL }, excluded = { 0, NULL };
4046
4047 TRACE("%p\n", pvStructInfo);
4048
4049 __TRY
4050 {
4051 const CERT_NAME_CONSTRAINTS_INFO *constraints = pvStructInfo;
4052 struct AsnEncodeSequenceItem items[2] = { { 0 } };
4053 struct AsnEncodeTagSwappedItem swapped[2] = { { 0 } };
4054 DWORD i, cItem = 0, cSwapped = 0;
4055
4056 ret = TRUE;
4057 if (constraints->cPermittedSubtree)
4058 {
4059 permitted.rgBlob = CryptMemAlloc(
4060 constraints->cPermittedSubtree * sizeof(CRYPT_DER_BLOB));
4061 if (permitted.rgBlob)
4062 {
4063 permitted.cBlob = constraints->cPermittedSubtree;
4064 memset(permitted.rgBlob, 0,
4065 permitted.cBlob * sizeof(CRYPT_DER_BLOB));
4066 for (i = 0; ret && i < permitted.cBlob; i++)
4068 NULL, &constraints->rgPermittedSubtree[i],
4070 (BYTE *)&permitted.rgBlob[i].pbData,
4071 &permitted.rgBlob[i].cbData);
4072 if (ret)
4073 {
4074 swapped[cSwapped].tag = ASN_CONTEXT | ASN_CONSTRUCTOR | 0;
4075 swapped[cSwapped].pvStructInfo = &permitted;
4076 swapped[cSwapped].encodeFunc = CRYPT_DEREncodeSet;
4077 items[cItem].pvStructInfo = &swapped[cSwapped];
4078 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
4079 cSwapped++;
4080 cItem++;
4081 }
4082 }
4083 else
4084 ret = FALSE;
4085 }
4086 if (constraints->cExcludedSubtree)
4087 {
4088 excluded.rgBlob = CryptMemAlloc(
4089 constraints->cExcludedSubtree * sizeof(CRYPT_DER_BLOB));
4090 if (excluded.rgBlob)
4091 {
4092 excluded.cBlob = constraints->cExcludedSubtree;
4093 memset(excluded.rgBlob, 0,
4094 excluded.cBlob * sizeof(CRYPT_DER_BLOB));
4095 for (i = 0; ret && i < excluded.cBlob; i++)
4097 NULL, &constraints->rgExcludedSubtree[i],
4099 (BYTE *)&excluded.rgBlob[i].pbData,
4100 &excluded.rgBlob[i].cbData);
4101 if (ret)
4102 {
4103 swapped[cSwapped].tag = ASN_CONTEXT | ASN_CONSTRUCTOR | 1;
4104 swapped[cSwapped].pvStructInfo = &excluded;
4105 swapped[cSwapped].encodeFunc = CRYPT_DEREncodeSet;
4106 items[cItem].pvStructInfo = &swapped[cSwapped];
4107 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
4108 cSwapped++;
4109 cItem++;
4110 }
4111 }
4112 else
4113 ret = FALSE;
4114 }
4115 if (ret)
4117 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
4118 for (i = 0; i < permitted.cBlob; i++)
4119 LocalFree(permitted.rgBlob[i].pbData);
4120 for (i = 0; i < excluded.cBlob; i++)
4121 LocalFree(excluded.rgBlob[i].pbData);
4122 }
4124 {
4126 }
4127 __ENDTRY
4128 CryptMemFree(permitted.rgBlob);
4129 CryptMemFree(excluded.rgBlob);
4130 TRACE("returning %d\n", ret);
4131 return ret;
4132}
static BOOL CRYPT_AsnEncodeGeneralSubtree(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:4002
static BOOL WINAPI CRYPT_DEREncodeSet(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1201
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define memset(x, y, z)
Definition: compat.h:39
PCERT_GENERAL_SUBTREE rgPermittedSubtree
Definition: wincrypt.h:579
PCERT_GENERAL_SUBTREE rgExcludedSubtree
Definition: wincrypt.h:581
BYTE * pbData
Definition: wincrypt.h:103
PCRYPT_DATA_BLOB rgBlob
Definition: wincrypt.h:1569

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeNameValue()

static BOOL WINAPI CRYPT_AsnEncodeNameValue ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1044 of file encode.c.

1047{
1048 BOOL ret = TRUE;
1049
1050 __TRY
1051 {
1052 const CERT_NAME_VALUE *value = pvStructInfo;
1053
1054 switch (value->dwValueType)
1055 {
1056 case CERT_RDN_ANY_TYPE:
1057 /* explicitly disallowed */
1059 ret = FALSE;
1060 break;
1063 &value->Value, dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1064 break;
1067 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1068 break;
1071 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1072 break;
1075 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1076 break;
1079 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1080 break;
1084 break;
1087 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1088 break;
1091 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1092 break;
1095 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1096 break;
1099 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1100 break;
1102 FIXME("CERT_RDN_UNIVERSAL_STRING: unimplemented\n");
1104 ret = FALSE;
1105 break;
1107 ret = CRYPT_AsnEncodeBMPString(value, dwFlags, pEncodePara,
1109 break;
1113 break;
1114 default:
1116 ret = FALSE;
1117 }
1118 }
1120 {
1122 ret = FALSE;
1123 }
1124 __ENDTRY
1125 return ret;
1126}
#define ASN_GENERALSTRING
#define ASN_VIDEOTEXSTRING
#define ASN_NUMERICSTRING
#define ASN_GRAPHICSTRING
#define ASN_T61STRING
#define ASN_PRINTABLESTRING
#define ASN_VISIBLESTRING
static BOOL CRYPT_AsnEncodeBMPString(const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:967
static BOOL CRYPT_AsnEncodeUTF8String(const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1007
static BOOL CRYPT_AsnEncodeStringCoerce(const CERT_NAME_VALUE *value, BYTE tag, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:938
#define ASN_OCTETSTRING
Definition: snmp.h:105
#define CERT_RDN_UTF8_STRING
Definition: wincrypt.h:2793
#define CERT_RDN_IA5_STRING
Definition: wincrypt.h:2784
#define CERT_RDN_GENERAL_STRING
Definition: wincrypt.h:2788
#define CERT_RDN_PRINTABLE_STRING
Definition: wincrypt.h:2780
#define CERT_RDN_UNIVERSAL_STRING
Definition: wincrypt.h:2789
#define CERT_RDN_VISIBLE_STRING
Definition: wincrypt.h:2786
#define CERT_RDN_VIDEOTEX_STRING
Definition: wincrypt.h:2783
#define CERT_RDN_OCTET_STRING
Definition: wincrypt.h:2778
#define CERT_RDN_ENCODED_BLOB
Definition: wincrypt.h:2777
#define CERT_RDN_NUMERIC_STRING
Definition: wincrypt.h:2779
#define CERT_RDN_TELETEX_STRING
Definition: wincrypt.h:2781
#define CERT_RDN_BMP_STRING
Definition: wincrypt.h:2791
#define CERT_RDN_ANY_TYPE
Definition: wincrypt.h:2776
#define CERT_RDN_GRAPHIC_STRING
Definition: wincrypt.h:2785
#define CRYPT_E_ASN1_CHOICE
Definition: winerror.h:3096

Referenced by CRYPT_AsnEncodeName(), CRYPT_AsnEncodeNoticeReference(), CRYPT_AsnEncodePolicyQualifierUserNotice(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeNoticeNumbers()

static BOOL WINAPI CRYPT_AsnEncodeNoticeNumbers ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1758 of file encode.c.

1761{
1762 const CERT_POLICY_QUALIFIER_NOTICE_REFERENCE *noticeRef = pvStructInfo;
1763 DWORD bytesNeeded, dataLen, lenBytes, i;
1764 BOOL ret = TRUE;
1765
1766 for (i = 0, dataLen = 0; ret && i < noticeRef->cNoticeNumbers; i++)
1767 {
1768 DWORD size;
1769
1771 &noticeRef->rgNoticeNumbers[i], 0, NULL, NULL, &size);
1772 if (ret)
1773 dataLen += size;
1774 }
1775 if (ret)
1776 {
1777 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
1778 bytesNeeded = 1 + lenBytes + dataLen;
1779 if (!pbEncoded)
1780 *pcbEncoded = bytesNeeded;
1781 else
1782 {
1783 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded,
1784 pcbEncoded, bytesNeeded)))
1785 {
1786 BYTE *out;
1787
1789 pbEncoded = *(BYTE **)pbEncoded;
1790 out = pbEncoded;
1791 *out++ = ASN_SEQUENCE;
1792 CRYPT_EncodeLen(dataLen, out, &lenBytes);
1793 out += lenBytes;
1794 for (i = 0; i < noticeRef->cNoticeNumbers; i++)
1795 {
1796 DWORD size = dataLen;
1797
1799 &noticeRef->rgNoticeNumbers[i], 0, NULL, out, &size);
1800 out += size;
1801 dataLen -= size;
1802 }
1804 CRYPT_FreeSpace(pEncodePara, pbEncoded);
1805 }
1806 }
1807 }
1808 return ret;
1809}
#define ASN_SEQUENCE
Definition: snmp.h:110

Referenced by CRYPT_AsnEncodeNoticeReference().

◆ CRYPT_AsnEncodeNoticeReference()

static BOOL WINAPI CRYPT_AsnEncodeNoticeReference ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1811 of file encode.c.

1814{
1815 const CERT_POLICY_QUALIFIER_NOTICE_REFERENCE *noticeRef = pvStructInfo;
1816 BOOL ret;
1818 { 0, (LPBYTE)noticeRef->pszOrganization } };
1819 struct AsnEncodeSequenceItem items[] = {
1820 { &orgValue, CRYPT_AsnEncodeNameValue, 0 },
1821 { noticeRef, CRYPT_AsnEncodeNoticeNumbers, 0 },
1822 };
1823
1825 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
1826 pcbEncoded);
1827 return ret;
1828}
static BOOL WINAPI CRYPT_AsnEncodeNoticeNumbers(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1758

Referenced by CRYPT_AsnEncodePolicyQualifierUserNotice().

◆ CRYPT_AsnEncodeNumericString()

static BOOL CRYPT_AsnEncodeNumericString ( const CERT_NAME_VALUE value,
DWORD  dwFlags,
const CRYPT_ENCODE_PARA pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2028 of file encode.c.

2031{
2032 BOOL ret = TRUE;
2033 LPCWSTR str = (LPCWSTR)value->Value.pbData;
2034 DWORD bytesNeeded, lenBytes, encodedLen;
2035
2036 if (value->Value.cbData)
2037 encodedLen = value->Value.cbData / sizeof(WCHAR);
2038 else if (str)
2039 encodedLen = strlenW(str);
2040 else
2041 encodedLen = 0;
2042 CRYPT_EncodeLen(encodedLen, NULL, &lenBytes);
2043 bytesNeeded = 1 + lenBytes + encodedLen;
2044 if (!pbEncoded)
2045 *pcbEncoded = bytesNeeded;
2046 else
2047 {
2048 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
2049 pbEncoded, pcbEncoded, bytesNeeded)))
2050 {
2051 DWORD i;
2052 BYTE *ptr;
2053
2055 ptr = *(BYTE **)pbEncoded;
2056 else
2057 ptr = pbEncoded;
2059 CRYPT_EncodeLen(encodedLen, ptr, &lenBytes);
2060 ptr += lenBytes;
2061 for (i = 0; ret && i < encodedLen; i++)
2062 {
2063 if (isdigitW(str[i]))
2064 *ptr++ = (BYTE)str[i];
2065 else
2066 {
2067 *pcbEncoded = i;
2069 ret = FALSE;
2070 }
2071 }
2073 CRYPT_FreeSpace(pEncodePara, *(BYTE **)pbEncoded);
2074 }
2075 }
2076 return ret;
2077}
#define isdigitW(n)
Definition: unicode.h:56
#define CRYPT_E_INVALID_NUMERIC_STRING
Definition: winerror.h:3024

Referenced by CRYPT_AsnEncodeUnicodeNameValue().

◆ CRYPT_AsnEncodeOctets()

BOOL WINAPI CRYPT_AsnEncodeOctets ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)

Definition at line 3178 of file encode.c.

3181{
3182 BOOL ret;
3183
3184 __TRY
3185 {
3186 const CRYPT_DATA_BLOB *blob = pvStructInfo;
3187 DWORD bytesNeeded, lenBytes;
3188
3189 TRACE("(%d, %p), %08x, %p, %p, %d\n", blob->cbData, blob->pbData,
3190 dwFlags, pEncodePara, pbEncoded, pbEncoded ? *pcbEncoded : 0);
3191
3192 CRYPT_EncodeLen(blob->cbData, NULL, &lenBytes);
3193 bytesNeeded = 1 + lenBytes + blob->cbData;
3194 if (!pbEncoded)
3195 {
3196 *pcbEncoded = bytesNeeded;
3197 ret = TRUE;
3198 }
3199 else
3200 {
3201 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded,
3202 pcbEncoded, bytesNeeded)))
3203 {
3205 pbEncoded = *(BYTE **)pbEncoded;
3207 CRYPT_EncodeLen(blob->cbData, pbEncoded, &lenBytes);
3208 pbEncoded += lenBytes;
3209 if (blob->cbData)
3210 memcpy(pbEncoded, blob->pbData, blob->cbData);
3211 }
3212 }
3213 }
3215 {
3217 ret = FALSE;
3218 }
3219 __ENDTRY
3220 TRACE("returning %d (%08x)\n", ret, GetLastError());
3221 return ret;
3222}

Referenced by CRYPT_AsnEncodeAuthorityKeyId(), CRYPT_AsnEncodeAuthorityKeyId2(), CRYPT_AsnEncodeCMSSignerInfo(), CRYPT_AsnEncodeCTL(), CRYPT_AsnEncodeCTLEntry(), CRYPT_AsnEncodeEncryptedContentInfo(), CRYPT_AsnEncodeExtension(), CRYPT_AsnEncodePKCSDigestedData(), CRYPT_AsnEncodePKCSSignerInfo(), CRYPT_AsnEncodeRecipientInfo(), CRYPT_EncodePKCSDigestedData(), CRYPT_GetBuiltinEncoder(), and CSignedMsgData_AppendMessageDigestAttribute().

◆ CRYPT_AsnEncodeOid()

BOOL WINAPI CRYPT_AsnEncodeOid ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)

Definition at line 820 of file encode.c.

823{
824 LPCSTR pszObjId = pvStructInfo;
825 DWORD bytesNeeded = 0, lenBytes;
826 BOOL ret = TRUE;
827 int firstPos = 0;
828 BYTE firstByte = 0;
829
830 TRACE("%s\n", debugstr_a(pszObjId));
831
832 if (pszObjId)
833 {
834 const char *ptr;
835 int val1, val2;
836
837 if (sscanf(pszObjId, "%d.%d%n", &val1, &val2, &firstPos) != 2)
838 {
840 return FALSE;
841 }
842 bytesNeeded++;
843 firstByte = val1 * 40 + val2;
844 ptr = pszObjId + firstPos;
845 if (*ptr == '.')
846 {
847 ptr++;
848 firstPos++;
849 }
850 while (ret && *ptr)
851 {
852 int pos;
853
854 /* note I assume each component is at most 32-bits long in base 2 */
855 if (sscanf(ptr, "%d%n", &val1, &pos) == 1)
856 {
857 if (val1 >= 0x10000000)
858 bytesNeeded += 5;
859 else if (val1 >= 0x200000)
860 bytesNeeded += 4;
861 else if (val1 >= 0x4000)
862 bytesNeeded += 3;
863 else if (val1 >= 0x80)
864 bytesNeeded += 2;
865 else
866 bytesNeeded += 1;
867 ptr += pos;
868 if (*ptr == '.')
869 ptr++;
870 }
871 else
872 {
874 return FALSE;
875 }
876 }
877 CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes);
878 }
879 else
880 lenBytes = 1;
881 bytesNeeded += 1 + lenBytes;
882 if (pbEncoded)
883 {
884 if (*pcbEncoded < bytesNeeded)
885 {
887 ret = FALSE;
888 }
889 else
890 {
892 CRYPT_EncodeLen(bytesNeeded - 1 - lenBytes, pbEncoded, &lenBytes);
893 pbEncoded += lenBytes;
894 if (pszObjId)
895 {
896 const char *ptr;
897 int val, pos;
898
899 *pbEncoded++ = firstByte;
900 ptr = pszObjId + firstPos;
901 while (ret && *ptr)
902 {
903 sscanf(ptr, "%d%n", &val, &pos);
904 {
905 unsigned char outBytes[5];
906 int numBytes, i;
907
908 if (val >= 0x10000000)
909 numBytes = 5;
910 else if (val >= 0x200000)
911 numBytes = 4;
912 else if (val >= 0x4000)
913 numBytes = 3;
914 else if (val >= 0x80)
915 numBytes = 2;
916 else
917 numBytes = 1;
918 for (i = numBytes; i > 0; i--)
919 {
920 outBytes[i - 1] = val & 0x7f;
921 val >>= 7;
922 }
923 for (i = 0; i < numBytes - 1; i++)
924 *pbEncoded++ = outBytes[i] | 0x80;
925 *pbEncoded++ = outBytes[i];
926 ptr += pos;
927 if (*ptr == '.')
928 ptr++;
929 }
930 }
931 }
932 }
933 }
934 *pcbEncoded = bytesNeeded;
935 return ret;
936}
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define debugstr_a
Definition: kernel32.h:31
#define ASN_OBJECTIDENTIFIER
Definition: snmp.h:107
#define CRYPT_E_ASN1_ERROR
Definition: winerror.h:3084
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by CRYPT_AsnEncodeAccessDescription(), CRYPT_AsnEncodeAlgorithmId(), CRYPT_AsnEncodeAlgorithmIdWithNullParams(), CRYPT_AsnEncodeAltNameEntry(), CRYPT_AsnEncodeCertPolicy(), CRYPT_AsnEncodeCertPolicyMapping(), CRYPT_AsnEncodeCertPolicyQualifiers(), CRYPT_AsnEncodeCTLSubjectAlgorithm(), CRYPT_AsnEncodeEncryptedContentInfo(), CRYPT_AsnEncodeEnhancedKeyUsage(), CRYPT_AsnEncodeExtension(), CRYPT_AsnEncodePKCSAttribute(), CRYPT_AsnEncodePKCSContentInfoInternal(), CRYPT_AsnEncodeRdnAttr(), CRYPT_AsnEncodeSMIMECapability(), and CRYPT_EncodeDataContentInfoHeader().

◆ CRYPT_AsnEncodeOrCopyUnicodeNameValue()

static BOOL WINAPI CRYPT_AsnEncodeOrCopyUnicodeNameValue ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1384 of file encode.c.

1388{
1389 const CERT_NAME_VALUE *value = pvStructInfo;
1390 BOOL ret;
1391
1392 if (value->dwValueType == CERT_RDN_ENCODED_BLOB)
1394 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1395 else
1397 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1398 return ret;
1399}
static BOOL WINAPI CRYPT_AsnEncodeUnicodeNameValue(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2231

Referenced by CRYPT_AsnEncodeUnicodeName().

◆ CRYPT_AsnEncodePKCSAttribute()

static BOOL WINAPI CRYPT_AsnEncodePKCSAttribute ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1870 of file encode.c.

1873{
1874 BOOL ret = FALSE;
1875
1876 __TRY
1877 {
1878 const CRYPT_ATTRIBUTE *attr = pvStructInfo;
1879
1880 if (!attr->pszObjId)
1882 else
1883 {
1884 struct AsnEncodeSequenceItem items[2] = {
1885 { attr->pszObjId, CRYPT_AsnEncodeOid, 0 },
1886 { &attr->cValue, CRYPT_DEREncodeSet, 0 },
1887 };
1888
1890 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
1891 pcbEncoded);
1892 }
1893 }
1895 {
1897 }
1898 __ENDTRY
1899 return ret;
1900}
Definition: cookie.c:202

Referenced by CRYPT_AsnEncodePKCSAttributes(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodePKCSAttributes()

static BOOL WINAPI CRYPT_AsnEncodePKCSAttributes ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1902 of file encode.c.

1905{
1906 BOOL ret = FALSE;
1907
1908 __TRY
1909 {
1910 const CRYPT_ATTRIBUTES *attributes = pvStructInfo;
1911 struct DERSetDescriptor desc = { attributes->cAttr, attributes->rgAttr,
1913
1915 &desc, dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1916 }
1918 {
1920 }
1921 __ENDTRY
1922 return ret;
1923}
static BOOL WINAPI CRYPT_AsnEncodePKCSAttribute(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1870
static const WCHAR desc[]
Definition: protectdata.c:36
PCRYPT_ATTRIBUTE rgAttr
Definition: wincrypt.h:595
struct _CRYPT_ATTRIBUTE CRYPT_ATTRIBUTE

Referenced by CRYPT_AsnEncodeCMSSignerInfo(), CRYPT_AsnEncodeCTLEntry(), CRYPT_AsnEncodePKCSSignerInfo(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodePKCSContentInfo()

static BOOL WINAPI CRYPT_AsnEncodePKCSContentInfo ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1966 of file encode.c.

1969{
1970 BOOL ret = FALSE;
1971
1972 __TRY
1973 {
1974 const CRYPT_CONTENT_INFO *info = pvStructInfo;
1975
1976 if (!info->pszObjId)
1978 else
1980 lpszStructType, pvStructInfo, dwFlags, pEncodePara, pbEncoded,
1981 pcbEncoded);
1982 }
1984 {
1986 }
1987 __ENDTRY
1988 return ret;
1989}

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodePKCSContentInfoInternal()

static BOOL WINAPI CRYPT_AsnEncodePKCSContentInfoInternal ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1926 of file encode.c.

1930{
1931 const CRYPT_CONTENT_INFO *info = pvStructInfo;
1932 struct AsnEncodeSequenceItem items[2] = {
1933 { info->pszObjId, CRYPT_AsnEncodeOid, 0 },
1934 { NULL, NULL, 0 },
1935 };
1936 struct AsnConstructedItem constructed = { 0 };
1937 DWORD cItem = 1;
1938
1939 if (info->Content.cbData)
1940 {
1941 constructed.tag = 0;
1942 constructed.pvStructInfo = &info->Content;
1943 constructed.encodeFunc = CRYPT_CopyEncodedBlob;
1944 items[cItem].pvStructInfo = &constructed;
1945 items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed;
1946 cItem++;
1947 }
1949 cItem, dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1950}

Referenced by CRYPT_AsnEncodeCMSSignedInfo(), CRYPT_AsnEncodePKCSContentInfo(), and CRYPT_AsnEncodePKCSDigestedData().

◆ CRYPT_AsnEncodePKCSDigestedData()

BOOL CRYPT_AsnEncodePKCSDigestedData ( const CRYPT_DIGESTED_DATA digestedData,
void pvData,
DWORD pcbData 
)

Definition at line 1952 of file encode.c.

1954{
1955 struct AsnEncodeSequenceItem items[] = {
1956 { &digestedData->version, CRYPT_AsnEncodeInt, 0 },
1958 0 },
1960 { &digestedData->hash, CRYPT_AsnEncodeOctets, 0 },
1961 };
1962
1964}
CRYPT_CONTENT_INFO ContentInfo
CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm
CRYPT_HASH_BLOB hash

Referenced by CRYPT_EncodePKCSDigestedData().

◆ CRYPT_AsnEncodePKCSEnvelopedData()

BOOL CRYPT_AsnEncodePKCSEnvelopedData ( const CRYPT_ENVELOPED_DATA envelopedData,
void pvData,
DWORD pcbData 
)

Definition at line 4418 of file encode.c.

4420{
4421 struct DERSetDescriptor recipientInfosSet = { envelopedData->cRecipientInfo,
4422 envelopedData->rgRecipientInfo, sizeof(CMSG_KEY_TRANS_RECIPIENT_INFO), 0,
4424 struct AsnEncodeSequenceItem items[] = {
4425 { &envelopedData->version, CRYPT_AsnEncodeInt, 0 },
4426 { &recipientInfosSet, CRYPT_DEREncodeItemsAsSet, 0 },
4427 { &envelopedData->encryptedContentInfo,
4429 };
4430
4433}
static BOOL WINAPI CRYPT_AsnEncodeRecipientInfo(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:4382
static BOOL WINAPI CRYPT_AsnEncodeEncryptedContentInfo(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:4400
CRYPT_ENCRYPTED_CONTENT_INFO encryptedContentInfo
PCMSG_KEY_TRANS_RECIPIENT_INFO rgRecipientInfo
struct _CMSG_KEY_TRANS_RECIPIENT_INFO CMSG_KEY_TRANS_RECIPIENT_INFO

Referenced by CEnvelopedEncodeMsg_GetParam().

◆ CRYPT_AsnEncodePKCSSignerInfo()

static BOOL WINAPI CRYPT_AsnEncodePKCSSignerInfo ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 4151 of file encode.c.

4154{
4155 BOOL ret = FALSE;
4156
4158 {
4160 return FALSE;
4161 }
4162
4163 __TRY
4164 {
4165 const CMSG_SIGNER_INFO *info = pvStructInfo;
4166
4167 if (!info->Issuer.cbData)
4169 else
4170 {
4171 struct AsnEncodeSequenceItem items[7] = {
4172 { &info->dwVersion, CRYPT_AsnEncodeInt, 0 },
4173 { &info->Issuer, CRYPT_AsnEncodeIssuerSerialNumber, 0 },
4175 0 },
4176 };
4177 struct AsnEncodeTagSwappedItem swapped[2] = { { 0 } };
4178 DWORD cItem = 3, cSwapped = 0;
4179
4180 if (info->AuthAttrs.cAttr)
4181 {
4182 swapped[cSwapped].tag = ASN_CONTEXT | ASN_CONSTRUCTOR | 0;
4183 swapped[cSwapped].pvStructInfo = &info->AuthAttrs;
4184 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodePKCSAttributes;
4185 items[cItem].pvStructInfo = &swapped[cSwapped];
4186 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
4187 cSwapped++;
4188 cItem++;
4189 }
4190 items[cItem].pvStructInfo = &info->HashEncryptionAlgorithm;
4192 cItem++;
4193 items[cItem].pvStructInfo = &info->EncryptedHash;
4194 items[cItem].encodeFunc = CRYPT_AsnEncodeOctets;
4195 cItem++;
4196 if (info->UnauthAttrs.cAttr)
4197 {
4198 swapped[cSwapped].tag = ASN_CONTEXT | ASN_CONSTRUCTOR | 1;
4199 swapped[cSwapped].pvStructInfo = &info->UnauthAttrs;
4200 swapped[cSwapped].encodeFunc = CRYPT_AsnEncodePKCSAttributes;
4201 items[cItem].pvStructInfo = &swapped[cSwapped];
4202 items[cItem].encodeFunc = CRYPT_AsnEncodeSwapTag;
4203 cSwapped++;
4204 cItem++;
4205 }
4207 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
4208 }
4209 }
4211 {
4213 }
4214 __ENDTRY
4215 return ret;
4216}

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodePolicyQualifierUserNotice()

static BOOL WINAPI CRYPT_AsnEncodePolicyQualifierUserNotice ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1830 of file encode.c.

1834{
1835 BOOL ret = FALSE;
1836
1837 __TRY
1838 {
1839 const CERT_POLICY_QUALIFIER_USER_NOTICE *notice = pvStructInfo;
1840 struct AsnEncodeSequenceItem items[2];
1841 CERT_NAME_VALUE displayTextValue;
1842 DWORD cItem = 0;
1843
1844 if (notice->pNoticeReference)
1845 {
1846 items[cItem].encodeFunc = CRYPT_AsnEncodeNoticeReference;
1847 items[cItem].pvStructInfo = notice->pNoticeReference;
1848 cItem++;
1849 }
1850 if (notice->pszDisplayText)
1851 {
1852 displayTextValue.dwValueType = CERT_RDN_BMP_STRING;
1853 displayTextValue.Value.cbData = 0;
1854 displayTextValue.Value.pbData = (LPBYTE)notice->pszDisplayText;
1855 items[cItem].encodeFunc = CRYPT_AsnEncodeNameValue;
1856 items[cItem].pvStructInfo = &displayTextValue;
1857 cItem++;
1858 }
1860 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
1861 }
1863 {
1865 }
1866 __ENDTRY
1867 return ret;
1868}
static BOOL WINAPI CRYPT_AsnEncodeNoticeReference(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1811
notice
Definition: t1tokens.h:26

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodePrintableString()

static BOOL CRYPT_AsnEncodePrintableString ( const CERT_NAME_VALUE value,
DWORD  dwFlags,
const CRYPT_ENCODE_PARA pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2086 of file encode.c.

2089{
2090 BOOL ret = TRUE;
2091 LPCWSTR str = (LPCWSTR)value->Value.pbData;
2092 DWORD bytesNeeded, lenBytes, encodedLen;
2093
2094 if (value->Value.cbData)
2095 encodedLen = value->Value.cbData / sizeof(WCHAR);
2096 else if (str)
2097 encodedLen = strlenW(str);
2098 else
2099 encodedLen = 0;
2100 CRYPT_EncodeLen(encodedLen, NULL, &lenBytes);
2101 bytesNeeded = 1 + lenBytes + encodedLen;
2102 if (!pbEncoded)
2103 *pcbEncoded = bytesNeeded;
2104 else
2105 {
2106 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
2107 pbEncoded, pcbEncoded, bytesNeeded)))
2108 {
2109 DWORD i;
2110 BYTE *ptr;
2111
2113 ptr = *(BYTE **)pbEncoded;
2114 else
2115 ptr = pbEncoded;
2117 CRYPT_EncodeLen(encodedLen, ptr, &lenBytes);
2118 ptr += lenBytes;
2119 for (i = 0; ret && i < encodedLen; i++)
2120 {
2121 if (isprintableW(str[i]))
2122 *ptr++ = (BYTE)str[i];
2123 else
2124 {
2125 *pcbEncoded = i;
2127 ret = FALSE;
2128 }
2129 }
2131 CRYPT_FreeSpace(pEncodePara, *(BYTE **)pbEncoded);
2132 }
2133 }
2134 return ret;
2135}
static BOOL isprintableW(WCHAR wc)
Definition: encode.c:2079
#define CRYPT_E_INVALID_PRINTABLE_STRING
Definition: winerror.h:3025

Referenced by CRYPT_AsnEncodeUnicodeNameValue().

◆ CRYPT_AsnEncodePubKeyInfo()

static BOOL WINAPI CRYPT_AsnEncodePubKeyInfo ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 425 of file encode.c.

428{
429 BOOL ret;
430
431 __TRY
432 {
433 const CERT_PUBLIC_KEY_INFO *info = pvStructInfo;
434 struct AsnEncodeSequenceItem items[] = {
436 { &info->PublicKey, CRYPT_AsnEncodeBits, 0 },
437 };
438
439 TRACE("Encoding public key with OID %s\n",
440 debugstr_a(info->Algorithm.pszObjId));
442 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
443 pcbEncoded);
444 }
446 {
448 ret = FALSE;
449 }
451 return ret;
452}

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodePubKeyInfoNoNull()

BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)

Definition at line 484 of file encode.c.

487{
488 BOOL ret;
489 const CERT_PUBLIC_KEY_INFO *info = pvStructInfo;
490 struct AsnEncodeSequenceItem items[] = {
491 { &info->Algorithm, CRYPT_AsnEncodeAlgorithmId, 0 },
492 { &info->PublicKey, CRYPT_AsnEncodeBits, 0 },
493 };
494
495 TRACE("Encoding public key with OID %s\n",
496 debugstr_a(info->Algorithm.pszObjId));
498 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
499 pcbEncoded);
500 return ret;
501}

Referenced by CRYPT_AsnEncodeCertInfo(), and CryptHashPublicKeyInfo().

◆ CRYPT_AsnEncodeRdn()

static BOOL CRYPT_AsnEncodeRdn ( DWORD  dwCertEncodingType,
const CERT_RDN rdn,
CryptEncodeObjectExFunc  nameValueEncodeFunc,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1319 of file encode.c.

1322{
1323 BOOL ret;
1324 CRYPT_BLOB_ARRAY setOf = { 0, NULL };
1325
1326 __TRY
1327 {
1328 DWORD i;
1329
1330 ret = TRUE;
1331 if (rdn->cRDNAttr)
1332 {
1333 setOf.rgBlob = CryptMemAlloc(rdn->cRDNAttr *
1334 sizeof(CRYPT_DER_BLOB));
1335 if (!setOf.rgBlob)
1336 ret = FALSE;
1337 else
1338 {
1339 setOf.cBlob = rdn->cRDNAttr;
1340 memset(setOf.rgBlob, 0, setOf.cBlob * sizeof(CRYPT_DER_BLOB));
1341 }
1342 }
1343 for (i = 0; ret && i < rdn->cRDNAttr; i++)
1344 {
1345 setOf.rgBlob[i].cbData = 0;
1347 nameValueEncodeFunc, NULL, &setOf.rgBlob[i].cbData);
1348 if (ret)
1349 {
1350 setOf.rgBlob[i].pbData = CryptMemAlloc(setOf.rgBlob[i].cbData);
1351 if (!setOf.rgBlob[i].pbData)
1352 ret = FALSE;
1353 else
1355 &rdn->rgRDNAttr[i], nameValueEncodeFunc,
1356 setOf.rgBlob[i].pbData, &setOf.rgBlob[i].cbData);
1357 }
1358 if (!ret)
1359 {
1360 /* Have to propagate index of failing character */
1361 *pcbEncoded = setOf.rgBlob[i].cbData;
1362 }
1363 }
1364 if (ret)
1367 for (i = 0; i < setOf.cBlob; i++)
1368 CryptMemFree(setOf.rgBlob[i].pbData);
1369 }
1371 {
1373 ret = FALSE;
1374 }
1375 __ENDTRY
1376 CryptMemFree(setOf.rgBlob);
1377 return ret;
1378}
static BOOL CRYPT_AsnEncodeRdnAttr(DWORD dwCertEncodingType, const CERT_RDN_ATTR *attr, CryptEncodeObjectExFunc nameValueEncodeFunc, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1128
DWORD cRDNAttr
Definition: wincrypt.h:262
PCERT_RDN_ATTR rgRDNAttr
Definition: wincrypt.h:263

Referenced by CRYPT_AsnEncodeName(), and CRYPT_AsnEncodeUnicodeName().

◆ CRYPT_AsnEncodeRdnAttr()

static BOOL CRYPT_AsnEncodeRdnAttr ( DWORD  dwCertEncodingType,
const CERT_RDN_ATTR attr,
CryptEncodeObjectExFunc  nameValueEncodeFunc,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1128 of file encode.c.

1131{
1132 DWORD bytesNeeded = 0, lenBytes, size;
1133 BOOL ret;
1134
1136 0, NULL, NULL, &size);
1137 if (ret)
1138 {
1139 bytesNeeded += size;
1140 /* hack: a CERT_RDN_ATTR is identical to a CERT_NAME_VALUE beginning
1141 * with dwValueType, so "cast" it to get its encoded size
1142 */
1143 ret = nameValueEncodeFunc(dwCertEncodingType, NULL, &attr->dwValueType,
1144 0, NULL, NULL, &size);
1145 if (ret)
1146 {
1147 bytesNeeded += size;
1148 CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes);
1149 bytesNeeded += 1 + lenBytes;
1150 if (pbEncoded)
1151 {
1152 if (*pcbEncoded < bytesNeeded)
1153 {
1155 ret = FALSE;
1156 }
1157 else
1158 {
1160 CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded,
1161 &lenBytes);
1162 pbEncoded += lenBytes;
1163 size = bytesNeeded - 1 - lenBytes;
1165 attr->pszObjId, 0, NULL, pbEncoded, &size);
1166 if (ret)
1167 {
1168 pbEncoded += size;
1169 size = bytesNeeded - 1 - lenBytes - size;
1170 ret = nameValueEncodeFunc(dwCertEncodingType, NULL,
1171 &attr->dwValueType, 0, NULL, pbEncoded, &size);
1172 if (!ret)
1173 *pcbEncoded = size;
1174 }
1175 }
1176 }
1177 if (ret)
1178 *pcbEncoded = bytesNeeded;
1179 }
1180 else
1181 {
1182 /* Have to propagate index of failing character */
1183 *pcbEncoded = size;
1184 }
1185 }
1186 return ret;
1187}

Referenced by CRYPT_AsnEncodeRdn().

◆ CRYPT_AsnEncodeRecipientInfo()

static BOOL WINAPI CRYPT_AsnEncodeRecipientInfo ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 4382 of file encode.c.

4385{
4386 const CMSG_KEY_TRANS_RECIPIENT_INFO *info = pvStructInfo;
4387 struct AsnEncodeSequenceItem items[] = {
4388 { &info->dwVersion, CRYPT_AsnEncodeInt, 0 },
4389 { &info->RecipientId.u.IssuerSerialNumber,
4391 { &info->KeyEncryptionAlgorithm,
4393 { &info->EncryptedKey, CRYPT_AsnEncodeOctets, 0 },
4394 };
4395
4397 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
4398}

Referenced by CRYPT_AsnEncodePKCSEnvelopedData().

◆ CRYPT_AsnEncodeRsaPubKey()

static BOOL WINAPI CRYPT_AsnEncodeRsaPubKey ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3139 of file encode.c.

3142{
3143 BOOL ret;
3144
3145 __TRY
3146 {
3147 const BLOBHEADER *hdr = pvStructInfo;
3148
3149 if (hdr->bType != PUBLICKEYBLOB)
3150 {
3152 ret = FALSE;
3153 }
3154 else
3155 {
3156 const RSAPUBKEY *rsaPubKey = (const RSAPUBKEY *)
3157 ((const BYTE *)pvStructInfo + sizeof(BLOBHEADER));
3158 CRYPT_INTEGER_BLOB blob = { rsaPubKey->bitlen / 8,
3159 (BYTE *)pvStructInfo + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) };
3160 struct AsnEncodeSequenceItem items[] = {
3162 { &rsaPubKey->pubexp, CRYPT_AsnEncodeInt, 0 },
3163 };
3164
3166 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
3167 }
3168 }
3170 {
3172 ret = FALSE;
3173 }
3174 __ENDTRY
3175 return ret;
3176}
char hdr[14]
Definition: iptest.cpp:33
DWORD pubexp
Definition: wincrypt.h:145
DWORD bitlen
Definition: wincrypt.h:144
struct _RSAPUBKEY RSAPUBKEY
#define PUBLICKEYBLOB
Definition: wincrypt.h:2240
struct _PUBLICKEYSTRUC BLOBHEADER

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeSequence()

BOOL WINAPI CRYPT_AsnEncodeSequence ( DWORD  dwCertEncodingType,
struct AsnEncodeSequenceItem  items[],
DWORD  cItem,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)

Definition at line 180 of file encode.c.

183{
184 BOOL ret;
185 DWORD i, dataLen = 0;
186
187 TRACE("%p, %d, %08x, %p, %p, %d\n", items, cItem, dwFlags, pEncodePara,
189 for (i = 0, ret = TRUE; ret && i < cItem; i++)
190 {
191 ret = items[i].encodeFunc(dwCertEncodingType, NULL,
192 items[i].pvStructInfo, dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL,
193 NULL, &items[i].size);
194 /* Some functions propagate their errors through the size */
195 if (!ret)
196 *pcbEncoded = items[i].size;
197 dataLen += items[i].size;
198 }
199 if (ret)
200 {
201 DWORD lenBytes, bytesNeeded;
202
203 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
204 bytesNeeded = 1 + lenBytes + dataLen;
205 if (!pbEncoded)
206 *pcbEncoded = bytesNeeded;
207 else
208 {
209 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded,
210 pcbEncoded, bytesNeeded)))
211 {
212 BYTE *out;
213
215 pbEncoded = *(BYTE **)pbEncoded;
216 out = pbEncoded;
217 *out++ = ASN_SEQUENCE;
218 CRYPT_EncodeLen(dataLen, out, &lenBytes);
219 out += lenBytes;
220 for (i = 0; ret && i < cItem; i++)
221 {
222 ret = items[i].encodeFunc(dwCertEncodingType, NULL,
223 items[i].pvStructInfo, dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG,
224 NULL, out, &items[i].size);
225 /* Some functions propagate their errors through the size */
226 if (!ret)
227 *pcbEncoded = items[i].size;
228 out += items[i].size;
229 }
231 CRYPT_FreeSpace(pEncodePara, pbEncoded);
232 }
233 }
234 }
235 TRACE("returning %d (%08x)\n", ret, GetLastError());
236 return ret;
237}

Referenced by CRYPT_AsnEncodeAccessDescription(), CRYPT_AsnEncodeAlgorithmId(), CRYPT_AsnEncodeAlgorithmIdWithNullParams(), CRYPT_AsnEncodeAuthorityKeyId(), CRYPT_AsnEncodeAuthorityKeyId2(), CRYPT_AsnEncodeBasicConstraints(), CRYPT_AsnEncodeBasicConstraints2(), CRYPT_AsnEncodeCert(), CRYPT_AsnEncodeCertInfo(), CRYPT_AsnEncodeCertPolicy(), CRYPT_AsnEncodeCertPolicyConstraints(), CRYPT_AsnEncodeCertPolicyMapping(), CRYPT_AsnEncodeCertPolicyQualifiers(), CRYPT_AsnEncodeCMSSignedInfo(), CRYPT_AsnEncodeCMSSignerInfo(), CRYPT_AsnEncodeCRLEntry(), CRYPT_AsnEncodeCRLInfo(), CRYPT_AsnEncodeCTL(), CRYPT_AsnEncodeCTLEntry(), CRYPT_AsnEncodeCTLSubjectAlgorithm(), CRYPT_AsnEncodeDistPoint(), CRYPT_AsnEncodeEncryptedContentInfo(), CRYPT_AsnEncodeExtension(), CRYPT_AsnEncodeGeneralSubtree(), CRYPT_AsnEncodeIssuerSerialNumber(), CRYPT_AsnEncodeIssuingDistPoint(), CRYPT_AsnEncodeNameConstraints(), CRYPT_AsnEncodeNoticeReference(), CRYPT_AsnEncodePKCSAttribute(), CRYPT_AsnEncodePKCSContentInfoInternal(), CRYPT_AsnEncodePKCSDigestedData(), CRYPT_AsnEncodePKCSEnvelopedData(), CRYPT_AsnEncodePKCSSignerInfo(), CRYPT_AsnEncodePolicyQualifierUserNotice(), CRYPT_AsnEncodePubKeyInfo(), CRYPT_AsnEncodePubKeyInfoNoNull(), CRYPT_AsnEncodeRecipientInfo(), CRYPT_AsnEncodeRsaPubKey(), CRYPT_AsnEncodeSMIMECapability(), CRYPT_AsnEncodeValidity(), and CRYPT_EncodeDataContentInfoHeader().

◆ CRYPT_AsnEncodeSequenceOfAny()

static BOOL WINAPI CRYPT_AsnEncodeSequenceOfAny ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3656 of file encode.c.

3659{
3660 BOOL ret;
3661
3662 __TRY
3663 {
3664 DWORD bytesNeeded, dataLen, lenBytes, i;
3665 const CRYPT_SEQUENCE_OF_ANY *seq = pvStructInfo;
3666
3667 for (i = 0, dataLen = 0; i < seq->cValue; i++)
3668 dataLen += seq->rgValue[i].cbData;
3669 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
3670 bytesNeeded = 1 + lenBytes + dataLen;
3671 if (!pbEncoded)
3672 {
3673 *pcbEncoded = bytesNeeded;
3674 ret = TRUE;
3675 }
3676 else
3677 {
3678 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded,
3679 pcbEncoded, bytesNeeded)))
3680 {
3682 pbEncoded = *(BYTE **)pbEncoded;
3684 CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes);
3685 pbEncoded += lenBytes;
3686 for (i = 0; i < seq->cValue; i++)
3687 {
3689 seq->rgValue[i].cbData);
3690 pbEncoded += seq->rgValue[i].cbData;
3691 }
3692 }
3693 }
3694 }
3696 {
3698 ret = FALSE;
3699 }
3700 __ENDTRY
3701 return ret;
3702}
PCRYPT_DER_BLOB rgValue
Definition: wincrypt.h:459

Referenced by CRYPT_AsnEncodeBasicConstraints(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeSMIMECapabilities()

static BOOL WINAPI CRYPT_AsnEncodeSMIMECapabilities ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1694 of file encode.c.

1697{
1698 BOOL ret = FALSE;
1699
1700 __TRY
1701 {
1702 DWORD bytesNeeded, dataLen, lenBytes, i;
1703 const CRYPT_SMIME_CAPABILITIES *capabilities = pvStructInfo;
1704
1705 ret = TRUE;
1706 for (i = 0, dataLen = 0; ret && i < capabilities->cCapability; i++)
1707 {
1708 DWORD size;
1709
1711 &capabilities->rgCapability[i], 0, NULL, NULL, &size);
1712 if (ret)
1713 dataLen += size;
1714 }
1715 if (ret)
1716 {
1717 CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
1718 bytesNeeded = 1 + lenBytes + dataLen;
1719 if (!pbEncoded)
1720 *pcbEncoded = bytesNeeded;
1721 else
1722 {
1723 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
1724 pbEncoded, pcbEncoded, bytesNeeded)))
1725 {
1726 BYTE *out;
1727
1729 pbEncoded = *(BYTE **)pbEncoded;
1730 out = pbEncoded;
1731 *out++ = ASN_SEQUENCEOF;
1732 CRYPT_EncodeLen(dataLen, out, &lenBytes);
1733 out += lenBytes;
1734 for (i = 0; i < capabilities->cCapability; i++)
1735 {
1736 DWORD size = dataLen;
1737
1739 NULL, &capabilities->rgCapability[i], 0, NULL,
1740 out, &size);
1741 out += size;
1742 dataLen -= size;
1743 }
1745 CRYPT_FreeSpace(pEncodePara, pbEncoded);
1746 }
1747 }
1748 }
1749 }
1751 {
1753 }
1754 __ENDTRY
1755 return ret;
1756}
static BOOL CRYPT_AsnEncodeSMIMECapability(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1662
PCRYPT_SMIME_CAPABILITY rgCapability
Definition: wincrypt.h:693

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeSMIMECapability()

static BOOL CRYPT_AsnEncodeSMIMECapability ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1662 of file encode.c.

1665{
1666 BOOL ret = FALSE;
1667
1668 __TRY
1669 {
1670 const CRYPT_SMIME_CAPABILITY *capability = pvStructInfo;
1671
1672 if (!capability->pszObjId)
1674 else
1675 {
1676 struct AsnEncodeSequenceItem items[] = {
1677 { capability->pszObjId, CRYPT_AsnEncodeOid, 0 },
1678 { &capability->Parameters, CRYPT_CopyEncodedBlob, 0 },
1679 };
1680
1682 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
1683 pcbEncoded);
1684 }
1685 }
1687 {
1689 }
1690 __ENDTRY
1691 return ret;
1692}
CRYPT_OBJID_BLOB Parameters
Definition: wincrypt.h:688

Referenced by CRYPT_AsnEncodeSMIMECapabilities().

◆ CRYPT_AsnEncodeStringCoerce()

static BOOL CRYPT_AsnEncodeStringCoerce ( const CERT_NAME_VALUE value,
BYTE  tag,
DWORD  dwFlags,
const CRYPT_ENCODE_PARA pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 938 of file encode.c.

941{
942 BOOL ret = TRUE;
943 LPCSTR str = (LPCSTR)value->Value.pbData;
944 DWORD bytesNeeded, lenBytes, encodedLen;
945
946 encodedLen = value->Value.cbData ? value->Value.cbData : strlen(str);
947 CRYPT_EncodeLen(encodedLen, NULL, &lenBytes);
948 bytesNeeded = 1 + lenBytes + encodedLen;
949 if (!pbEncoded)
950 *pcbEncoded = bytesNeeded;
951 else
952 {
953 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
954 pbEncoded, pcbEncoded, bytesNeeded)))
955 {
957 pbEncoded = *(BYTE **)pbEncoded;
958 *pbEncoded++ = tag;
959 CRYPT_EncodeLen(encodedLen, pbEncoded, &lenBytes);
960 pbEncoded += lenBytes;
961 memcpy(pbEncoded, str, encodedLen);
962 }
963 }
964 return ret;
965}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269

Referenced by CRYPT_AsnEncodeNameValue().

◆ CRYPT_AsnEncodeSwapTag()

static BOOL WINAPI CRYPT_AsnEncodeSwapTag ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

◆ CRYPT_AsnEncodeUnicodeName()

static BOOL WINAPI CRYPT_AsnEncodeUnicodeName ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1401 of file encode.c.

1404{
1405 BOOL ret = TRUE;
1406
1407 __TRY
1408 {
1409 const CERT_NAME_INFO *info = pvStructInfo;
1410 DWORD bytesNeeded = 0, lenBytes, size, i;
1411
1412 TRACE("encoding name with %d RDNs\n", info->cRDN);
1413 ret = TRUE;
1414 for (i = 0; ret && i < info->cRDN; i++)
1415 {
1418 if (ret)
1419 bytesNeeded += size;
1420 else
1421 *pcbEncoded = size;
1422 }
1423 CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes);
1424 bytesNeeded += 1 + lenBytes;
1425 if (ret)
1426 {
1427 if (!pbEncoded)
1428 *pcbEncoded = bytesNeeded;
1429 else
1430 {
1431 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
1432 pbEncoded, pcbEncoded, bytesNeeded)))
1433 {
1434 BYTE *out;
1435
1437 pbEncoded = *(BYTE **)pbEncoded;
1438 out = pbEncoded;
1439 *out++ = ASN_SEQUENCEOF;
1440 CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, out, &lenBytes);
1441 out += lenBytes;
1442 for (i = 0; ret && i < info->cRDN; i++)
1443 {
1444 size = bytesNeeded;
1447 out, &size);
1448 if (ret)
1449 {
1450 out += size;
1451 bytesNeeded -= size;
1452 }
1453 else
1454 *pcbEncoded = size;
1455 }
1457 CRYPT_FreeSpace(pEncodePara, pbEncoded);
1458 }
1459 }
1460 }
1461 }
1463 {
1465 ret = FALSE;
1466 }
1467 __ENDTRY
1468 return ret;
1469}
static BOOL WINAPI CRYPT_AsnEncodeOrCopyUnicodeNameValue(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1384

Referenced by CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeUnicodeNameValue()

static BOOL WINAPI CRYPT_AsnEncodeUnicodeNameValue ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2231 of file encode.c.

2234{
2235 BOOL ret = FALSE;
2236
2237 __TRY
2238 {
2239 const CERT_NAME_VALUE *value = pvStructInfo;
2240
2241 switch (value->dwValueType)
2242 {
2243 case CERT_RDN_ANY_TYPE:
2247 break;
2251 break;
2255 break;
2258 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
2259 break;
2263 break;
2265 ret = CRYPT_AsnEncodeIA5String(value, dwFlags, pEncodePara,
2267 break;
2270 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
2271 break;
2274 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
2275 break;
2278 dwFlags, pEncodePara, pbEncoded, pcbEncoded);
2279 break;
2283 break;
2285 ret = CRYPT_AsnEncodeBMPString(value, dwFlags, pEncodePara,
2287 break;
2291 break;
2292 default:
2294 }
2295 }
2297 {
2299 }
2300 __ENDTRY
2301 return ret;
2302}
static BOOL CRYPT_AsnEncodeIA5String(const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2137
static BOOL CRYPT_AsnEncodeUniversalString(const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2188
static BOOL CRYPT_AsnEncodePrintableString(const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2086
static BOOL CRYPT_AsnEncodeNumericString(const CERT_NAME_VALUE *value, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2028
static BOOL CRYPT_AsnEncodeUnicodeStringCoerce(const CERT_NAME_VALUE *value, BYTE tag, DWORD dwFlags, const CRYPT_ENCODE_PARA *pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1991
#define CRYPT_E_NOT_CHAR_STRING
Definition: winerror.h:3028

Referenced by CRYPT_AsnEncodeOrCopyUnicodeNameValue(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeUnicodeStringCoerce()

static BOOL CRYPT_AsnEncodeUnicodeStringCoerce ( const CERT_NAME_VALUE value,
BYTE  tag,
DWORD  dwFlags,
const CRYPT_ENCODE_PARA pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1991 of file encode.c.

1994{
1995 BOOL ret = TRUE;
1996 LPCWSTR str = (LPCWSTR)value->Value.pbData;
1997 DWORD bytesNeeded, lenBytes, encodedLen;
1998
1999 if (value->Value.cbData)
2000 encodedLen = value->Value.cbData / sizeof(WCHAR);
2001 else if (str)
2002 encodedLen = strlenW(str);
2003 else
2004 encodedLen = 0;
2005 CRYPT_EncodeLen(encodedLen, NULL, &lenBytes);
2006 bytesNeeded = 1 + lenBytes + encodedLen;
2007 if (!pbEncoded)
2008 *pcbEncoded = bytesNeeded;
2009 else
2010 {
2011 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
2012 pbEncoded, pcbEncoded, bytesNeeded)))
2013 {
2014 DWORD i;
2015
2017 pbEncoded = *(BYTE **)pbEncoded;
2018 *pbEncoded++ = tag;
2019 CRYPT_EncodeLen(encodedLen, pbEncoded, &lenBytes);
2020 pbEncoded += lenBytes;
2021 for (i = 0; i < encodedLen; i++)
2022 *pbEncoded++ = (BYTE)str[i];
2023 }
2024 }
2025 return ret;
2026}

Referenced by CRYPT_AsnEncodeUnicodeNameValue().

◆ CRYPT_AsnEncodeUniversalString()

static BOOL CRYPT_AsnEncodeUniversalString ( const CERT_NAME_VALUE value,
DWORD  dwFlags,
const CRYPT_ENCODE_PARA pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 2188 of file encode.c.

2191{
2192 BOOL ret = TRUE;
2193 LPCWSTR str = (LPCWSTR)value->Value.pbData;
2194 DWORD bytesNeeded, lenBytes, strLen;
2195
2196 /* FIXME: doesn't handle composite characters */
2197 if (value->Value.cbData)
2198 strLen = value->Value.cbData / sizeof(WCHAR);
2199 else if (str)
2200 strLen = strlenW(str);
2201 else
2202 strLen = 0;
2203 CRYPT_EncodeLen(strLen * 4, NULL, &lenBytes);
2204 bytesNeeded = 1 + lenBytes + strLen * 4;
2205 if (!pbEncoded)
2206 *pcbEncoded = bytesNeeded;
2207 else
2208 {
2209 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
2210 pbEncoded, pcbEncoded, bytesNeeded)))
2211 {
2212 DWORD i;
2213
2215 pbEncoded = *(BYTE **)pbEncoded;
2217 CRYPT_EncodeLen(strLen * 4, pbEncoded, &lenBytes);
2218 pbEncoded += lenBytes;
2219 for (i = 0; i < strLen; i++)
2220 {
2221 *pbEncoded++ = 0;
2222 *pbEncoded++ = 0;
2223 *pbEncoded++ = (BYTE)((str[i] & 0xff00) >> 8);
2224 *pbEncoded++ = (BYTE)(str[i] & 0x00ff);
2225 }
2226 }
2227 }
2228 return ret;
2229}
#define ASN_UNIVERSALSTRING

Referenced by CRYPT_AsnEncodeUnicodeNameValue().

◆ CRYPT_AsnEncodeUnsignedInteger()

static BOOL WINAPI CRYPT_AsnEncodeUnsignedInteger ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3431 of file encode.c.

3434{
3435 BOOL ret;
3436
3437 __TRY
3438 {
3439 DWORD significantBytes, lenBytes, bytesNeeded;
3440 BOOL pad = FALSE;
3441 const CRYPT_INTEGER_BLOB *blob = pvStructInfo;
3442
3443 significantBytes = blob->cbData;
3444 if (significantBytes)
3445 {
3446 /* positive, lop off leading (little-endian) zeroes */
3447 for (; significantBytes > 0 && !blob->pbData[significantBytes - 1];
3448 significantBytes--)
3449 ;
3450 if (significantBytes == 0)
3451 significantBytes = 1;
3452 if (blob->pbData[significantBytes - 1] > 0x7f)
3453 pad = TRUE;
3454 }
3455 if (pad)
3456 CRYPT_EncodeLen(significantBytes + 1, NULL, &lenBytes);
3457 else
3458 CRYPT_EncodeLen(significantBytes, NULL, &lenBytes);
3459 bytesNeeded = 1 + lenBytes + significantBytes;
3460 if (pad)
3461 bytesNeeded++;
3462 if (!pbEncoded)
3463 {
3464 *pcbEncoded = bytesNeeded;
3465 ret = TRUE;
3466 }
3467 else
3468 {
3469 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded,
3470 pcbEncoded, bytesNeeded)))
3471 {
3473 pbEncoded = *(BYTE **)pbEncoded;
3475 if (pad)
3476 {
3477 CRYPT_EncodeLen(significantBytes + 1, pbEncoded, &lenBytes);
3478 pbEncoded += lenBytes;
3479 *pbEncoded++ = 0;
3480 }
3481 else
3482 {
3483 CRYPT_EncodeLen(significantBytes, pbEncoded, &lenBytes);
3484 pbEncoded += lenBytes;
3485 }
3486 for (; significantBytes > 0; significantBytes--)
3487 *(pbEncoded++) = blob->pbData[significantBytes - 1];
3488 }
3489 }
3490 }
3492 {
3494 ret = FALSE;
3495 }
3496 __ENDTRY
3497 return ret;
3498}

Referenced by CRYPT_AsnEncodeEnumerated(), CRYPT_AsnEncodeRsaPubKey(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeUtcTime()

static BOOL WINAPI CRYPT_AsnEncodeUtcTime ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 3521 of file encode.c.

3524{
3525 BOOL ret;
3526
3527 __TRY
3528 {
3529 SYSTEMTIME sysTime;
3530 /* sorry, magic number: enough for tag, len, YYMMDDHHMMSSZ. I use a
3531 * temporary buffer because the output buffer is not NULL-terminated.
3532 */
3533 static const DWORD bytesNeeded = 15;
3534 char buf[40];
3535
3536 if (!pbEncoded)
3537 {
3538 *pcbEncoded = bytesNeeded;
3539 ret = TRUE;
3540 }
3541 else
3542 {
3543 /* Sanity check the year, this is a two-digit year format */
3544 ret = FileTimeToSystemTime(pvStructInfo, &sysTime);
3545 if (ret && (sysTime.wYear < 1950 || sysTime.wYear > 2050))
3546 {
3548 ret = FALSE;
3549 }
3550 if (ret)
3551 {
3552 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
3553 pbEncoded, pcbEncoded, bytesNeeded)))
3554 {
3556 pbEncoded = *(BYTE **)pbEncoded;
3557 buf[0] = ASN_UTCTIME;
3558 buf[1] = bytesNeeded - 2;
3559 snprintf(buf + 2, sizeof(buf) - 2,
3560 "%02d%02d%02d%02d%02d%02dZ", sysTime.wYear >= 2000 ?
3561 sysTime.wYear - 2000 : sysTime.wYear - 1900,
3562 sysTime.wMonth, sysTime.wDay, sysTime.wHour,
3563 sysTime.wMinute, sysTime.wSecond);
3564 memcpy(pbEncoded, buf, bytesNeeded);
3565 }
3566 }
3567 }
3568 }
3570 {
3572 ret = FALSE;
3573 }
3574 __ENDTRY
3575 return ret;
3576}
#define ASN_UTCTIME
#define CRYPT_E_BAD_ENCODE
Definition: winerror.h:3005

Referenced by CRYPT_AsnEncodeChoiceOfTime(), and CRYPT_GetBuiltinEncoder().

◆ CRYPT_AsnEncodeUTF8String()

static BOOL CRYPT_AsnEncodeUTF8String ( const CERT_NAME_VALUE value,
DWORD  dwFlags,
const CRYPT_ENCODE_PARA pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1007 of file encode.c.

1010{
1011 BOOL ret = TRUE;
1012 LPCWSTR str = (LPCWSTR)value->Value.pbData;
1013 DWORD bytesNeeded, lenBytes, encodedLen, strLen;
1014
1015 if (value->Value.cbData)
1016 strLen = value->Value.cbData / sizeof(WCHAR);
1017 else if (str)
1018 strLen = strlenW(str);
1019 else
1020 strLen = 0;
1021 encodedLen = WideCharToMultiByte(CP_UTF8, 0, str, strLen, NULL, 0, NULL,
1022 NULL);
1023 CRYPT_EncodeLen(encodedLen, NULL, &lenBytes);
1024 bytesNeeded = 1 + lenBytes + encodedLen;
1025 if (!pbEncoded)
1026 *pcbEncoded = bytesNeeded;
1027 else
1028 {
1029 if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
1030 pbEncoded, pcbEncoded, bytesNeeded)))
1031 {
1033 pbEncoded = *(BYTE **)pbEncoded;
1035 CRYPT_EncodeLen(encodedLen, pbEncoded, &lenBytes);
1036 pbEncoded += lenBytes;
1038 bytesNeeded - lenBytes - 1, NULL, NULL);
1039 }
1040 }
1041 return ret;
1042}
#define ASN_UTF8STRING
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_UTF8
Definition: nls.h:20
char * LPSTR
Definition: xmlstorage.h:182

Referenced by CRYPT_AsnEncodeNameValue(), and CRYPT_AsnEncodeUnicodeNameValue().

◆ CRYPT_AsnEncodeValidity()

static BOOL WINAPI CRYPT_AsnEncodeValidity ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 362 of file encode.c.

365{
366 BOOL ret;
367 /* This has two filetimes in a row, a NotBefore and a NotAfter */
368 const FILETIME *timePtr = pvStructInfo;
369 struct AsnEncodeSequenceItem items[] = {
370 { timePtr, CRYPT_AsnEncodeChoiceOfTime, 0 },
371 { timePtr + 1, CRYPT_AsnEncodeChoiceOfTime, 0 },
372 };
373
375 ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
376 pcbEncoded);
377 return ret;
378}

Referenced by CRYPT_AsnEncodeCertInfo().

◆ CRYPT_CopyEncodedBlob()

static BOOL WINAPI CRYPT_CopyEncodedBlob ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

◆ CRYPT_DEREncodeItemsAsSet()

static BOOL WINAPI CRYPT_DEREncodeItemsAsSet ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1245 of file encode.c.

1248{
1249 const struct DERSetDescriptor *desc = pvStructInfo;
1250 CRYPT_BLOB_ARRAY setOf = { 0, NULL };
1251 BOOL ret = TRUE;
1252 DWORD i;
1253
1254 if (desc->cItems)
1255 {
1256 setOf.rgBlob = CryptMemAlloc(desc->cItems * sizeof(CRYPT_DER_BLOB));
1257 if (!setOf.rgBlob)
1258 ret = FALSE;
1259 else
1260 {
1261 setOf.cBlob = desc->cItems;
1262 memset(setOf.rgBlob, 0, setOf.cBlob * sizeof(CRYPT_DER_BLOB));
1263 }
1264 }
1265 for (i = 0; ret && i < setOf.cBlob; i++)
1266 {
1267 ret = desc->encode(dwCertEncodingType, lpszStructType,
1268 (const BYTE *)desc->items + i * desc->itemSize + desc->itemOffset,
1269 0, NULL, NULL, &setOf.rgBlob[i].cbData);
1270 if (ret)
1271 {
1272 setOf.rgBlob[i].pbData = CryptMemAlloc(setOf.rgBlob[i].cbData);
1273 if (!setOf.rgBlob[i].pbData)
1274 ret = FALSE;
1275 else
1276 ret = desc->encode(dwCertEncodingType, lpszStructType,
1277 (const BYTE *)desc->items + i * desc->itemSize +
1278 desc->itemOffset, 0, NULL, setOf.rgBlob[i].pbData,
1279 &setOf.rgBlob[i].cbData);
1280 }
1281 /* Some functions propagate their errors through the size */
1282 if (!ret)
1283 *pcbEncoded = setOf.rgBlob[i].cbData;
1284 }
1285 if (ret)
1286 {
1287 DWORD bytesNeeded = 0, lenBytes;
1288
1289 for (i = 0; i < setOf.cBlob; i++)
1290 bytesNeeded += setOf.rgBlob[i].cbData;
1291 CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes);
1292 bytesNeeded += 1 + lenBytes;
1293 if (!pbEncoded)
1294 *pcbEncoded = bytesNeeded;
1295 else if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
1296 pbEncoded, pcbEncoded, bytesNeeded)))
1297 {
1299 pbEncoded = *(BYTE **)pbEncoded;
1300 qsort(setOf.rgBlob, setOf.cBlob, sizeof(CRYPT_DER_BLOB),
1301 BLOBComp);
1303 CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, &lenBytes);
1304 pbEncoded += lenBytes;
1305 for (i = 0; i < setOf.cBlob; i++)
1306 {
1307 memcpy(pbEncoded, setOf.rgBlob[i].pbData,
1308 setOf.rgBlob[i].cbData);
1309 pbEncoded += setOf.rgBlob[i].cbData;
1310 }
1311 }
1312 }
1313 for (i = 0; i < setOf.cBlob; i++)
1314 CryptMemFree(setOf.rgBlob[i].pbData);
1315 CryptMemFree(setOf.rgBlob);
1316 return ret;
1317}
#define ASN_SETOF
static int BLOBComp(const void *l, const void *r)
Definition: encode.c:1189
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))

Referenced by CRYPT_AsnEncodeCMSSignedInfo(), CRYPT_AsnEncodePKCSAttributes(), and CRYPT_AsnEncodePKCSEnvelopedData().

◆ CRYPT_DEREncodeSet()

static BOOL WINAPI CRYPT_DEREncodeSet ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded 
)
static

Definition at line 1201 of file encode.c.

1204{
1205 const CRYPT_BLOB_ARRAY *set = pvStructInfo;
1206 DWORD bytesNeeded = 0, lenBytes, i;
1207 BOOL ret;
1208
1209 for (i = 0; i < set->cBlob; i++)
1210 bytesNeeded += set->rgBlob[i].cbData;
1211 CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes);
1212 bytesNeeded += 1 + lenBytes;
1213 if (!pbEncoded)
1214 {
1215 *pcbEncoded = bytesNeeded;
1216 ret = TRUE;
1217 }
1218 else if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
1219 pbEncoded, pcbEncoded, bytesNeeded)))
1220 {
1222 pbEncoded = *(BYTE **)pbEncoded;
1223 qsort(set->rgBlob, set->cBlob, sizeof(CRYPT_DER_BLOB), BLOBComp);
1225 CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, &lenBytes);
1226 pbEncoded += lenBytes;
1227 for (i = 0; i < set->cBlob; i++)
1228 {
1229 memcpy(pbEncoded, set->rgBlob[i].pbData, set->rgBlob[i].cbData);
1230 pbEncoded += set->rgBlob[i].cbData;
1231 }
1232 }
1233 return ret;
1234}
Definition: _set.h:50

Referenced by CRYPT_AsnEncodeNameConstraints(), CRYPT_AsnEncodePKCSAttribute(), and CRYPT_AsnEncodeRdn().

◆ CRYPT_EncodeEnsureSpace()

BOOL CRYPT_EncodeEnsureSpace ( DWORD  dwFlags,
const CRYPT_ENCODE_PARA pEncodePara,
BYTE pbEncoded,
DWORD pcbEncoded,
DWORD  bytesNeeded 
)

Definition at line 103 of file encode.c.

105{
106 BOOL ret = TRUE;
107
109 {
110 if (pEncodePara && pEncodePara->pfnAlloc)
111 *(BYTE **)pbEncoded = pEncodePara->pfnAlloc(bytesNeeded);
112 else
113 *(BYTE **)pbEncoded = LocalAlloc(0, bytesNeeded);
114 if (!*(BYTE **)pbEncoded)
115 ret = FALSE;
116 else
117 *pcbEncoded = bytesNeeded;
118 }
119 else if (bytesNeeded > *pcbEncoded)
120 {
121 *pcbEncoded = bytesNeeded;
123 ret = FALSE;
124 }
125 else
126 *pcbEncoded = bytesNeeded;
127 return ret;
128}
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
PFN_CRYPT_ALLOC pfnAlloc
Definition: wincrypt.h:1136

Referenced by CRYPT_AsnEncodeAltName(), CRYPT_AsnEncodeAuthorityInfoAccess(), CRYPT_AsnEncodeBits(), CRYPT_AsnEncodeBMPString(), CRYPT_AsnEncodeCertPolicies(), CRYPT_AsnEncodeCertPolicyMappings(), CRYPT_AsnEncodeCertPolicyQualifiers(), CRYPT_AsnEncodeConstructed(), CRYPT_AsnEncodeCRLDistPoints(), CRYPT_AsnEncodeCRLEntries(), CRYPT_AsnEncodeCTLEntries(), CRYPT_AsnEncodeEnhancedKeyUsage(), CRYPT_AsnEncodeExtensions(), CRYPT_AsnEncodeGeneralizedTime(), CRYPT_AsnEncodeIA5String(), CRYPT_AsnEncodeInteger(), CRYPT_AsnEncodeName(), CRYPT_AsnEncodeNoticeNumbers(), CRYPT_AsnEncodeNumericString(), CRYPT_AsnEncodeOctets(), CRYPT_AsnEncodePrintableString(), CRYPT_AsnEncodeSequence(), CRYPT_AsnEncodeSequenceOfAny(), CRYPT_AsnEncodeSMIMECapabilities(), CRYPT_AsnEncodeStringCoerce(), CRYPT_AsnEncodeUnicodeName(), CRYPT_AsnEncodeUnicodeStringCoerce(), CRYPT_AsnEncodeUniversalString(), CRYPT_AsnEncodeUnsignedInteger(), CRYPT_AsnEncodeUtcTime(), CRYPT_AsnEncodeUTF8String(), CRYPT_CopyEncodedBlob(), CRYPT_DEREncodeItemsAsSet(), CRYPT_DEREncodeSet(), CRYPT_EncodeContentLength(), and CryptEncodeObjectEx().

◆ CRYPT_EncodeLen()

BOOL CRYPT_EncodeLen ( DWORD  len,
BYTE pbEncoded,
DWORD pcbEncoded 
)

Definition at line 138 of file encode.c.

139{
140 DWORD bytesNeeded, significantBytes = 0;
141
142 if (len <= 0x7f)
143 bytesNeeded = 1;
144 else
145 {
146 DWORD temp;
147
148 for (temp = len, significantBytes = sizeof(temp); !(temp & 0xff000000);
149 temp <<= 8, significantBytes--)
150 ;
151 bytesNeeded = significantBytes + 1;
152 }
153 if (!pbEncoded)
154 {
155 *pcbEncoded = bytesNeeded;
156 return TRUE;
157 }
158 if (*pcbEncoded < bytesNeeded)
159 {
161 return FALSE;
162 }
163 if (len <= 0x7f)
164 *pbEncoded = (BYTE)len;
165 else
166 {
167 DWORD i;
168
169 *pbEncoded++ = significantBytes | 0x80;
170 for (i = 0; i < significantBytes; i++)
171 {
172 *(pbEncoded + significantBytes - i - 1) = (BYTE)(len & 0xff);
173 len >>= 8;
174 }
175 }
176 *pcbEncoded = bytesNeeded;
177 return TRUE;
178}
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by CRYPT_AsnEncodeAltName(), CRYPT_AsnEncodeAltNameEntry(), CRYPT_AsnEncodeAuthorityInfoAccess(), CRYPT_AsnEncodeBits(), CRYPT_AsnEncodeBMPString(), CRYPT_AsnEncodeCertPolicies(), CRYPT_AsnEncodeCertPolicyMappings(), CRYPT_AsnEncodeCertPolicyQualifiers(), CRYPT_AsnEncodeConstructed(), CRYPT_AsnEncodeCRLDistPoints(), CRYPT_AsnEncodeCRLEntries(), CRYPT_AsnEncodeCTLEntries(), CRYPT_AsnEncodeEnhancedKeyUsage(), CRYPT_AsnEncodeExtensions(), CRYPT_AsnEncodeIA5String(), CRYPT_AsnEncodeInteger(), CRYPT_AsnEncodeName(), CRYPT_AsnEncodeNoticeNumbers(), CRYPT_AsnEncodeNumericString(), CRYPT_AsnEncodeOctets(), CRYPT_AsnEncodeOid(), CRYPT_AsnEncodePrintableString(), CRYPT_AsnEncodeRdnAttr(), CRYPT_AsnEncodeSequence(), CRYPT_AsnEncodeSequenceOfAny(), CRYPT_AsnEncodeSMIMECapabilities(), CRYPT_AsnEncodeStringCoerce(), CRYPT_AsnEncodeUnicodeName(), CRYPT_AsnEncodeUnicodeStringCoerce(), CRYPT_AsnEncodeUniversalString(), CRYPT_AsnEncodeUnsignedInteger(), CRYPT_AsnEncodeUTF8String(), CRYPT_DEREncodeItemsAsSet(), CRYPT_DEREncodeSet(), and CRYPT_EncodeContentLength().

◆ CRYPT_ExportPublicKeyInfoEx()

static BOOL WINAPI CRYPT_ExportPublicKeyInfoEx ( HCRYPTPROV_OR_NCRYPT_KEY_HANDLE  hCryptProv,
DWORD  dwKeySpec,
DWORD  dwCertEncodingType,
LPSTR  pszPublicKeyObjId,
DWORD  dwFlags,
void pvAuxInfo,
PCERT_PUBLIC_KEY_INFO  pInfo,
DWORD pcbInfo 
)
static

Definition at line 4786 of file encode.c.

4789{
4790 BOOL ret;
4791 HCRYPTKEY key;
4792 static CHAR rsa_oid[] = szOID_RSA_RSA;
4793
4794 TRACE_(crypt)("(%08lx, %d, %08x, %s, %08x, %p, %p, %d)\n", hCryptProv,
4795 dwKeySpec, dwCertEncodingType, debugstr_a(pszPublicKeyObjId), dwFlags,
4796 pvAuxInfo, pInfo, pInfo ? *pcbInfo : 0);
4797
4798 if ((ret = CryptGetUserKey(hCryptProv, dwKeySpec, &key)))
4799 {
4800 DWORD keySize = 0;
4801
4802 ret = CryptExportKey(key, 0, PUBLICKEYBLOB, 0, NULL, &keySize);
4803 if (ret)
4804 {
4806
4807 if (pubKey)
4808 {
4809 ret = CryptExportKey(key, 0, PUBLICKEYBLOB, 0, (BYTE *)pubKey, &keySize);
4810 if (ret)
4811 {
4812 DWORD encodedLen;
4813
4814 if (!pszPublicKeyObjId)
4815 {
4816 static HCRYPTOIDFUNCSET set;
4818 HCRYPTOIDFUNCADDR hFunc = NULL;
4819
4820 pszPublicKeyObjId = (LPSTR)CertAlgIdToOID(pubKey->aiKeyAlg);
4821 TRACE("public key algid %#x (%s)\n", pubKey->aiKeyAlg, debugstr_a(pszPublicKeyObjId));
4822
4823 if (!set) /* FIXME: there is no a public macro */
4824 set = CryptInitOIDFunctionSet("CryptDllEncodePublicKeyAndParameters", 0);
4825
4826 CryptGetOIDFunctionAddress(set, dwCertEncodingType, pszPublicKeyObjId, 0, (void **)&encodeFunc, &hFunc);
4827 if (encodeFunc)
4828 {
4829 BYTE *key_data = NULL;
4830 DWORD key_size = 0;
4831 BYTE *params = NULL;
4832 DWORD params_size = 0;
4833
4834 ret = encodeFunc(dwCertEncodingType, pszPublicKeyObjId, (BYTE *)pubKey, keySize,
4835 dwFlags, pvAuxInfo, &key_data, &key_size, &params, &params_size);
4836 if (ret)
4837 {
4838 DWORD oid_size = strlen(pszPublicKeyObjId) + 1;
4839 DWORD size_needed = sizeof(*pInfo) + oid_size + key_size + params_size;
4840
4841 if (!pInfo)
4842 *pcbInfo = size_needed;
4843 else if (*pcbInfo < size_needed)
4844 {
4845 *pcbInfo = size_needed;
4847 ret = FALSE;
4848 }
4849 else
4850 {
4851 *pcbInfo = size_needed;
4852 pInfo->Algorithm.pszObjId = (char *)(pInfo + 1);
4853 lstrcpyA(pInfo->Algorithm.pszObjId, pszPublicKeyObjId);
4854 if (params)
4855 {
4856 pInfo->Algorithm.Parameters.cbData = params_size;
4857 pInfo->Algorithm.Parameters.pbData = (BYTE *)pInfo->Algorithm.pszObjId + oid_size;
4858 memcpy(pInfo->Algorithm.Parameters.pbData, params, params_size);
4859 }
4860 else
4861 {
4862 pInfo->Algorithm.Parameters.cbData = 0;
4863 pInfo->Algorithm.Parameters.pbData = NULL;
4864 }
4865 pInfo->PublicKey.pbData = (BYTE *)pInfo->Algorithm.pszObjId + oid_size + params_size;
4866 pInfo->PublicKey.cbData = key_size;
4867 memcpy(pInfo->PublicKey.pbData, key_data, key_size);
4868 pInfo->PublicKey.cUnusedBits = 0;
4869 }
4870
4871 CryptMemFree(key_data);
4873 }
4874
4877 return ret;
4878 }
4879
4880 /* fallback to RSA */
4881 pszPublicKeyObjId = rsa_oid;
4882 }
4883
4884 encodedLen = 0;
4886 RSA_CSP_PUBLICKEYBLOB, pubKey, NULL, &encodedLen);
4887 if (ret)
4888 {
4889 DWORD sizeNeeded = sizeof(CERT_PUBLIC_KEY_INFO) +
4890 strlen(pszPublicKeyObjId) + 1 + encodedLen;
4891
4892 if (!pInfo)
4893 *pcbInfo = sizeNeeded;
4894 else if (*pcbInfo < sizeNeeded)
4895 {
4897 *pcbInfo = sizeNeeded;
4898 ret = FALSE;
4899 }
4900 else
4901 {
4902 *pcbInfo = sizeNeeded;
4903 pInfo->Algorithm.pszObjId = (char *)pInfo +
4904 sizeof(CERT_PUBLIC_KEY_INFO);
4905 lstrcpyA(pInfo->Algorithm.pszObjId,
4906 pszPublicKeyObjId);
4907 pInfo->Algorithm.Parameters.cbData = 0;
4908 pInfo->Algorithm.Parameters.pbData = NULL;
4909 pInfo->PublicKey.pbData =
4910 (BYTE *)pInfo->Algorithm.pszObjId
4911 + lstrlenA(pInfo->Algorithm.pszObjId) + 1;
4912 pInfo->PublicKey.cbData = encodedLen;
4913 pInfo->PublicKey.cUnusedBits = 0;
4916 pInfo->PublicKey.pbData, &pInfo->PublicKey.cbData);
4917 }
4918 }
4919 }
4921 }
4922 else
4923 ret = FALSE;
4924 }
4926 }
4927 return ret;
4928}
BOOL WINAPI CryptExportKey(HCRYPTKEY hKey, HCRYPTKEY hExpKey, DWORD dwBlobType, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
Definition: crypt.c:1416
BOOL WINAPI CryptDestroyKey(HCRYPTKEY hKey)
Definition: crypt.c:930
BOOL WINAPI CryptGetUserKey(HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY *phUserKey)
Definition: crypt.c:1718
BOOL WINAPI CryptEncodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:4655
BOOL(WINAPI * EncodePublicKeyAndParametersFunc)(DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, BYTE *pbPubKey, DWORD cbPubKey, DWORD dwFlags, void *pvAuxInfo, BYTE **ppPublicKey, DWORD *pcbPublicKey, BYTE **ppbParams, DWORD *pcbParams)
Definition: encode.c:4782
HCRYPTOIDFUNCSET WINAPI CryptInitOIDFunctionSet(LPCSTR pszFuncName, DWORD dwFlags)
Definition: oid.c:114
BOOL WINAPI CryptGetOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet, DWORD dwEncodingType, LPCSTR pszOID, DWORD dwFlags, void **ppvFuncAddr, HCRYPTOIDFUNCADDR *phFuncAddr)
Definition: oid.c:387
LPCSTR WINAPI CertAlgIdToOID(DWORD dwAlgId)
Definition: oid.c:1888
BOOL WINAPI CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr, DWORD dwFlags)
Definition: oid.c:468
#define TRACE_(x)
Definition: compat.h:76
GLenum const GLfloat * params
Definition: glext.h:5645
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static BYTE pubKey[]
Definition: msg.c:1214
Definition: copy.c:22
struct _CERT_PUBLIC_KEY_INFO CERT_PUBLIC_KEY_INFO
#define RSA_CSP_PUBLICKEYBLOB
Definition: wincrypt.h:3384
#define szOID_RSA_RSA
Definition: wincrypt.h:3015
ULONG_PTR HCRYPTKEY
Definition: wincrypt.h:49
char CHAR
Definition: xmlstorage.h:175

Referenced by CryptExportPublicKeyInfoEx().

◆ CRYPT_FreeSpace()

◆ CRYPT_GetBuiltinEncoder()

static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType 
)
static

Definition at line 4435 of file encode.c.

4437{
4438 CryptEncodeObjectExFunc encodeFunc = NULL;
4439
4442 {
4444 return NULL;
4445 }
4446
4447 if (IS_INTOID(lpszStructType))
4448 {
4449 switch (LOWORD(lpszStructType))
4450 {
4451 case LOWORD(X509_CERT):
4452 encodeFunc = CRYPT_AsnEncodeCert;
4453 break;
4455 encodeFunc = CRYPT_AsnEncodeCertInfo;
4456 break;
4458 encodeFunc = CRYPT_AsnEncodeCRLInfo;
4459 break;
4460 case LOWORD(X509_EXTENSIONS):
4461 encodeFunc = CRYPT_AsnEncodeExtensions;
4462 break;
4463 case LOWORD(X509_NAME_VALUE):
4464 encodeFunc = CRYPT_AsnEncodeNameValue;
4465 break;
4466 case LOWORD(X509_NAME):
4467 encodeFunc = CRYPT_AsnEncodeName;
4468 break;
4470 encodeFunc = CRYPT_AsnEncodePubKeyInfo;
4471 break;
4473 encodeFunc = CRYPT_AsnEncodeAuthorityKeyId;
4474 break;
4476 encodeFunc = CRYPT_AsnEncodeAltName;
4477 break;
4480 break;
4483 break;
4485 encodeFunc = CRYPT_AsnEncodeCertPolicies;
4486 break;
4488 encodeFunc = CRYPT_AsnEncodeRsaPubKey;
4489 break;
4491 encodeFunc = CRYPT_AsnEncodeUnicodeName;
4492 break;
4494 encodeFunc = CRYPT_AsnEncodePKCSContentInfo;
4495 break;
4496 case LOWORD(PKCS_ATTRIBUTE):
4497 encodeFunc = CRYPT_AsnEncodePKCSAttribute;
4498 break;
4501 break;
4503 encodeFunc = CRYPT_AsnEncodeOctets;
4504 break;
4505 case LOWORD(X509_BITS):
4506 case LOWORD(X509_KEY_USAGE):
4507 encodeFunc = CRYPT_AsnEncodeBits;
4508 break;
4509 case LOWORD(X509_INTEGER):
4510 encodeFunc = CRYPT_AsnEncodeInt;
4511 break;
4513 encodeFunc = CRYPT_AsnEncodeInteger;
4514 break;
4516 encodeFunc = CRYPT_AsnEncodeUnsignedInteger;
4517 break;
4518 case LOWORD(X509_ENUMERATED):
4519 encodeFunc = CRYPT_AsnEncodeEnumerated;
4520 break;
4522 encodeFunc = CRYPT_AsnEncodeChoiceOfTime;
4523 break;
4525 encodeFunc = CRYPT_AsnEncodeAuthorityKeyId2;
4526 break;
4529 break;
4531 encodeFunc = CRYPT_AsnEncodeSequenceOfAny;
4532 break;
4533 case LOWORD(PKCS_UTC_TIME):
4534 encodeFunc = CRYPT_AsnEncodeUtcTime;
4535 break;
4537 encodeFunc = CRYPT_AsnEncodeCRLDistPoints;
4538 break;
4541 break;
4542 case LOWORD(PKCS_CTL):
4543 encodeFunc = CRYPT_AsnEncodeCTL;
4544 break;
4547 break;
4550 break;
4551 case LOWORD(PKCS_ATTRIBUTES):
4552 encodeFunc = CRYPT_AsnEncodePKCSAttributes;
4553 break;
4556 break;
4558 encodeFunc = CRYPT_AsnEncodeNameConstraints;
4559 break;
4562 break;
4565 break;
4567 encodeFunc = CRYPT_AsnEncodePKCSSignerInfo;
4568 break;
4569 case LOWORD(CMS_SIGNER_INFO):
4570 encodeFunc = CRYPT_AsnEncodeCMSSignerInfo;
4571 break;
4572 }
4573 }
4574 else if (!strcmp(lpszStructType, szOID_CERT_EXTENSIONS))
4575 encodeFunc = CRYPT_AsnEncodeExtensions;
4576 else if (!strcmp(lpszStructType, szOID_RSA_signingTime))
4577 encodeFunc = CRYPT_AsnEncodeUtcTime;
4578 else if (!strcmp(lpszStructType, szOID_RSA_SMIMECapabilities))
4579 encodeFunc = CRYPT_AsnEncodeUtcTime;
4580 else if (!strcmp(lpszStructType, szOID_AUTHORITY_KEY_IDENTIFIER))
4581 encodeFunc = CRYPT_AsnEncodeAuthorityKeyId;
4582 else if (!strcmp(lpszStructType, szOID_LEGACY_POLICY_MAPPINGS))
4584 else if (!strcmp(lpszStructType, szOID_AUTHORITY_KEY_IDENTIFIER2))
4585 encodeFunc = CRYPT_AsnEncodeAuthorityKeyId2;
4586 else if (!strcmp(lpszStructType, szOID_CRL_REASON_CODE))
4587 encodeFunc = CRYPT_AsnEncodeEnumerated;
4588 else if (!strcmp(lpszStructType, szOID_KEY_USAGE))
4589 encodeFunc = CRYPT_AsnEncodeBits;
4590 else if (!strcmp(lpszStructType, szOID_SUBJECT_KEY_IDENTIFIER))
4591 encodeFunc = CRYPT_AsnEncodeOctets;
4592 else if (!strcmp(lpszStructType, szOID_BASIC_CONSTRAINTS))
4594 else if (!strcmp(lpszStructType, szOID_BASIC_CONSTRAINTS2))
4596 else if (!strcmp(lpszStructType, szOID_ISSUER_ALT_NAME))
4597 encodeFunc = CRYPT_AsnEncodeAltName;
4598 else if (!strcmp(lpszStructType, szOID_ISSUER_ALT_NAME2))
4599 encodeFunc = CRYPT_AsnEncodeAltName;
4600 else if (!strcmp(lpszStructType, szOID_NEXT_UPDATE_LOCATION))
4601 encodeFunc = CRYPT_AsnEncodeAltName;
4602 else if (!strcmp(lpszStructType, szOID_SUBJECT_ALT_NAME))
4603 encodeFunc = CRYPT_AsnEncodeAltName;
4604 else if (!strcmp(lpszStructType, szOID_SUBJECT_ALT_NAME2))
4605 encodeFunc = CRYPT_AsnEncodeAltName;
4606 else if (!strcmp(lpszStructType, szOID_CRL_DIST_POINTS))
4607 encodeFunc = CRYPT_AsnEncodeCRLDistPoints;
4608 else if (!strcmp(lpszStructType, szOID_CERT_POLICIES))
4609 encodeFunc = CRYPT_AsnEncodeCertPolicies;
4610 else if (!strcmp(lpszStructType, szOID_POLICY_MAPPINGS))
4612 else if (!strcmp(lpszStructType, szOID_POLICY_CONSTRAINTS))
4614 else if (!strcmp(lpszStructType, szOID_ENHANCED_KEY_USAGE))
4616 else if (!strcmp(lpszStructType, szOID_ISSUING_DIST_POINT))
4618 else if (!strcmp(lpszStructType, szOID_NAME_CONSTRAINTS))
4619 encodeFunc = CRYPT_AsnEncodeNameConstraints;
4620 else if (!strcmp(lpszStructType, szOID_AUTHORITY_INFO_ACCESS))
4622 else if (!strcmp(lpszStructType, szOID_PKIX_POLICY_QUALIFIER_USERNOTICE))
4624 else if (!strcmp(lpszStructType, szOID_CTL))
4625 encodeFunc = CRYPT_AsnEncodeCTL;
4626 return encodeFunc;
4627}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
BOOL(WINAPI * CryptEncodeObjectExFunc)(DWORD, LPCSTR, const void *, DWORD, PCRYPT_ENCODE_PARA, BYTE *, DWORD *)
#define IS_INTOID(x)
static BOOL WINAPI CRYPT_AsnEncodeCertPolicyMappings(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3027
static BOOL WINAPI CRYPT_AsnEncodeAuthorityKeyId2(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2642
static BOOL WINAPI CRYPT_AsnEncodeCRLInfo(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:674
static BOOL WINAPI CRYPT_AsnEncodeAuthorityInfoAccess(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2713
static BOOL WINAPI CRYPT_AsnEncodeNameConstraints(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:4040
static BOOL WINAPI CRYPT_AsnEncodePKCSSignerInfo(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:4151
static BOOL WINAPI CRYPT_AsnEncodePolicyQualifierUserNotice(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1830
static BOOL WINAPI CRYPT_AsnEncodeUnicodeName(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1401
static BOOL WINAPI CRYPT_AsnEncodeSMIMECapabilities(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1694
static BOOL WINAPI CRYPT_AsnEncodeAuthorityKeyId(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2505
static BOOL WINAPI CRYPT_AsnEncodeName(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2304
static BOOL WINAPI CRYPT_AsnEncodeIssuingDistPoint(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3913
static BOOL WINAPI CRYPT_AsnEncodeRsaPubKey(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3139
static BOOL WINAPI CRYPT_AsnEncodeBasicConstraints(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2777
static BOOL WINAPI CRYPT_AsnEncodeCertPolicies(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2945
static BOOL WINAPI CRYPT_AsnEncodeCertPolicyConstraints(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3092
static BOOL WINAPI CRYPT_AsnEncodePubKeyInfo(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:425
static BOOL WINAPI CRYPT_AsnEncodeCertInfo(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:507
static BOOL WINAPI CRYPT_AsnEncodeBasicConstraints2(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:2816
static BOOL WINAPI CRYPT_AsnEncodeCTL(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1596
static BOOL WINAPI CRYPT_AsnEncodeCert(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:454
static BOOL WINAPI CRYPT_AsnEncodePKCSContentInfo(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:1966
static BOOL WINAPI CRYPT_AsnEncodeEnumerated(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3500
static BOOL WINAPI CRYPT_AsnEncodeCRLDistPoints(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
Definition: encode.c:3763
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define LOWORD(l)
Definition: pedump.c:82
#define X509_ISSUING_DIST_POINT
Definition: wincrypt.h:3424
#define X509_AUTHORITY_KEY_ID2
Definition: wincrypt.h:3398
#define szOID_AUTHORITY_KEY_IDENTIFIER
Definition: wincrypt.h:3175
#define CERT_ENCODING_TYPE_MASK
Definition: wincrypt.h:2290
#define PKCS_UTC_TIME
Definition: wincrypt.h:3382
#define szOID_RSA_SMIMECapabilities
Definition: wincrypt.h:3045
#define szOID_CERT_EXTENSIONS
Definition: wincrypt.h:3208
#define X509_POLICY_MAPPINGS
Definition: wincrypt.h:3426
#define X509_NAME
Definition: wincrypt.h:3372
#define X509_CERT_TO_BE_SIGNED
Definition: wincrypt.h:3366
#define X509_UNICODE_NAME
Definition: wincrypt.h:3385
#define szOID_POLICY_MAPPINGS
Definition: wincrypt.h:3199
#define PKCS_ATTRIBUTE
Definition: wincrypt.h:3387
#define szOID_CRL_DIST_POINTS
Definition: wincrypt.h:3196
#define X509_OCTET_STRING
Definition: wincrypt.h:3391
#define szOID_BASIC_CONSTRAINTS2
Definition: wincrypt.h:3189
#define X509_CERT
Definition: wincrypt.h:3365
#define szOID_LEGACY_POLICY_MAPPINGS
Definition: wincrypt.h:3179
#define X509_AUTHORITY_INFO_ACCESS
Definition: wincrypt.h:3399
#define szOID_NAME_CONSTRAINTS
Definition: wincrypt.h:3195
#define X509_ENUMERATED
Definition: wincrypt.h:3395
#define CMSG_ENCODING_TYPE_MASK
Definition: wincrypt.h:2291
#define szOID_ISSUER_ALT_NAME2
Definition: wincrypt.h:3188
#define PKCS_CONTENT_INFO
Definition: wincrypt.h:3400
#define szOID_KEY_USAGE
Definition: wincrypt.h:3185
#define X509_NAME_VALUE
Definition: wincrypt.h:3370
#define X509_EXTENSIONS
Definition: wincrypt.h:3369
#define X509_CHOICE_OF_TIME
Definition: wincrypt.h:3397
#define szOID_BASIC_CONSTRAINTS
Definition: wincrypt.h:3183
#define szOID_SUBJECT_KEY_IDENTIFIER
Definition: wincrypt.h:3184
#define X509_AUTHORITY_KEY_ID
Definition: wincrypt.h:3374
#define szOID_CRL_REASON_CODE
Definition: wincrypt.h:3191
#define X509_CERT_POLICIES
Definition: wincrypt.h:3381
#define szOID_RSA_signingTime
Definition: wincrypt.h:3039
#define X509_SEQUENCE_OF_ANY
Definition: wincrypt.h:3401
#define szOID_SUBJECT_ALT_NAME
Definition: wincrypt.h:3180
#define szOID_CERT_POLICIES
Definition: wincrypt.h:3197
#define PKCS7_SIGNER_INFO
Definition: wincrypt.h:3436
#define X509_BITS
Definition: wincrypt.h:3392
#define szOID_ENHANCED_KEY_USAGE
Definition: wincrypt.h:3202
#define szOID_SUBJECT_ALT_NAME2
Definition: wincrypt.h:3187
#define X509_BASIC_CONSTRAINTS2
Definition: wincrypt.h:3380
#define PKCS_SMIME_CAPABILITIES
Definition: wincrypt.h:3410
#define CMS_SIGNER_INFO
Definition: wincrypt.h:3437
#define szOID_PKIX_POLICY_QUALIFIER_USERNOTICE
Definition: wincrypt.h:3292
#define szOID_NEXT_UPDATE_LOCATION
Definition: wincrypt.h:3209
#define X509_PUBLIC_KEY_INFO
Definition: wincrypt.h:3373
#define szOID_AUTHORITY_INFO_ACCESS
Definition: wincrypt.h:3290
#define szOID_CTL
Definition: wincrypt.h:3245
#define X509_ALTERNATE_NAME
Definition: wincrypt.h:3377
#define szOID_AUTHORITY_KEY_IDENTIFIER2
Definition: wincrypt.h:3200
#define PKCS_ATTRIBUTES
Definition: wincrypt.h:3418
#define X509_NAME_CONSTRAINTS
Definition: wincrypt.h:3425
#define szOID_POLICY_CONSTRAINTS
Definition: wincrypt.h:3201
#define szOID_ISSUING_DIST_POINT
Definition: wincrypt.h:3194
#define PKCS_CTL
Definition: wincrypt.h:3404
#define X509_CRL_DIST_POINTS
Definition: wincrypt.h:3402
#define X509_CERT_CRL_TO_BE_SIGNED
Definition: wincrypt.h:3367
#define X509_BASIC_CONSTRAINTS
Definition: wincrypt.h:3378
#define X509_ENHANCED_KEY_USAGE
Definition: wincrypt.h:3403
#define X509_PKIX_POLICY_QUALIFIER_USERNOTICE
Definition: wincrypt.h:3414
#define szOID_ISSUER_ALT_NAME
Definition: wincrypt.h:3181
#define X509_KEY_USAGE
Definition: wincrypt.h:3379
#define X509_POLICY_CONSTRAINTS
Definition: wincrypt.h:3427
#define X509_UNICODE_NAME_VALUE
Definition: wincrypt.h:3389

Referenced by CryptEncodeObject(), and CryptEncodeObjectEx().

◆ CRYPT_ImportPublicKeyInfoEx()

static BOOL WINAPI CRYPT_ImportPublicKeyInfoEx ( HCRYPTPROV  hCryptProv,
DWORD  dwCertEncodingType,
PCERT_PUBLIC_KEY_INFO  pInfo,
ALG_ID  aiKeyAlg,
DWORD  dwFlags,
void pvAuxInfo,
HCRYPTKEY phKey 
)
static

Definition at line 4981 of file encode.c.

4984{
4985 static HCRYPTOIDFUNCSET set = NULL;
4986 ConvertPublicKeyInfoFunc convertFunc = NULL;
4987 HCRYPTOIDFUNCADDR hFunc = NULL;
4988 BOOL ret;
4989 DWORD pubKeySize;
4990 LPBYTE pubKey;
4991
4992 TRACE_(crypt)("(%08lx, %08x, %p, %08x, %08x, %p, %p)\n", hCryptProv,
4993 dwCertEncodingType, pInfo, aiKeyAlg, dwFlags, pvAuxInfo, phKey);
4994
4995 if (!set)
4997 CryptGetOIDFunctionAddress(set, dwCertEncodingType, pInfo->Algorithm.pszObjId,
4998 0, (void **)&convertFunc, &hFunc);
4999 if (convertFunc)
5000 {
5001 pubKey = NULL;
5002 pubKeySize = 0;
5003 ret = convertFunc(dwCertEncodingType, pInfo, aiKeyAlg, dwFlags, &pubKey, &pubKeySize);
5004 if (ret)
5005 {
5006 ret = CryptImportKey(hCryptProv, pubKey, pubKeySize, 0, 0, phKey);
5008 }
5009
5011 return ret;
5012 }
5013
5015 pInfo->PublicKey.pbData, pInfo->PublicKey.cbData, 0, NULL, &pubKeySize);
5016 if (ret)
5017 {
5018 pubKey = CryptMemAlloc(pubKeySize);
5019
5020 if (pubKey)
5021 {
5023 pInfo->PublicKey.pbData, pInfo->PublicKey.cbData, 0, pubKey,
5024 &pubKeySize);
5025 if (ret)
5026 {
5027 if(aiKeyAlg)
5028 ((BLOBHEADER*)pubKey)->aiKeyAlg = aiKeyAlg;
5029 ret = CryptImportKey(hCryptProv, pubKey, pubKeySize, 0, 0,
5030 phKey);
5031 }
5033 }
5034 else
5035 ret = FALSE;
5036 }
5037 return ret;
5038}
BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6278
BOOL WINAPI CryptImportKey(HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey)
Definition: crypt.c:1850
BOOL(WINAPI * ConvertPublicKeyInfoFunc)(DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, BYTE **ppbData, DWORD *dwDataLen)
Definition: encode.c:4977
#define CRYPT_OID_CONVERT_PUBLIC_KEY_INFO_FUNC
Definition: wincrypt.h:2508

Referenced by CryptImportPublicKeyInfoEx().

◆ CRYPT_LoadEncoderExFunc()

static CryptEncodeObjectExFunc CRYPT_LoadEncoderExFunc ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
HCRYPTOIDFUNCADDR hFunc 
)
static

Definition at line 4642 of file encode.c.

4644{
4645 static HCRYPTOIDFUNCSET set = NULL;
4646 CryptEncodeObjectExFunc encodeFunc = NULL;
4647
4648 if (!set)
4651 (void **)&encodeFunc, hFunc);
4652 return encodeFunc;
4653}
#define CRYPT_OID_ENCODE_OBJECT_EX_FUNC
Definition: wincrypt.h:2494

Referenced by CryptEncodeObject(), and CryptEncodeObjectEx().

◆ CRYPT_LoadEncoderFunc()

static CryptEncodeObjectFunc CRYPT_LoadEncoderFunc ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
HCRYPTOIDFUNCADDR hFunc 
)
static

Definition at line 4629 of file encode.c.

4631{
4632 static HCRYPTOIDFUNCSET set = NULL;
4633 CryptEncodeObjectFunc encodeFunc = NULL;
4634
4635 if (!set)
4638 (void **)&encodeFunc, hFunc);
4639 return encodeFunc;
4640}
BOOL(WINAPI * CryptEncodeObjectFunc)(DWORD, LPCSTR, const void *, BYTE *, DWORD *)
Definition: encode.c:55
#define CRYPT_OID_ENCODE_OBJECT_FUNC
Definition: wincrypt.h:2492

Referenced by CryptEncodeObject(), and CryptEncodeObjectEx().

◆ CryptEncodeObject()

BOOL WINAPI CryptEncodeObject ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
BYTE pbEncoded,
DWORD pcbEncoded 
)

Definition at line 4655 of file encode.c.

4657{
4658 BOOL ret = FALSE;
4659 HCRYPTOIDFUNCADDR hFunc = NULL;
4660 CryptEncodeObjectFunc pCryptEncodeObject = NULL;
4661 CryptEncodeObjectExFunc pCryptEncodeObjectEx = NULL;
4662
4663 TRACE_(crypt)("(0x%08x, %s, %p, %p, %p)\n", dwCertEncodingType,
4664 debugstr_a(lpszStructType), pvStructInfo, pbEncoded,
4665 pcbEncoded);
4666
4667 if (!pbEncoded && !pcbEncoded)
4668 {
4670 return FALSE;
4671 }
4672
4673 if (!(pCryptEncodeObjectEx = CRYPT_GetBuiltinEncoder(dwCertEncodingType,
4674 lpszStructType)))
4675 {
4676 TRACE_(crypt)("OID %s not found or unimplemented, looking for DLL\n",
4677 debugstr_a(lpszStructType));
4678 pCryptEncodeObject = CRYPT_LoadEncoderFunc(dwCertEncodingType,
4679 lpszStructType, &hFunc);
4680 if (!pCryptEncodeObject)
4681 pCryptEncodeObjectEx = CRYPT_LoadEncoderExFunc(dwCertEncodingType,
4682 lpszStructType, &hFunc);
4683 }
4684 if (pCryptEncodeObject)
4685 ret = pCryptEncodeObject(dwCertEncodingType, lpszStructType,
4686 pvStructInfo, pbEncoded, pcbEncoded);
4687 else if (pCryptEncodeObjectEx)
4688 ret = pCryptEncodeObjectEx(dwCertEncodingType, lpszStructType,
4689 pvStructInfo, 0, NULL, pbEncoded, pcbEncoded);
4690 if (hFunc)
4692 TRACE_(crypt)("returning %d\n", ret);
4693 return ret;
4694}
static CryptEncodeObjectExFunc CRYPT_LoadEncoderExFunc(DWORD dwCertEncodingType, LPCSTR lpszStructType, HCRYPTOIDFUNCADDR *hFunc)
Definition: encode.c:4642
static CryptEncodeObjectFunc CRYPT_LoadEncoderFunc(DWORD dwCertEncodingType, LPCSTR lpszStructType, HCRYPTOIDFUNCADDR *hFunc)
Definition: encode.c:4629
static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType, LPCSTR lpszStructType)
Definition: encode.c:4435
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101

Referenced by CDataEncodeMsg_GetParam(), CRYPT_CopyKeyIdAsIssuerAndSerial(), CRYPT_ExportPublicKeyInfoEx(), CRYPT_SizeOfKeyIdAsIssuerAndSerial(), and CryptSignAndEncodeCertificate().

◆ CryptEncodeObjectEx()

BOOL WINAPI CryptEncodeObjectEx ( DWORD  dwCertEncodingType,
LPCSTR  lpszStructType,
const void pvStructInfo,
DWORD  dwFlags,
PCRYPT_ENCODE_PARA  pEncodePara,
void pvEncoded,
DWORD pcbEncoded 
)

Definition at line 4696 of file encode.c.

4699{
4700 BOOL ret = FALSE;
4701 HCRYPTOIDFUNCADDR hFunc = NULL;
4702 CryptEncodeObjectExFunc encodeFunc = NULL;
4703
4704 TRACE_(crypt)("(0x%08x, %s, %p, 0x%08x, %p, %p, %p)\n", dwCertEncodingType,
4705 debugstr_a(lpszStructType), pvStructInfo, dwFlags, pEncodePara,
4706 pvEncoded, pcbEncoded);
4707
4708 if (!pvEncoded && !pcbEncoded)
4709 {
4711 return FALSE;
4712 }
4713
4716 if (!pvEncoded) {
4718 return FALSE;
4719 }
4720 *(BYTE **)pvEncoded = NULL;
4721 }
4722 encodeFunc = CRYPT_GetBuiltinEncoder(dwCertEncodingType, lpszStructType);
4723 if (!encodeFunc)
4724 {
4725 TRACE_(crypt)("OID %s not found or unimplemented, looking for DLL\n",
4726 debugstr_a(lpszStructType));
4727 encodeFunc = CRYPT_LoadEncoderExFunc(dwCertEncodingType, lpszStructType,
4728 &hFunc);
4729 }
4730 if (encodeFunc)
4731 ret = encodeFunc(dwCertEncodingType, lpszStructType, pvStructInfo,
4732 dwFlags, pEncodePara, pvEncoded, pcbEncoded);
4733 else
4734 {
4735 CryptEncodeObjectFunc pCryptEncodeObject =
4736 CRYPT_LoadEncoderFunc(dwCertEncodingType, lpszStructType, &hFunc);
4737
4738 if (pCryptEncodeObject)
4739 {
4741 {
4742 ret = pCryptEncodeObject(dwCertEncodingType, lpszStructType,
4743 pvStructInfo, NULL, pcbEncoded);
4744 if (ret && (ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
4745 pvEncoded, pcbEncoded, *pcbEncoded)))
4746 ret = pCryptEncodeObject(dwCertEncodingType,
4747 lpszStructType, pvStructInfo, *(BYTE **)pvEncoded,
4748 pcbEncoded);
4749 }
4750 else
4751 ret = pCryptEncodeObject(dwCertEncodingType, lpszStructType,
4752 pvStructInfo, pvEncoded, pcbEncoded);
4753 }
4754 }
4755 if (hFunc)
4757 TRACE_(crypt)("returning %d\n", ret);
4758 return ret;
4759}
#define NOERROR
Definition: winerror.h:2354

Referenced by CDataEncodeMsg_Update(), CDecodeSignedMsg_GetParam(), CEnvelopedEncodeMsg_GetParam(), CertCreateSelfSignCertificate(), CertSetEnhancedKeyUsage(), CertStrToNameW(), CHashEncodeMsg_GetParam(), CRYPT_CreateSignedCert(), CRYPT_EncodeValueWithType(), CryptMsgEncodeAndSignCTL(), CSignedEncodeMsg_GetParam(), CSignedMsgData_UpdateAuthenticatedAttributes(), and init_function_pointers().

◆ CryptExportPublicKeyInfo()

BOOL WINAPI CryptExportPublicKeyInfo ( HCRYPTPROV_OR_NCRYPT_KEY_HANDLE  hCryptProv,
DWORD  dwKeySpec,
DWORD  dwCertEncodingType,
PCERT_PUBLIC_KEY_INFO  pInfo,
DWORD pcbInfo 
)

Definition at line 4775 of file encode.c.

4777{
4778 return CryptExportPublicKeyInfoEx(hCryptProv, dwKeySpec, dwCertEncodingType,
4779 NULL, 0, NULL, pInfo, pcbInfo);
4780}
BOOL WINAPI CryptExportPublicKeyInfoEx(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, DWORD dwFlags, void *pvAuxInfo, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)
Definition: encode.c:4934

Referenced by CertCreateSelfSignCertificate().

◆ CryptExportPublicKeyInfoEx()

BOOL WINAPI CryptExportPublicKeyInfoEx ( HCRYPTPROV_OR_NCRYPT_KEY_HANDLE  hCryptProv,
DWORD  dwKeySpec,
DWORD  dwCertEncodingType,
LPSTR  pszPublicKeyObjId,
DWORD  dwFlags,
void pvAuxInfo,
PCERT_PUBLIC_KEY_INFO  pInfo,
DWORD pcbInfo 
)

Definition at line 4934 of file encode.c.

4937{
4938 static HCRYPTOIDFUNCSET set = NULL;
4939 BOOL ret;
4940 ExportPublicKeyInfoExFunc exportFunc = NULL;
4941 HCRYPTOIDFUNCADDR hFunc = NULL;
4942
4943 TRACE_(crypt)("(%08lx, %d, %08x, %s, %08x, %p, %p, %d)\n", hCryptProv,
4944 dwKeySpec, dwCertEncodingType, debugstr_a(pszPublicKeyObjId), dwFlags,
4945 pvAuxInfo, pInfo, pInfo ? *pcbInfo : 0);
4946
4947 if (!hCryptProv)
4948 {
4950 return FALSE;
4951 }
4952
4953 if (pszPublicKeyObjId)
4954 {
4955 if (!set)
4957 0);
4959 0, (void **)&exportFunc, &hFunc);
4960 }
4961 if (!exportFunc)
4962 exportFunc = CRYPT_ExportPublicKeyInfoEx;
4963 ret = exportFunc(hCryptProv, dwKeySpec, dwCertEncodingType,
4964 pszPublicKeyObjId, dwFlags, pvAuxInfo, pInfo, pcbInfo);
4965 if (hFunc)
4967 return ret;
4968}
static BOOL WINAPI CRYPT_ExportPublicKeyInfoEx(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, DWORD dwFlags, void *pvAuxInfo, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)
Definition: encode.c:4786
BOOL(WINAPI * ExportPublicKeyInfoExFunc)(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCryptProv, DWORD dwKeySpec, DWORD dwCertEncodingType, LPSTR pszPublicKeyObjId, DWORD dwFlags, void *pvAuxInfo, PCERT_PUBLIC_KEY_INFO pInfo, DWORD *pcbInfo)
Definition: encode.c:4930
#define CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC
Definition: wincrypt.h:2502

Referenced by CryptExportPublicKeyInfo(), testAcquireCertPrivateKey(), testExportPublicKey(), testVerifyCertSig(), and testVerifyCertSigEx().

◆ CryptImportPublicKeyInfo()

BOOL WINAPI CryptImportPublicKeyInfo ( HCRYPTPROV  hCryptProv,
DWORD  dwCertEncodingType,
PCERT_PUBLIC_KEY_INFO  pInfo,
HCRYPTKEY phKey 
)

Definition at line 4970 of file encode.c.

4972{
4973 return CryptImportPublicKeyInfoEx(hCryptProv, dwCertEncodingType, pInfo,
4974 0, 0, NULL, phKey);
4975}
BOOL WINAPI CryptImportPublicKeyInfoEx(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey)
Definition: encode.c:5044

Referenced by CDecodeSignedMsg_VerifySignatureWithKey(), CertGetPublicKeyLength(), CRYPT_ExportKeyTrans(), and testAcquireCertPrivateKey().

◆ CryptImportPublicKeyInfoEx()

BOOL WINAPI CryptImportPublicKeyInfoEx ( HCRYPTPROV  hCryptProv,
DWORD  dwCertEncodingType,
PCERT_PUBLIC_KEY_INFO  pInfo,
ALG_ID  aiKeyAlg,
DWORD  dwFlags,
void pvAuxInfo,
HCRYPTKEY phKey 
)

Definition at line 5044 of file encode.c.

5047{
5048 static HCRYPTOIDFUNCSET set = NULL;
5049 BOOL ret;
5050 ImportPublicKeyInfoExFunc importFunc = NULL;
5051 HCRYPTOIDFUNCADDR hFunc = NULL;
5052
5053 TRACE_(crypt)("(%08lx, %08x, %p, %08x, %08x, %p, %p)\n", hCryptProv,
5054 dwCertEncodingType, pInfo, aiKeyAlg, dwFlags, pvAuxInfo, phKey);
5055
5056 if (!set)
5059 pInfo->Algorithm.pszObjId, 0, (void **)&importFunc, &hFunc);
5060 if (!importFunc)
5061 importFunc = CRYPT_ImportPublicKeyInfoEx;
5062 ret = importFunc(hCryptProv, dwCertEncodingType, pInfo, aiKeyAlg, dwFlags,
5063 pvAuxInfo, phKey);
5064 if (hFunc)
5066 return ret;
5067}
static BOOL WINAPI CRYPT_ImportPublicKeyInfoEx(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey)
Definition: encode.c:4981
BOOL(WINAPI * ImportPublicKeyInfoExFunc)(HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, ALG_ID aiKeyAlg, DWORD dwFlags, void *pvAuxInfo, HCRYPTKEY *phKey)
Definition: encode.c:5040
#define CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC
Definition: wincrypt.h:2503

Referenced by CRYPT_VerifySignature(), CryptImportPublicKeyInfo(), rdssl_cert_to_rkey(), and testImportPublicKey().

◆ isprintableW()

static BOOL isprintableW ( WCHAR  wc)
inlinestatic

Definition at line 2079 of file encode.c.

2080{
2081 return isalnumW(wc) || isspaceW(wc) || wc == '\'' || wc == '(' ||
2082 wc == ')' || wc == '+' || wc == ',' || wc == '-' || wc == '.' ||
2083 wc == '/' || wc == ':' || wc == '=' || wc == '?';
2084}
#define isspaceW(n)
Definition: unicode.h:58
#define isalnumW(n)
Definition: unicode.h:55

Referenced by CRYPT_AsnEncodePrintableString().

◆ PFXExportCertStore()

BOOL WINAPI PFXExportCertStore ( HCERTSTORE  hStore,
CRYPT_DATA_BLOB pPFX,
LPCWSTR  szPassword,
DWORD  dwFlags 
)

Definition at line 4761 of file encode.c.

4763{
4764 return PFXExportCertStoreEx(hStore, pPFX, szPassword, NULL, dwFlags);
4765}
BOOL WINAPI PFXExportCertStoreEx(HCERTSTORE hStore, CRYPT_DATA_BLOB *pPFX, LPCWSTR szPassword, void *pvReserved, DWORD dwFlags)
Definition: encode.c:4767

Referenced by save_pfx().

◆ PFXExportCertStoreEx()

BOOL WINAPI PFXExportCertStoreEx ( HCERTSTORE  hStore,
CRYPT_DATA_BLOB pPFX,
LPCWSTR  szPassword,
void pvReserved,
DWORD  dwFlags 
)

Definition at line 4767 of file encode.c.

4769{
4770 FIXME_(crypt)("(%p, %p, %p, %p, %08x): stub\n", hStore, pPFX, szPassword,
4772 return FALSE;
4773}
#define FIXME_(x)
Definition: compat.h:77
static LPCSTR DWORD void * pvReserved
Definition: str.c:196

Referenced by PFXExportCertStore().

◆ WINE_DECLARE_DEBUG_CHANNEL()

WINE_DECLARE_DEBUG_CHANNEL ( crypt  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( cryptasn  )