DBA Data[Home] [Help]

PACKAGE: SYS.DBMS_OBFUSCATION_TOOLKIT

Source


1 PACKAGE dbms_obfuscation_toolkit AS
2 
3     -- Note that the following pragma applies to both functions
4     -- and procedures (see doc bug 3103959).
5     pragma restrict_references (default, RNDS, WNDS, RNPS, WNPS);
6 
7     ------------------------------- TYPES ------------------------------------
8     -- Types used to make it easier for the user to reserve the correct
9     -- amount of memory for a checksum.
10 
11     SUBTYPE varchar2_checksum IS VARCHAR2(16);
12     SUBTYPE raw_checksum IS RAW(16);
13 
14     ----------------------------- CONSTANTS -----------------------------------
15     -- Triple DES modes
16     TwoKeyMode   INTEGER := 0;
17     ThreeKeyMode INTEGER := 1;
18 
19     ----------------------------- EXCEPTIONS ----------------------------------
20     -- Invalid mode specified for Triple DES.
21     InvalidTripleDESMode EXCEPTION;
22     PRAGMA EXCEPTION_INIT(InvalidTripleDESMode, -28236);
23 
24     ---------------------- FUNCTIONS AND PROCEDURES ---------------------------
25 
26     ---------------------------- KEY GENERATION ------------------------------
27     -- The following routines generate encryption keys. Each takes a random
28     -- value which it uses in the generation of the key. This value must be
29     -- at least 80 characters long.
30     -- There are two versions of each procedure and function: one for raw data
31     -- and the other for strings.
32     ---------------------------------------------------------------------------
33     PROCEDURE DESGetKey(seed  IN     RAW,
34                         key      OUT RAW);
35     pragma restrict_references (DESGetKey, RNDS, WNDS, WNPS);
36 
37     FUNCTION DESGetKey(seed IN RAW) RETURN RAW;
38     pragma restrict_references (DESGetKey, RNDS, WNDS, WNPS);
39 
40     PROCEDURE DESGetKey(seed_string IN     VARCHAR2,
41                         key            OUT VARCHAR2);
42     pragma restrict_references (DESGetKey, RNDS, WNDS, WNPS);
43 
44     FUNCTION DESGetKey(seed_string IN VARCHAR2) RETURN VARCHAR2;
45     pragma restrict_references (DESGetKey, RNDS, WNDS, WNPS);
46 
47     -- For Triple DES, the mode is specified so that the key has the proper
48     -- length is returned.
49     PROCEDURE DES3GetKey(which IN     PLS_INTEGER DEFAULT TwoKeyMode,
50                          seed  IN     RAW,
51                          key      OUT RAW);
52     pragma restrict_references (DES3GetKey, RNDS, WNDS, WNPS);
53 
54     FUNCTION DES3GetKey(which IN PLS_INTEGER DEFAULT TwoKeyMode,
55                         seed  IN RAW)
56         RETURN RAW;
57     pragma restrict_references (DES3GetKey, RNDS, WNDS, WNPS);
58 
59     PROCEDURE DES3GetKey(which       IN     PLS_INTEGER DEFAULT TwoKeyMode,
60                          seed_string IN     VARCHAR2,
61                          key            OUT VARCHAR2);
62     pragma restrict_references (DES3GetKey, RNDS, WNDS, WNPS);
63 
64     FUNCTION DES3GetKey(which        IN PLS_INTEGER DEFAULT TwoKeyMode,
65                         seed_string  IN VARCHAR2)
66         RETURN VARCHAR2;
67     pragma restrict_references (DES3GetKey, RNDS, WNDS, WNPS);
68 
69     ---------------------------- DATA ENCRYPTION ------------------------------
70     -- The following routines encrypt and decrypt data.
71     -- There are two versions of each procedure and function: one for raw data
72     -- and the other for strings.
73     ---------------------------------------------------------------------------
74 
75     -- DES
76     PROCEDURE DESEncrypt(input            IN     RAW,
77                          key              IN     RAW,
78                          encrypted_data      OUT RAW);
79 
80     FUNCTION DESEncrypt(input            IN  RAW,
81                         key              IN  RAW)
82         RETURN RAW;
83 
84     PROCEDURE DESEncrypt(input_string    IN     VARCHAR2,
85                         key_string       IN     VARCHAR2,
86                         encrypted_string    OUT VARCHAR2);
87 
88     FUNCTION DESEncrypt(input_string     IN  VARCHAR2,
89                         key_string       IN  VARCHAR2)
90         RETURN VARCHAR2;
91 
92     PROCEDURE DESDecrypt(input            IN      RAW,
93                          key              IN      RAW,
94                          decrypted_data       OUT RAW);
95 
96     FUNCTION DESDecrypt(input            IN  RAW,
97                         key              IN  RAW)
98         RETURN RAW;
99 
100     PROCEDURE DESDecrypt(input_string     IN    VARCHAR2,
101                          key_string       IN    VARCHAR2,
102                          decrypted_string    OUT VARCHAR2);
103 
104     FUNCTION DESDecrypt(input_string     IN     VARCHAR2,
105                         key_string       IN  VARCHAR2)
106         RETURN VARCHAR2;
107 
108     -- Triple DES
109 
110     PROCEDURE DES3Encrypt(input          IN     RAW,
111                           key            IN     RAW,
112                           encrypted_data    OUT RAW,
113                           which          IN     PLS_INTEGER
114                                                   DEFAULT TwoKeyMode,
115                           iv             IN     RAW DEFAULT NULL);
116     pragma restrict_references (DES3Encrypt, RNDS, WNDS, WNPS);
117 
118     FUNCTION DES3Encrypt(input IN RAW,
119                          key   IN RAW,
120                          which IN PLS_INTEGER DEFAULT TwoKeyMode,
121                          iv    IN RAW DEFAULT NULL)
122         RETURN RAW;
123     pragma restrict_references (DES3Encrypt, RNDS, WNDS, WNPS);
124 
125     PROCEDURE DES3Encrypt(input_string     IN     VARCHAR2,
126                           key_string       IN     VARCHAR2,
127                           encrypted_string    OUT VARCHAR2,
128                           which            IN     PLS_INTEGER
129                                                     DEFAULT TwoKeyMode,
130                           iv_string        IN     VARCHAR2 DEFAULT NULL);
131     pragma restrict_references (DES3Encrypt, RNDS, WNDS, WNPS);
132 
133     FUNCTION DES3Encrypt(input_string  IN VARCHAR2,
134                          key_string    IN VARCHAR2,
135                          which         IN PLS_INTEGER DEFAULT TwoKeyMode,
136                          iv_string     IN VARCHAR2 DEFAULT NULL)
137         RETURN VARCHAR2;
138     pragma restrict_references (DES3Encrypt, RNDS, WNDS, WNPS);
139 
140     PROCEDURE DES3Decrypt(input          IN     RAW,
141                           key            IN     RAW,
142                           decrypted_data    OUT RAW,
143                           which          IN     PLS_INTEGER
144                                                   DEFAULT TwoKeyMode,
145                           iv             IN     RAW DEFAULT NULL);
146     pragma restrict_references (DES3Decrypt, RNDS, WNDS, WNPS);
147 
148     FUNCTION DES3Decrypt(input IN RAW,
149                          key   IN RAW,
150                          which IN PLS_INTEGER DEFAULT TwoKeyMode,
151                          iv    IN RAW DEFAULT NULL)
152         RETURN RAW;
153     pragma restrict_references (DES3Decrypt, RNDS, WNDS, WNPS);
154 
155     PROCEDURE DES3Decrypt(input_string     IN     VARCHAR2,
156                           key_string       IN     VARCHAR2,
157                           decrypted_string    OUT VARCHAR2,
158                           which            IN     PLS_INTEGER
159                                                     DEFAULT TwoKeyMode,
160                           iv_string        IN VARCHAR2 DEFAULT NULL);
161     pragma restrict_references (DES3Decrypt, RNDS, WNDS, WNPS);
162 
163     FUNCTION DES3Decrypt(input_string IN VARCHAR2,
164                          key_string   IN VARCHAR2,
165                          which        IN PLS_INTEGER DEFAULT TwoKeyMode,
166                          iv_string    IN VARCHAR2 DEFAULT NULL)
167         RETURN VARCHAR2;
168     pragma restrict_references (DES3Decrypt, RNDS, WNDS, WNPS);
169 
170     -------------------------------- MD5 --------------------------------------
171     -- The following routines generate MD5 hashes of data.
172     -- There are two versions: one for raw data and the other for strings.
173     ---------------------------------------------------------------------------
174 
175     PROCEDURE MD5(input    IN  RAW,
176                   checksum OUT raw_checksum);
177 
178     FUNCTION MD5(input    IN  RAW)
179         RETURN raw_checksum;
180 
181     PROCEDURE MD5(input_string    IN     VARCHAR2,
182                   checksum_string    OUT varchar2_checksum);
183 
184     FUNCTION MD5(input_string    IN     VARCHAR2)
185         RETURN varchar2_checksum;
186 
187 END dbms_obfuscation_toolkit;