Creating encryption keys

All the information related to keys and encryption is encapsulated by the create encryption key, which allows you to specify the key’s name, the encryption algorithm, the key size, the key’s default property, as well as whether an initialization vector or padding is used during the encryption process. See below for the create encryption key syntax.

Column encryption in Adaptive Server 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 Security Builder Crypto API.

You can create separate keys for each encrypted column. Keys can be shared between columns, but each column can have only one key.

The System Security Officer can set up a default encryption key for the database. The default key is used whenever the encrypt qualifier is used without a key name on create table, alter table, and select into. For more information, see “Syntax for create encryption”.

To securely protect key values, Adaptive Server uses the system encryption password to generate a 128-bit key-encrypting key, which in turn is used to encrypt the newly created key (this is the column entryption key.) The column-encryption key is stored in encrypted form in the sysencryptkeys system table.

Figure 2: Encrypting user keys

Syntax for create encryption

The syntax for create encryption key is:

create encryption key keyname [as default] for algorithm 
[with [keylength num_bits] 
[init_vector [null | random]] 
[pad [null | random]]]

where:

create encryption key examples

Example 1

This example specifies a 256-bit key called “safe_key” as the database default key:

create encryption key safe_key as default for AES with         keylength 256

Only the System Security Officer can create a default key.

Example 2

This 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

This 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

The System Security Officer has default permission to create encryption keys and may grant that permission to other users.

For example:

grant create encryption key to key_admin_role