This tutorial describes how you can use Transparent Database Encrption to encrypt data stored on disk.
30 minutes
This tutorial covers the following topics:
Place
the cursor over this icon to load and view all the screenshots for this tutorial.
(Caution: This action loads all screenshots simultaneously, so response time
may be slow depending on your Internet connection.)
Note: Alternatively, you can place the cursor over each individual icon in the following steps to load and view only the screenshot associated with that step.
Oracle Database 10g Release 2 Transparent Database Encryption simplifies encryption of sensitive personal information such as credit card numbers and social security numbers. Transparent Data Encryption eliminates the need to embed encryption routines in existing applications and dramatically lowers the cost and complexity of encryption. With a few simple commands, sensitive application data can be encrypted.
Automatic Encryption Of Sensitive Information
Most encryption solutions require specific calls to encryption functions within the application code. This is expensive because it typically requires extensive understanding of an application as well as the ability to write and maintain software. In general, most organizations don't have the time or expertise to modify existing applications to make calls to encryption routines. Oracle Transparent Data Encryption addresses the encryption problem by deeply embedding encryption in the Oracle database.
Application logic performed through SQL will continue to work without modification. In other words, applications can use the same syntax to insert data into an application table and the Oracle database will automatically encrypt the data before writing the information to disk. Subsequent select operations will have the data transparently decrypted so the application will continue to work normally. This is important because existing applications generally expect to see application data unencrypted. Displaying encrypted data may, at a minimum, confuse the application user and may even break an existing application.
Setting The Encryption Key
Oracle Transparent Data Encryption provides the key management infrastructure necessary for implementing encryption. Encryption works by passing clear text data along with a secret, known as the key, into an encryption program. The encryption program encrypts the clear text data using the supplied key and returns the data encrypted. Historically the burden of creating and maintaining the secret or key has been on the application. Oracle Transparent Data Encryption solves this problem by automatically generating a master key for the entire database. Upon starting up the Oracle database, an administrator must open an object known as an Oracle Wallet using password separate from the system or DBA password. The administrator then initializes the database master key. The master key is automatically generated.
Performance
Encryption typically creates problems for existing application indexes because the index data isn't encrypted. Oracle Transparent Data Encryption encrypts the index value associated with a given application table. This means that equality searches within an application will see little to no decrease in performance. For example, assume an index exists on application PERSON ID and the application executes the following statement:
SQL> Select rating from credit where person id = '23590';
Oracle database will use the existing application index even though the PERSON ID information is encrypted in the database.
In this tutorial, you create a table that contains an encrypted column. You create an index on the encrypted column and grant access to the column for a particular user. This user then makes a change to the data. Then, you create a function which contains proper access control to the encrypted data and then apply the function through a VPD policy.
Transparent Data Encryption encrypts data right before it is written to disk and de-crypts it when it is read. It's transparent to all applications that use the SQL layer. Hence there is no easy way to verify that data has truly been encrypted. Since Oracle LogMiner records what is written to disk, you can access the information.
Before starting this tutorial, you should:
| 1. |
Perform the Installing Oracle Database 10g on Windows tutorial. |
| 2. | Download and unzip tde.zip into your working directory(c:\wkdir) |
In this section, you update your sqlnet.ora, create an encrypted wallet (ewallet.p12), open the wallet, and create the master key for TDE. Perform the following steps:
In this tutorial, you create some users, create a table with an encrypted column to store credit card information. You insert some data into the table, create an index on the encrypted column and grant access to the data. Perform the following steps:
| 1. | You first need to create some users. From your SQL*Plus session, execute the following script: @c:\wkdir\tde01_crusers
connect system/oracle
prompt Create users: JKING, LSMITH and LDORAN
grant connect to JKING identified by welcome1;
grant connect, DBA to LSMITH identified by welcome1;
grant connect to LDORAN identified by welcome1;
Note: You have granted LSMITH DBA role to demonstrate that TDE supports indices for equality searches. As a result, the output of dbms_xplan should include INDEX RANGE SCAN.
|
|
| 2. |
Next you create a table that contains a column to store encrypted (default AES192) credit card information. NO SALT is specified since there will be an index on the credit_card_number column, which is not possible when the encrypted values are salted. From your SQL*Plus session, execute the following script: @c:\wkdir\tde02_crtabl
connect oe/oe
|
|
| 3. | Now you can add some data to the table you just created . From your SQL*Plus session, execute the following script: @c:\wkdir\tde03_poptabl insert into cust_payment_info values
|
|
| 4. |
To improve performance, you create an index on the credit card number column. From your SQL*Plus session, execute the following script: @c:\wkdir\tde04_cridx
create index cust_payment_info_idx on cust_payment_info (credit_card_number);
|
|
| 5. |
You need to grant access to your users to the customer payment information table. In this case, LSMITH is the only user who can update the information. The other users can only view it. From your SQL*Plus session, execute the following script: @c:\wkdir\tde05_grant_access grant select on oe.CUST_PAYMENT_INFO to LDORAN; grant select, update on oe.CUST_PAYMENT_INFO to LSMITH; grant select on oe.CUST_PAYMENT_INFO to JKING;
|
|
In this section, you make a change to the table as LSMITH. Perform the following steps:
| 1. | Since you gave LSMITH update access, you should be able to make a change. From your SQL*Plus session, execute the following script: @c:\wkdir\tde06_make_update prompt *** Connect as Lindsay Smith (Card_V)
|
|
| 2. | In order to see the execution plan, execute the following script: @c:\wkdir\tde06a_review_xplan select * from table (dbms_xplan.display_cursor);
|
|
| 3. |
The table user_encrypted_columns will tell you which column is encrypted and its algorithm. From your SQL*Plus session, execute the following script: @c:\wkdir\tde07_select_encrypt_col connect oe/oe
|
|
Since encryption does not replace proper access control, you will limit access to the rows with a very simple VPD policy: At first you will check if the person who logs into the database is an employee, and then you will limit access to oe.cust_payment_info by credit card number:
| Card_A begins with '34' or '37' | Janette King | |
| Card_V begins with '4' | Lindsay Smith | |
| Card_M begins with '5' | Louise Doran | |
If you review the data you loaded into the table, you see that the credit card number associated with 'Albert Einstein' will never be selected by authorized users. It is only selected by intruders who circumvented the access control policies or administrative users who are exempt from these policies. This allows for highly focused auditing of this table.
Perform the following steps:
| 1. | You first need to create the function that contains the logic you want for the credit card and employee validation. From your SQL*Plus session, execute the following script: @c:\wkdir\tde08_crfunction connect system/oracle;
|
|
| 2. |
Now you can add the policy to the cust_payment_info table. From your SQL*Plus session, execute the following script: @c:\wkdir\tde09_addpolicy prompt
|
|
In this section, you connect as each employee to see if the policy works. Three things happen to show the true transparency of TDE:
| An index has been used on the encrypted column | ||
| Even though the credit card numbers are stored encrypted, the where clause in the VPD policy looks for numbers in clear text and retrieves the correct rows. | ||
| The rows visible to the three employees contain the credit card numbers in clear text. Most likely, the employees wouldn't even know that the data was stored encrypted. | ||
Perform the following steps:
| 1. |
You first connect as Janette King. She has access to Card_A that begins with '34' or '37'. From your SQL*Plus session, execute the following script: @c:\wkdir\tde10_testpolicy_jking prompt
|
|
| 2. |
Now you connect as Louise Doran. She has access to Card_M that begins with '5'. From your SQL*Plus session, execute the following script: @c:\wkdir\tde11_testpolicy_ldoran prompt
|
|
| 3. |
Then you connect as Lindsay Smith. She has access to Card_V that begins with '4'. From your SQL*Plus session, execute the following script: @c:\wkdir\tde12_testpolicy_lsmith prompt
|
|
Since TDE is done right before the data is written and transparent to all applications, there is no easy way to verify that the data has truly been encrypted. Since Oracle LogMiner records what has been written to disk, you can use it to view what is contained in the log files. Perform the following steps:
| 1. |
From your SQL*Plus session, execute the following script: @c:\wkdir\tde13_logminer connect / as sysdba;
LogMiner does not support encrypted data, so the encrypted values in the credit_card_number column are displayed as Unsupported Type. Note: If you run this tutorial in your own environment, you need to run the following command to determine the logfile names and then modify the script accordingly: select member as LOG_FILE_LOCATION from v$logfile;
|
|
To show the difference between what you would see if the column was not encrypted, you drop the table and recreate it with no columns encrypted. Perform the following steps:
| 1. | From your SQL*Plus session, execute the following script: @c:\wkdir\tde14_crtabl2 connect oe/oe
|
|
You can now rerun the logminer script to see what it contains. Perform the following steps:
| 1. | From your SQL*Plus session, execute the following script: @c:\wkdir\tde15_logminer2 connect / as sysdba;
The column is not encrypted, and LogMiner shows the clear text data which has been written to disk.
|
|
To cleanup your environment, perform the following step:
| 1. | From your SQL*Plus session, execute the following script: @c:\wkdir\tde16_cleanup connect system/oracle
|
|
In this tutorial, you learned how to:
| Prepare the database for encryption | ||
| Create a table with an encrypted column | ||
| Make a change to your encrypted data | ||
| Apply a VPD policy | ||
| Use LogMiner to view redo logs | ||
| Recreate your table without the encrypted column | ||
| Review the redo logs again | ||