A column encryption key must exist before a table owner can mark a column for encryption on a new or existing table.
Key owner or custodian assignment – the system security officer (SSO) must grant create encryption key permission to create keys. By default, the sso_role and the keycustodian_role have create encryption key permission.
Whether keys should be created in a separate key database – SAP recommends that you use a separate database for keys, especially if keys are encrypted by the system encryption password.
The number of keys needed – you can create a separate key for each encrypted column, or you can use the same key to encrypt columns across multiple tables. From a performance standpoint, encrypted columns that join with equivalent columns in other tables should share the same key. For security purposes, unrelated columns should use different keys.
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.
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:
keyname – must be unique in the user’s table, view, and procedure name space in the current database. Specify the database name if the key is in another database, and specify the owner’s name if more than one key of that name exists in the database. The default value for owner is the current user, and the default value for database is the current database. Only the system security officer can create keys for other users.
as default – allows the system security officer or key custodian to create a database default key for encryption. This enables the table creator to specify encryption without using a keyname on create table, alter table, and select into. SAP ASE uses the default key from the same database. The default key may be changed.
for algorithm – Advanced Encryption Standard (AES) is the only algorithm supported. AES supports key sizes of 128, 192, and 256 bits, and a block size of 16 bytes. The block size is the number of bytes in an encryption unit. Large data is subdivided for encryption.
keylength num_bits – the size, in bits, of the key to be created. For AES, valid key lengths are 128, 192, and 256 bits. The default keylength is 128 bits.
passwd password_phrase – indicates to ASE to protect the CEK using the user password password_phrase, which can be a quoted alphanumeric string up to 255 bytes in length.
passwd system_encr_passwd – indicates to ASE to protect the CEK using the system encryption password.
master key – indicates to ASE to protect the CEK using the master key. By default, SAP ASE uses the master key (if it exists) to protect column encryption keys.
random – specifies use of an initialization vector during encryption. When an initialization vector is used by the encryption algorithm, the cipher text of two identical pieces of plain text are different, which prevents detection of data patterns. Using an initialization vector can add to the security of your data.
Use of an initialization vector implies using a cipher-block chaining (CBC) mode of encryption, where each block of data is combined with the previous block before encryption, with the first block being combined with the initialization vector.
However, initialization vectors have some performance implications. You can create indexes and optimize joins and searches only on columns where the encryption key does not specify an initialization vector.
null – omits the use of an initialization vector when encrypting. This makes the column suitable for supporting an index.
The default is to use an initialization vector, that is, init_vector random.
Setting init_vector null implies the electronic codebook (ECB) mode, where each block of data is encrypted independently.
To encrypt one column using an initialization vector and another column without using an initialization vector, create two separate keys—one that specifies use of an initialization vector and another that specifies no initialization vector.
null – the default, omits random padding of data.
You cannot use padding if the column must support an index.
random – data is automatically padded with random bytes before encryption. You can use padding instead of an initialization vector to randomize the cipher text. Padding is suitable only for columns whose plain text length is less than half the block length. For the AES algorithm the block length is 16 bytes.
dual control – indicates whether the new key must be encrypted using dual control. By default, dual control is not configured.
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.
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.
create encryption key salary_key for AES with init_vector null pad random
create encryption key mykey for AES with keylength 192 init_vector random
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.
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.
grant create encryption key to user_name | role_name | group_name
grant create encryption key to key_admin_role
revoke create encryption key {to | from} user_name | role_name | group_name