Jwe ActiveX Reference Documentation
Jwe
Current Version: 10.1.2
An API for JSON Web Encryption (JWE). Provides the ability to create (encrypt) and decrypt JWE's.
Supported Algorithms:
- RSAES OAEP 256 (using SHA-256 and MGF1 with SHA-256) encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- RSAES OAEP (using SHA-1 and MGF1 with SHA-1) encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- RSAES-PKCS1-V1_5 encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- Direct symmetric key encryption with pre-shared key A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM and A256GCM
- A128KW, A192KW, A256KW encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- A128GCMKW, A192GCMKW, A256GCMKW encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- PBES2-HS256+A128KW, PBES2-HS384+A192KW, PBES2-HS512+A256KW with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
Object Creation
Note: For versions of Chilkat < 10.0.0, use "Chilkat_9_5_0.Jwe" instead of "Chilkat.Jwe" For a specific major version, use "Chilkat.Jwe.<major_version>", such as "Chilkat.Jwe.10" for Chilkat v10.*.* See Chilkat ActiveX Object Creation (ASP) set obj = Server.CreateObject("Chilkat.Jwe") (AutoIt) $obj = ObjCreate("Chilkat.Jwe") (Visual Basic 6.0) Dim obj As New ChilkatJwe (VBScript) set obj = CreateObject("Chilkat.Jwe") (Delphi) obj := TChilkatJwe.Create(Self); (FoxPro) loObject = CreateObject('Chilkat.Jwe') (PowerBuilder) lole_object = create oleobject li_rc = lole_object.ConnectToNewObject("Chilkat.Jwe") (SQL Server) EXEC @hr = sp_OACreate 'Chilkat.Jwe', @obj OUT (Javascript) var obj = new ActiveXObject("Chilkat.Jwe");
Properties
DebugLogFilePath
If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.
Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.
Possible causes of hangs include:
- A timeout property set to 0, indicating an infinite timeout.
- A hang occurring within an event callback in the application code.
- An internal bug in the Chilkat code causing the hang.
LastBinaryResult
This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. It is only accessible if Chilkat.Global.KeepBinaryResult is set to 1. This feature allows for the retrieval of large varbinary results in an SQL Server environment, which has restrictions on returning large data via method calls, though temp tables can handle binary properties.
topLastErrorHtml
Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastErrorText
Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
LastErrorXml
Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastMethodSuccess
Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages.
topLastStringResult
In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. It is accessible only when Chilkat.Global.KeepStringResult is set to TRUE. SQL Server has limitations on string lengths returned from methods and properties, but temp tables can be used to access large strings.
LastStringResultLen
The length, in characters, of the string contained in the LastStringResult property.
topNumRecipients
The number of recipients for this JWE.
topPreferCompact
Controls whether the JWE Compact Serialization or JWE JSON Serialization is preferred when creating JWEs. The default value is 1, 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.
topPreferFlattened
Controls whether the flattened serialization is preferred when JWE JSON Serialization is used. The default value is 1, 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.
UncommonOptions
This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.
topVerboseLogging
If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.
topVersion
Version of the component/library, such as "10.1.0"
Methods
Decrypt
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.)
Supported Algorithms:
- RSAES OAEP 256 (using SHA-256 and MGF1 with SHA-256) encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- RSAES OAEP (using SHA-1 and MGF1 with SHA-1) encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- RSAES-PKCS1-V1_5 encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- Direct symmetric key encryption with pre-shared key A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM and A256GCM
- A128KW, A192KW, A256KW encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- A128GCMKW, A192GCMKW, A256GCMKW encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- PBES2-HS256+A128KW, PBES2-HS384+A192KW, PBES2-HS512+A256KW with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
Returns Nothing on failure
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.)
Returns 1 for success, 0 for failure.
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.)
Returns 1 for success, 0 for failure.
Encrypt
Encrypts string content to produce a JWE. The byte representation of the content is indicated by charset (such as "utf-8").
Supported Algorithms:
- RSAES OAEP 256 (using SHA-256 and MGF1 with SHA-256) encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- RSAES OAEP (using SHA-1 and MGF1 with SHA-1) encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- RSAES-PKCS1-V1_5 encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- Direct symmetric key encryption with pre-shared key A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM and A256GCM
- A128KW, A192KW, A256KW encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- A128GCMKW, A192GCMKW, A256GCMKW encryption with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
- PBES2-HS256+A128KW, PBES2-HS384+A192KW, PBES2-HS512+A256KW with A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM
Returns Nothing on failure
EncryptBd
Encrypts the contents of contentBd to produce a JWE that is appended to the contents of jweSb. (This method provides the means to produce a JWE from binary content.)
Returns 1 for success, 0 for failure.
EncryptSb
Encrypts the contents of contentSb to produce a JWE that is appended to the contents of jweSb. The byte representation of the string to be encrypted is indicated by charset (such as "utf-8").
Returns 1 for success, 0 for failure.
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 1, 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.
GetHeader
Returns the JSON header from the JWE. The JSON header is loaded into json.
Returns 1 for success, 0 for failure.
topGetProtectedHeader
Returns the shared protected JSON header from the JWE. The shared protected header is loaded into json.
Returns 1 for success, 0 for failure.
topLoadJwe
Loads the contents of a JWE.
Returns 1 for success, 0 for failure.
LoadJweSb
Loads the contents of a JWE from a StringBuilder object.
Returns 1 for success, 0 for failure.
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.
Returns 1 for success, 0 for failure.
topSetAadBd
Sets the optional Additional Authenticated Data. This is only used for non-compact serializations. This method provides a way for binary (non-text) additional authenticated data to be used.
Returns 1 for success, 0 for failure.
topSetPassword
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+A256KWThe 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.)
Returns 1 for success, 0 for failure.
topSetPrivateKey
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:
RSA1_5 RSA-OAEP RSA-OAEP-256 RSA-OAEP-384 (added in Chilkat v9.5.0.71) RSA-OAEP-512 (added in Chilkat v9.5.0.71)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.)
Returns 1 for success, 0 for failure.
SetProtectedHeader
Sets the JWE Protected Header.
Returns 1 for success, 0 for failure.
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-256The 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.)
Returns 1 for success, 0 for failure.
SetRecipientHeader
Sets a per-recipient unprotected header. This method would only be called if the JWE is for multiple recipients. The 1st recipient is at index 0.
Returns 1 for success, 0 for failure.
topSetUnprotectedHeader
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 dirThe 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.
Returns 1 for success, 0 for failure.