@@ -566,32 +566,52 @@ def test_with_fallback(self):
566
566
cache .pop ('foo' )
567
567
568
568
569
- class PyRFCTestCase (PyTestVectorsMixin , ThroughObjectMixin ,
570
- RFCTestCasesMixin , unittest .TestCase ):
571
- """Python implementation of HMAC using hmac.HMAC()."""
572
-
573
-
574
- class PyDotNewRFCTestCase (PyTestVectorsMixin , ThroughModuleAPIMixin ,
575
- RFCTestCasesMixin , unittest .TestCase ):
576
- """Python implementation of HMAC using hmac.new()."""
577
-
578
-
579
- @hashlib_helper .requires_hashlib ()
580
- class OpenSSLRFCTestCase (OpenSSLTestVectorsMixin , RFCTestCasesMixin ,
581
- unittest .TestCase ):
582
- """OpenSSL implementation of HMAC."""
569
+ class RFCWithOpenSSLHashFunctionTestCasesMixin (RFCTestCasesMixin ):
583
570
584
571
def __init_subclass__ (cls , * args , ** kwargs ):
585
572
super ().__init_subclass__ (* args , ** kwargs )
586
573
587
574
for name in cls .ALGORITHMS :
588
575
@property
576
+ @hashlib_helper .requires_hashlib ()
589
577
@hashlib_helper .requires_hashdigest (name , openssl = True )
590
578
def func (self , * , __name = name ): # __name needed to bind 'name'
591
579
return getattr (_hashlib , f'openssl_{ __name } ' )
592
580
setattr (cls , name , func )
593
581
594
582
583
+ class PyRFCTestCase (PyTestVectorsMixin , ThroughObjectMixin ,
584
+ RFCWithOpenSSLHashFunctionTestCasesMixin ,
585
+ unittest .TestCase ):
586
+ """Python implementation of HMAC using hmac.HMAC().
587
+
588
+ The underlying hash functions are OpenSSL-based.
589
+ """
590
+
591
+
592
+ class PyDotNewRFCTestCase (PyTestVectorsMixin , ThroughModuleAPIMixin ,
593
+ RFCWithOpenSSLHashFunctionTestCasesMixin ,
594
+ unittest .TestCase ):
595
+ """Python implementation of HMAC using hmac.new().
596
+
597
+ The underlying hash functions are OpenSSL-based.
598
+ """
599
+
600
+
601
+ class OpenSSLRFCTestCase (OpenSSLTestVectorsMixin ,
602
+ RFCWithOpenSSLHashFunctionTestCasesMixin ,
603
+ unittest .TestCase ):
604
+ """OpenSSL implementation of HMAC.
605
+
606
+ The underlying hash functions are also OpenSSL-based."""
607
+
608
+
609
+ # TODO(picnixz): once we have a HACL* HMAC, we should also test the Python
610
+ # implementation of HMAC with a HACL*-based hash function. For now, we only
611
+ # test it partially via the '_sha2' module, but for completeness we could
612
+ # also test the RFC test vectors against all possible implementations.
613
+
614
+
595
615
class DigestModTestCaseMixin (CreatorMixin , DigestMixin ):
596
616
"""Tests for the 'digestmod' parameter."""
597
617
0 commit comments