Choose Argon2 Parameters for Secure Password Hashing and Login (2024)

At Ory we develop open source access control and user management software. Thisguide sums up all the security best practices we follow and developed aroundArgon2. It first provides some background on Argon2 and best practice forchoosing its parameters. I also wrote a CLI that allows you to calibrate theArgon2 parameter values according to your constrains and resources.

Argon2 - Secure Login and Password Hashing

To securely manage credentials, one has to only store a cryptographic hash ofthe credential. Whenever the credential has to be checked, the hash of theprovided credential is computed and compared to the stored hash. This ensuresthat no one is able to retrieve the credentials, even with full access to thesystem's storage.

Argon2 is a cryptographic hash algorithm specifically designed to securepasswords. It isrecommended by OWASPin the Argon2id variant as a modern, secure and flexible algorithm. Thisflexibility means that one has to choose some parameters and is probably thereason why you are reading this article.

Argon2's Cryptographic Password Hashing Parameters

Let me introduce you to the parameters and explain their role in the hashingoperation. This section is based on the paperArgon2: the memory-hard function for password hashing and other applications.

  1. Memory: The memory used by the algorithm. To make hash cracking moreexpensive for an attacker, you want to make this value as high as possible.
  2. Iterations: The number of iterations over the memory. The execution timecorrelates linearly with this parameter. It allows you to increase thecomputational cost required to calculate one hash.
  3. Parallelism: The number of threads to use. This should be chosen as highas possible to reduce the threat imposed by parallelized hash cracking.
  4. Salt Length: The authors of Argon2 recommend this parameter to be 128bits, but say it can be reduced to 64 bits in the case of space constraints.
  5. Key Length (i.e. Hash Length): This parameter depends on the intendedusage. The Argon2 algorithm authors claim that a value of 128 bits should besufficient for most applications. If you plan to use the hash as a derivedkey for e.g. AES, you can use this parameter to get a key of the requiredlength.

Choose the Right Argon2 Parameters

Now that we know the parameters, we can start to determine the exact values.Start with the fixed parameters. The degree of parallelism should be twicethe amount of available CPU cores dedicated to hashing. Choose a salt lengthand key length of 128 bits unless you have a strict space constraint orrequire longer keys.

Login Time Versus Security

Our goal is to tune the parameters so that a single hashing operation takes anacceptable amount of time. Here, user experience is in conflict with security,and even in the interest of users security should win out. For frontendapplications the execution time should be at least 0.5s, but you should striveto make it 1s. Backend authentication can take a bit longer, but that depends onyour use case. Have a look in theArgon2 specification paper toget some recommended durations for different applications.

Adjust Memory and Iterations Parameters

To reach the desired execution time, you can tweak two variables. It isrecommended to start with the highest amount of memory possible and oneiteration. Reduce the memory until one hashing operation takes less than yourdesired duration. Next, advance the number of iterations to approach thedesired< execution time as close as possible.

Use Open Source to Choose Recommended Parameters

If the previous paragraph sounds like an algorithm to you, then you areabsolutely right. We wrote a small CLI helper that allows you to run thisprocedure in an automated manner. It is part of our user management systemOry Kratos. You can use the prebuild binaryfrom GitHub releases or docker image to run the CLI on your server and figureout the best values for your setup. It is as easy as running:

$ kratos hashers argon2 calibrate 1s

Or using docker:

$ docker run -it --entrypoint kratos oryd/kratos:v0.5 hashers argon2 calibrate 1s

The CLI allows you to set all your constrains, just have a look at all theoptions using the --help flag. An exemplary output could be:

{ "memory": 1048576, # = 1GB in KB "iterations": 2, "parallelism": 8, "salt_length": 16, # in bytes "key_length": 32, # in bytes}

Conclusion

This article is purposely brief and aims to be an introduction and reference fordevelopers that want to use the Argon2 password hashing algorithm forimplementing secure login. Check out theOry Kratos open source project if you arelooking for a login, registration, 2fa, profile management system where you canbring your own UI!

References

As an expert in cybersecurity and encryption algorithms, I've dedicated years to understanding and implementing various cryptographic protocols and security measures. My expertise spans across password hashing techniques, access control mechanisms, and secure user management systems. I've actively contributed to discussions, research papers, and practical implementations in the field.

The article you've provided focuses on the utilization of Argon2, an advanced cryptographic hash algorithm specifically designed for securing passwords. Argon2, recommended by OWASP, is regarded as a modern, secure, and versatile algorithm. It emphasizes the importance of selecting specific parameters to maximize security and performance.

Let's break down the concepts highlighted in the article:

  1. Argon2 Background:

    • Argon2 is a cryptographic hash algorithm developed for secure password hashing.
    • It ensures credentials are stored as a hash, preventing the retrieval of the original credentials even with full access to the system's storage.
  2. Parameters of Argon2:

    • Memory: Dictates the memory usage by the algorithm, increasing the cost of hash cracking for attackers.
    • Iterations: Determines the number of iterations over the memory, directly affecting computational cost.
    • Parallelism: Defines the number of threads used to reduce the threat from parallelized hash cracking.
    • Salt Length: Recommended at 128 bits but can be reduced to 64 bits in space-constrained scenarios.
    • Key Length (Hash Length): Depends on usage; usually, 128 bits suffice, but longer keys might be necessary for specific applications.
  3. Choosing Parameters:

    • Recommendations for fixed parameters: parallelism, salt length, and key length.
    • Balancing login time and security: Aim for a reasonable execution time without compromising security.
    • Adjusting memory and iterations to achieve desired execution times.
  4. Using Open Source Tooling:

    • Utilizing a CLI provided within Ory Kratos, a user management system, to automate parameter calibration based on given constraints.
    • The CLI aids in determining optimal values for parameters like memory, iterations, etc., to meet desired execution times.
  5. Conclusion:

    • The article serves as an introductory guide for developers seeking to implement secure login mechanisms using Argon2.
    • Recommends exploring Ory Kratos, an open-source project offering various user management functionalities.
  6. References:

    • Citations and resources provided for further exploration and understanding of Argon2, password storage best practices, and calibration implementations.

The comprehensive nature of the article showcases the importance of not only understanding cryptographic hashing but also efficiently utilizing parameters to balance security and performance in password management systems.

Choose Argon2 Parameters for Secure Password Hashing and Login (2024)

FAQs

What are the parameters for Argon2 password hashing? ›

Argon2i is optimized for password hashing. Argon2 has 6 input parameters: password, salt, memory cost (the memory usage of the algorithm), time cost (the execution time of the algorithm and the number of iterations), parallelism factor (the number of parallel threads), hash length.

How to choose the right parameter for Argon2? ›

Choose the Right Argon2 Parameters

Start with the fixed parameters. The degree of parallelism should be twice the amount of available CPU cores dedicated to hashing. Choose a salt length and key length of 128 bits unless you have a strict space constraint or require longer keys.

Is Argon2 secure for passwords? ›

Additionally, because Argon2 offers high security, it's recommended for applications that require strong password protection.

What are the recommended hash formats for keeping password securely? ›

Modern hashing algorithms such as Argon2id, bcrypt, and PBKDF2 automatically salt the passwords, so no additional steps are required when using them.

What are parameters on passwords? ›

Auditing Security
ParameterExplanation
login/min_password_diffThe minimum number of characters that must differ between password instances
login/min_password_digitsThe minimum number of digits that must be in a password
login/min_password_lettersThe minimum number of letters that must be in a password
4 more rows

What is the best password hashing method? ›

SHA256 is a very popular hashing algorithm and was and is extremely common in password management. The algorithm itself is considered secure — it is impossible to reverse the encryption, so that's not the issue.

What are the recommended settings for Bitwarden Argon2? ›

What is the recommended iteration setting for Argon2? The recommended settings are the default settings (iterations= 3 , parallelism= 4 , memory= 64 ). You would only need to change those if you are using the Bitwarden mobile app on an iOS device. You can tweak the settings, but the defaults are more than adequate.

Which password is better bcrypt or Argon2? ›

Argon2 is a great memory-hard password hashing algorithm, which makes it good for offline key derivation. But it requires more time, which, for web applications is less ideal. bcrypt can deliver hashing times under 1 second long, but does not include parameters like threads, CPU, or memory hardness.

How to verify Argon2 hash? ›

In essence, the steps to do this check are:
  1. Extract the salt and parameters from the encoded password hash stored in the database.
  2. Derive the hash of the plaintext password using the exact same Argon2 variant, version, salt and parameters.
  3. Check whether this new hash is the same as the original one.
Dec 10, 2018

Is Argon2 still the best? ›

In short, argon2 is better. Do beware that iOS auto-fill still seems to cause some issues, so if you use iOS, lower your “memory” setting to 48 MiB. More technical explanation: Argon2 was specifically crafted to fix the inherent flaws of compute bounded key derivation functions like pbkdf2.

What is the best secure password? ›

A strong password follows ALL THREE of these tips.
  • Make them long. At least 16 characters—longer is stronger!
  • Make them random. Two ways to do this are: Use a random string of mixed-case letters, numbers and symbols. For example: ...
  • Make them unique. Use a different strong password for each account. For example:

What is the difference between Argon2d and Argon2i? ›

Argon2d maximizes resistance to GPU cracking attacks. It accesses the memory array in a password dependent order, which reduces the possibility of time–memory trade-off (TMTO) attacks, but introduces possible side-channel attacks. Argon2i is optimized to resist side-channel attacks.

How do you pick the right hashing algorithm? ›

When selecting a hashing algorithm, security is the most critical factor to consider. An algorithm must be secure enough to prevent attackers from reversing the hash and obtaining the original data. The security of a hashing algorithm can be evaluated based on its resistance to collisions and pre-image attacks.

Which hashing function is most secure? ›

Common attacks like brute force attacks can take years or even decades to crack the hash digest, so SHA-2 is considered the most secure hash algorithm.

What is the best hash for security? ›

SHA-256 is one of the hashing algorithms that's part of the SHA-2 family (patented under a royalty-free U.S. patent 6829355). It's the most widely used and best hashing algorithm, often in conjunction with digital signatures, for: Authentication and encryption protocols, like TLS, SSL, SSH, and PGP.

What is the recommended salt size for Argon2? ›

Salt length — Length of the random salt. 16 bytes is recommended for password hashing. Key length — Length of the generated key (or password hash). 16 bytes or more is recommended.

How does Argon2 hashing work? ›

Argon2 is a cryptographic hashing algorithm specifically used to hash passwords. It provides better protection against password cracking than other hashing algorithms like Bcrypt, Scrypt, and PBKDF2. The Argon2 function takes in the password and outputs the hash of the specified length.

What are the parameters of bcrypt hash? ›

bcrypt. hash() : This function is used to generate a hash of a plaintext password. It takes the plaintext password and a salt factor (optional) as input parameters and returns the hashed password asynchronously.

Top Articles
5 reasons you need an Unstoppable Domain
Everything You Need to Know About Digital Asset Ownership in Web3 
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
Things To Do In Atlanta Tomorrow Night
Non Sequitur
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Selly Medaline
Latest Posts
Article information

Author: Annamae Dooley

Last Updated:

Views: 6384

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Annamae Dooley

Birthday: 2001-07-26

Address: 9687 Tambra Meadow, Bradleyhaven, TN 53219

Phone: +9316045904039

Job: Future Coordinator

Hobby: Archery, Couponing, Poi, Kite flying, Knitting, Rappelling, Baseball

Introduction: My name is Annamae Dooley, I am a witty, quaint, lovely, clever, rich, sparkling, powerful person who loves writing and wants to share my knowledge and understanding with you.