ReactOS 0.4.15-dev-8093-g3285f69
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:33
#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: debug.h:114
#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:905

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

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:906
WORD wHour
Definition: winbase.h:909
WORD wSecond
Definition: winbase.h:911
WORD wMinute
Definition: winbase.h:910
WORD wDay
Definition: winbase.h:908
#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;