@@ -1133,6 +1133,11 @@ def HMAC(self, key, msg=None):
11331133 """Create a HMAC object."""
11341134 raise NotImplementedError
11351135
1136+ @property
1137+ def gil_minsize (self ):
1138+ """Get the maximal input length for the GIL to be held."""
1139+ raise NotImplementedError
1140+
11361141 def check_update (self , key , chunks ):
11371142 chunks = list (chunks )
11381143 msg = b'' .join (chunks )
@@ -1150,6 +1155,13 @@ def test_update(self):
11501155 with self .subTest (key = key , msg = msg ):
11511156 self .check_update (key , [msg ])
11521157
1158+ def test_update_large (self ):
1159+ gil_minsize = self .gil_minsize
1160+ key = random .randbytes (16 )
1161+ top = random .randbytes (gil_minsize + 1 )
1162+ bot = random .randbytes (gil_minsize + 1 )
1163+ self .check_update (key , [top , bot ])
1164+
11531165 def test_update_exceptions (self ):
11541166 h = self .HMAC (b"key" )
11551167 for msg in ['invalid msg' , 123 , (), []]:
@@ -1163,13 +1175,21 @@ class PyUpdateTestCase(PyModuleMixin, UpdateTestCaseMixin, unittest.TestCase):
11631175 def HMAC (self , key , msg = None ):
11641176 return self .hmac .HMAC (key , msg , digestmod = 'sha256' )
11651177
1178+ @property
1179+ def gil_minsize (self ):
1180+ return sha2 ._GIL_MINSIZE
1181+
11661182
11671183@hashlib_helper .requires_openssl_hashdigest ('sha256' )
11681184class OpenSSLUpdateTestCase (UpdateTestCaseMixin , unittest .TestCase ):
11691185
11701186 def HMAC (self , key , msg = None ):
11711187 return _hashlib .hmac_new (key , msg , digestmod = 'sha256' )
11721188
1189+ @property
1190+ def gil_minsize (self ):
1191+ return _hashlib ._GIL_MINSIZE
1192+
11731193
11741194class BuiltinUpdateTestCase (BuiltinModuleMixin ,
11751195 UpdateTestCaseMixin , unittest .TestCase ):
@@ -1179,6 +1199,10 @@ def HMAC(self, key, msg=None):
11791199 # are still built, making it possible to use SHA-2 hashes.
11801200 return self .hmac .new (key , msg , digestmod = 'sha256' )
11811201
1202+ @property
1203+ def gil_minsize (self ):
1204+ return self .hmac ._GIL_MINSIZE
1205+
11821206
11831207class CopyBaseTestCase :
11841208
0 commit comments