New submission from Armin Ronacher:

Is there a specific reason why hashlib.pbkdf2_hmac now has a completely 
inconsistent API with the rest of the stdlib?  So far the concept in both 
hashlib and hmac has been to accept hash constructors as parameters.

As such you would expect the API to look like this:

hashlib.pbkdf2_hmac(hashlib.sha256, b'password', b'salt', 100000)

Instead the API now is string based.

This is annoying because a lot of code already in the past exposed a pbkdf2 
implementation that allows passing in a hashlib constructor by passing it to 
HMAC.

If such code now wants to use the stdlib pbkdf2_hmac implementation it has to 
special case known implementations.  If a non known implementation is found it 
needs to dispatch to a separate implementation of PBKDF2.

In addition to that there is no nice way to detect if a algorithm is not 
supported as the exception raised for an invalid algorithm is the same as an 
invalid parameter for the iteration count (ValueError).

I would propose to change the API to allow hash constructors to be passed in in 
addition to strings.

----------
messages: 216728
nosy: aronacher
priority: normal
severity: normal
status: open
title: hashlib.pbkdf2_hmac Hash Constructor
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21288>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to