| 1 |
|
| 2 |
|
| 3 |
""" |
| 4 |
This module offers access to standardized parameters that you can load using |
| 5 |
:meth:`argon2.PasswordHasher.from_parameters()`. See the `source code |
| 6 |
<https://github.com/hynek/argon2-cffi/blob/main/src/argon2/profiles.py>`_ for |
| 7 |
concrete values and :doc:`parameters` for more information. |
| 8 |
|
| 9 |
.. versionadded:: 21.2.0 |
| 10 |
""" |
| 11 |
|
| 12 |
from __future__ import annotations |
| 13 |
|
| 14 |
import dataclasses |
| 15 |
|
| 16 |
from ._utils import Parameters, _is_wasm |
| 17 |
from .low_level import Type |
| 18 |
|
| 19 |
|
| 20 |
def get_default_parameters() -> Parameters: |
| 21 |
""" |
| 22 |
Create default parameters for current platform. |
| 23 |
|
| 24 |
Returns: |
| 25 |
Default, compatible, parameters for current platform. |
| 26 |
|
| 27 |
.. versionadded:: 25.1.0 |
| 28 |
""" |
| 29 |
params = RFC_9106_LOW_MEMORY |
| 30 |
|
| 31 |
if _is_wasm(): |
| 32 |
params = dataclasses.replace(params, parallelism=1) |
| 33 |
|
| 34 |
return params |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
RFC_9106_HIGH_MEMORY = Parameters( |
| 39 |
type=Type.ID, |
| 40 |
version=19, |
| 41 |
salt_len=16, |
| 42 |
hash_len=32, |
| 43 |
time_cost=1, |
| 44 |
memory_cost=2097152, |
| 45 |
parallelism=4, |
| 46 |
) |
| 47 |
|
| 48 |
|
| 49 |
RFC_9106_LOW_MEMORY = Parameters( |
| 50 |
type=Type.ID, |
| 51 |
version=19, |
| 52 |
salt_len=16, |
| 53 |
hash_len=32, |
| 54 |
time_cost=3, |
| 55 |
memory_cost=65536, |
| 56 |
parallelism=4, |
| 57 |
) |
| 58 |
|
| 59 |
|
| 60 |
PRE_21_2 = Parameters( |
| 61 |
type=Type.ID, |
| 62 |
version=19, |
| 63 |
salt_len=16, |
| 64 |
hash_len=16, |
| 65 |
time_cost=2, |
| 66 |
memory_cost=102400, |
| 67 |
parallelism=8, |
| 68 |
) |
| 69 |
|
| 70 |
|
| 71 |
CHEAPEST = Parameters( |
| 72 |
type=Type.ID, |
| 73 |
version=19, |
| 74 |
salt_len=8, |
| 75 |
hash_len=4, |
| 76 |
time_cost=1, |
| 77 |
memory_cost=8, |
| 78 |
parallelism=1, |
| 79 |
) |