All Products
Search
Document Center

MaxCompute:NEW_KEYSET

Last Updated:Sep 21, 2026

Creates a keyset based on the specified algorithm type.

Command format

binary NEW_KEYSET(string <key_type>, [string <description>])

Parameter descriptions

  • key_type: Required. The algorithm type used to create a data key. Supported algorithms include AES-GCM-256, AES-SIV-CMAC-128, and AES-SIV-CMAC-256.

  • description: Optional. The description of the data key.

Return value

A keyset of the BINARY type is returned.

Note

You can use HEX to convert the BINARY type into the STRING type or use UNHEX to convert the STRING type into the BINARY type based on your business requirements.

Usage example

select hex(NEW_KEYSET('AES-GCM-256', 'hello world'));

The following result is returned.

+------------+
| _c0        |
+------------+
| 0A10577567735A514541554D42776E684C4212580A330A0B4145532D47434D2D323536122017F7A430B9D4B59B55454FD4B486216059F1B748CE0502D901EBEACEAB6569191801200210011A10577567735A514541554D42776E684C4220022A0B68656C6C6F20776F726C64 |
+------------+

References

Document

Description

Keyset usage instructions

Instructions on how to use keyset encryption functions.

ADD_KEY_TO_KEYSET

Adds a new key to a keyset and sets the new key as the master key.

KEYSET_TO_JSON

Converts a BINARY keyset to a readable JSON format to view the keyset details.

KEYSET_FROM_JSON

Converts a JSON keyset to the BINARY type.

ROTATE_KEYSET

The system automatically generates a new key and sets it as the master key.

NEW_WRAPPED_KEYSET

Grants the role_arn of a role that has permission to use the KMS customer master key (CMK) resource name (kms_cmk_arn) to MaxCompute to create a new wrapped keyset. You can also use a role chain (role_chain) to grant other Alibaba Cloud accounts the permission to decrypt the keyset.

REWRAP_KEYSET

Re-encrypts a wrapped keyset using a specified KMS key.

ROTATE_WRAPPED_KEYSET

Decrypts an existing encrypted keyset, performs key rotation, and then encrypts the keyset with the new key.

USE_WRAPPED_KEYSET

Converts a wrapped keyset to a basic keyset to be used as a parameter for encryption and decryption functions. You can also use this function to obtain and save information about the wrapped keyset for maintenance.

ENHANCED_SYM_ENCRYPT

Encrypts data using a specified keyset.

ENHANCED_SYM_DECRYPT

Decrypts data using a specified keyset.