Check that HACL* HMAC interface is enabled/disabled.
(self, name, *, disabled=True)
| 932 | _ = do_hash(b"") |
| 933 | |
| 934 | def check_builtin_hmac(self, name, *, disabled=True): |
| 935 | """Check that HACL* HMAC interface is enabled/disabled.""" |
| 936 | if name in hashlib_helper.NON_HMAC_DIGEST_NAMES: |
| 937 | # HMAC-BLAKE and HMAC-SHAKE raise a ValueError as they are not |
| 938 | # supported at all (they do not make any sense in practice). |
| 939 | with self.assertRaises(ValueError): |
| 940 | self._hmac.compute_digest(b"", b"", name) |
| 941 | else: |
| 942 | with self.check_context(disabled): |
| 943 | _ = self._hmac.compute_digest(b"", b"", name) |
| 944 | |
| 945 | with self.check_context(disabled): |
| 946 | _ = self._hmac.new(b"", b"", name) |
| 947 | |
| 948 | if do_hmac := self.fetch_hmac_function(name): |
| 949 | self.assertStartsWith(do_hmac.__name__, 'compute_') |
| 950 | with self.check_context(disabled): |
| 951 | _ = do_hmac(b"", b"") |
| 952 | else: |
| 953 | self.assertIn(name, hashlib_helper.NON_HMAC_DIGEST_NAMES) |
| 954 | |
| 955 | @support.subTests( |
| 956 | ('name', 'allow_openssl', 'allow_builtin'), |
no test coverage detected