From PBKDF2 vs Bcrypt, which is better? - Learn & Grow with Popular eLearning Community (2024)

718Asked by MichaelVaughaninCyber Security, Asked on Oct 20, 2022

We know that to slow down password cracking in case a password database leak, passwords should be saved only in a hashed format. And not only that, but hashed with a strong and slow function with a possibility to vary the number of rounds.

Often algorithms like PBKDF2, bcrypt and scrypt are recommended for this, with bcrypt seemingly getting the loudest votes, e.g. here, here and here.

But what about the SHA256 and SHA512 based hashes implemented in at least glibc (description, specification) and used by default at least on some Linux distributions for regular login accounts? Is there some reason not to use them, or to otherwise prefer bcrypt over the SHA-2 based hashes?

Of course bcrypt is significantly older (1999) and thus more established, but the SHA-2 hashes are already nine years old by now (2007), and scrypt is even younger by a bit (2009), but still seems to be mentioned more often. Is it just an accepted practice, or is there some other reason? Are there any known weaknesses in the SHA-2 based hashes, or has anyone looked?

Answered by Michelle Hunter

The SHA-2 family of hashes was designed to be fast. BCrypt was designed to be slow. From PBKDF2 vs Bcrypt, both are considered robust. With enough rounds or work-factor, either one can take longer than the other, but I would lean towards the one that was designed to be slow. (if server load is an issue, the Work Factor is adjustable)


Additionally, I would lean towards BCrypt because it is usually a Compiled implementation (C or C++).

The multi-round SHA can easily be implemented in high-level language, at least for the iteration, if not also for the hash itself. High level languages are less efficient for basic mathematical operations, reducing the number of rounds your production hardware can complete per millisecond.

While both algorithms can be implemented in either high- or low-level languages, or a hybrid; in BCrypt the options available dictate that you are more likely to land on an efficient implementation. (puts you on a more even playing field with the attacker)

In regards to your specific example from the /etc/shadow file, you are likely on only low-level (efficient) algorithms either way. (SHA or BCrypt) In this example I would suggest you consult the OS documentation to optimise the rounds (work factor) based on the speed of the hardware -vs- how strong you would like the hash to be.

scrypt (with a great enough work factor) has the added benefit of having extra RAM/Memory requirements (not just CPU), making it more GPU-resistant than SHA, BCrypt or PBKDF2.

I am an expert in cybersecurity with a profound understanding of various encryption and hashing algorithms, as well as their applications in securing password databases. My expertise is grounded in both theoretical knowledge and hands-on experience in implementing and analyzing cryptographic techniques.

In the provided article, the question revolves around the choice between different hashing algorithms, particularly focusing on bcrypt, PBKDF2, scrypt, and SHA-2-based hashes (SHA256 and SHA512). The user seeks to understand why bcrypt is often recommended over SHA-2-based hashes in the context of password storage.

Firstly, the user acknowledges the common recommendation of algorithms like PBKDF2, bcrypt, and scrypt for slowing down password cracking in the event of a database leak. However, there is a specific inquiry about the SHA256 and SHA512-based hashes used in some Linux distributions and whether there is any reason not to prefer them over bcrypt.

Michelle Hunter provides a comprehensive answer, highlighting key aspects to consider in the choice of hashing algorithms:

  1. Speed and Design Philosophy:

    • SHA-2 family hashes are designed to be fast.
    • BCrypt, on the other hand, was intentionally designed to be slow.
  2. Robustness and Adjustability:

    • Both PBKDF2 and bcrypt are considered robust.
    • With sufficient rounds or work-factor, either algorithm can be made to take a considerable amount of time.
    • The user suggests leaning towards the one designed to be slow, especially if server load is not a significant concern.
  3. Implementation Efficiency:

    • BCrypt is usually implemented in compiled languages like C or C++, which tends to be more efficient.
    • Multi-round SHA can be implemented in high-level languages, but they are less efficient for basic mathematical operations, potentially reducing the effectiveness of the hashing process.
  4. Hardware Considerations:

    • BCrypt offers more options that are likely to lead to an efficient implementation.
    • The choice between SHA and BCrypt in the /etc/shadow file may depend on the efficiency of low-level algorithms and is recommended to consult the OS documentation for optimization.
  5. scrypt and GPU Resistance:

    • scrypt, with a sufficient work factor, imposes extra RAM/memory requirements, making it more GPU-resistant compared to SHA, BCrypt, or PBKDF2.

In conclusion, Michelle Hunter emphasizes the importance of considering factors such as the design philosophy, robustness, efficiency of implementation, and hardware considerations when choosing a hashing algorithm. The response provides a nuanced understanding of the strengths and considerations for each algorithm in the context of password storage and security.

From PBKDF2 vs Bcrypt, which is better? - Learn & Grow with Popular eLearning Community (2024)

FAQs

Is PBKDF2 better than bcrypt? ›

PBKDF2 is simple to implement but is considered to be less secure than more advanced algorithms. Bcrypt is more secure but is more resource-intensive. Scrypt is the most secure but is also the most resource-intensive.

Is anything better than bcrypt? ›

Factors such as the number of users, the computing resources available, and the security requirements should all be taken into account. In general, newer algorithms like Argon2 are considered to be stronger than older ones like bcrypt and PBKDF2, but they may require more memory or processing power to compute.

Is PBKDF2 recommended? ›

PBKDF2. Since PBKDF2 is recommended by NIST and has FIPS-140 validated implementations, so it should be the preferred algorithm when these are required. The PBKDF2 algorithm requires that you select an internal hashing algorithm such as an HMAC or a variety of other hashing algorithms.

What are the advantages of PBKDF2? ›

The Advantages of Using PBKDF2

Enhanced Security Against Brute-Force Attacks: By making the hash computation slow and resource-intensive, PBKDF2 significantly reduces the risk of brute-force attacks.

What is the disadvantage of bcrypt? ›

Bcrypt is slower and requires some memory (4 kiB IIRC), so one spends 100ms to check a valid password whereas an attacker needs days / years to crack it because he's slowed down and can't use GPUs efficiently.

What is the weakness of PBKDF2? ›

One weakness of PBKDF2 is that while its number of iterations can be adjusted to make it take an arbitrarily large amount of computing time, it can be implemented with a small circuit and very little RAM, which makes brute-force attacks using application-specific integrated circuits or graphics processing units ...

Can bcrypt be hacked? ›

Even with higher computer speeds, bcrypt is very time-consuming to hack via brute force thanks to its variable number of password iterations. Compare this to popular hashing algorithms such as MD5 and SHA256, which are designed to hash quickly.

Is bcrypt outdated? ›

bcrypt is just obsolete – this was to find a successor to it. yescrypt, one of the recommended finalists, is an improved/fixed version of scrypt. "Obsolete" is a very strong word for bcrypt.

What to use instead of bcrypt? ›

If you want to store passwords, then bcrypt, scrypt, and argon2 are commonly used. They are available in Go's extended library. SHA is a hashing algorithm but by itself is not meant for password storage. Unlike bcrypt, scrypt and argon2, SHA is designed to be fast.

Why is PBKDF2 slow? ›

Hash function PBKDF2 is purposely designed to be slow by a large iteration count which makes the brute force attack on the created key with PBKDF2 much harder. The length of the derived key (output hash) can be configurable.

What is the best password hashing algorithm? ›

Choosing a slow algorithm is actually preferred for password hashing. Of the hashing schemes provided, only PBKDF2 and Bcrypt are designed to be slow which makes them the best choice for password hashing, MD5 and SHA-256 were designed to be fast and as such this makes them a less than ideal choice.

Can PBKDF2 be reversed? ›

You cannot really reverse PBKDF2, and guessing the value of the previous iteration round (256 bits) is even with merely one iteration way harder than guessing the password (<100 bits) at 100k iterations.

What are the alternatives to PBKDF2? ›

Alternatives to PBKDF2

1. Bcrypt: Introduction: Bcrypt is a key derivation function designed specifically for securely hashing passwords. Like PBKDF2, it is resistant to brute-force attacks and adds an additional layer of security through salting.

How fast is PBKDF2? ›

If you do 1,000 iterations of PBKDF2 then that will cut the attack down from 50 billion per second to 50 million per second. 10,000 iterations will be 5 million per second. A typical web server however will not be anywhere near that fast.

Is bcrypt better than SHA256? ›

Another important detail is that SHA256 hashes don't include the salt element, which makes them more susceptible to dictionary-based cyberattacks. So while SHA256 is more suitable for applications that require frequent interaction, bcrypt is a better solution for safely storing passwords.

What is the most secure hash algorithm? ›

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 most efficient hashing algorithm? ›

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.

Top Articles
How to Form a Series LLC | ZenBusiness Inc.
2 Reasons Student Loans Are So Difficult to Pay Off, and 2 Ways to Prepare | The Motley Fool
Fredatmcd.read.inkling.com
Jonathon Kinchen Net Worth
La connexion à Mon Compte
Southeast Iowa Buy Sell Trade
How to Type German letters ä, ö, ü and the ß on your Keyboard
Western Razor David Angelo Net Worth
Slay The Spire Red Mask
Find your energy supplier
Tcu Jaggaer
Nonne's Italian Restaurant And Sports Bar Port Orange Photos
Jvid Rina Sauce
I Touch and Day Spa II
Grab this ice cream maker while it's discounted in Walmart's sale | Digital Trends
Swgoh Turn Meter Reduction Teams
The Exorcist: Believer (2023) Showtimes
Kylie And Stassie Kissing: A Deep Dive Into Their Friendship And Moments
Craigslist West Valley
Walgreens Alma School And Dynamite
Riversweeps Admin Login
پنل کاربری سایت همسریابی هلو
BJ 이름 찾는다 꼭 도와줘라 | 짤방 | 일베저장소
Turbo Tenant Renter Login
208000 Yen To Usd
Healthy Kaiserpermanente Org Sign On
Frank Vascellaro
How rich were the McCallisters in 'Home Alone'? Family's income unveiled
031515 828
Fbsm Greenville Sc
Vistatech Quadcopter Drone With Camera Reviews
15 Downer Way, Crosswicks, NJ 08515 - MLS NJBL2072416 - Coldwell Banker
123Moviestvme
Lake Dunson Robertson Funeral Home Lagrange Georgia Obituary
Seymour Johnson AFB | MilitaryINSTALLATIONS
Solemn Behavior Antonym
Cherry Spa Madison
Ticket To Paradise Showtimes Near Marshall 6 Theatre
Nancy Pazelt Obituary
Dispensaries Open On Christmas 2022
Postgraduate | Student Recruitment
Dwc Qme Database
Brown launches digital hub to expand community, career exploration for students, alumni
Enr 2100
Holzer Athena Portal
Sky Dental Cartersville
Syrie Funeral Home Obituary
8 4 Study Guide And Intervention Trigonometry
Bank Of America Appointments Near Me
2000 Ford F-150 for sale - Scottsdale, AZ - craigslist
Germany’s intensely private and immensely wealthy Reimann family
Latest Posts
Article information

Author: Saturnina Altenwerth DVM

Last Updated:

Views: 6422

Rating: 4.3 / 5 (44 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Saturnina Altenwerth DVM

Birthday: 1992-08-21

Address: Apt. 237 662 Haag Mills, East Verenaport, MO 57071-5493

Phone: +331850833384

Job: District Real-Estate Architect

Hobby: Skateboarding, Taxidermy, Air sports, Painting, Knife making, Letterboxing, Inline skating

Introduction: My name is Saturnina Altenwerth DVM, I am a witty, perfect, combative, beautiful, determined, fancy, determined person who loves writing and wants to share my knowledge and understanding with you.