--- title: KMFCryptoOperation - Scoped, Global description: The KMFCryptoOperation class provides methods for performing cryptographic operations using a Key Management Framework \(KMF\) cryptographic module or a Field Encryption encryption module.Creates a KMFCryptoOperation object for the specified module and operation.Performs the cryptographic operation defined by the current KMFCryptoOperation object on the supplied data and returns the result.Sets the additional input needed to perform the cryptographic operation.Sets the algorithm associated with the key material to wrap.Sets the data format for the input data on which the cryptographic operation will be performed. Uses the specified format when decoding the data.Sets the data format of the output data that is returned by the cryptographic operation. Uses the specified format when encoding the data.Sets the data type for the output data returned after the cryptographic operation is performed.Sets the sys\_id of the key to wrap on the KMFCryptoOperation object. Applicable to symmetric and asymmetric wrapping of keys. locale: en-US canonical_url: https://www.servicenow.com/docs/r/api-reference/server-api-reference/KMFCryptoOperationBothAPI.html release: brazil product: Server API Reference classification: server-api-reference topic_type: concept last_updated: "2026-09-10" reading_time_minutes: 13 breadcrumb: [Server API reference, API reference, API implementation and reference] --- # KMFCryptoOperation - Scoped, Global The KMFCryptoOperation class provides methods for performing cryptographic operations using a Key Management Framework \(KMF\) cryptographic module or a Field Encryption encryption module. To use this API, you must have already created and configured a KMF cryptographic module or a CLE encryption module. The module must have one or more cryptographic specifications and you must create or import its associated key. For details, see [Cryptographic modules](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/platform-security/crypto-module-overview.md). The KMFCryptoOperation object generated using this API represents a cryptographic operation, such as a Symmetric Encryption. Use the KMFCryptoOperations\(\) method to create this object, the builder methods to set properties on the object, and the doOperation\(\) method to execute the operation. You can use this API in both scoped and global applications. You must always specify the `sn_kmf_ns` namespace when calling this API. **Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/api-server.md) ## KMFCryptoOperation - KMFCryptoOperation\(String cryptoModuleName, String operationName\) Creates a KMFCryptoOperation object for the specified module and operation. This API leverages builder methods. Builder methods update properties on the KMFCryptoOperation object, such as changing the desired output format of the data. Not all builder methods are valid for all operations. The builder methods available for each operation are noted in the parameters table below. The following builder methods are valid for all operation types: - [withInputFormat\(\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/KMFCryptoOperationBothAPI.md) - [withOutputFormat\(\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/KMFCryptoOperationBothAPI.md) - [withOutputType\(\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/KMFCryptoOperationBothAPI.md) **Important:** Base64 input values used in this document must be URL safe \(contains only A-Z, a-z, 0-9, dash\( - \) and underscore\( \_ \) characters\).
| Name | Type | Description |
|---|---|---|
| cryptoModuleName | String | Name of the Key Management Framework \(KMF\) cryptographic module or Field Encryption encryption module to use. You must create the module before calling this method. For details, see [Cryptographic module overview](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/platform-security/crypto-module-overview.md). |
| operationName | String | Name of the operation to perform.Valid values \(not case-sensitive\): - ASYMMETRIC\_DECRYPTION: Data decryption using an asymmetric-key algorithm. Requires a KMF cryptographic module with an Asymmetric Data Decryption cryptographic purpose. - Additional builder methods: withAdditionalInput\(\) - Default input format: Formatted - Formatted to the KMF specifications - Default output format: KMFBase64 - Base64 encoded - Default output type: String - ASYMMETRIC\_ENCRYPTION: Data encryption using an asymmetric-key algorithm. Requires a KMF cryptographic module with an Asymmetric Data Encryption cryptographic purpose. - Additional builder methods: withAdditionalInput\(\) - Default input format: KMFBase64 - Base64 encoded - Default output format: Formatted - Formatted to the KMF specifications - Default output type: String . Output can also be an [KMFEncryptionPayload](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/KMFCryptoOperationBothAPI.md) object. RSA and EC-IES are compatible with both. For additional information on the KMFEncryptionPayload object, see [withAdditionalInput\(\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/KMFCryptoOperationBothAPI.md). - ASYMMETRIC\_UNWRAPPING: Key unwrapping using an asymmetric-key algorithm. Requires a KMF cryptographic module with an Asymmetric Key Unwrapping cryptographic purpose. - Additional builder methods: withAlgorithm\(\) - Default input format: Formatted - Formatted to the KMF specifications - Default output format: KMFBase64 - Base64 encoded - Default output type: String - ASYMMETRIC\_WRAPPING: Key wrapping using an asymmetric-key algorithm. Requires a KMF cryptographic module with an Asymmetric Key Wrapping cryptographic purpose. - Additional builder methods: withAlgorithm\(\), withSysId\(\) - Default input format: KMFBase64 - Base64 encoded - Default output format: Formatted - Formatted to the KMF specifications - Default output type: String - JWT\_SIGN: Generate a JSON Web Token \(JWT\) signature using an asymmetric-key algorithm. Requires a KMF cryptographic module with a Signature Generation cryptographic purpose. The JWT header must be passed via the withAdditionalInput\(\) method. The generated JWT can be verified by external systems that have access to the public key material. - Additional builder methods:withAdditionalInput\(\) - Default input format: String, JWT payload in JSON format - Default output format: String, a complete JWT token \(header.payload.signature\) - Default output type: String - JWT\_VERIFY: JSON Web Token \(JWT\) signature verification using an asymmetric-key algorithm. Requires a KMF cryptographic module with a Signature Verification cryptographic purpose. - Additional builder methods: None. - Default input format: String, a complete JWT token \(header.payload.signature\) - Default output format: String, containing validity status, decoded header, and decoded payload - Default output type: String. Returns a JSON object with signature validity \(true/false\) and decoded JWT components if verification succeeds. Can verify JWTs generated both within and outside the ServiceNow instance. - MAC\_GENERATION: Generation of a Message Authentication Code \(MAC\). Symmetric-key algorithm based to provides data integrity and authentication. Requires a KMF cryptographic module with a Symmetric Authenticity cryptographic purpose. - Additional builder methods: None - Default input format: KMFBase64 - Base64 encoded - Default output format: Formatted - Formatted to the KMF specifications - Default output type: String - MAC\_VERIFICATION: Verification of a MAC. Symmetric-key algorithm based to provide data integrity and authentication. Requires a KMF cryptographic module with a Symmetric Authenticity cryptographic purpose. - Additional builder methods: withAdditionalInput\(\) - Default input format: KMFBase64 - Base64 encoded - Default output format: KMFNone - No decoding - Default output type: Boolean - SIGNATURE\_GENERATION: Generation of a digital signature. Asymmetric-key algorithm based to provide data integrity and authentication. Requires a KMF cryptographic module with a Signature Generation cryptographic purpose. - Additional builder methods: None - Default input format: KMFBase64 - Base64 encoded - Default output format: Formatted - Formatted to the KMF specifications - Default output type: String - SIGNATURE\_VERIFICATION: Verification of a digital signature. Asymmetric-key algorithm based to provide data integrity and authentication. Requires a KMF cryptographic module with a Signature Verification cryptographic purpose. - Additional builder methods: withAdditionalInput\(\) - Default input format: KMFBase64 - Base64 encoded - Default output format: KMFNone - No decoding - Default output type: Boolean - SYMMETRIC\_ENCRYPTION: Data encryption using a symmetric-key algorithm. If the algorithm is not equality preserving, only formatted output is allowed. Requires a KMF cryptographic module with a Symmetric Data Encryption/Decryption cryptographic purpose. - Additional builder methods: None - Default input format: KMFBase64 - Base64 encoded - Default output format: Formatted - Formatted to the KMF specifications - Default output type: String - SYMMETRIC\_DECRYPTION: Data decryption using a symmetric-key algorithm. If the algorithm is not equality preserving, KMFBase64 input is allowed. Requires a KMF cryptographic module with a Symmetric Data Encryption/Decryption cryptographic purpose. - Additional builder methods: None - Default input format: Formatted - Formatted to the KMF specifications - Default output format: KMFBase64 - Base64 encoded - Default output type: String - SYMMETRIC\_WRAPPING: Key wrapping using a symmetric-key algorithm. If the algorithm is not equality preserving, only formatted output is allowed. Requires a KMF cryptographic module with a Symmetric Key Wrapping/Unwrapping cryptographic purpose. - Additional builder methods: withAlgorithm\(\) and withSysId\(\) - Default input format: KMFBase64 - Base64 encoded - Default output format: Formatted - Formatted to the KMF specifications - Default output type: String - SYMMETRIC\_UNWRAPPING: Key unwrapping using a symmetric-key algorithm. If the algorithm is not equality preserving, KMFBase64 input is allowed. Requires a KMF cryptographic module with a Symmetric Key Wrapping/Unwrapping cryptographic purpose. - Additional builder methods: withAlgorithm\(\) - Default input format: Formatted - Formatted to the KMF specifications - Default output format: KMFBase64 - Base64 encoded - Default output type: String |
| Type | Description |
|---|---|
| Depends on the operation type. - **MAC\_VERIFICATION** and **SIGNATURE\_VERIFICATION**: Boolean - All others: String | Data results after performing the operation specified in the associated KMFCryptoOperation object. |
| Name | Type | Description |
|---|---|---|
| additionalInput | String or Object | Optional, except for Asymmetric Decryption operations when using EC-IES. Additional input data needed to perform the cryptographic operation specified in the KMFCryptoOperation object.Supported string formats: - FORMATTED: Formatted to the Key Management Framework \(KMF\) specifications. - KMFBASE64: Base64 encoded. KMFEncryptionPayload object format: ``` { "ciphertext": String, "derivation_secret": String, "ephemeral_key": String, "ephemeral_key_format": String, "signature": String } ``` |
| additionalInput.ciphertext | String \(Base64\) | Required for Asymmetric Decryption, optional for all other operations.Valid values: - If using an RSA algorithm: RSA ciphertext - If using an EC-IES algorithm: Integrated AES ciphertext Available from the Asymmetric Encryption operation when the output type is set to **payload**. |
| additionalInput.derivation\_secret | String \(Base64\) | Optional, only used for the Asymmetric Encryption or Asymmetric Decryption operations with EC-IES. Shared secret to use during the key derivation process of the integrated scheme. |
| additionalInput.ephemeral\_key | String \(Base64\) | Required for the Asymmetric Decryption operation when using EC-IES, optional for all other operations. Ephemeral public key to use during the basic agreement process of the integrated scheme.Available from the Asymmetric Encryption operation when the output type is set to **payload**. |
| additionalInput.ephemeral\_key\_format | String | Optional, only used for the Asymmetric Encryption or Asymmetric Decryption operations with EC-IES. Overrides the format of the public key represented by the **ephemeral\_key** parameter.Valid values: - x962 - der |
| additionalInput.signature | String \(Base64\) | Required for the Asymmetric Decryption operation with EC-IES, optional for all others. The signature of the ciphertext to validate using the signature verification process of the integrated scheme.Available from the Asymmetric Encryption operation when the output type is set to **payload**. |
| Name | Type | Description |
|---|---|---|
| algorithm | String | Algorithm to use.Valid values: - AES: Symmetric key type - EC: Asymmetric key type - HMAC: Symmetric key type - RSA: Asymmetric key type |
| Name | Type | Description |
|---|---|---|
| inputFormat | String | Format of the input data.Valid values: - FORMATTED: Formatted to the Key Management Framework \(KMF\) specifications. - KMFBASE64: Base64 encoded. - KMF\_GLIDE\_ENCRYPTER\_FORMATTED: Support decryptions of both KMF encrypted values and GlideEncrypter encrypted values. - KMFNONE: No encoding. Default: Value determined by the operation specified when the KMFCryptoOperation object was instantiated. For more information, see [KMFCryptoOperation - KMFCryptoOperation\(String cryptoModuleName, String operationName\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/KMFCryptoOperationBothAPI.md). |
| Name | Type | Description |
|---|---|---|
| outputFormat | String | Format of the output data.Valid values: - FORMATTED: Formatted to the Key Management Framework \(KMF\) specifications. - KMFBASE64: Base64 encoded. - KMFNONE: No decoding. Only supported for MAC\_VERIFICATION and SIGNATURE\_VERIFICATION. Default if this method is not called: Value determined by the operation specified when the KMFCryptoOperation object was instantiated. For more information, see [KMFCryptoOperation - KMFCryptoOperation\(String cryptoModuleName, String operationName\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/KMFCryptoOperationBothAPI.md). |
| Name | Type | Description |
|---|---|---|
| outputType | String | Type of output data.Not all output types are applicable to all operations. For an unsupported type, an exception is thrown. Valid values \(not case-sensitive\): - String: Not valid for **MAC\_VERIFICATION** or **SIGNATURE\_VERIFICATION** operations. - Boolean: Only valid for **MAC\_VERIFICATION** or **SIGNATURE\_VERIFICATION** operations. - Payload: Only valid for the **ASYMMETRIC\_ENCRYPTION** operation. Use this output type for EC-IES. **Note:** When specifying an output of `Payload`, the output of the doOperation\(\) method is a KMFEncryptionPayload object. For more information on the structure of this object, see [withAdditionalInput\(\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/KMFCryptoOperationBothAPI.md). Default: Value determined by the operation, specified when the KMFCryptoOperation object was instantiated. For more information, see [KMFCryptoOperation - KMFCryptoOperation\(String cryptoModuleName, String operationName\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/server-api-reference/KMFCryptoOperationBothAPI.md). |
| Name | Type | Description |
|---|---|---|
| sysId | String | Sys\_id of the key to wrap.Table: Module Key \[sys\_kmf\_module\_key\] |