`
380071587
  • 浏览: 454849 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

oracle Wallet的使用

 
阅读更多

摘自:http://www.2cto.com/database/201107/97945.html

oracle Wallet的使用(即内部加密技术TDE(Transparent Data Encryption ))

1. TDE是Oracle10gR2中推出的一个新功能,使用时要保证Oracle版本是在10gR2或者以上

--查看oracle版本:

select * from v$version;

2、创建一个新目录,并指定为Wallet目录

D:\oracle\product\10.2.0\admin\ora10\ora_wallet

3. 设置wallet目录,在参数文件sqlnet.ora中,按照下面的格式加入信息:

ENCRYPTION_WALLET_LOCATION=(SOURCE=(METHOD=FILE)

(METHOD_DATA=(DIRECTORY=D:\oracle\product\10.2.0\admin\ora10\ora_wallet)))

4. 创建master key文件,指定wallet密码,使用SYS用户登入系统,建立加密文件

SQL> alter system set encryption key identified by "wallet";

System altered

-- 密码"wallet"不加引号时,后面使用时也不需要用引号

此时在设置的目录下,多出一个Personal Information Exchange类型的文件,相当于我们生成的master key文件。D:\oracle\product\10.2.0\admin\ora10\ora_wallet\ewallet.p12

5、启动、关闭Wallet

SQL> ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "wallet";

ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "wallet"

ORA-28354: wallet 已经打开

SQL> ALTER SYSTEM SET ENCRYPTION WALLET CLOSE; --关闭

System altered

SQL> ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "wallet"; --打开

System altered

到此,已经成功配置了Wallet,创建了master key。

下面看如何使用TDE进行数据加密:

加密数据列:

对数据列加密是TDE一个常用的功能。常需要对数据库中某个表的某个敏感数据进行加密处理,方式信息的外泄。

首先,在定义数据表中的数据列(或者修改数据列)的时候,使用ENCRYPT进行标注。表示这个字段是使用加密保护的重要字典。

--建临时表:

create table t_tmp_emplorey

as

select * from emplorey t

--加密数据列,使用了ENCRYPT进行标志,表明需要对这个字段进行加密处理,采用默认的加密配置。

alter table scott.t_tmp_emplorey modify (sal encrypt);

注意:在默认不指定的情况下,Oracle在加密之前,对明文都要进行salt处理。所谓salt处理是一种强化加密数据的方法。通过在加密前明文中掺入一个随机字符串,来强化加密层级,防止进行字典攻击和其他类型的破解操作。如果不需要进行salt处理,就是在ENCRYPT后面加No Salt。

--例:alter table scott.t_tmp_emplorey modify (sal encrypt no salt);

--指定加密算法

alter table scott.t_tmp_emplorey modify (sal encrypt using '3DES168');

--如果要对一个已经加密处理的数据列,解除加密,使用alter table…和DECRYPT关键字就可以实现。

SQL> alter table scott.t_tmp_emplorey modify (sal DECRYPT) ;

Table altered

--解除加密后,关闭Wallet后,查询数据不受影响。

6. 对查询、索引的影响:

查询结果似乎和一般的没有差别,但是如果关闭了解密Wallet会如何?

SQL> ALTER SYSTEM SET ENCRYPTION WALLET CLOSE;

System altered

--再次查询时报错

select * from scott.t_tmp_emplorey t;

ORA-28365: Wallet 未打开

--能够查找到数目

select count(1) from scott.t_tmp_emplorey t;

--对索引的影响,如果列加密使用了salt,在对该列进行索引的时候,会报错。:

SQL> create index ind_t_tmp_emplorey on t_tmp_emplorey(sal);

create index ind_t_tmp_emplorey on t_tmp_emplorey(sal);

ORA-28338: 无法使用salt 值加密索引列

SQL> create index ind_t_tmp_emplorey on t_tmp_emplorey(EMPNO);

Index created

--没有加密的列可以建立索引

ocp 考核题:

Q401. You opened the walletand then issued the following command:

SQL>CREATE TABLESPACE securespace

DATAFILE '/home/user/oradata/secure01.dbf'

SIZE 150M

ENCRYPTION USING '3DES168'

DEFAULT STORAGE(ENCRYPT);

Then you closed the wallet. Later, you issued the followingcommand to create the EMPLOYEES table in the SECURESPACE tablespace and you usethe NO SALT option for the EMPID column.

What is the outcome?

A. It creates the table and encrypts the data in it.

B. It generates an error because the wallet is closed.

C. It creates the table but does not encrypt the data in it.

D. It generates an error because the NO SALT option cannot beused with the ENCRYPT option.

Answer: B


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics