|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.Utilities.crypto.py3PBKDF2</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.Utilities.crypto.py3PBKDF2</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing PBKDF2 functions. |
|
13 </p> |
|
14 <h3>Global Attributes</h3> |
|
15 |
|
16 <table> |
|
17 <tr><td>Delimiter</td></tr><tr><td>Hashes</td></tr> |
|
18 </table> |
|
19 <h3>Classes</h3> |
|
20 |
|
21 <table> |
|
22 <tr><td>None</td></tr> |
|
23 </table> |
|
24 <h3>Functions</h3> |
|
25 |
|
26 <table> |
|
27 |
|
28 <tr> |
|
29 <td><a href="#hashPassword">hashPassword</a></td> |
|
30 <td>Module function to hash a password according to the PBKDF2 specification.</td> |
|
31 </tr> |
|
32 <tr> |
|
33 <td><a href="#hashPasswordTuple">hashPasswordTuple</a></td> |
|
34 <td>Module function to hash a password according to the PBKDF2 specification.</td> |
|
35 </tr> |
|
36 <tr> |
|
37 <td><a href="#pbkdf2">pbkdf2</a></td> |
|
38 <td>Module function to hash a password according to the PBKDF2 specification.</td> |
|
39 </tr> |
|
40 <tr> |
|
41 <td><a href="#rehashPassword">rehashPassword</a></td> |
|
42 <td>Module function to recreate a password hash given the hash parameters.</td> |
|
43 </tr> |
|
44 <tr> |
|
45 <td><a href="#verifyPassword">verifyPassword</a></td> |
|
46 <td>Module function to verify a password against a hash encoded password.</td> |
|
47 </tr> |
|
48 </table> |
|
49 <hr /> |
|
50 <hr /> |
|
51 <a NAME="hashPassword" ID="hashPassword"></a> |
|
52 <h2>hashPassword</h2> |
|
53 <b>hashPassword</b>(<i>password, digestMod=hashlib.sha512, iterations=10000, saltSize=32</i>) |
|
54 |
|
55 <p> |
|
56 Module function to hash a password according to the PBKDF2 specification. |
|
57 </p> |
|
58 <dl> |
|
59 |
|
60 <dt><i>password</i></dt> |
|
61 <dd> |
|
62 clear text password (string) |
|
63 </dd> |
|
64 <dt><i>digestMod</i></dt> |
|
65 <dd> |
|
66 hash function |
|
67 </dd> |
|
68 <dt><i>iterations</i></dt> |
|
69 <dd> |
|
70 number of times hash function should be applied (integer) |
|
71 </dd> |
|
72 <dt><i>saltSize</i></dt> |
|
73 <dd> |
|
74 size of the salt (integer) |
|
75 </dd> |
|
76 </dl> |
|
77 <dl> |
|
78 <dt>Return:</dt> |
|
79 <dd> |
|
80 hashed password entry according to PBKDF2 specification (string) |
|
81 </dd> |
|
82 </dl> |
|
83 <div align="right"><a href="#top">Up</a></div> |
|
84 <hr /> |
|
85 <hr /> |
|
86 <a NAME="hashPasswordTuple" ID="hashPasswordTuple"></a> |
|
87 <h2>hashPasswordTuple</h2> |
|
88 <b>hashPasswordTuple</b>(<i>password, digestMod=hashlib.sha512, iterations=10000, saltSize=32</i>) |
|
89 |
|
90 <p> |
|
91 Module function to hash a password according to the PBKDF2 specification. |
|
92 </p> |
|
93 <dl> |
|
94 |
|
95 <dt><i>password</i></dt> |
|
96 <dd> |
|
97 clear text password (string) |
|
98 </dd> |
|
99 <dt><i>digestMod</i></dt> |
|
100 <dd> |
|
101 hash function |
|
102 </dd> |
|
103 <dt><i>iterations</i></dt> |
|
104 <dd> |
|
105 number of times hash function should be applied (integer) |
|
106 </dd> |
|
107 <dt><i>saltSize</i></dt> |
|
108 <dd> |
|
109 size of the salt (integer) |
|
110 </dd> |
|
111 </dl> |
|
112 <dl> |
|
113 <dt>Return:</dt> |
|
114 <dd> |
|
115 tuple of digestname (string), number of iterations (integer), |
|
116 salt (bytes) and hashed password (bytes) |
|
117 </dd> |
|
118 </dl> |
|
119 <div align="right"><a href="#top">Up</a></div> |
|
120 <hr /> |
|
121 <hr /> |
|
122 <a NAME="pbkdf2" ID="pbkdf2"></a> |
|
123 <h2>pbkdf2</h2> |
|
124 <b>pbkdf2</b>(<i>password, salt, iterations, digestMod</i>) |
|
125 |
|
126 <p> |
|
127 Module function to hash a password according to the PBKDF2 specification. |
|
128 </p> |
|
129 <dl> |
|
130 |
|
131 <dt><i>password</i></dt> |
|
132 <dd> |
|
133 clear text password (bytes) |
|
134 </dd> |
|
135 <dt><i>salt</i></dt> |
|
136 <dd> |
|
137 salt value (bytes) |
|
138 </dd> |
|
139 <dt><i>iterations</i></dt> |
|
140 <dd> |
|
141 number of times hash function should be applied (integer) |
|
142 </dd> |
|
143 <dt><i>digestMod</i></dt> |
|
144 <dd> |
|
145 hash function |
|
146 </dd> |
|
147 </dl> |
|
148 <dl> |
|
149 <dt>Return:</dt> |
|
150 <dd> |
|
151 hashed password (bytes) |
|
152 </dd> |
|
153 </dl> |
|
154 <div align="right"><a href="#top">Up</a></div> |
|
155 <hr /> |
|
156 <hr /> |
|
157 <a NAME="rehashPassword" ID="rehashPassword"></a> |
|
158 <h2>rehashPassword</h2> |
|
159 <b>rehashPassword</b>(<i>password, hashParameters</i>) |
|
160 |
|
161 <p> |
|
162 Module function to recreate a password hash given the hash parameters. |
|
163 </p> |
|
164 <dl> |
|
165 |
|
166 <dt><i>password</i></dt> |
|
167 <dd> |
|
168 clear text password (string) |
|
169 </dd> |
|
170 <dt><i>hashParameters</i></dt> |
|
171 <dd> |
|
172 hash parameters in the form |
|
173 'digestmod$iterations$salt' (string) |
|
174 </dd> |
|
175 </dl> |
|
176 <dl> |
|
177 <dt>Return:</dt> |
|
178 <dd> |
|
179 hashed password (bytes) |
|
180 </dd> |
|
181 </dl> |
|
182 <dl> |
|
183 |
|
184 <dt>Raises <b>ValueError</b>:</dt> |
|
185 <dd> |
|
186 the hash parameters string is not of the expected |
|
187 format or the digest is not one of the known ones |
|
188 </dd> |
|
189 </dl> |
|
190 <div align="right"><a href="#top">Up</a></div> |
|
191 <hr /> |
|
192 <hr /> |
|
193 <a NAME="verifyPassword" ID="verifyPassword"></a> |
|
194 <h2>verifyPassword</h2> |
|
195 <b>verifyPassword</b>(<i>password, pwHash</i>) |
|
196 |
|
197 <p> |
|
198 Module function to verify a password against a hash encoded password. |
|
199 </p> |
|
200 <dl> |
|
201 |
|
202 <dt><i>password</i></dt> |
|
203 <dd> |
|
204 clear text password (string) |
|
205 </dd> |
|
206 <dt><i>pwHash</i></dt> |
|
207 <dd> |
|
208 hash encoded password in the form |
|
209 'digestmod$iterations$salt$hashed_password' as produced by the |
|
210 hashPassword function (string) |
|
211 </dd> |
|
212 </dl> |
|
213 <dl> |
|
214 <dt>Return:</dt> |
|
215 <dd> |
|
216 flag indicating a successfull verification (boolean) |
|
217 </dd> |
|
218 </dl> |
|
219 <dl> |
|
220 |
|
221 <dt>Raises <b>ValueError</b>:</dt> |
|
222 <dd> |
|
223 the hash is not of the expected format or the |
|
224 digest is not one of the known ones |
|
225 </dd> |
|
226 </dl> |
|
227 <div align="right"><a href="#top">Up</a></div> |
|
228 <hr /> |
|
229 </body></html> |