| 116 | self.block_size = self._hmac.block_size |
| 117 | |
| 118 | def _init_old(self, key, msg, digestmod): |
| 119 | import warnings |
| 120 | |
| 121 | digest_cons = _get_digest_constructor(digestmod) |
| 122 | if _is_shake_constructor(digest_cons): |
| 123 | raise ValueError(f"unsupported hash algorithm {digestmod}") |
| 124 | |
| 125 | self._hmac = None |
| 126 | self._outer = digest_cons() |
| 127 | self._inner = digest_cons() |
| 128 | self.digest_size = self._inner.digest_size |
| 129 | |
| 130 | if hasattr(self._inner, 'block_size'): |
| 131 | blocksize = self._inner.block_size |
| 132 | if blocksize < 16: |
| 133 | warnings.warn(f"block_size of {blocksize} seems too small; " |
| 134 | f"using our default of {self.blocksize}.", |
| 135 | RuntimeWarning, 2) |
| 136 | blocksize = self.blocksize # pragma: no cover |
| 137 | else: |
| 138 | warnings.warn("No block_size attribute on given digest object; " |
| 139 | f"Assuming {self.blocksize}.", |
| 140 | RuntimeWarning, 2) |
| 141 | blocksize = self.blocksize # pragma: no cover |
| 142 | |
| 143 | if len(key) > blocksize: |
| 144 | key = digest_cons(key).digest() |
| 145 | |
| 146 | self.block_size = blocksize |
| 147 | |
| 148 | key = key.ljust(blocksize, b'\0') |
| 149 | self._outer.update(key.translate(trans_5C)) |
| 150 | self._inner.update(key.translate(trans_36)) |
| 151 | if msg is not None: |
| 152 | self.update(msg) |
| 153 | |
| 154 | @property |
| 155 | def name(self): |