You can configure software or hardware keystores, for use on both individual table columns or entire tablespaces.
Topics:
A software keystore is a container for the TDE master encryption key, and it resides in the software file system.
Topics:
A software keystore is a container that stores the Transparent Data Encryption master encryption key. Before you can configure the keystore, you first must define a location for it in the sqlnet.ora
file.
There is one keystore per database, and the database locates this keystore by checking the keystore location that you define in the sqlnet.ora
file. You can create other keystores, such as copies of the keystore and export files that contain keys, depending on your needs. However, you must never remove or delete the keystore that you configured in the sqlnet.ora
location, nor replace it with a different keystore.
After you configure the software keystore location in the sqlnet.ora
file, you can log in to the database instance to create and open the keystore, and then set the TDE master encryption key. After you complete these steps, you can begin to encrypt data.
The first step you must take to configure a software keystore is to designate a location for it in the sqlnet.ora
file.
Topics:
Configuring the sqlnet.ora File for a Software Keystore Location
Example: Configuring a Software Keystore for a Regular File System
Example: Configuring a Software Keystore When Multiple Databases Share the sqlnet.ora File
Example: Configuring a Software Keystore for Oracle Automatic Storage Management
Example: Configuring a Software Keystore for an Oracle Automatic Storage Management Disk Group
Oracle Database checks the sqlnet.ora
file for the directory location of the keystore, whether it is a software keystore or a hardware module security (HSM) keystore.
You must edit the sqlnet.ora
file to define a directory location for the keystore that you plan to create. Ensure that this directory exists beforehand. Preferably, this directory should be empty.
In a multitenant environment, the keystore location is set for the entire multitenant container database (CDB), not for individual pluggable databases (PDBs).
In the sqlnet.ora
file, you must set the ENCRYPTION_WALLET_LOCATION
parameter to specify the keystore location. When determining which keystore to use, Oracle Database searches for the keystore location in the following places, in this order:
It attempts to use the keystore in the location specified by the parameter ENCRYPTION_WALLET_LOCATION
in the sqlnet.ora
file.
If the ENCRYPTION_WALLET_LOCATION
parameter is not set, then it attempts to use the keystore in the location that is specified by the parameter WALLET_LOCATION
.
If the WALLET_LOCATION
parameter is also not set, then Oracle Database looks for a keystore at the default database location, which is ORACLE_BASE
/admin/
DB_UNIQUE_NAME
/wallet
or ORACLE_HOME
/admin/
DB_UNIQUE_NAME
/wallet
. (DB_UNIQUE_NAME
is the unique name of the database specified in the initialization parameter file.) When the keystore location is not set in the sqlnet.ora
file, then the V$ENCRYPTION_WALLET
view displays the default location. You can check the location and status of the keystore in the V$ENCRYPTION_WALLET
view.
By default, the sqlnet.ora
file is located in the ORACLE_HOME
/network/admin
directory or in the location set by the TNS_ADMIN
environment variable. Ensure that you have properly set the TNS_ADMIN
environment variable to point to the correct sqlnet.ora
file. See SQL*Plus User's Guide and Reference for more information and examples of setting the TNS_ADMIN
environment variable.
See Also:
"Migrating a Software Password Keystore to a Hardware Keystore and Vice Versa" for information about how to configure the sqlnet.ora
file for migration between these two keystore types
You can configure the sqlnet.ora
file for use on a regular file system, a system in which multiple databases must access the same sqlnet.ora
file, and for use with an Oracle Automatic Storage Management (ASM) disk group.
To create a software keystore on a regular file system, use the following format when you edit the sqlnet.ora
file:
ENCRYPTION_WALLET_LOCATION= (SOURCE= (METHOD=FILE) (METHOD_DATA= (DIRECTORY=path_to_keystore)))
You can configure a software keystore for a regular file system.
The following example shows how to configure a software keystore location in the sqlnet.ora
file for a regular file system in which the database name is orcl
.
ENCRYPTION_WALLET_LOCATION= (SOURCE= (METHOD=FILE) (METHOD_DATA= (DIRECTORY=/etc/ORACLE/WALLETS/orcl)))
You can configure multiple databases to share the sqlnet.ora
file.
The following example shows how to configure a software keystore location when multiple databases share the sqlnet.ora
file.
ENCRYPTION_WALLET_LOCATION= (SOURCE= (METHOD=FILE) (METHOD_DATA= (DIRECTORY=/etc/ORACLE/WALLETS/$ORACLE_SID/)))
You can configure sqlnet.ora
for an Automatic Storage Management (ASM) file system
The following example shows how to configure a software keystore location in the sqlnet.ora
file for an ASM file system:
ENCRYPTION_WALLET_LOCATION= (SOURCE= (METHOD=FILE) (METHOD_DATA= (DIRECTORY=+disk1/mydb/wallet)))
You can configure sqlnet.ora
for an Oracle Automatic Storage Management (ASM) disk group.
The following format shows how to configure a software keystore if you want to create a software keystore location on an ASM disk group:
ENCRYPTION_WALLET_LOCATION=
(SOURCE=
(METHOD=FILE)
(METHOD_DATA=
(DIRECTORY=+ASM_file_path_of_the_diskgroup)))
After you have specified a directory location for the software keystore, you can create the keystore.
Topics:
There are three different types of software keystores.
You can create password-based software keystores, auto-login software keystores, and local auto-login software keystores.
See Also:
"Types of Keystores" for more information about software keystores
A password-based software keystore requires a user password, which is used to protect the keys and credentials stored in the keystore.
Ensure that you complete the procedure described in "Step 1: Set the Software Keystore Location in the sqlnet.ora File".
Log in to the database instance as a user who has been granted the ADMINISTER KEY MANAGEMENT
or SYSKM
privilege.
In a multitenant environment, log in to the root. For example:
sqlplus c##sec_admin as syskm
Enter password: password
Connected.
If SQL*Plus is already open and you had modified the sqlnet.ora
file during this time, then reconnect to SQL*Plus. The database session must be changed before the sqlnet.ora
changes can take effect.
Run the ADMINISTER KEY MANAGEMENT
SQL statement to create the keystore.
The syntax is as follows:
ADMINISTER KEY MANAGEMENT CREATE KEYSTORE 'keystore_location' IDENTIFIED BY software_keystore_password;
In this specification:
keystore_location
is the path to the keystore directory location of the password-based keystore for which you want to create the auto-login keystore (for example, /etc/ORACLE/WALLETS/orcl
). Enclose the keystore_location
setting in single quotation marks (' '). To find this location, you can query the WRL_PARAMETER
column of the V$ENCRYPTION_WALLET
view. (If the keystore was not created in the default location, then the STATUS
column of the V$ENCRYPTION_WALLET
view is NOT_AVAILABLE
.)
software_keystore_password
is the password of the keystore that you, the security administrator, creates.
For example, to create the keystore in the /etc/ORACLE/WALLETS/orcl
directory:
ADMINISTER KEY MANAGEMENT CREATE KEYSTORE '/etc/ORACLE/WALLETS/orcl' IDENTIFIED BY password;
keystore altered.
After you run this statement, the ewallet.p12
file, which is the keystore, appears in the keystore location.
As an alternative to password-based keystores, you can create either an auto-login or local auto-login software keystore.
Both of these keystores have system-generated passwords. They are also PKCS#12-based files. The auto-login software keystore can be opened from different computers from the computer where this keystore resides, but the local auto-login software keystore can only be opened from the computer on which it was created. Both the auto-login and local auto-login keystores are created from the password-based software keystores.
Ensure that you complete the procedure described in "Step 1: Set the Software Keystore Location in the sqlnet.ora File".
Log in to the database instance as a user who has been granted the ADMINISTER KEY MANAGEMENT
or SYSKM
privilege.
In a multitenant environment, log in to the root. For example:
sqlplus c##sec_admin as syskm
Enter password: password
Connected.
If SQL*Plus is already open and you had modified the sqlnet.ora
file during this time, then reconnect to SQL*Plus. The database session must be changed before the sqlnet.ora
changes can take effect.
Create a password-based software keystore, as described in "Creating a Password-Based Software Keystore".
Run the ADMINISTER KEY MANAGEMENT
SQL statement to create the keystore.
The syntax is as follows:
ADMINISTER KEY MANAGEMENT CREATE [LOCAL] AUTO_LOGIN KEYSTORE FROM KEYSTORE 'keystore_location' IDENTIFIED BY software_keystore_password;
In this specification:
LOCAL
enables you to create a local auto-login software keystore. Otherwise, omit this clause if you want the keystore to be accessible by other computers.
keystore_location
is the path to the directory location of the password-based keystore for which you want to create the auto-login keystore (for example, /etc/ORACLE/WALLETS/orcl
). Enclose this setting in single quotation marks (' '). To find this location, query the WRL_PARAMETER
column of the V$ENCRYPTION_WALLET
view.
software_keystore_password
is the password-based keystore for which you want to create the auto-login keystore.
For example, to create an auto-login software keystore of the password-based keystore that is located in the/etc/ORACLE/WALLETS/orcl
directory:
ADMINISTER KEY MANAGEMENT CREATE AUTO_LOGIN KEYSTORE FROM KEYSTORE '/etc/ORACLE/WALLETS/orcl' IDENTIFIED BY password;
keystore altered.
After you run this statement, the cwallet.sso
file appears in the keystore location. The ewallet.p12
file is the password-based wallet.
Note:
Do not remove the PKCS#12
wallet (ewallet.p12
file) after you create the auto login keystore (.sso
file). You must have the PKCS#12
wallet to regenerate or rekey the TDE master encryption key in the future. By default, this file is located in the $ORACLE_HOME/admin/
ORACLE_SID
/wallet
directory.
Transparent Data Encryption uses an auto login keystore only if it is available at the correct location (ENCRYPTION_WALLET_LOCATION
,
WALLET_LOCATION
,
or the default keystore location), and the SQL statement to open an encrypted keystore has not already been executed. (Note that auto-login keystores are encrypted, because they have system-generated passwords.)
See Also:
Depending on the type of keystore you create, you must manually open the keystore before you can use it.
Topics:
You must manually open a password-based software keystore before any TDE master encryption keys can be created or accessed in the keystore.
You do not need to manually open auto-login or local auto-login software keystores. These keystore are automatically opened when it is required, that is, when an encryption operation must access the key. If necessary, you can explicitly close any of these types of keystores. You can check the status of whether a keystore is open, closed, open but with no master key, or open but with an unknown master key by querying the STATUS
column of the V$ENCRYPTION_WALLET
view.
After you open a keystore, it remains open until you manually close it. Each time you restart a database instance, you must manually open the password keystore to reenable encryption and decryption operations.
To open a software keystore, you must use the ADMINISTER KEY MANAGEMENT
statement with the SET KEYSTORE OPEN
clause.
Note that if the keystore is open but you have not created a TDE master encryption key yet (described next), the STATUS
column of the V$ENCRYPTION_WALLET
view reminds you with an OPEN_NO_MASTER_KEY
status.
Once the keystore is open, you can set a TDE master encryption key for it.
Topics:
The TDE master encryption key is stored in the keystore.
This key protects the TDE table keys and tablespace encryption keys. By default, the TDE master encryption key is a key that Transparent Data Encryption (TDE) generates.
In a multitenant environment, you can create and manage the TDE master encryption key from either the root or the PDB.
Note:
You can create TDE master encryption keys for use later on, and then manually activate them. See "Creating TDE Master Encryption Keys for Later Use" for more information.
To set the TDE master encryption key in a software keystore, use the ADMINISTER KEY MANAGEMENT
statement with the SET KEY
clause.
For password software keystores, ensure that you complete the procedure described in "Step 3: Open the Software Keystore" to open the key.
Auto-login or local auto-login software keys are opened automatically after you create them. Password-based software keystores must be open before you can set the TDE master encryption key. If the auto-login software keystore is open, then you must close it and open the password-based software keystore. If both the password-based keystore and auto-login keystores are present in the configured location and the password-based keystore is open, then the TDE master encryption key is automatically written to the auto-login keystore as well.
Log in to the database instance as a user who has been granted the ADMINISTER KEY MANAGEMENT
or SYSKM
privilege.
In a multitenant environment, log in to the root or to the PDB. For example, to log in to a PDB:
sqlplus sec_admin@hrpdb as syskm
Enter password: password
Connected.
To find the available PDBs, query the DBA_PDBS
data dictionary view. To check the current PDB, run the show con_name
command.
Ensure that the database is open in READ WRITE
mode.
You can set the TDE master encryption key if OPEN_MODE
is set to READ WRITE
. To find the status, for a non-multitenant environment, query the OPEN_MODE
column of the V$DATABASE
dynamic view. If you are using a multitenant environment, then query the V$PDBS
view. (If you cannot access these views, then connect as SYSDBA
and try the query again. In order to connect as SYSKM
for this type of query, you must create a password file for it. See Oracle Database Administrator's Guide for more information.)
Connect using the SYSKM
administrative privilege and then run the ADMINISTER KEY MANAGEMENT
SQL statement to set the software management keystore.
ADMINISTER KEY MANAGEMENT SET KEY [USING TAG 'tag'] IDENTIFIED BY password [WITH BACKUP [USING 'backup_identifier']] [CONTAINER = ALL | CURRENT];
In this specification:
tag
is the associated attributes and information that you define. Enclose this setting in single quotation marks (' ').
password
is the mandatory keystore password that you created when you created the keystore in "Step 2: Create the Software Keystore".
WITH BACKUP
creates a backup of the keystore. You must use this option for password-based keystores. Optionally, you can use the USING
clause to add a brief description of the backup. Enclose this description in single quotation marks (' '). This identifier is appended to the named keystore file (for example, ewallet_
time_stamp
_emp_key_backup.p12
, with emp_key_backup
being the backup identifier). Follow the file naming conventions that your operating system uses.
CONTAINER
is for use in a multitenant environment. Enter ALL
to set the key in all of the PDBs in this CDB, or CURRENT
for the current PDB.
For example:
ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY password WITH BACKUP USING 'emp_key_backup';
keystore altered.
A hardware keystore resides in a hardware security module (HSM), which is designed to store encryption keys.
Topics:
A hardware security module (HSM) is a physical device that provides secure storage for encryption keys.
To configure a keystore for a hardware security module (hardware keystore), you must first include the keystore type in the sqlnet.ora
file, configure and open the hardware keystore, and then set the hardware keystore TDE master encryption key. In short, there is one hardware keystore per database, and the database locates this keystore by checking the keystore type that you define in the sqlnet.ora
file.
After you configure the hardware keystore, you are ready to begin encrypting your data.
Before you can configure a hardware keystore, you must enable the database to recognize that it is a hardware security module by editing the sqlnet.ora
file. By default, this file is located in the ORACLE_HOME
/network/admin
directory or in the location set by the TNS_ADMIN
environment variable.
Use the following setting in the sqlnet.ora
file to define the hardware keystore type, which is HSM
.
ENCRYPTION_WALLET_LOCATION=
(SOURCE=
(METHOD=HSM))
See Also:
"About the Keystore Location in the sqlnet.ora File" for more information about how Oracle Database finds the keystore location
"Migrating a Software Password Keystore to a Hardware Keystore and Vice Versa" for information about how to configure the sqlnet.ora
file for migration between these two keystore types
To configure a hardware security module, you must copy the PKCS#11 library to the correct location and then follow your vendor's instructions to complete the configuration.
Ensure that you complete the procedure described in "Step 1: Set the Hardware Keystore Type in the sqlnet.ora File".
Copy the PKCS#11 library to its correct path.
Your hardware security module vendor should provide you with an associated PKCS#11 library. Only one PKCS#11 library is supported at a time. If you want to use an HSM from a new vendor, then you must replace the PKCS#11 library from the earlier vendor with the library from the new vendor.
Copy this library to the appropriate location to ensure that Oracle Database can find this library:
UNIX systems: Use the following syntax to copy the library to this directory:
/opt/oracle/extapi/[32,64]/hsm/{VENDOR}/{VERSION}/libapiname.so
Windows systems: Use the following syntax to copy the library to this directory:
%SYSTEM_DRIVE%\oracle\extapi\[32,64]\hsm\{VENDOR}\{VERSION}\libapiname.dll
In this specification:
[32,64]
specifies whether the supplied binary is 32 bits or 64 bits.
VENDOR
stands for the name of the vendor supplying the library
VERSION
refers to the version of the library. This should preferably be in the format, number.number.number
apiname
requires no special format. However, the apiname
must be prefixed with the word lib
, as illustrated in the syntax.
Follow your vendor's instructions to set up the hardware security module.
Use your hardware security module management interface and the instructions provided by your HSM vendor to set up the hardware security module. Create the user account and password that must be used by the database to interact with the hardware security module. This process creates and configures a hardware keystore that communicates with your Oracle database.
After you have configured the hardware security module, you must open the hardware keystore before it can be used.
Topics:
You must open the hardware keystore so that it is accessible to the database before you can perform any encryption or decryption.
You can check the status of whether a keystore is open, closed, open but with no TDE master encryption key, or open but with an unknown master encryption key by querying the STATUS
column of the V$ENCRYPTION_WALLET
view.
To open a hardware keystore, use the ADMINISTER KEY MANAGEMENT
statement with the SET KEYSTORE OPEN
clause.
Ensure that you complete the procedure described in "Step 2: Configure the Hardware Security Module".
Log in to the database instance as a user who has been granted the ADMINISTER KEY MANAGEMENT
or SYSKM
privilege.
In a multitenant environment, you must open the keystore first in the root before you can open it in a PDB. For example, to log in to the root:
sqlplus sec_admin as syskm
Enter password: password
Connected.
To find the available PDBs, query the DBA_PDBS
data dictionary view. To check the current PDB, run the show con_name
command.
If SQL*Plus is already open and you had modified the sqlnet.ora
file during this time, then reconnect to SQL*Plus. The database session must be changed before the sqlnet.ora
changes can take effect.
Run the ADMINISTER KEY MANAGEMENT
SQL statement using the following syntax:
ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY "user_id:password" [CONTAINER = ALL | CURRENT];
In this specification:
user_id
is the user ID created for the database using the HSM management interface
password
is the password created for the user ID using the HSM management interface.
Enclose the user_id:password
string in double quotation marks (" ") and separate user_id
and password
with a colon (:
).
CONTAINER
is for use in a multitenant environment. Enter ALL
to set the keystore in all of the PDBs in this CDB, or CURRENT
for the current PDB.
For example:
ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY "psmith:password";
keystore altered.
Repeat this procedure each time you restart the database instance.
After you have opened the hardware keystore, you are ready to set the hardware keystore TDE master encryption key.
Topics:
To start using hardware security module-based encryption, you must create a TDE master encryption key that is stored inside the hardware keystore.
Oracle Database uses the TDE master encryption key to encrypt or decrypt TDE table keys or tablespace encryption keys inside the hardware security module.
If you have not previously configured a software keystore for Transparent Data Encryption, then follow the steps in "Setting a TDE Master Encryption Key if You Have Not Previously Configured One". If you have already configured a software keystore for TDE, then you must migrate it to the hardware security module, as described in "Migration of a Previously Configured TDE Master Encryption Key".
Along with the current TDE master key, Oracle wallets maintain historical TDE master keys that are generated after every re-key operation that rotates the TDE master key. These historical TDE master keys help to restore Oracle database backups that were taken previously using one of the historical TDE master keys.
You should complete this procedure if you have not previously configured a software keystore for Transparent Data Encryption.
In a multitenant environment, you can create and manage the TDE master encryption key from either the root or the PDB.
Note:
You can create TDE master encryption keys for use later on, and then manually activate them. See "Creating TDE Master Encryption Keys for Later Use" for more information.
Ensure that you complete the procedure described in "Step 3: Open the Hardware Keystore".
Log in to the database instance as a user who has been granted the ADMINISTER KEY MANAGEMENT
or SYSKM
privilege.
In a multitenant environment, log in to the root or to the PDB. For example:
sqlplus sec_admin@hrpdb as syskm
Enter password: password
Connected.
To find the available PDBs, query the DBA_PDBS
data dictionary view. To check the current PDB, run the show con_name
command.
Ensure that the database is open in READ WRITE
mode.
You can set the TDE master encryption key if OPEN_MODE
is set to READ WRITE
. To find the status, for a non-multitenant environment, query the OPEN_MODE
column of the V$DATABASE
dynamic view. If you are in a multitenant environment, then query the V$PDBS
view. (If you cannot access these views, then connect as SYSDBA
and try the query again. In order to connect as SYSKM
for this type of query, you must create a password file for it. See Oracle Database Administrator's Guide for more information.)
Run the following SQL statement:
ADMINISTER KEY MANAGEMENT SET KEY [USING TAG 'tag'] IDENTIFIED BY "user_id:password" [CONTAINER = ALL | CURRENT];
In this specification:
tag
is the associated attributes and information that you define. Enclose this setting in single quotation marks (' ').
user_id
is the user ID created for the database using the HSM management interface.
password
is the password created for the user ID using the HSM management interface. Enclose the user_id:password
string in double quotation marks (" ") and separate user_id
and password
with a colon (:
).
CONTAINER
is for use in a multitenant environment. Enter ALL
to set the keystore in all of the PDBs in this CDB, or CURRENT
for the current PDB.
For example:
ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY "psmith:password";
keystore altered.
You must migrate the previously configured TDE master encryption key if you previously configured a software keystore.
Tools such as Oracle Data Pump and Oracle Recovery Manager require access to the old software keystore to perform decryption and encryption operations on data exported or backed up using the software keystore. You can migrate from the software to the hardware keystore by following the instructions in "Migrating a Software Password Keystore to a Hardware Keystore and Vice Versa".
Along with the current TDE master key, Oracle wallets maintain historical TDE master keys that are generated after every re-key operation that rotates the TDE master key. These historical TDE master keys help to restore Oracle database backups that were taken previously using one of the historical TDE master keys.
You can use Transparent Data Encryption to encrypt individual columns in database tables.
Topics:
You can encrypt individual columns in tables.
Whether you choose to encrypt individual columns or entire tablespaces depends on the data types that the table has. There are also several features that do not support TDE column encryption.
Oracle Database supports a specific set of data types that can be used with TDE column encryption.
You can encrypt data columns that use a variety of different data types.
Supported data types are as follows:
BINARY_DOUBLE
BINARY_FLOAT
CHAR
DATE
INTERVAL DAY TO SECOND
INTERVAL YEAR TO MONTH
NCHAR
NUMBER
NVARCHAR2
RAW
(legacy or extended)
TIMESTAMP
(includes TIMESTAMP WITH TIME ZONE
and TIMESTAMP WITH LOCAL TIME ZONE
)
VARCHAR2
(legacy or extended)
You cannot encrypt a column if the encrypted column size is greater than the size allowed by the data type of the column.
Table 3-1 shows the maximum allowable sizes for various data types.
Table 3-1 Maximum Allowable Size for Data Types
Data Type | Maximum Size |
---|---|
|
1932 bytes |
|
3932 bytes |
|
32,699 bytes |
|
1966 bytes |
|
16,315 bytes |
|
966 bytes |
|
32,699 bytes |
Note:
TDE tablespace encryption does not have these data type restrictions. See "Encrypting Tablespaces" for more information.
Transparent Data Encryption (TDE) column encryption encrypts and decrypts data at the SQL layer. Oracle Database utilities and features that bypass the SQL layer cannot use the services provided by TDE column encryption.
Do not use TDE column encryption with the following database features:
Index types other than B-tree
Range scan search through an index
Synchronous change data capture
Transportable tablespaces
In addition, you cannot use TDE column encryption to encrypt columns used in foreign key constraints.
Applications that must use these unsupported features can use the DBMS_CRYPTO
PL/SQL package for their encryption needs.
Transparent Data Encryption protects data stored on a disk or other media. It does not protect data in transit. Use the network encryption solutions discussed in Oracle Database Security Guide to encrypt data over the network.
See Also:
"How Transparent Data Encryption Works with Export and Import Operations"
"Data Types That Can Be Encrypted with TDE Column Encryption"
Oracle Database PL/SQL Packages and Types Reference for information about the DBMS_CRYPTO
PL/SQL package
You can create new tables that have encrypted columns. Oracle Database provides a selection of different algorithms that you can use to definite the encryption.
Topics:
You can use the CREATE TABLE
SQL statement to create a table with an encrypted column.
To create relational tables with encrypted columns, you can specify the SQL ENCRYPT
clause when you define database columns with the CREATE TABLE
SQL statement.
By default, TDE uses the AES
encryption algorithm with a 192-bit key length (AES192
). If you encrypt a table column without specifying an algorithm, then the column is encrypted using the AES192
algorithm.
TDE adds salt to plaintext before encrypting it. Adding salt makes it harder for attackers to steal data through a brute force attack. TDE also adds a Message Authentication Code (MAC) to the data for integrity checking. The SHA-1
integrity algorithm is used by default.
To create a table that encrypts a column, use the CREATE TABLE
SQL statement with the ENCRYPT
clause.
For example, to encrypt a table column using the default algorithm:
CREATE TABLE employee (
first_name VARCHAR2(128),
last_name VARCHAR2(128),
empID NUMBER,
salary NUMBER(6) ENCRYPT);
This example creates a new table with an encrypted column (salary
). The column is encrypted using the default encryption algorithm (AES192
). Salt and MAC are added by default. This example assumes that the wallet is open and a master key is set.
Note:
If there are multiple encrypted columns in a table, then all of these columns must use the same pair of encryption and integrity algorithms.
Salt is specified at the column level. This means that an encrypted column in a table can choose not to use salt irrespective of whether or not other encrypted columns in the table use salt.
You an use the CREATE TABLE
SQL statement to create a table with an encrypted column.
By default, TDE adds salt to plaintext before encrypting it. Adding salt makes it harder for attackers to steal data through a brute force attack. However, if you plan to index the encrypted column, then you must use the NO SALT
parameter.
To create a table that uses an encrypted column that is a non-default algorithm or no algorithm, run the CREATE TABLE
SQL statement as follows:
If you do not want to use any algorithm, then include the ENCRYPT NO SALT
clause.
If you want to use a non-default algorithm, then use the ENCRYPT USING
clause, followed by one of the following algorithms enclosed in single quotation marks:
3DES168
AES128
AES192
(default)
AES256
The following example shows how to specify encryption settings for the empID
and salary
columns.
CREATE TABLE employee ( first_name VARCHAR2(128), last_name VARCHAR2(128), empID NUMBER ENCRYPT NO SALT, salary NUMBER(6) ENCRYPT USING '3DES168');
In this example:
The empID
column is encrypted and does not use salt. Both the empID
and salary
columns will use the 3DES168
encryption algorithm, because all of the encrypted columns in a table must use the same encryption algorithm.
The salary
column is encrypted using the 3DES168
encryption algorithm. Note that the string that specifies the algorithm must be enclosed in single quotation marks (' '). The salary
column uses salt by default.
You can bypass checks that TDE performs. This can save up to 20 bytes of disk space per encrypted value.
If the number of rows and encrypted columns in the table is large, then bypassing TDE checks can add up to a significant amount of disk space. In addition, this saves processing cycles and reduces the performance overhead associated with TDE.
TDE uses the SHA-1
integrity algorithm by default. All of the encrypted columns in a table must use the same integrity algorithm. If you already have a table column using the SHA-1
algorithm, then you cannot use the NOMAC
parameter to encrypt another column in the same table.
To bypass the integrity check during encryption and decryption operations, use the NOMAC
parameter in the CREATE TABLE
and ALTER TABLE
statements.
You can use the CREATE TABLE SQL statement to encrypt a table column using the NOMAC parameter.
Example 3-1 creates a table with an encrypted column. The empID
column is encrypted using the NOMAC
parameter.
Example 3-1 Using the NOMAC parameter in a CREATE TABLE statement
CREATE TABLE employee (
first_name VARCHAR2(128),
last_name VARCHAR2(128),
empID NUMBER ENCRYPT 'NOMAC' ,
salary NUMBER(6));
You can use the ALTER TABLE SQL statement to change the integrity algorithm for a database table.
Example 3-2 shows how to change the integrity algorithm for encrypted columns in a table. The encryption algorithm is set to 3DES168
and the integrity algorithm is set to SHA-1
. The second ALTER TABLE
statement sets the integrity algorithm to NOMAC
.
Example 3-2 Changing the Integrity Algorithm for a Table
ALTER TABLE EMPLOYEE REKEY USING '3DES168' 'SHA-1'; ALTER TABLE EMPLOYEE REKEY USING '3DES168' 'NOMAC';
The external table feature enables you to access data in external sources as if the data were in a database table. External tables can be updated using the ORACLE_DATAPUMP
access driver.
To encrypt specific columns in an external table, use the ENCRYPT
clause when you define those columns:
A system-generated key encrypts the columns. For example, the following CREATE TABLE
SQL statement encrypts the ssn
column using the 3DES168
algorithm:
CREATE TABLE emp_ext (
first_name,
....
ssn ENCRYPT USING '3DES168',
....
If you plan to move an external table to a new location, then you cannot use a randomly generated key to encrypt the columns. This is because the randomly generated key will not be available at the new location.
For such scenarios, you should specify a password while you encrypt the columns. After you move the data, you can use the same password to regenerate the key required to access the encrypted column data at the new location.
Table partition exchange also requires a password-based TDE table key.
Example 3-3 creates an external table using a password to create the TDE table key.
Example 3-3 Creating a New External Table with a Password-Generated TDE Table Key
CREATE TABLE emp_ext ( first_name, last_name, empID, salary, ssn ENCRYPT IDENTIFIED BY password ) ORGANIZATION EXTERNAL ( TYPE ORACLE_DATAPUMP DEFAULT DIRECTORY "D_DIR" LOCATION('emp_ext.dat') ) REJECT LIMIT UNLIMITED AS SELECT * FROM EMPLOYEE;
You can encryption columns in existing tables. As with new tables, you have a choice of different algorithms to use to definite the encryption.
Topics:
The ALTER TABLE
SQL statement enables you to encrypt columns in an existing table.
To add an encrypted column to an existing table, or to encrypt or decrypt an existing column, you use the ALTER TABLE
SQL statement with the ADD
or MODIFY
clause.
You can set a column in an existing table to be encrypted. You also can You can choose to encrypt the column using a different algorithm. You can also specify NO SALT
, if you want to index the column.
To add an encrypted column to an existing table, use the ALTER TABLE ADD
statement, specifying the new column with the ENCRYPT
clause.
Example 3-4 adds an encrypted column, ssn
, to an existing table, called employee
. The ssn
column is encrypted with the default AES192
algorithm. Salt and MAC are added by default.
Example 3-4 Adding an Encrypted Column to an Existing Table
ALTER TABLE employee ADD (ssn VARCHAR2(11) ENCRYPT);
You can use the ALTER TABLE MODIFY
statement to encrypt an existing unencrypted column.
To encrypt an existing unencrypted column, use the ALTER TABLE MODIFY
statement, specifying the unencrypted column with the ENCRYPT
clause.
The following example encrypts the first_name
column in the employee
table. The first_name
column is encrypted with the default AES192
algorithm. Salt is added to the data, by default. You can encrypt the column using a different algorithm. If you want to index a column, then you must specify NO SALT
. You can also bypass integrity checks by using the NOMAC
parameter.
ALTER TABLE employee MODIFY (first_name ENCRYPT);
The following example encrypts the first_name
column in the employee table using the NOMAC
parameter.
ALTER TABLE employee MODIFY (first_name ENCRYPT 'NOMAC');
You may want to disable encryption for reasons of compatibility or performance.
To disable column encryption, use the ALTER TABLE MODIFY
command with the DECRYPT
clause.
Example 3-5 decrypts the first_name
column in the employee
table.
Example 3-5 Turning Off Column Encryption
ALTER TABLE employee MODIFY (first_name DECRYPT);
You can create an index on an encrypted column.
The column being indexed must be encrypted without salt. If the column is encrypted with salt, then the ORA-28338: cannot encrypt indexed column(s) with salt
error is raised.
To create an index on an encrypted column, use the CREATE INDEX
statement with the ENCRYPT NO SALT
clause.
Example 3-6 shows how to create an index on a column that has been encrypted without salt.
Example 3-6 Creating Index on a Column Encrypted Without Salt
CREATE TABLE employee (
first_name VARCHAR2(128),
last_name VARCHAR2(128),
empID NUMBER ENCRYPT NO SALT,
salary NUMBER(6) ENCRYPT USING '3DES168');
CREATE INDEX employee_idx on employee (empID);
Salt is a way to strengthen the security of encrypted data. It is a random string added to the data before it is encrypted.
Salt ensures that the same plaintext data does not always translate to the same encrypted text. Salt removes the one common method that intruders use to steal data, namely, matching patterns of encrypted text. Adding salt requires an additional 16 bytes of storage per encrypted data value.
To add or remove salt from encrypted columns, use the ALTER TABLE MODIFY
SQL statement.
For example, suppose you want to encrypt the first_name
column using salt. If the first_name
column was encrypted without salt earlier, then the ALTER TABLE MODIFY
statement reencrypts it using salt.
ALTER TABLE employee MODIFY (first_name ENCRYPT SALT);
You can use the ALTER TABLE SQL statement to remove salt from an encrypted column.
To remove salt from an encrypted column, use the ENCRYPT NO SALT
clause in the ALTER TABLE SQL statement.
For example, suppose you wanted to remove salt from the first_name
column. If you must index a column that was encrypted using salt, then you can use this statement to remove the salt before indexing
ALTER TABLE employee MODIFY (first_name ENCRYPT NO SALT);
You can use the ALTER TABLE
SQL statement to change the encryption key or algorithm for tables for containing encrypted columns.
Each table can have only one TDE table key for its columns. You can regenerate the TDE table key with the ALTER TABLE
statement. This process generates a new key, decrypts the data in the table using the previous key, reencrypts the data using the new key, and then updates the table metadata with the new key information. You can also use a different encryption algorithm for the new TDE table key.
To change the encryption key or algorithm for tables that contain encrypted columns, use the ALTER TABLE
SQL statement with the REKEY
or REKEY USING
clause.
For example:
ALTER TABLE employee REKEY;
Example 3-7 regenerates the TDE table key for the employee
table by using the 3DES168
algorithm.
Example 3-7 Changing an Encrypted Table Column Encryption Key and Algorithm
ALTER TABLE employee REKEY USING '3DES168';
You can create a new tablespace and encryption it. However, you cannot encrypt an existing tablespace. Before you decide to encrypt a tablespace, you should understand the restrictions.
Topics:
You should be aware of restrictions on using Transparent Data Encryption when you encrypt a tablespace.
Note the following restrictions:
Transparent Data Encryption (TDE) tablespace encryption encrypts or decrypts data during read and write operations, as opposed to TDE column encryption, which encrypts and decrypts data at the SQL layer. This means that most restrictions that apply to TDE column encryption, such as data type restrictions and index type restrictions, do not apply to TDE tablespace encryption.
To perform import and export operations, use Oracle Data Pump.
See Also:
Oracle Database Utilities for more information about Oracle Data Pump
You must set the COMPATIBLE
initialization parameter before creating an encrypted tablespace.
Topics:
Before you can use the full set of tablespace encryption features, you must set the COMPATIBLE
initialization parameter for the database to 11.2.0.0
or later.
Setting the compatibility to 11.2.0.0
instead of 11.1.0.0
enables the following additional features:
The 11.2.0.0
setting enables the database to use any of the four supported algorithms for data encryption (3DES168
, AES128
, AES192
, and AES256
).
The 11.2.0.0
setting enables the migration of a key from a software keystore to a hardware keystore (ensure that the TDE master encryption key was configured for the hardware keystore)
The 11.2.0.0
setting enables resetting and rotating the TDE master encryption key
Be aware that once you set this parameter to 11.2.0.0
, the change is irreversible. To use tablespace encryption, ensure that the compatibility setting is at the minimum, which is 11.1.0.0
.
See Also:
Oracle Database SQL Language Reference for more information about the COMPATIBLE
parameter
Oracle Database Administrator's Guide for more information about initialization parameter files
To set the COMPATIBLE
initialization parameter, you must edit the initialization parameter file for the database instance.
Log in to the database instance.
In a multitenant environment, log in to the PDB. For example:
sqlplus sec_admin@hrpdb
Enter password: password
Connected.
To find the available PDBs, query the DBA_PDBS
data dictionary view. To check the current PDB, run the show con_name
command.
Check the current setting of the COMPATIBLE
parameter.
For example:
SHOW PARAMETER COMPATIBLE NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ compatible string 12.0.0.0 noncdbcompatible BOOLEAN FALSE
If you must change the COMPATIBLE
parameter, then complete the remaining steps in this procedure.
The value should be 11.2.0.0 or higher.
Locate the initialization parameter file for the database instance.
UNIX systems: This file is in the ORACLE_HOME
/dbs
directory and is named init
ORACLE_SID
.ora
(for example, initmydb.ora
).
Windows systems: This file is in the ORACLE_HOME
\database
directory and is named init
ORACLE_SID
.ora
(for example, initmydb.ora
).
In SQL*Plus, connect as a user who has the SYSDBA
administrative privilege, and then shut down the database.
For example:
CONNECT /AS SYSDBA SHUTDOWN
Edit the initialization parameter file to use the correct COMPATIBLE
setting.
For example:
COMPATIBLE = 12.2.0.0
In SQL*Plus, ensure that you are connected as a user who has the SYSDBA
administrative privilege, and then start the database.
For example:
CONNECT /AS SYSDBA STARTUP
If tablespace encryption is in use, then open the keystore at the database mount. The keystore must be open before you can access data in an encrypted tablespace.
STARTUP MOUNT;
ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY password;
ALTER DATABASE OPEN;
You should ensure that you have configured the TDE master encryption key.
Set the TDE master encryption key as follows:
For software TDE master encryption keys, see "Step 4: Set the Software TDE Master Encryption Key".
For hardware TDE master encryption keys, see "Step 4: Set the Hardware Keystore TDE Master Encryption Key".
After you have set the COMPATIBLE
initialization parameter, you are ready to create the encrypted tablespace.
Topics:
To create an encrypted tablespace, you can use the CREATE TABLESPACE
SQL statement.
You must have the CREATE TABLESPACE
system privilege to create an encrypted tablespace.
You cannot change an existing tablespace to make it encrypted. You can, however, import data into an encrypted tablespace by using Oracle Data Pump. You can also use a SQL statement such as CREATE TABLE...AS SELECT...
or ALTER TABLE...MOVE...
to move data into an encrypted tablespace. The CREATE TABLE...AS SELECT...
statement creates a table from an existing table. The ALTER TABLE...MOVE...
statement moves a table into the encrypted tablespace.
For security reasons, you cannot encrypt a tablespace with the NO SALT
option.
You can query the ENCRYPTED
column of the DBA_TABLESPACES
and USER_TABLESPACES
data dictionary views to verify if a tablespace was encrypted.
See Also:
Oracle Database Reference for more information about these data dictionary views
To create an encrypted tablespace, you must use the CREATE TABLESPACE
statement with the ENCRYPTION USING
clause.
Log in to the database instance as a user who has been granted the CREATE TABLESPACE
system privilege.
In a multitenant environment, log in to the PDB. For example:
sqlplus sec_admin@hrpdb as syskm
Enter password: password
Connected.
To find the available PDBs, query the DBA_PDBS
data dictionary view. To check the current PDB, run the show con_name
command.
Run the CREATE TABLESPACE
statement, using its encryption clauses.
For example:
CREATE TABLESPACE encrypt_ts DATAFILE '$ORACLE_HOME/dbs/encrypt_df.dbf' SIZE 1M ENCRYPTION USING 'AES256' DEFAULT STORAGE (ENCRYPT);
In this specification:
ENCRYPTION USING 'AES256'
specifies the encryption algorithm and the key length for the encryption. Enclose this setting in single quotation marks (' '). The key lengths are included in the names of the algorithms. If you do not specify an encryption algorithm, then the default encryption algorithm, AES128
, is used. Choose from the following algorithms:
3DES168
AES128
AES192
AES256
ENCRYPT
in the DEFAULT STORAGE
clause encrypts the tablespace.
See Also:
Oracle Database SQL Language Reference for the CREATE TABLESPACE
statement syntax
You can use the CREATE TABLESPACE SQL statement to create an encrypted tablespace.
Example 3-8 creates a tablespace called securespace_1
that is encrypted using the 3DES
algorithm. The key length is 168 bits.
Example 3-8 Creating an Encrypted Tablespace That Uses 3DES168
CREATE TABLESPACE securespace_1 DATAFILE '/home/user/oradata/secure01.dbf' SIZE 150M ENCRYPTION USING '3DES168' DEFAULT STORAGE(ENCRYPT);
You can use the CREATE TABLESPACE SQL statement to create an encrypted tablespace that uses the default algorithm.
Example 3-9 creates a tablespace called securespace_2
. Because no encryption algorithm is specified, the default encryption algorithm (AES128
) is used. The key length is 128 bits.
You cannot encrypt an existing tablespace.
Example 3-9 Creating an Encrypted Tablespace That Uses the Default Algorithm
CREATE TABLESPACE securespace_2 DATAFILE '/home/user/oradata/secure01.dbf' SIZE 150M ENCRYPTION DEFAULT STORAGE(ENCRYPT);
Oracle Database provides a set of dynamic and data dictionary views that you can query to find more information about Transparent Data Encryption data.
Table 3-2 describes these dynamic and data dictionary views.
Table 3-2 Transparent Data Encryption Related Views
View | Description |
---|---|
|
Displays encryption information about encrypted columns in the tables accessible to the current user |
|
Displays encryption information for all of the encrypted columns in the database |
|
Displays encryption information for encrypted table columns in the current user's schema |
|
Lists the properties of the strings (secrets) that were stored in the keystore for various features (clients). In a multitenant environment, when you query this view in a PDB, then it displays information about keys that were created or activated for the current PDB. If you query this view in the root, then it displays this information about keys for all of the PDBs. |
|
Displays information about the tablespaces that are encrypted |
|
Displays information about the TDE master encryption keys. In a multitenant environment, when you query this view in a PDB, it displays information about keys that were created or activated for the current PDB. If you query this view in the root, it displays this information about keys for all of the PDBs. |
|
Displays information on the status of the keystore and the keystore location for TDE |
|
Displays metadata information for a PKI certificate, which can be used as a master encryption key for TDE |
See Also:
Oracle Database Reference for detailed information about these views