@@ -206,6 +206,52 @@ def invalid_implementation_error(self, implementation):
206206 return AssertionError (msg )
207207
208208
209+ class _HashFuncInfo (_HashInfoBase ):
210+ """Dataclass containing information for hash functions constructors.
211+
212+ - *builtin* is the fully-qualified name of the HACL*
213+ hash constructor function, e.g., "_md5.md5".
214+
215+ - *openssl* is the fully-qualified name of the "_hashlib" method
216+ for the OpenSSL named constructor, e.g., "_hashlib.openssl_md5".
217+
218+ - *hashlib* is the fully-qualified name of the "hashlib" method
219+ for the explicit named hash constructor, e.g., "hashlib.md5".
220+ """
221+
222+ def __init__ (self , canonical_name , builtin , openssl = None , hashlib = None ):
223+ super ().__init__ (canonical_name )
224+ self .builtin = _HashInfoItem (builtin , strict = True )
225+ self .openssl = _HashInfoItem (openssl , strict = False )
226+ self .hashlib = _HashInfoItem (hashlib , strict = False )
227+
228+ def fullname (self , implementation ):
229+ """Get the fully qualified name of a given implementation.
230+
231+ This returns a string of the form "MODULE_NAME.METHOD_NAME" or None
232+ if the hash function does not have a corresponding implementation.
233+
234+ *implementation* must be "builtin", "openssl" or "hashlib".
235+ """
236+ return self [implementation ].fullname
237+
238+ def module_name (self , implementation ):
239+ """Get the name of the constructor function module.
240+
241+ The *implementation* must be "builtin", "openssl" or "hashlib".
242+ """
243+ return self [implementation ].module_name
244+
245+ def method_name (self , implementation ):
246+ """Get the name of the constructor function module method.
247+
248+ Use fullname() to get the constructor function fully-qualified name.
249+
250+ The *implementation* must be "builtin", "openssl" or "hashlib".
251+ """
252+ return self [implementation ].member_name
253+
254+
209255class HashInfo :
210256 """Dataclass storing explicit hash constructor names.
211257
0 commit comments