You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow to specify the number of rounds for SHA-* hashing in crypt #75883
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2017-11-16.11:23:51.851>created_at=<Date2017-10-05.12:32:51.925>labels= ['3.7', 'type-feature', 'library']
title='Allow to specify the number of rounds for SHA-* hashing in crypt'updated_at=<Date2017-11-16.11:23:51.850>user='https://github.com/serhiy-storchaka'
Blowfish salt should contain the binary logarithm of the number of rounds (from 4 to 31) (see bpo-31664). SHA-* salt can contain an explicit number of rounds in the form '$rounds={value}$'. It is bound to the range from 1000 to 999999999, the default is 5000.
I propose to allow to specify the number of rounds in generated salt for SHA-* methods as well as for Blowfish. For unifying interface we can specify the number of rounds instead of its logarithm for Blowfish, and calculate the logarithm internally.
The question is what to do with the value that is not a power of two for Blowfish. Should we raise an error or silently replace it with the upper power of two?
What to do with values outside of the valid range (2**4 to 2**31 for Blowfish, 1000 to 999999999 for SHA*). Raise ValueError, OverflowError, or bound it, or just generate an invalid salt and allow crypt() to handle it?
I'd stick with ValueError in that case as well. if someone dislikes the
valueerrors because they _want_ to use an invalid one, they can file a bug
and we'll reconsider only if they have a meaningful use case.
What to do with values outside of the valid range (2**4 to 2**31 for
Blowfish, 1000 to 999999999 for SHA*). Raise ValueError, OverflowError, or
bound it, or just generate an invalid salt and allow crypt() to handle it?
New changeset cede8c9 by Serhiy Storchaka in branch 'master': bpo-31702: Allow to specify rounds for SHA-2 hashing in crypt.mksalt(). (bpo-4110) cede8c9
Activity
serhiy-storchaka commentedon Oct 5, 2017
Blowfish salt should contain the binary logarithm of the number of rounds (from 4 to 31) (see bpo-31664). SHA-* salt can contain an explicit number of rounds in the form '$rounds={value}$'. It is bound to the range from 1000 to 999999999, the default is 5000.
I propose to allow to specify the number of rounds in generated salt for SHA-* methods as well as for Blowfish. For unifying interface we can specify the number of rounds instead of its logarithm for Blowfish, and calculate the logarithm internally.
The question is what to do with the value that is not a power of two for Blowfish. Should we raise an error or silently replace it with the upper power of two?
gpshead commentedon Oct 24, 2017
I'd raise a ValueError in that case.
serhiy-storchaka commentedon Oct 25, 2017
What to do with values outside of the valid range (2**4 to 2**31 for Blowfish, 1000 to 999999999 for SHA*). Raise ValueError, OverflowError, or bound it, or just generate an invalid salt and allow crypt() to handle it?
gpshead commentedon Oct 25, 2017
I'd stick with ValueError in that case as well. if someone dislikes the
valueerrors because they _want_ to use an invalid one, they can file a bug
and we'll reconsider only if they have a meaningful use case.
On Wed, Oct 25, 2017 at 9:36 AM Serhiy Storchaka <report@bugs.python.org>
wrote:
serhiy-storchaka commentedon Nov 16, 2017
New changeset cede8c9 by Serhiy Storchaka in branch 'master':
bpo-31702: Allow to specify rounds for SHA-2 hashing in crypt.mksalt(). (bpo-4110)
cede8c9