Salut,
J'aimerai savoir s'il existe une fonction permettant de crypter / décrypter les données d'un attribut sous Oracle (pour crypter un mot de passe par exemple).
Merci par avance
Salut,
J'aimerai savoir s'il existe une fonction permettant de crypter / décrypter les données d'un attribut sous Oracle (pour crypter un mot de passe par exemple).
Merci par avance
Voir le package SYS.DBMS_OBFUSCATION_LIB
Source = $ORACLE_HOME/rdbms/admin/dbmsobtk.sql
Il faut dans les préférence de l'administrateur sysman désigner une
utilisateur windows du noeud du serveur oracle afin qu'il puisse ouvrir
une session en tant que tache, il serait bien qu'il soit administrateur
local.
Voici l'exemple extrait de la doc Oracle
"Oracle8i Supplied PL/SQL Packages Reference" :
(c'est un peu long mais ça peut se révéler utile...)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198 DESEncryption and DESDecryption Code Example Following is a sample PL/SQL program for your reference. Segments of the code are numbered and contain narrative text explaining portions of the code. DECLARE input_string VARCHAR2(16) := 'tigertigertigert'; raw_input RAW(128) := UTL_RAW.CAST_TO_RAW(input_string); key_string VARCHAR2(8) := 'scottsco'; raw_key RAW(128) := UTL_RAW.CAST_TO_RAW(key_string); wrong_input_string VARCHAR2(25) := 'not_a_multiple_of_8_bytes'; wrong_raw_input RAW(128) := UTL_RAW.CAST_TO_RAW(wrong_input_string); wrong_key_string VARCHAR2(8) := 'scottsco'; wrong_raw_key RAW(128) := UTL_RAW.CAST_TO_RAW(wrong_key_string); encrypted_raw RAW(2048); encrypted_string VARCHAR2(2048); double_encrypted_raw RAW(2048); double_encrypted_string VARCHAR2(2048); decrypted_raw RAW(2048); decrypted_string VARCHAR2(2048); error_in_input_buffer_length EXCEPTION; PRAGMA EXCEPTION_INIT(error_in_input_buffer_length, -28232); INPUT_BUFFER_LENGTH_ERR_MSG VARCHAR2(100) := '*** DES INPUT BUFFER NOT A MULTIPLE OF 8 BYTES - IGNORING EXCEPTION ***'; double_encrypt_not_permitted EXCEPTION; PRAGMA EXCEPTION_INIT(double_encrypt_not_permitted, -28233); DOUBLE_ENCRYPTION_ERR_MSG VARCHAR2(100) := '*** CANNOT DOUBLE ENCRYPT DATA - IGNORING EXCEPTION ***'; -- 1. Begin testing raw data encryption and decryption BEGIN dbms_output.put_line('> ========= BEGIN TEST RAW DATA ========='); dbms_output.put_line('> Raw input : ' || UTL_RAW.CAST_TO_VARCHAR2(raw_input)); BEGIN dbms_obfuscation_toolkit.DESEncrypt(input => raw_input, key => raw_key, encrypted_data => encrypted_raw ); dbms_output.put_line('> encrypted hex value : ' || rawtohex(encrypted_raw)); dbms_obfuscation_toolkit.DESDecrypt(input => encrypted_raw, key => raw_key, decrypted_data => decrypted_raw); dbms_output.put_line('> Decrypted raw output : ' || UTL_RAW.CAST_TO_VARCHAR2(decrypted_raw)); dbms_output.put_line('> '); if UTL_RAW.CAST_TO_VARCHAR2(raw_input) = UTL_RAW.CAST_TO_VARCHAR2(decrypted_raw) THEN dbms_output.put_line('> Raw DES Encyption and Decryption successful'); END if; EXCEPTION WHEN error_in_input_buffer_length THEN dbms_output.put_line('> ' || INPUT_BUFFER_LENGTH_ERR_MSG); END; dbms_output.put_line('> '); -- 2. Begin testing raw data double encryption prevention BEGIN dbms_output.put_line('> testing double encryption prevention'); dbms_output.put_line('> '); dbms_obfuscation_toolkit.DESEncrypt(input => raw_input, key => raw_key, encrypted_data => encrypted_raw ); dbms_output.put_line('> input hex value : ' || rawtohex(encrypted_raw)); dbms_obfuscation_toolkit.DESEncrypt( input => encrypted_raw, key => raw_key, encrypted_data => double_encrypted_raw ); dbms_output.put_line('> double encrypted hex value : ' || rawtohex(double_encrypted_raw)); EXCEPTION WHEN double_encrypt_not_permitted THEN dbms_output.put_line('> ' || DOUBLE_ENCRYPTION_ERR_MSG); END; dbms_output.put_line('> '); -- 3. Begin testing wrong raw input length values for encrypt operation BEGIN dbms_output.put_line('> Wrong Raw input for encryption : ' || UTL_RAW.CAST_TO_VARCHAR2(wrong_raw_input)); dbms_obfuscation_toolkit.DESEncrypt( input => wrong_raw_input, key => raw_key, encrypted_data => encrypted_raw ); dbms_output.put_line('> encrypted hex value : ' || rawtohex(encrypted_raw)); EXCEPTION WHEN error_in_input_buffer_length THEN dbms_output.put_line('> ' || INPUT_BUFFER_LENGTH_ERR_MSG); END; dbms_output.put_line('> '); -- 4. Begin testing wrong raw input length values for decrypt operation BEGIN -- testing wrong input values for decyrpt operation dbms_output.put_line('> Wrong Raw input for decryption : ' || UTL_RAW.CAST_TO_VARCHAR2(wrong_raw_input)); dbms_obfuscation_toolkit.DESDecrypt (input => wrong_raw_input, key => raw_key, decrypted_data => decrypted_raw ); dbms_output.put_line('> decrypted hex value : ' || rawtohex(decrypted_raw)); EXCEPTION WHEN error_in_input_buffer_length THEN dbms_output.put_line('> ' || INPUT_BUFFER_LENGTH_ERR_MSG); END; dbms_output.put_line('> '); dbms_output.put_line('> ========= END TEST RAW DATA ========='); -- 5. Begin testing string data encryption and decryption dbms_output.put_line('> ========= BEGIN TEST STRING DATA ========='); BEGIN dbms_output.put_line('> input string : ' || input_string); dbms_obfuscation_toolkit.DESEncrypt( input_string => input_string, key_string => key_string, encrypted_string => encrypted_string ); dbms_output.put_line('> encrypted hex value : ' || rawtohex(UTL_RAW.CAST_TO_RAW(encrypted_string))); dbms_obfuscation_toolkit.DESDecrypt( input_string => encrypted_string, key_string => key_string, decrypted_string => decrypted_string ); dbms_output.put_line('> decrypted string output : ' || decrypted_string); if input_string = decrypted_string THEN dbms_output.put_line('> String DES Encyption and Decryption successful'); END if; EXCEPTION WHEN error_in_input_buffer_length THEN dbms_output.put_line(' ' || INPUT_BUFFER_LENGTH_ERR_MSG); END; dbms_output.put_line('> '); -- 6. Begin testing string data double encryption prevention BEGIN dbms_output.put_line('> testing double encryption prevention'); dbms_output.put_line('> '); dbms_obfuscation_toolkit.DESEncrypt( input_string => input_string, key_string => key_string, encrypted_string => encrypted_string ); dbms_output.put_line('> input hex value : ' || rawtohex(UTL_RAW.CAST_TO_RAW(encrypted_string))); dbms_obfuscation_toolkit.DESEncrypt( input_string => encrypted_string, key_string => key_string, encrypted_string => double_encrypted_string ); dbms_output.put_line('> double encrypted hex value : ' || rawtohex(UTL_RAW.CAST_TO_RAW(double_encrypted_string))); EXCEPTION WHEN double_encrypt_not_permitted THEN dbms_output.put_line('> ' || DOUBLE_ENCRYPTION_ERR_MSG); END; dbms_output.put_line('> '); -- 7. Begin testing wrong string input length values for encyrpt operation BEGIN dbms_output.put_line('> testing wrong input values for encyrpt operation'); dbms_output.put_line('> Wrong Raw input for encryption : ' || wrong_input_string); dbms_obfuscation_toolkit.DESEncrypt( input_string => wrong_input_string, key_string => wrong_key_string, encrypted_string => encrypted_string ); dbms_output.put_line('> encrypted hex value : ' || rawtohex(UTL_RAW.CAST_TO_RAW(encrypted_string))); EXCEPTION WHEN error_in_input_buffer_length THEN dbms_output.put_line('> ' || INPUT_BUFFER_LENGTH_ERR_MSG); END; dbms_output.put_line('> '); -- 8. Begin testing wrong string input length values for decrypt operation BEGIN -- testing wrong input values for decyrpt operation dbms_output.put_line('> Wrong Raw input for encryption : ' || wrong_input_string); dbms_obfuscation_toolkit.DESDecrypt( input_string => wrong_input_string, key_string => wrong_key_string, decrypted_string => decrypted_string ); dbms_output.put_line('> decrypted string output : ' || decrypted_string); EXCEPTION WHEN error_in_input_buffer_length THEN dbms_output.put_line('> ' || INPUT_BUFFER_LENGTH_ERR_MSG); END; dbms_output.put_line('> '); dbms_output.put_line('> ========= END TEST STRING DATA ========='); END; /
Salut,
Jette un oeil ici :
http://www.developpez.net/forums/viewtopic.php?t=29779
Si tu as besoin d'autres renseignement sur le cryptage n'hésites pas à m'en faire part .
A+
Et voici un exmeple de cryptage puisqu'a l'url que j'ai laissé ci dessus je ne traite que du decryptage :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 CREATE OR REPLACE PROCEDURE create_user(l_key in varchar2, l_userid in varchar2, l_nomprenom in varchar2, l_tel in varchar2, l_fax in varchar2, l_site in number, l_log in varchar2, l_service in number, l_password in varchar2,) is l_data varchar2(2000); Key_check_flag number; l_encrypted_string varchar2(2000); BEGIN --- the key and the input data must have a length -- divisible by eight (the key must be exactly 8 bytes long). l_data := RPAD(l_password,(TRUNC(LENGTH(l_password)/8)+1)*8,CHR(0)); key_check_flag := mod(length(l_key),8); if key_check_flag != 0 then Raise_application_error(-20199,'Key should be 8 char long'); end if; -- Encrypt the input string DBMS_OBFUSCATION_TOOLKIT.DESENCRYPT (input_string => l_data, key_string => l_key, encrypted_string => l_encrypted_string); -- DBMS_OUTPUT.PUT_LINE('l_string ENCRYPTED: ' || l_encrypted_string); insert into users (userid, nomprenom, tel, fax, site, date_creation, createur, service,password) values (LOWER(l_userid), UPPER(l_nomprenom), l_tel, l_fax, l_site, sysdate, l_log, l_service, l_encrypted_string); END; /
Bonjour,
voila je suis en trai de faire l'analyse pour l'encryption d'une donnée(colonne ) sur une table. cette colonne est de type confidentiel.
J'ai cherché sur le web et j'ai trouvé que je peut faire l'encryption et la decryption en utilisant la package dms_obfuscation, donc là kle problème ne se pose pas.
Mon problème est que cette colonne est affichée dans un écran forms et elle est accéssible pour des usagers ayant le role necessaire. (elle est aussi inseré dans la bd via cet écran, l'encryption se fait via le trigger before insert de la table concernée)
donc je voudrais savoir comment faire pour l'afficher decryptée dans cet écran ?
- comment gérer toutes les mise à jour de champ qui est encrypté dans la table ?
Merci.
Le probleme de l'encryption, c'est la decryption. Si la valeur cryptee subsiste a proximite de la routine de decryption, on a rien resolu en terme de securite, exception faite d'un faux sentiment de securite accrue.
Pourquoi dans le cas present ne pas conserver la colonne non cryptee, mais filtrer au contraire l'acces a la colonne en question avec VPD, cad la rendre visible en fonction des privileges dont beneficie l'utilisateur. Oracle10g permets le filtrage des donnees non seulement par enregistrement, mais egalement au niveau des colonnes.
Bonjour,
Ca semble trés interessant mais comment faire ?
ou pourrais-je trouve plus de détails 6
est ce c'est facile à mettre en place ?
merci pour tout complément d'information.
.
Le mieux serait d'ouvrir un sujet sur VPD.
Jetes un coup d'oeil sur http://www.oracle.com/technology/deploy/security/db_security/htdocs/vpd.html et sur la documentation concernant le package dbms_rls.
VPD est extremement simple a implementer et a l'avantage d'etre relativement transparent pour l'application. Le principe consistera a attacher des 'policies' sur les tables a filtrer. Lors de l'execution, le noyau ajoutera automatiquement lors de chaque access a ces tables les elements de jointures correspondant a ces 'policies' (polices en francais?), ce en fonction du 'contexte' etabli pour la session. La principale difficulte reviendra a trouver le bon angle pour initializer ce contexte, en fonction des outils utilises (forms, jdbc, sql*plus, etc).
Correction: Lien corrige (retire extra ',')
Envoyé par UbiK
de plus en plus de lien ne fontionnent plus sous developpez.net... c moyen quand meme ... comment on utilise ces petits script???
Bah un lien de 2002 en même temps...
Il vaut mieux monopoliser son intelligence sur des bêtises que sa bêtise sur des choses intelligentes.
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager