Hot answers tagged

24 votes
Accepted

What's the difference between PBKDF and SHA and why use them together?

SHA-512 is a cryptographically secure hash, PBKDF2 is what we call a Password Based Key Derivation Function. If the resulting secret isn't used as key but as hash value it's also called a password ...
user avatar
  • 85.1k
19 votes
Accepted

Do I need to sanitize user input to scrypt, or to PBKDF's in general?

No, you do not need to do escaping or sanitization on data that you pass in as the user input to these functions. They accept arbitrary byte sequences, so any arbitrary byte sequence you pass is ...
user avatar
  • 1,572
18 votes

Password hash that can be upgraded without plaintext password

This is called Client-Independent Update, according to the Catena paper. It is desirable to be able to compute a new password hash (with some higher security parameter) from the old one (with the ...
user avatar
  • 586
15 votes

What's the difference between PBKDF and SHA and why use them together?

To paraphrase my answer to an earlier question, PBKDF2 is a generic high-level algorithm that internally calls a pseudorandom function (PRF) to process its input. The PBKDF2 spec does not mandate any ...
user avatar
15 votes
Accepted

Is deriving the IV from the password secure?

Yes, it is. PBKDF2 derives a DK, a "derived key", which is indistinguishable from random. This is mainly because function within PBKDF2 is HMAC, and HMAC is a PRF. Let's see the definition from ...
user avatar
  • 85.1k
13 votes
Accepted

Should we run PBKDF2 for every plaintext to be protected or should we run PBKDF2 only once?

Assume you have an IND-CCA secure cryptosystem $E$ that runs a password through a slow KDF and implicitly handles salts and random IVs, a human-chosen password $p$, and messages $m_1$ through $m_n$ to ...
user avatar
  • 13.3k
10 votes
Accepted

Does a big salt have the same memory effects as Bcrypt?

So in general, isn't this equivalent to what Bcrypt and PBKDF2 do in terms of password storage security? PBKDF2, yes, pretty much. The only real difference is that salt/password are used the other ...
user avatar
  • 31.3k
10 votes
Accepted

Argon2i versus Argon2d?

TL;DR: You want to use Argon2d here. Even though Argon2 was standardized only somewhat recently, it is the result of the Password-Hashing Competition (2013-2015) and was a late re-design of Argon ...
user avatar
  • 44.6k
9 votes
Accepted

Is PBKDF2/RFC 2898 broken because SHA1 is broken?

That particular usage of SHA-1 uses HMAC, and then iterates that as part of PBKDF2 (which is actually defined for any PRF, not just HMAC-SHA1). As of this date (2017-05-18) HMAC-SHA1 is unbroken in ...
user avatar
  • 2,217
9 votes
Accepted

Is it necessary to stretch/derive an AES key when I already have enough bytes from a 'cryptographically secure RNG'?

You're right. Unless the software is doing something very peculiar, which should be very apparent when reading the code and documentation, and I can't imagine what it could be, the salt generation and ...
user avatar
8 votes

How long does it take to crack PBKDF2?

PBKDF2 (as defined by RFC 2898) is a function of the form $$DK = \text{PBKDF2}(\text{PRF}, Password, Salt, c, dkLen)$$ In most practical use cases, the $\text{PRF}$ is $\text{HMAC}$ instantiated ...
user avatar
  • 124k
8 votes
Accepted

Can I use PBKDF2 as a stream cipher?

TL;DR: Yes, you can use PBKDF2 as a stream cipher. However, you should not use it for that and for its intended purpose (i.e. password-based key derivation) at the same time. Instead, if you need to ...
user avatar
8 votes

The logic of preferring PBKDF2 over iterative SHA2

I think you are overstating the complexity of PBKDF2, and also, not matching it feature-wise with your alternative. Let's dispatch the latter first: as gammatester's comment mentioned, PBKDF2 ...
user avatar
7 votes
Accepted

Maximum password length in PBKDF2

There's no practical limit to password or salt length you can use with PBKDF2. Theoretical limit, however, is determined by the hash function used by PBKDF2: under the hood, it uses $HMAC(Password, ...
user avatar
  • 837
7 votes
Accepted

How long does it take to crack PBKDF2?

Firstly, How much time will it take to crack PBKDF2 while using a 9 character password? and how do I calculate the cost? I'm not specifying any specific system or platform. If a brute force attack is ...
user avatar
  • 31.3k
7 votes
Accepted

Does salt size affect password hash security?

So, here's my question: is there a point where the salt size doesn't matter anymore in terms of security and where it might even decrease it? The purpose of a salt is to prevent the attacker from ...
user avatar
  • 31.3k
7 votes
Accepted

Some Questions about the Veracrypt hash functions

These hash functions are also used for the key derivation function. Both are roughly equally secure for a KDF in the sense of collision resistance etc., but SHA512 offers a bit more security as ...
user avatar
  • 853
7 votes
Accepted

Is it safe to store both the AES-related data and the PBKDF2-related data (except passwords) in one file?

All the parameters you've mentioned can be public. Furthermore, only the salt, IV and ciphertext cannot simply be guessed. The IV is generally easy to retrieve once the key is known, so the making ...
user avatar
  • 85.1k
7 votes

I think PBKDF2 may be better than Scrypt? Looking for someone to point out my logical error

There's no point in using either an ASIC or a GPU to calculate a single password hash. That's true whether you use PBKDF2 or scrypt or Argon2 or whatever. What massively parallel devices like GPUs ...
user avatar
6 votes

Replacing the PRF in PBKDF2 with Keccak

Is there anything wrong with swapping SHA2 for Keccak for use in PBKDF2? There are 2 main issues. Performance and implementation. Performance The performance issue is from an attacker-defender ...
user avatar
  • 12.7k
6 votes
Accepted

Deriving a key for HMAC, using PBKDF2

No, you should not use a password directly as an HMAC key. However, it is fine to use HMAC as part of a key derivation function, which generates keys from a password. However, do not mistake the ...
user avatar
  • 12.7k
6 votes
Accepted

What are KDF parameters in OpenSSL command-line utility for `enc`?

OpenSSL uses EVP_BytesToKey, an algorithm proprietary to OpenSSL, with a salt and an iteration count set to 1. The algorithm is secure; the iteration count of 1 of ...
user avatar
  • 85.1k
6 votes
Accepted

HMACSHA1 vs HMACSHA2 (for PBKDF2)

The only downside to SHA-2 over SHA-1 is that SHA-2 is a little slower. In this case, that is of no practical consequence whatsoever because you're trying to make something slow to compute, and it is ...
user avatar
6 votes
Accepted

How many bits of entropy are leaked for every derived password from a master?

From an information-theoretic perspective, and with an ideal password hash function, with $k=68$ possibilities for each character of derived password, each such character leaks about $\log_2(k)\...
user avatar
  • 124k
6 votes

I think PBKDF2 may be better than Scrypt? Looking for someone to point out my logical error

The question correctly finds that In the case of PBKDF2, you will need to buy an ASIC to be ideal and proceeds assuming the legitimate server does that; or at least, uses a GPU as substitute. ...
user avatar
  • 124k
6 votes
Accepted

Is it problematic to use PBKDF2-HMAC-SHA256 to derive a 512-bit XTS key?

Background. PBKDF2 has a stupid design where generating two blocks of output costs the legitimate user twice as much as generating one block of output, without necessarily putting additional cost on ...
user avatar
6 votes
Accepted

Using a KDF (PBKDF2) properly

PBKDF2 is deliberately slow (and gets slower and safer with more iterations, so you want to make it as slow as you practically can). Because of this, you should generally avoid running it more times ...
user avatar
6 votes

Generate AES key from weak string

You need a key stretching function, not a mere key derivation function. A key stretching function is technically a kind of key derivation function, but most key derivation functions are not key ...
user avatar
5 votes
Accepted

Generate secure password hashes without access to PBKDF2 or bcrypt

Actually you are quite near on implementing PBKDF2. It is kind of iterated HMAC execution. So have a look here and just implement the missing parts: PBKDF2
user avatar
  • 768
5 votes
Accepted

Is SHA256 good enough to shrink a key?

I agree with the comments that SHA-256 should be fine here. However, if you already use HMAC-SHA-256 for PBKDF2, you could use HKDF Expand, which despite its name is defined even for output lengths ...
user avatar
  • 31.3k

Only top scored, non community-wiki answers of a minimum length are eligible