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