Create/Dispose

Creates an instance of the HCkJweW object and returns a handle ("void *" pointer).
The handle is passed in the 1st argument for the functions listed on this page.

void CkJweW_Dispose(HCkJweW handle);

Objects created by calling CkJweW_Create must be freed by calling this method.
A memory leak occurs if a handle is not disposed by calling this function.
Also, any handle returned by a Chilkat "C" function must also be freed by the application by calling the appropriate Dispose method, such as CkJweW_Dispose.

Properties

DebugLogFilePath

If set to a file path, causes each Chilkat method or property call to automatically append it's LastErrorText to the specified log file. The information is appended such that if a hang or crash occurs, it is possible to see the context in which the problem occurred, as well as a history of all Chilkat calls up to the point of the problem. The VerboseLogging property can be set to provide more detailed information.

This property is typically used for debugging the rare cases where a Chilkat method call hangs or generates an exception that halts program execution (i.e. crashes).
A hang or crash should generally never happen. The typical causes of a hang are:

a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired,

the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or

there is an internal problem (bug) in the Chilkat code that causes the hang.

LastErrorText

Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

LastMethodSuccess

Indicate whether the last method call succeeded or failed. A value of TRUE indicates success, a value of FALSE indicates failure. This property is automatically set for method calls. It is not modified by property accesses. The property is automatically set to indicate success for the following types of method calls:

PreferCompact

Controls whether the JWE Compact Serialization or JWE JSON Serialization is preferred when creating JWEs. The default value is TRUE, which is to use compact serialization when possible. If multiple recipients exist, or if any unprotected headers exist, then JWE JSON Serialization is used regardless of this property setting.

PreferFlattened

Controls whether the flattened serialization is preferred when JWE JSON Serialization is used. The default value is TRUE, which is to use the flattened serialization when possible. If multiple recipients exist, then the general (non-flattened) JWE JSON Serialization is used regardless of this property setting.

VerboseLogging

If set to TRUE, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is FALSE. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

Decrypts a JWE and returns the original (decrypted) string content. The byte representation of the decrypted bytes is indicated by charset (such as "utf-8"). (The charset tells Chilkat how to intepret the decrypted bytes as characters.)

The index specifies which recipient key is used for decryption. (Most JWEs have only a single recipent, and thus the index is typically 0.)

DecryptBd

Decrypts the loaded JWE and appends the decrypted bytes to the contents of bd. The index specifies which recipient key is used for decryption. (Most JWEs have only a single recipent, and thus the index is typically 0.)

DecryptSb

Decrypts the loaded JWE and appends the decrypted content to contentSb. The byte representation of the decrypted bytes is indicated by charset (such as "utf-8"). (This tells Chilkat how to interpret the bytes as characters.)

The index specifies which recipient key is used for decryption. (Most JWEs have only a single recipent, and thus the index is typically 0.)

FindRecipient

Finds the index of the recipient with a header parameter (paramName) equal to a specified value (paramValue). Returns -1 if no recipient contains a header with the given name/value. If caseSensitive is TRUE, then the header param name/value comparisons are case sensitive. Otherwise it is case insensitive.

The procedure for decrypting a JWE with multiple recipients is the following:

Load the JWE via one of the Load* methods.

Find the recipient index by some identifying header paramter. The typical case is via the "kid" header parameter. ("kid" is an arbitrary key ID applications can assign to identify keys.)

Set the key for decryption at the found index by calling SetPrivateKey, SetWrappingKey, or SetPassword, depending on the type of key wrapping that is employed.

Call Decrypt, DecryptSb, or DecryptBd to decrypt for the recipient (and key) at the given index.

SetAad

Sets the optional Additional Authenticated Data. This is only used for non-compact serializations. The charset specifies the character encoding (such as "utf-8") to be used for the byte representation for the additional authenticated data.

SetPassword

Sets the PBES2 password for key encryption or decryption. This is for the case where the content encryption key (CEK) is encrypted using PBES2. An PBES2 password should be used in the cases where the "alg" header parameter value is equal to one of the following:

PBES2-HS256+A128KW
PBES2-HS384+A192KW
PBES2-HS512+A256KW

The index is the index of the recipient, where the 1st recipient is at index 0. (The typical use case for JWEs is for a single recipient.)

SetPrivateKey

Sets a private key for RSA key unwrapping/decryption. This is for the case where the content encryption key (CEK) is encrypted using RSA. An RSA private key should be used for decrypting in the cases where the "alg" header parameter value is equal to one of the following:

SetPublicKey

Sets a public key for RSA key wrapping encryption. This is for the case where the content encryption key (CEK) is encrypted using RSA. An RSA public key should be used when encrypting for the cases where the "alg" header parameter value is equal to one of the following:

RSA1_5
RSA-OAEP
RSA-OAEP-256

The index is the index of the recipient, where the 1st recipient is at index 0. (The typical use case for JWEs is for a single recipient.)

SetWrappingKey

Sets the AES wrapping key for encryption or decryption. This is for the case where the content encryption key (CEK) is encrypted using AES Key Wrap or AES GCM. An AES key should be used in the cases where the "alg" header parameter value is equal to one of the following:

A128KW
A192KW
A256KW
A128GCMKW
A192GCMKW
A256GCMKW
dir

The index is the index of the recipient, where the 1st recipient is at index 0. (The typical use case for JWEs is for a single recipient.)

Note: This method also sets the shared direct symmetric key for the case when the "alg" is equal to "dir". In this case, the key specified is not actualy a key encryption key, but is the direct content encryption key.

The encoding indicates the representation, such as "base64", "hex", "base64url", etc. of the encodedKey.