TDE(Transparent Data Encryption ),通过使用wallet 对数据加密,物理上对数据文件中的数据进行加密。
工作过程:
当用户插入数据到需要加密的列中的时候,Oracle 10g从钱夹中获取master密钥,用master密钥解密数据字典中的表密钥,然后用解密后的表密钥加密输入数据,再将加密后的数据保存在数据库中。
当用户查询一个加密列的时候,Oracle 将加密的表密钥从数据字典中取出,再取出master密钥,然后解密表密钥,再用解密后的表密钥来解密磁盘上加密的数据,最后返回明文给用户。
所有操作对用户而言是透明的。
1. 创建钱包
sqlplus中查看,文件路径和查询中的一致
1.SQL> SELECT * FROM V$ENCRYPTION_WALLET;
2.
3.WRL_TYPE WRL_PARAMETER STATUS
4.-------------------- ------------------------------------------------------------ ------------------
5.file /oracle/app/oracle/admin/PROD/wallet CLOSED
默认是关闭的,修改sqlnet.ora文件,wallet不存在,创建一下
1.mkdir -p /oracle/app/oracle/admin/PROD/wallet
.
1.ENCRYPTION_WALLET_LOCATION=
2. (SOURCE=
3. (METHOD=FILE)
4. (METHOD_DATA=
5. (DIRECTORY=/oracle/app/oracle/admin/wallet)))
创建wallet.
1.SQL> ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY "oracle";
2.
3.System altered.
4.
5.SQL> col WRL_PARAMETER for a60
6.SQL> set line 200
7.SQL> SELECT * FROM V$ENCRYPTION_WALLET;
8.
9.WRL_TYPE WRL_PARAMETER STATUS
10.-------------------- ------------------------------------------------------------ ------------------
11.file /oracle/app/oracle/admin/PROD/wallet OPEN
.
1.PROD@localhost.localdomain /oracle/app/oracle/admin/PROD/wallet$ ll
2.total 4
3.-rw-r--r-- 1 oracle oinstall 2845 Jul 9 06:43 ewallet.p12
4.PROD@localhost.localdomain /oracle/app/oracle/admin/PROD/wallet$
2.透明列级加密.
1.-- 不能对 sys用户的表加密
2.
.
1.SQL> conn hxy/hxy
.
1.Connected.
.
1.
.
1.CREATE TABLE cust_payment_info
2. (first_name VARCHAR2(11),
3. last_name VARCHAR2(10),
4. order_number NUMBER(5),
5. credit_card_number VARCHAR2(16) ENCRYPT NO SALT,
6. active_card VARCHAR2(3));
.
1.INSERT INTO cust_payment_info VALUES
2. (‘Jon‘, ‘Oldfield‘, 10001, ‘5446959708812985‘,‘YES‘);
3.INSERT INTO cust_payment_info VALUES
4. (‘Chris‘, ‘White‘, 10002, ‘5122358046082560‘,‘YES‘);
5.INSERT INTO cust_payment_info VALUES
6. (‘Alan‘, ‘Squire‘, 10003, ‘5595968943757920‘,‘YES‘);
7.INSERT INTO cust_payment_info VALUES
8. (‘Mike‘, ‘Anderson‘, 10004, ‘4929889576357400‘,‘YES‘);
9.INSERT INTO cust_payment_info VALUES
10. (‘Annie‘, ‘Schmidt‘, 10005, ‘4556988708236902‘,‘YES‘);
11.INSERT INTO cust_payment_info VALUES
12. (‘Elliott‘, ‘Meyer‘, 10006, ‘374366599711820‘,‘YES‘);
13.INSERT INTO cust_payment_info VALUES
14. (‘Celine‘, ‘Smith‘, 10007, ‘4716898533036‘,‘YES‘);
15.INSERT INTO cust_payment_info VALUES
16. (‘Steve‘, ‘Haslam‘, 10008, ‘340975900376858‘,‘YES‘);
17.INSERT INTO cust_payment_info VALUES
18. (‘Albert‘, ‘Einstein‘, 10009, ‘310654305412389‘,‘YES‘);
.
1.SQL> select * from cust_payment_info
2. 2 ;
3.
4.FIRST_NAME LAST_NAME ORDER_NUMBER CREDIT_CARD_NUMB ACT
5.----------- ---------- ------------ ---------------- ---
6.Chris White 10002 5122358046082560 YES
7.Alan Squire 10003 5595968943757920 YES
8.Mike Anderson 10004 4929889576357400 YES
9.Annie Schmidt 10005 4556988708236902 YES
10.Elliott Meyer 10006 374366599711820 YES
11.Celine Smith 10007 4716898533036 YES
12.Steve Haslam 10008 340975900376858 YES
13.Albert Einstein 10009 310654305412389 YES
14.
15.8 rows selected.
关闭钱包,则无法访问
1.SQL> ALTER SYSTEM SET ENCRYPTION WALLET close identified by oracle;
2.
3.System altered.
4.
5.SQL> conn hxy/hxy
6.Connected.
7.SQL> select * from cust_payment_info;
8.select * from cust_payment_info
9. *
10.ERROR at line 1:
11.ORA-28365: wallet is not open
3. 透明表空间加密 (表空间上所有的数据都加密)
1.SQL> CREATE TABLESPACE securespace
2. 2 DATAFILE ‘/home/oracle/oracle3/product/11.1.0/db_1/secure01.dbf‘
3. 3 SIZE 150M
4. 4 ENCRYPTION
5. 5 DEFAULT STORAGE(ENCRYPT);
6.Tablespace created.
.
1.SQL> CREATE TABLE customer_payment_info
2. 2 (first_name VARCHAR2(11),
3. 3 last_name VARCHAR2(10),
4. 4 order_number NUMBER(5),
5. 5 credit_card_number VARCHAR2(16),
6. 6 active_card VARCHAR2(3))TABLESPACE securespace;
7.Table created.
4. 删除了操作系统的加密文件
执行下面的命令,输入原来的密码会生成一个.p12文件
.
1.PROD@localhost.localdomain /oracle/app/oracle/product/11.2.0/network/admin$ mkstore -wrl /oracle/app/oracle/product/11.2.0/network/admin/wallet/ -list
2.Oracle Secret Store Tool : Version 11.2.0.4.0 - Production
3.Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
4.
5.Enter wallet password:
6.
7.Oracle Secret Store entries:
8.ORACLE.SECURITY.DB.ENCRYPTION.ARMxdklw5k9zv9UpvDKPCDMAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
9.ORACLE.SECURITY.DB.ENCRYPTION.MASTERKEY
10.
.
1.PROD@localhost.localdomain /oracle/app/oracle/product/11.2.0/network/admin/wallet$ ll
2.total 4
3.-rw-r--r-- 1 oracle oinstall 2581 Jul 9 08:35 ewallet.p12
本文由职坐标整理并发布,希望对同学们学习加密--wallet有所理解。
了解更多详情请关注职坐标Oracle数据库频道!