| 1178 | return base |
| 1179 | |
| 1180 | def get_algorithm_impls(self, algorithm): |
| 1181 | # algorithm names taken from RFC 7616 Section 6.1 |
| 1182 | # lambdas assume digest modules are imported at the top level |
| 1183 | if algorithm == 'MD5': |
| 1184 | H = lambda x: hashlib.md5(x.encode("ascii")).hexdigest() |
| 1185 | elif algorithm == 'SHA': # non-standard, retained for compatibility. |
| 1186 | H = lambda x: hashlib.sha1(x.encode("ascii")).hexdigest() |
| 1187 | elif algorithm == 'SHA-256': |
| 1188 | H = lambda x: hashlib.sha256(x.encode("ascii")).hexdigest() |
| 1189 | # XXX MD5-sess |
| 1190 | else: |
| 1191 | raise ValueError("Unsupported digest authentication " |
| 1192 | "algorithm %r" % algorithm) |
| 1193 | KD = lambda s, d: H("%s:%s" % (s, d)) |
| 1194 | return H, KD |
| 1195 | |
| 1196 | def get_entity_digest(self, data, chal): |
| 1197 | # XXX not implemented yet |