The CryptDecodeObjectEx function decodes a structure of the type indicated by the lpszStructType parameter. CryptDecodeObjectEx offers a significant performance improvement over CryptDecodeObject by supporting memory allocation with the CRYPT_DECODE_ALLOC_FLAG value.
BOOL WINAPI CryptDecodeObjectEx( _In_ DWORD dwCertEncodingType, _In_ LPCSTR lpszStructType, _In_ const BYTE *pbEncoded, _In_ DWORD cbEncoded, _In_ DWORD dwFlags, _In_ PCRYPT_DECODE_PARA pDecodePara, _Out_ void *pvStructInfo, _Inout_ DWORD *pcbStructInfo );
- dwCertEncodingType [in]
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING
Currently defined encoding types are:
Note Either a certificate or message encoding type is required. X509_ASN_ENCODING is the default. If that type is indicated, it is used. Otherwise, if the PKCS7_ASN_ENCODING type is indicated, it is used.
- lpszStructType [in]
A pointer to an object identifier (OID) that defines the structure type. If the high-order word of the lpszStructType parameter is zero, the low-order word specifies the integer identifier for the type of the specified structure. Otherwise, this parameter is a long pointer to a null-terminated string.
For more information about object identifier strings, their predefined constants, and corresponding structures, see Constants for CryptEncodeObject and CryptDecodeObject.
- pbEncoded [in]
A pointer to the data to be decoded. The structure must be of the type specified by lpszStructType.
- cbEncoded [in]
The number of bytes pointed to by pbEncoded. This is the number of bytes to be decoded.
- dwFlags [in]
This parameter can be one or more of the following flags. The flags can be combined by using a bitwise-OR operation.
- pDecodePara [in]
A pointer to a CRYPT_DECODE_PARA structure that contains decoding paragraph information. If pDecodePara is set to NULL, then LocalAlloc and LocalFree are used to allocate and free memory. If pDecodePara points to a CRYPT_DECODE_PARA structure, that structure passes in callback functions to allocate and free memory. These callback functions override the default memory allocation of LocalAlloc and LocalFree.
- pvStructInfo [out]
If the dwFlags CRYPT_ENCODE_ALLOC_FLAG is set, pvStructInfo is not a pointer to a buffer but is the address of a pointer to the buffer. Because memory is allocated inside the function and the pointer is stored at *pvStructInfo, pvStructInfo must never be NULL.
If CRYPT_ENCODE_ALLOC_FLAG is not set, pvStructInfo is a pointer to a buffer that receives the decoded structure. When the buffer that is specified is not large enough to receive the decoded structure, the function sets the ERROR_MORE_DATA code and stores the required buffer size, in bytes, in the variable pointed to by pcbStructInfo.
This parameter can be NULL to retrieve the size of this information for memory allocation purposes. For more information, see Retrieving Data of Unknown Length.
- pcbStructInfo [in, out]
A pointer to a DWORD variable that contains the size, in bytes, of the buffer pointed to by the pvStructInfo parameter. When the function returns, the DWORD value contains the number of bytes stored in the buffer. The size contained in the variable pointed to by pcbStructInfo can indicate a size larger than the decoded structure because the decoded structure can include pointers to auxiliary data. This size is the sum of the size needed by the decoded structure and the auxiliary data.
When CRYPT_DECODE_ALLOC_FLAG is set, the initial value of *pcbStructInfo is not used by the function, and on return, *pcbStructInfo contains the number of bytes allocated for pvStructInfo.Note When processing the data returned in the buffer, applications must use the actual size of the data returned. The actual size can be slightly smaller than the size of the buffer specified on input. (On input, buffer sizes are usually specified large enough to ensure that the largest possible output data fits in the buffer.) On output, the variable pointed to by this parameter is updated to reflect the actual size of the data copied to the buffer.
If the function succeeds, the function returns nonzero (TRUE).
If the function fails, it returns zero (FALSE). For extended error information, call GetLastError. The following table shows some possible error codes.
An error was encountered while decoding.
A decoding function could not be found for the specified dwCertEncodingType and lpszStructType.
If the buffer specified by the pvStructInfo parameter is not large enough to hold the returned data, the function sets the ERROR_MORE_DATA code and stores the required buffer size, in bytes, in the variable pointed to by pcbStructInfo.
When encoding a cryptographic object using the preferred CryptEncodeObjectEx function, the terminating NULL character is included. When decoding, using the preferred CryptDecodeObjectEx function, the terminating NULL character is not retained.
Each constant in the list below has an associated structure type that is pointed to by the pvStructInfo parameter. The structure pointed to, directly or indirectly, has a reference to a CERT_ALT_NAME_ENTRY structure.
The CRYPT_DECODE_ENABLE_PUNYCODE_FLAG flag, in conjunction with the value of the dwAltNameChoice member of the CERT_ALT_NAME_ENTRY structure, determines the manner in which strings are encoded.
|CERT_ALT_NAME_DNS_NAME||If the host name contains a Punycode encoded IA5String string, it is converted to the Unicode equivalent.|
|CERT_ALT_NAME_RFC822_NAME||If the host name portion of the email address contains a Punycode encoded IA5String string, it is converted to its Unicode equivalent.|
|CERT_ALT_NAME_URL||The URI is decoded. If the server host name of the URI contains a Punycode encoded IA5String string, the host name string is decoded to the Unicode equivalent.|
Each constant in the list below has an associated structure type that is pointed to by the pvStructInfo parameter. The structure pointed to, directly or indirectly, has a reference to a CERT_HASHED_URL structure.
When decoding the CERT_HASHED_URL structure value, the URI is decoded. If the host name contains a Punycode encoded host name, it is converted to the Unicode equivalent.
Each X509_UNICODE_NAME constant in the list below has an associated structure type that is pointed to by the pvStructInfo parameter.
If the pszObjId member of the CERT_RDN_ATTR structure is set to szOID_RSA_emailAddr and the email address in the Value member contains Punycode encoded string, it is converted to the Unicode equivalent.
For an example that uses this function, see Example C Program: ASN.1 Encoding and Decoding.
Minimum supported client
|Windows XP [desktop apps only]|
Minimum supported server
|Windows Server 2003 [desktop apps only]|