X509_UNICODE_ANY_STRING

When X509_UNICODE_ANY_STRING is used for the lpszStructType with CryptEncodeObject, CryptEncodeObjectEx, CryptDecodeObject, or CryptDecodeObjectEx the following details apply.

Object Identifier String

N/A

Corresponding Data Structure being encoded or decoded

pvStructInfo points to CERT_NAME_VALUE structure.

Additional Details

The name values are unicode strings.

For CryptEncodeObject and CryptEncodeObjectEx:

Value.pbData points to the unicode string.

If Value.cbData = 0, then, the unicode string is NULL terminated.

Otherwise, Value.cbData is the unicode string byte count. The byte count is twice the character count.

If the unicode string contains an invalid character for the specified dwValueType, then, *pcbEncoded is updated with the unicode character index of the first invalid character. LastError is set to:

CRYPT_E_INVALID_NUMERIC_STRING,
CRYPT_E_INVALID_PRINTABLE_STRING, or
CRYPT_E_INVALID_IA5_STRING.

The unicode string is converted before being encoded according to the specified dwValueType. If dwValueType is set to 0, LastError is set to E_INVALIDARG.

If the dwValueType isn't one of the character strings (it's a CERT_RDN_ENCODED_BLOB or CERT_RDN_OCTET_STRING), then, CryptEncodeObject will return FALSE with LastError set to CRYPT_E_NOT_CHAR_STRING.

For CryptDecodeObject and CryptDecodeObjectEx:

Value.pbData points to a NULL terminated unicode string. Value.cbData contains the byte count of the unicode string excluding the NULL terminator. dwValueType contains the type used in the encoded object. It's not forced to CERT_RDN_UNICODE_STRING. The encoded value is converted to the unicode string according to the dwValueType.

If the encoded object isn't one of the character string types, then, CryptDecodeObject will return FALSE with LastError set to CRYPT_E_NOT_CHAR_STRING. For a non character string, decode using X509_NAME_VALUE or X509_ANY_STRING.