My Experiments with Oracle

By Sriram Sanka -The AUAA

Archive for May 4th, 2011

Change In “Wrap” methods Of oracle Versions

Posted by sriram on May 4, 2011


As we all know ,

We can wrap the source code using wrapper utility.In the same way Oracle has wrapped some objects in Oracle Database By default.

But  there is some change in its wrapping methods.

For Example..
In Oracle 10g

CREATE OR REPLACE FUNCTION “SYSMAN”.”DECRYPT” wrapped
0
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
3
8
9000000
1
4
0
15
2 :e:
1FUNCTION:
1DECRYPT:
1CIPHER_TEXT:
1VARCHAR2:
1RETURN:
1RAW_TEXT:
1RAW:
132767:
1DBMS_CRYPTO:
1SRC:
1HEXTORAW:
1TYP:
1ENCRYPT_3DES:
1+:
1CHAIN_CBC:
1PAD_PKCS5:
1KEY:
1GETEMKEY:
1UTL_I18N:
1RAW_TO_CHAR:
1AL32UTF8:
0

0
0
48
2
0 a0 8d 8f a0 b0 3d b4
:2 a0 2c 6a a3 a0 51 a5 1c
81 b0 :3 a0 6b :3 a0 a5 b e
:3 a0 6b 7e :2 a0 6b b4 2e 7e
:2 a0 6b b4 2e e :2 a0 b4 2e
e a5 b d :3 a0 6b a0 6e
a5 b 65 b7 a4 b1 11 68
4f 1d 17 b5
48
2
0 3 7 23 1f 1e 2b 1b
30 34 38 3c 59 44 48 4b
4c 54 43 60 64 68 40 6c
70 74 78 79 7b 7d 81 85
89 8c 8f 93 97 9a 9b a0
a3 a7 ab ae af b4 b6 ba
be bf c4 c6 c7 c9 cd d1
d5 d9 dc e0 e5 e6 e8 ec
ee f2 f4 100 104 106 107 110
48
2
0 1 a 12 21 :2 12 11 b
12 :2 1 7 10 14 13 :2 10 7
5 11 :2 1d 16 1b 24 :2 1b :2 16
1b :2 27 33 34 :2 40 :2 1b 49 4a
:2 56 :2 1b :2 16 :3 1b 16 :2 11 :2 5 c
:2 15 21 2b :2 c 5 :9 1
48
4
0 :7 1 :2 2 :2 1
:7 3 :4 5 :6 6 :11 7
:5 8 :3 5 :9 a :2 4
:7 1
112
4
:3 0 1 :3 0 2
:a 0 43 1 :7 0
5 :2 0 3 4
:3 0 3 :7 0 5
4 :3 0 5 :3 0
4 :3 0 7 9
0 43 2 a
:2 0 14 15 0
9 7 :3 0 8
:2 0 7 d f
:6 0 12 10 0
41 0 6 :6 0
6 :3 0 9 :3 0
2 :3 0 a :3 0
b :3 0 3 :3 0
b 18 1a 17
1b c :3 0 9
:3 0 d :3 0 1e
1f 0 e :2 0
9 :3 0 f :3 0
22 23 0 d
21 25 :3 0 e
:2 0 9 :3 0 10
:3 0 28 29 0
10 27 2b :3 0
1d 2c 11 :3 0
12 :4 0 2f 30
:3 0 2e 31 13
16 33 13 34
0 3f 5 :3 0
13 :3 0 14 :3 0
37 38 0 6
:3 0 15 :4 0 17
39 3c 3d :2 0
3f 1a 42 :3 0
42 1d 42 41
3f 40 :6 0 43
:2 0 2 a 42
46 :3 0 45 43
47 :8 0
1f
4
:3 0 1 3 1
6 1 e 1
c 1 19 2
20 24 2 26
2a 3 1c 2d
32 2 3a 3b
2 35 3e 1
11
1
4
0
46
0
1
14
1
3
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0
3 1 0
c 1 0
2 0 1
0

where as in Oracle 11.2.0 the same function wrapped as

CREATE OR REPLACE FUNCTION “SYSMAN”.”DECRYPT” wrapped
a000000
1
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
8
1d9 16d
b7I22qBmrA5hngZ8PfHmiTb8O+UwgzJpNdxqfC9dbuqKO2FNZvfno/Ns8QsgqwomCzHLyLco
3aSo0eQcxmPI6Euw98YDgtrXDlO37aycscH+csQoFWNIszAHrssarFvJMNlZYLbOiNZIfJ2O
fPguqzMwjjlnm37HxGvpCYbc5c4137hhVayrRctxbcWTikHjZiJR0zVUFPpYrxC9n6AmTSg8
x4InsbDh78p8DHv99jCTDTUFru7JrX2SIDf9MpNiLmnpj8c3MyOhQN8amzSLH1/JFR4AxMS1
MM1SVgqke3o2ohYAkBJWC4PfU//ZEzvyC0TtT+xJsHs8S+BMQbLiMeKs38MrcRD7gl5SzA==

seems its more difficult than 10g.
for Examples see these lines from 10g code.

1FUNCTION:
1DECRYPT:
1CIPHER_TEXT:
1VARCHAR2:
1RETURN:
1RAW_TEXT:
1RAW:
132767:
1DBMS_CRYPTO:
1SRC:
1HEXTORAW:
1TYP:
1ENCRYPT_3DES:
1+:
1CHAIN_CBC:
1PAD_PKCS5:
1KEY:
1GETEMKEY:
1UTL_I18N:
1RAW_TO_CHAR:
1AL32UTF8:

which can give us some clues to re write it as below

create or replace FUNCTION DECRYPT(CIPHER_TEXT IN VARCHAR2)
RETURN VARCHAR2 AS
RAW_TEXT RAW(32767);
BEGIN
IF CIPHER_TEXT IS NULL THEN
RETURN NULL;
END IF;

RAW_TEXT := SYS.DBMS_CRYPTO.DECRYPT(

SRC=>HEXTORAW(CIPHER_TEXT),
TYP=>SYS.DBMS_CRYPTO.ENCRYPT_3DES+SYS.DBMS_CRYPTO.CHAIN_CBC+SYS.DBMS_CRYPTO.PAD_PKCS5,
KEY=>GETEMKEY());

RETURN SYS.UTL_I18N.RAW_TO_CHAR(RAW_TEXT, ‘AL32UTF8‘);
END;

Similarly some other methods.

Hope you Enjoyed it. 😉

Advertisements

Posted in Functions In oracle | 3 Comments »

 
%d bloggers like this: