MCPcopy Index your code
hub / github.com/python/cpython / _init_old

Method _init_old

Lib/hmac.py:118–152  ·  view source on GitHub ↗
(self, key, msg, digestmod)

Source from the content-addressed store, hash-verified

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):

Callers 4

__initMethod · 0.95
test_attributesMethod · 0.80
test_realcopyMethod · 0.80

Calls 7

updateMethod · 0.95
_get_digest_constructorFunction · 0.85
_is_shake_constructorFunction · 0.85
warnMethod · 0.45
digestMethod · 0.45
ljustMethod · 0.45
translateMethod · 0.45

Tested by 3

test_attributesMethod · 0.64
test_realcopyMethod · 0.64