|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' |
|
3 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> |
|
4 <html><head> |
|
5 <title>eric5.Utilities.crypto.py3PBKDF2</title> |
|
6 <style> |
|
7 body { |
|
8 background: #EDECE6; |
|
9 margin: 0em 1em 10em 1em; |
|
10 color: black; |
|
11 } |
|
12 |
|
13 h1 { color: white; background: #85774A; } |
|
14 h2 { color: white; background: #85774A; } |
|
15 h3 { color: white; background: #9D936E; } |
|
16 h4 { color: white; background: #9D936E; } |
|
17 |
|
18 a { color: #BA6D36; } |
|
19 |
|
20 </style> |
|
21 </head> |
|
22 <body><a NAME="top" ID="top"></a> |
|
23 <h1>eric5.Utilities.crypto.py3PBKDF2</h1> |
|
24 <p> |
|
25 Module implementing PBKDF2 functions. |
|
26 </p> |
|
27 <h3>Global Attributes</h3> |
|
28 <table> |
|
29 <tr><td>Delimiter</td></tr><tr><td>Hashes</td></tr> |
|
30 </table> |
|
31 <h3>Classes</h3> |
|
32 <table> |
|
33 <tr><td>None</td></tr> |
|
34 </table> |
|
35 <h3>Functions</h3> |
|
36 <table> |
|
37 <tr> |
|
38 <td><a href="#hashPassword">hashPassword</a></td> |
|
39 <td>Module function to hash a password according to the PBKDF2 specification.</td> |
|
40 </tr><tr> |
|
41 <td><a href="#hashPasswordTuple">hashPasswordTuple</a></td> |
|
42 <td>Module function to hash a password according to the PBKDF2 specification.</td> |
|
43 </tr><tr> |
|
44 <td><a href="#pbkdf2">pbkdf2</a></td> |
|
45 <td>Module function to hash a password according to the PBKDF2 specification.</td> |
|
46 </tr><tr> |
|
47 <td><a href="#rehashPassword">rehashPassword</a></td> |
|
48 <td>Module function to recreate a password hash given the hash parameters.</td> |
|
49 </tr><tr> |
|
50 <td><a href="#verifyPassword">verifyPassword</a></td> |
|
51 <td>Module function to verify a password against a hash encoded password.</td> |
|
52 </tr> |
|
53 </table> |
|
54 <hr /><hr /> |
|
55 <a NAME="hashPassword" ID="hashPassword"></a> |
|
56 <h2>hashPassword</h2> |
|
57 <b>hashPassword</b>(<i>password, digestMod=hashlib.sha512, iterations=10000, saltSize=32</i>) |
|
58 <p> |
|
59 Module function to hash a password according to the PBKDF2 specification. |
|
60 </p><dl> |
|
61 <dt><i>password</i></dt> |
|
62 <dd> |
|
63 clear text password (string) |
|
64 </dd><dt><i>digestMod</i></dt> |
|
65 <dd> |
|
66 hash function |
|
67 </dd><dt><i>iterations</i></dt> |
|
68 <dd> |
|
69 number of times hash function should be applied (integer) |
|
70 </dd><dt><i>saltSize</i></dt> |
|
71 <dd> |
|
72 size of the salt (integer) |
|
73 </dd> |
|
74 </dl><dl> |
|
75 <dt>Returns:</dt> |
|
76 <dd> |
|
77 hashed password entry according to PBKDF2 specification (string) |
|
78 </dd> |
|
79 </dl> |
|
80 <div align="right"><a href="#top">Up</a></div> |
|
81 <hr /><hr /> |
|
82 <a NAME="hashPasswordTuple" ID="hashPasswordTuple"></a> |
|
83 <h2>hashPasswordTuple</h2> |
|
84 <b>hashPasswordTuple</b>(<i>password, digestMod=hashlib.sha512, iterations=10000, saltSize=32</i>) |
|
85 <p> |
|
86 Module function to hash a password according to the PBKDF2 specification. |
|
87 </p><dl> |
|
88 <dt><i>password</i></dt> |
|
89 <dd> |
|
90 clear text password (string) |
|
91 </dd><dt><i>digestMod</i></dt> |
|
92 <dd> |
|
93 hash function |
|
94 </dd><dt><i>iterations</i></dt> |
|
95 <dd> |
|
96 number of times hash function should be applied (integer) |
|
97 </dd><dt><i>saltSize</i></dt> |
|
98 <dd> |
|
99 size of the salt (integer) |
|
100 </dd> |
|
101 </dl><dl> |
|
102 <dt>Returns:</dt> |
|
103 <dd> |
|
104 tuple of digestname (string), number of iterations (integer), |
|
105 salt (bytes) and hashed password (bytes) |
|
106 </dd> |
|
107 </dl> |
|
108 <div align="right"><a href="#top">Up</a></div> |
|
109 <hr /><hr /> |
|
110 <a NAME="pbkdf2" ID="pbkdf2"></a> |
|
111 <h2>pbkdf2</h2> |
|
112 <b>pbkdf2</b>(<i>password, salt, iterations, digestMod</i>) |
|
113 <p> |
|
114 Module function to hash a password according to the PBKDF2 specification. |
|
115 </p><dl> |
|
116 <dt><i>password</i></dt> |
|
117 <dd> |
|
118 clear text password (bytes) |
|
119 </dd><dt><i>salt</i></dt> |
|
120 <dd> |
|
121 salt value (bytes) |
|
122 </dd><dt><i>iterations</i></dt> |
|
123 <dd> |
|
124 number of times hash function should be applied (integer) |
|
125 </dd><dt><i>digestMod</i></dt> |
|
126 <dd> |
|
127 hash function |
|
128 </dd> |
|
129 </dl><dl> |
|
130 <dt>Returns:</dt> |
|
131 <dd> |
|
132 hashed password (bytes) |
|
133 </dd> |
|
134 </dl> |
|
135 <div align="right"><a href="#top">Up</a></div> |
|
136 <hr /><hr /> |
|
137 <a NAME="rehashPassword" ID="rehashPassword"></a> |
|
138 <h2>rehashPassword</h2> |
|
139 <b>rehashPassword</b>(<i>password, hashParameters</i>) |
|
140 <p> |
|
141 Module function to recreate a password hash given the hash parameters. |
|
142 </p><dl> |
|
143 <dt><i>password</i></dt> |
|
144 <dd> |
|
145 clear text password (string) |
|
146 </dd><dt><i>hashParameters</i></dt> |
|
147 <dd> |
|
148 hash parameters in the form |
|
149 'digestmod$iterations$salt' (string) |
|
150 </dd> |
|
151 </dl><dl> |
|
152 <dt>Returns:</dt> |
|
153 <dd> |
|
154 hashed password (bytes) |
|
155 </dd> |
|
156 </dl><dl> |
|
157 <dt>Raises <b>ValueError</b>:</dt> |
|
158 <dd> |
|
159 the hash parameters string is not of the expected format |
|
160 or the digest is not one of the known ones |
|
161 </dd> |
|
162 </dl> |
|
163 <div align="right"><a href="#top">Up</a></div> |
|
164 <hr /><hr /> |
|
165 <a NAME="verifyPassword" ID="verifyPassword"></a> |
|
166 <h2>verifyPassword</h2> |
|
167 <b>verifyPassword</b>(<i>password, hash</i>) |
|
168 <p> |
|
169 Module function to verify a password against a hash encoded password. |
|
170 </p><dl> |
|
171 <dt><i>password</i></dt> |
|
172 <dd> |
|
173 clear text password (string) |
|
174 </dd><dt><i>hash</i></dt> |
|
175 <dd> |
|
176 hash encoded password in the form |
|
177 'digestmod$iterations$salt$hashed_password' as produced by the |
|
178 hashPassword function (string) |
|
179 </dd> |
|
180 </dl><dl> |
|
181 <dt>Returns:</dt> |
|
182 <dd> |
|
183 flag indicating a successfull verification (boolean) |
|
184 </dd> |
|
185 </dl><dl> |
|
186 <dt>Raises <b>ValueError</b>:</dt> |
|
187 <dd> |
|
188 the hash is not of the expected format or the |
|
189 digest is not one of the known ones |
|
190 </dd> |
|
191 </dl> |
|
192 <div align="right"><a href="#top">Up</a></div> |
|
193 <hr /> |
|
194 </body></html> |