Transparent Data Encryption (TDE) in Oracle 10g Database Release 2
Oracle has many security features available within the database, but until now there has been no "out-of-the-box" method for protecting the data at the operating system level. The Transparent Data Encryption (TDE) feature introduced in Oracle 10g Database Release 2 allows sensitive data to be encrypted within the datafiles to prevent access to it from the operating system. This article presents some basic examples of its use.
Setup
In order to show the encryption working we need to open a datafile in a HEX editor. Rather than trying to open a huge datafile, it makes sense to create a small file for this test.
CONN sys/password AS SYSDBA CREATE TABLESPACE tde_test DATAFILE '/u01/oradata/DB10G/tde_test.dbf' SIZE 128K AUTOEXTEND ON NEXT 64K;
Next, create a user with with a quota on the new tablespace.
CREATE USER test IDENTIFIED BY test DEFAULT TABLESPACE tde_test; ALTER USER test QUOTA UNLIMITED ON tde_test; GRANT CONNECT TO test; GRANT CREATE TABLE TO test;
Normal Column
First we will prove that the data from a normal column can be seen from the OS. To do this create a test table and insert some data.
CONN test/test CREATE TABLE tde_test ( id NUMBER(10), data VARCHAR2(50) ) TABLESPACE tde_test; INSERT INTO tde_test (id, data) VALUES (1, 'This is a secret!'); COMMIT;
Then flush the buffer cache to make sure the data is written to the datafile.
CONN sys/password AS SYSDBA ALTER SYSTEM FLUSH BUFFER_CACHE;
Open the datafile using a HEX editor (like UltraEdit) and the sentence "This is a secret!" is clearly visible amongst all the non-printable characters.
Encrypted Column
Before attempting to create a table with encrypted columns, a wallet must be created to hold the encryption key. The search order for finding the wallet is as follows:
- If present, the location specified by the ENCRYPTION_WALLET_LOCATION parameter in the sqlnet.ora file.
- If present, the location specified by the WALLET_LOCATION parameter in the sqlnet.ora file.
- The default location for the wallet ($ORACLE_BASE/admin/$ORACLE_SID/wallet).
Although encrypted tablespaces can share the default database wallet, Oracle recommend you use a separate wallet for transparent data encryption functionality by specifying theENCRYPTION_WALLET_LOCATION parameter in the sqlnet.ora file. To accomplish this we add the following entry into the sqlnet.ora file on the server and make sure the specified directory has been created.
ENCRYPTION_WALLET_LOCATION= (SOURCE=(METHOD=FILE)(METHOD_DATA= (DIRECTORY=/u01/app/oracle/admin/DB10G/encryption_wallet/)))
The following command creates and opens the wallet.
CONN sys/password AS SYSDBA ALTER SYSTEM SET ENCRYPTION KEY AUTHENTICATED BY "myPassword";
Wallets must be reopened after an instance restart and can be closed to prevent access to encrypted columns.
ALTER SYSTEM SET WALLET OPEN IDENTIFIED BY "myPassword"; ALTER SYSTEM SET WALLET CLOSE;
Create a test table with an encrypted column and insert some data. Using the ENCRYPT clause on its own is the same as using the ENCRYPT USING 'AES192' clause, as AES192 is the default encryption method.
CONN test/test DROP TABLE tde_test; PURGE RECYCLEBIN; CREATE TABLE tde_test ( id NUMBER(10), data VARCHAR2(50) ENCRYPT ) TABLESPACE tde_test; INSERT INTO tde_test (id, data) VALUES (1, 'This is a secret!'); COMMIT;
Flush the buffer cache to make sure the data is written to the datafile.
CONN sys/password AS SYSDBA ALTER SYSTEM FLUSH BUFFER_CACHE;
When the file is opened using a HEX editor only non-printable characters are present. The test sentence cannot be seen anywhere, but the data is still clearly visible from a database connection.
SELECT * FROM tde_test; ID DATA ---------- -------------------------------------------------- 1 This is a secret! 1 row selected.
Performance
There is a performance overhead associated with the encryption/decryption process. The following tables are used in a performance comparison.
CONN test/test CREATE TABLE tde_test_1 ( id NUMBER(10), data VARCHAR2(50) ) TABLESPACE tde_test; CREATE TABLE tde_test_2 ( id NUMBER(10), data VARCHAR2(50) ENCRYPT ) TABLESPACE tde_test;
The following script. uses these tables to compare the speed of regular and encrypted inserts and regular and decrypted queries. Each test repeats 1000 times, with the timings reported in 100ths of a second.
SET SERVEROUTPUT ON SIZE UNLIMITED DECLARE l_loops NUMBER := 1000; l_data VARCHAR2(50); l_start NUMBER; BEGIN EXECUTE IMMEDIATE 'TRUNCATE TABLE tde_test_1'; EXECUTE IMMEDIATE 'TRUNCATE TABLE tde_test_2'; l_start := DBMS_UTILITY.get_time; FOR i IN 1 .. l_loops LOOP INSERT INTO tde_test_1 (id, data) VALUES (i, 'Data for ' || i); END LOOP; DBMS_OUTPUT.put_line('Normal Insert : ' || (DBMS_UTILITY.get_time - l_start)); l_start := DBMS_UTILITY.get_time; FOR i IN 1 .. l_loops LOOP INSERT INTO tde_test_2 (id, data) VALUES (i, 'Data for ' || i); END LOOP; DBMS_OUTPUT.put_line('Encrypted Insert: ' || (DBMS_UTILITY.get_time - l_start)); l_start := DBMS_UTILITY.get_time; FOR i IN 1 .. l_loops LOOP SELECT data INTO l_data FROM tde_test_1 WHERE id = i; END LOOP; DBMS_OUTPUT.put_line('Normal Query : ' || (DBMS_UTILITY.get_time - l_start)); l_start := DBMS_UTILITY.get_time; FOR i IN 1 .. l_loops LOOP SELECT data INTO l_data FROM tde_test_2 WHERE id = i; END LOOP; DBMS_OUTPUT.put_line('Decrypted Query : ' || (DBMS_UTILITY.get_time - l_start)); END; / Normal Insert : 31 Encrypted Insert: 45 Normal Query : 42 Decrypted Query : 58 PL/SQL procedure successfully completed. SQL>
The results clearly demonstrate that encrypted inserts and decrypted queries are slower than their normal counterparts.
External Tables
External tables can be encrypted in a similar way to regular tables. First, we make sure the default data pump directory is available to the test user.
CONN sys/password AS SYSDBA GRANT READ, WRITE ON DIRECTORY data_pump_dir TO test;
Next, we create the external table as a copy of an existing table, using the ENCRYPT clause.
CONN test/test CREATE TABLE tde_test_1_ext ( id, data ENCRYPT IDENTIFIED BY "myPassword" ) ORGANIZATION EXTERNAL ( TYPE ORACLE_DATAPUMP DEFAULT DIRECTORY data_pump_dir location ('tde_test_1_ext.dmp') ) AS SELECT id, data FROM tde_test_1;
Views
The %_ENCRYPTED_COLUMNS views are used to display information about encrypted columns.
SET LINESIZE 100 COLUMN owner FORMAT A15 COLUMN tble_name FORMAT A15 COLUMN column_name FORMAT A15 SELECT * FROM dba_encrypted_columns; OWNER TABLE_NAME COLUMN_NAME ENCRYPTION_ALG SAL --------------- ------------------------------ --------------- ----------------------------- --- TEST TDE_TEST_2 DATA AES 192 bits key YES TEST TDE_TEST_1_EXT DATA AES 192 bits key YES 2 rows selected. SQL>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24104518/viewspace-713754/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle 10g flashback databaseOracle 10gDatabase
- Scheduler in Oracle Database 10g(轉)OracleDatabase
- Oracle 19c Concepts(00):Changes in This Release for Oracle Database ConceptsOracleDatabase
- 1 Oracle Database Release 20c New FeaturesOracleDatabase
- Automatic Diagnostic Repository (ADR) in Oracle Database 11g Release 1 (ADRCI)OracleDatabase
- Oracle TDE加密測試Oracle加密
- [20181018]Oracle Database 12c: Data Redaction.txtOracleDatabase
- oracle 12c release 2 安裝Oracle
- Oracle設定日誌引數-ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;OracleDatabase
- 如何手工重建10g database consoleDatabase
- 2 Oracle Data Guard 安裝Oracle
- windows2008R2安裝oracle 10gWindowsOracle 10g
- ORACLE database vaultOracleDatabase
- Oracle clone databaseOracleDatabase
- Oracle Database Cloud - Database as a Service Quick StartOracleDatabaseCloudUI
- 2 開始實用 Oracle Data GuardOracle
- [轉帖]Release Schedule of Current Database Releases (Doc ID 742060.1)Database
- Oracle Database Scheduler整理OracleDatabase
- Oracle Physical Database LimitsOracleDatabaseMIT
- Oracle 10g 下載地址Oracle 10g
- oracle 10G特性之awrOracle 10g
- Oracle Database 12cR2多租戶權威指南OracleDatabase
- Oracle Database 12cR2/R1中的更改OracleDatabase
- Oracle Data Guard Feature 12cR2系列(二)Oracle
- Oracle Data Guard Feature 12cR2系列(一)Oracle
- Oracle 12.2 使用Database Link優化Standby Database WorkloadOracleDatabase優化
- ISO 映象安裝oracle 10gOracle 10g
- Oracle 10g RAC故障處理Oracle 10g
- Oracle 10g 增刪節點Oracle 10g
- Oralce 入門教程:Oracle Database 9i 10g 11g程式設計藝術 深入資料庫體系結構 第2版OracleDatabase程式設計資料庫
- Oracle 19c Concepts(01):Introduction to Oracle DatabaseOracleDatabase
- Oracle 19c Concepts(13):Oracle Database InstanceOracleDatabase
- Oracle OCP(35):Database 安裝OracleDatabase
- Oracle DG Standby Database型別OracleDatabase型別
- Oracle DG建立Physical Standby DatabaseOracleDatabase
- Oracle DG建立Logical Standby DatabaseOracleDatabase
- Oracle data link建立Oracle
- Oracle 12C Database File Mapping for Oracle ASM FilesOracleDatabaseAPPASM
- Transparent Tribe行動