@@ -138,7 +138,7 @@ def hmac_digest(self, key, msg=None, digestmod=None):
138
138
return self .hmac .compute_digest (key , msg , digest = digestmod )
139
139
140
140
141
- class CheckerMixin :
141
+ class ObjectCheckerMixin :
142
142
"""Mixin for checking HMAC objects (pure Python, OpenSSL or built-in)."""
143
143
144
144
def check_object (self , h , hexdigest , hashname , digest_size , block_size ):
@@ -159,7 +159,7 @@ def check_hexdigest(self, h, hexdigest, digest_size):
159
159
self .assertEqual (h .hexdigest ().upper (), hexdigest .upper ())
160
160
161
161
162
- class TestVectorsMixin (CreatorMixin , DigestMixin , CheckerMixin ):
162
+ class AssertersMixin (CreatorMixin , DigestMixin , ObjectCheckerMixin ):
163
163
"""Mixin class for common tests."""
164
164
165
165
def hmac_new_by_name (self , key , msg = None , * , hashname ):
@@ -318,7 +318,7 @@ def assert_hmac_extra_cases(
318
318
self .check_object (h1 , hexdigest , hashname , digest_size , block_size )
319
319
320
320
321
- class PyTestVectorsMixin (PyModuleMixin , TestVectorsMixin ):
321
+ class PyAssertersMixin (PyModuleMixin , AssertersMixin ):
322
322
323
323
def assert_hmac_extra_cases (
324
324
self , key , msg , hexdigest , digestmod , hashname , digest_size , block_size
@@ -332,7 +332,7 @@ def assert_hmac_extra_cases(
332
332
self .check_object (h , hexdigest , hashname , digest_size , block_size )
333
333
334
334
335
- class OpenSSLTestVectorsMixin (ThroughOpenSSLAPIMixin , TestVectorsMixin ):
335
+ class OpenSSLAssertersMixin (ThroughOpenSSLAPIMixin , AssertersMixin ):
336
336
337
337
def hmac_new_by_name (self , key , msg = None , * , hashname ):
338
338
self .assertIsInstance (hashname , str )
@@ -345,7 +345,7 @@ def hmac_digest_by_name(self, key, msg=None, *, hashname):
345
345
return self .hmac_digest (key , msg , digestmod = openssl_func )
346
346
347
347
348
- class BuiltinAssertersMixin (ThroughBuiltinAPIMixin , TestVectorsMixin ):
348
+ class BuiltinAssertersMixin (ThroughBuiltinAPIMixin , AssertersMixin ):
349
349
pass
350
350
351
351
@@ -390,7 +390,7 @@ def setUpClass(cls):
390
390
setattr (cls , name , name )
391
391
392
392
393
- class RFCTestCasesMixin (HashFunctionsTrait ):
393
+ class RFCTestCaseMixin (HashFunctionsTrait ):
394
394
"""Test HMAC implementations against test vectors from the RFC."""
395
395
396
396
def test_md5 (self ):
@@ -472,7 +472,6 @@ def test_sha2_512_rfc4231(self):
472
472
self ._test_sha2_rfc4231 (self .sha512 , 'sha512' , 64 , 128 )
473
473
474
474
def _test_sha2_rfc4231 (self , hashfunc , hashname , digest_size , block_size ):
475
-
476
475
def hmactest (key , data , hexdigests ):
477
476
hexdigest = hexdigests [hashname ]
478
477
@@ -592,26 +591,26 @@ def hmactest(key, data, hexdigests):
592
591
})
593
592
594
593
595
- class PyRFCTestCase (ThroughObjectMixin , PyTestVectorsMixin ,
596
- WithOpenSSLHashFunctions , RFCTestCasesMixin ,
594
+ class PyRFCTestCase (ThroughObjectMixin , PyAssertersMixin ,
595
+ WithOpenSSLHashFunctions , RFCTestCaseMixin ,
597
596
unittest .TestCase ):
598
597
"""Python implementation of HMAC using hmac.HMAC().
599
598
600
599
The underlying hash functions are OpenSSL-based.
601
600
"""
602
601
603
602
604
- class PyDotNewRFCTestCase (ThroughModuleAPIMixin , PyTestVectorsMixin ,
605
- WithOpenSSLHashFunctions , RFCTestCasesMixin ,
603
+ class PyDotNewRFCTestCase (ThroughModuleAPIMixin , PyAssertersMixin ,
604
+ WithOpenSSLHashFunctions , RFCTestCaseMixin ,
606
605
unittest .TestCase ):
607
606
"""Python implementation of HMAC using hmac.new().
608
607
609
608
The underlying hash functions are OpenSSL-based.
610
609
"""
611
610
612
611
613
- class OpenSSLRFCTestCase (OpenSSLTestVectorsMixin ,
614
- WithOpenSSLHashFunctions , RFCTestCasesMixin ,
612
+ class OpenSSLRFCTestCase (OpenSSLAssertersMixin ,
613
+ WithOpenSSLHashFunctions , RFCTestCaseMixin ,
615
614
unittest .TestCase ):
616
615
"""OpenSSL implementation of HMAC.
617
616
@@ -620,7 +619,7 @@ class OpenSSLRFCTestCase(OpenSSLTestVectorsMixin,
620
619
621
620
622
621
class BuiltinRFCTestCase (BuiltinAssertersMixin ,
623
- WithNamedHashFunctions , RFCTestCasesMixin ,
622
+ WithNamedHashFunctions , RFCTestCaseMixin ,
624
623
unittest .TestCase ):
625
624
"""Built-in HACL* implementation of HMAC.
626
625
@@ -689,7 +688,7 @@ def _invalid_digestmod_cases(self, func, key, msg, choices):
689
688
return cases
690
689
691
690
692
- class ConstructorTestCaseMixin (CreatorMixin , DigestMixin , CheckerMixin ):
691
+ class ConstructorTestCaseMixin (CreatorMixin , DigestMixin , ObjectCheckerMixin ):
693
692
"""HMAC constructor tests based on HMAC-SHA-2/256."""
694
693
695
694
key = b"key"
0 commit comments