Alternative implementation of hmac_new(). This is typically useful when one needs to test against an HMAC implementation which only recognizes underlying hash functions by their name (all HMAC implementations must at least recognize hash functions by their names but
(self, key, msg=None, *, hashname)
| 207 | """Mixin class for common tests.""" |
| 208 | |
| 209 | def hmac_new_by_name(self, key, msg=None, *, hashname): |
| 210 | """Alternative implementation of hmac_new(). |
| 211 | |
| 212 | This is typically useful when one needs to test against an HMAC |
| 213 | implementation which only recognizes underlying hash functions |
| 214 | by their name (all HMAC implementations must at least recognize |
| 215 | hash functions by their names but some may use aliases such as |
| 216 | `hashlib.sha1` instead of "sha1"). |
| 217 | |
| 218 | Unlike hmac_new(), this method may assert the type of 'hashname' |
| 219 | as it should only be used in tests that are expected to create |
| 220 | a HMAC object. |
| 221 | """ |
| 222 | self.assertIsInstance(hashname, str) |
| 223 | return self.hmac_new(key, msg, digestmod=hashname) |
| 224 | |
| 225 | def hmac_digest_by_name(self, key, msg=None, *, hashname): |
| 226 | """Alternative implementation of hmac_digest(). |
no test coverage detected