Creating Column Encryption Keys

A column encryption key must exist before a table owner can mark a column for encryption on a new or existing table.

When you set up keys for the first time, consider:

Column encryption in SAP ASE uses the Advanced Encryption Standard (AES) symmetric key encryption algorithm, with available key sizes of 128, 192, and 256 bits. Random-key generation and cryptographic functionality is provided by the FIPS 140-2 compliant modules.

To securely protect key values, SAP ASE uses a 256-bit key-encrypting key (KEK), which may be a master key, or an internal key derived from either the system encryption password or a user-specified password.

SAP ASE encrypts the new key (the column encryption key) and stores the result in sysencryptkeys.

By default, SAP ASE creates 256-bit key-encryption keys. For compatibility with versions earlier than 15.7, it uses a 128-bit key if the KEK is derived from the system encryption password.

The syntax is:
create encryption key [[database.][owner].]keyname 
	[as default] [for algorithm] 
	[with 
		{[key_length num_bits] 
		[{passwd 'passwd_phrase' | passwd system_encr_passwd | 
			master key}] 
		[init_vector {null | random}]
		[pad {null | random}]
		[[no] dual_control]
	}]

where:

Examples

These examples use various encryption attributes when creating a column encryption key, and many assume you have already created the master key or set the system encryption password.

  • Example 1 – specifies a 256-bit key called “safe_key” as the database default key. Because the key does not specify a password, SAP ASE uses the database-level master key as the KEK for safe_key. If there is no master key, SAP ASE uses the system encryption password:
    create encryption key safe_key as default for AES
        with keylength 256

    Only the system security officer or a user with the keycustodian_role can create a default key.

  • Example 2 – creates a 128-bit key called “salary_key” for encrypting columns using random padding:
    create encryption key salary_key for AES with
         init_vector null pad random
  • Example 3 – creates a 192-bit key named “mykey” for encrypting columns using an initialization vector:
    create encryption key mykey for AES 
         with keylength 192 init_vector random
  • Example 4 – creates a key protected by a user-specified password:
    create encryption key key1
         with passwd 'Worlds1Biggest6Secret'

    If a key is protected by a user-specified password, that password must be entered a column encrypted by the key can be accessed.

  • Example 5 – creates a key protected by dual-control:
    create encryption key dualprotectedkey
    with passwd "Pass4Tomorrow"
    dual_control

    Key “dualprotectedkey” is protected by the master key and a user password (in dual control). To access the key, you must enter both the user password for the key and the password for the master key.

Permissions

The sso_role and keycustodian_role implicitly have permission to create encryption keys. The system security officer or the key custodian uses this syntax to grant create encryption key permissions to others:
grant create encryption key 
	to user_name | role_name | group_name
For example:
grant create encryption key to key_admin_role
To revoke key creation permission, use:
revoke create encryption key 
	{to | from} user_name | role_name | group_name
Note: grant all does not grant create encryption key permission to the user. It must be explicitly granted by the system security officer.
Related concepts
Role of the Key Custodian
Database-Level Master and Dual Master Keys
Key Protection
Performance Considerations
Related tasks
Dropping Column Encryption Keys