Is SHA-3 slow?
keccak.noekeon.org
keccak.noekeon.org
As a developer you should use something like libsodium that has a default "hash" API. Underneath, the developers made the choice of choosing Blake2, but this is transparent to the user of the library.
If you do not have access to high level libraries like that, and don't want to loose time/dig too much into the topic, following standards (SHA-3) is easy.
Maybe for bubble code it'd be okay to just say "gimma a hash".
But most real code needs to interoperate with stuff. E.g. I need to send a SHA-256 from a JS client to a Python server. So there needs to be a consistent and portable "SHA-256" concept that everyone understands.
A cryptographic hash is not a complicated concept (even if developing one is).
I suppose you can think about whether you require collision resistance or merely second pre-image resistance, but the popular ones are all intended to be collision resistant anyway.
https://bitbucket.org/martin_scharrer/crccheck/src/default/c...
https://neosmart.net/blog/2017/will-amds-ryzen-finally-bring...
[0] https://deplinenoise.files.wordpress.com/2015/03/gdc2015_afr...
> If you have a 64-bit build, you WILL have SSE2 instructions
Go allows you to detect a few architecture when you build (amd64, arm, arm64, 386) but not really the CPU model. So using SSE2 for anything amd64/arm64 would probably be a good solution.
The idea there is not the absolute performance but rather the relative speed of the operation with and without hardware acceleration.
(additionally, openssl does not expose aes-128-ctr or gcm as an `openssl speed` option.)
Ignorance isn't the problem. The problem is ignorance combined with confidence.
I've been thinking for some time now about the state of cryptography education for non-experts, and what I've noticed over the years is we push a lot of digestible soundbites ("Don't use MD5, don't roll your own, use encrypt-then-mac", etc) without significant explanations. Sometimes there is an accessible explanation for these things that's appropriate for a message board comment, sometimes there isn't, and this advice is necessarily separated from a larger corpus of material due to the medium.
If telling developers what not to do over and over again in order to dissuade them from shooting themselves in the foot has made them more secure overall, this is a good thing. But I do think it comes at the cost of not encouraging real understanding of why not to do these things. You're right that they shouldn't take specific positions without that understanding, but I think it can be hard for them to know they don't have it due to the culture.
If you're looking for an online resource, try Crypto101 (https://raw.githubusercontent.com/crypto101/crypto101.github...).
1. Applied Cryptography by Bruce Schneier.
2. The Matasano Crypto Challenges: www.cryptopals.com
3. The Stanford cryptography courses taught by Dr. Boneh online (still waiting on the second one).
- On hardware, SHA3 is faster than every other contender in the competition.
- On software, K12 is so fast that the bottleneck will not be its computation.
"Generic" cryptographic hash functions like SHA-1/SHA-2/SHA-3 (or BLAKE, or MD5) don't iterate more times than is necessary for security, and are designed to be as fast as possible. This way, you can hash multi-gigabyte documents in a fraction of a second.
General cryptographic hash functions should not be slow, since in many scenarios they are used on a lot of data and slowness has no security benefits.
But for all other cryptographic purposes like message integrity checking, file verification, signing, or fingerprinting speed is extremely important.
In these cases, the input to the hash is generally public, so there is no reason to even try bruteforcing. And even if you did, these inputs are much longer than passwords.
Anyway the state of the art here is Argon2 which won the latest password hashing competition: https://password-hashing.net/
If you're thinking of PBKDF2, it's a "password-based" KDF as its name hints. While both password-based KDFs and password hashing functions seem to have common properties, I think the term "password hash" has caught up more (specifically thanks to the password hashing competition).
Ethereum uses SHA-3 to begin with.
I'm currently trying 21970881 passwords against the hash using fairly basic python code (ETA: 2-3 days), and can definitely use tips for speeding up the work, as Id likely need to try an order of magnitude or 2 more generated password in order to crack it.
1. https://etherchain.org/account/0x35f5860149e4bbc04b8ac5b272b...
It can test 588 passwords per second on my modest GPU. I guess that's a lot better than a basic Python script.
You should also have a look at probable wordlists[1], which contains a lot of passwords sorted by their popularity. It could significantly speedup the research, as long as your password has already leaked elsewhere.
When Ethereum was being developed, the spec for SHA-3 wasn't finished or something: https://ethereum.stackexchange.com/questions/550/which-crypt...
It sounds like you have it under control but I typically point people to Dave @ https://walletrecoveryservices.com/ for the less tech-savvy. He's pretty good. You can look at his site for what he can and can't crack. I know he's super super busy but it never hurts to give him a shout and ask him if he has any pro-tips or open-source code somewhere. A ping from someone who has a basic understanding of encryption might be refreshing.
Here are a random assortment of links I have saved regarding recovering presales:
https://www.reddit.com/r/ethereum/comments/46887p/tips_for_r...
https://forum.ethereum.org/discussion/3045/request-post-pass...
https://www.reddit.com/r/ethereum/comments/3g6aw0/i_lost_my_...
It makes brute forcing more difficult, and promotes decentralization of infrastructure (slowness adds up only for large-scale deployments like Google and Facebook, and we want to depend less on centralized actors, not more).
If you need to choose between strength and performance, choose strength in nearly 100% of all cases. You make the job of NSA or GRU much harder, and promote offsetting security mechanisms to the edge, where they ought to be.
Usually, security margins are planned against brute force according to Moore's law. This is not enough. Novel cryptographic attacks do not suddenly render the entire algorithm useless (usually); rather, they dramatically reduce its strength. And novel cryptographic attacks appear all the time even in the public space -- who knows what stays behind closed doors and clearances?
If you have large enough security margin, you can escape unscathed while you upgrade your infrastructure. And if not, not.
This is simply not correct. There are a few cryptographic problems where slowness is the solution, but in most cases you want your cryptographic algorithms to be fast.
1) It means default-secure will not happen. If the NSA has to spend 10x as long to attack your security, but 1/10th as much communication is encrypted, it's a win for them (since now the simple fact that something is encrypted means someone put effort into it, which is a good signal that it will be useful).
2) Brute force attacks are typically embarrassingly parallel, and can be amenable to special purpose hardware (e.g. GPUs). An attacker with an 8 GPU system spend $10k and can attack PBKDF2 much faster than a $10k server will be authenticating people.
3) If your security relies on slowness, then people will pick less-secure defaults. If you can get an equivalent level of security per cpu-cycle, then people will pick a higher security margin (this is the non-binary version of #1).
3DES is way slower than most crypto primitives used today. I haven't seen it recommended much though.
http://spectrum.ieee.org/computing/hardware/google-plans-to-...
I feel the same about all of those "faster" (read: weaker) IoT-optimized crypto algorithms that are being proposed right now for standardization.
What we should be talking about now is quantum-resistant algorithms that are likely to be even slower than SHA-3, but would at least protect communications against quantum computers. We need them soon, because they'll have to be deployed on 80%+ of the internet by 2030 or so, and we know how slow the internet ecosystem is at adopting a new protocol.
Actually the sponge capacity in the so called 128-bit keccak functions is 256, they only call them 128-bit because they provide 128bits of preimage and collision resistance (at 256 bits of output). In a quantum setting the difficulty for preimage and collision attacks for these functions is 2^(256/3), when assuming that the output is of at least 256 bits.
> What we should be talking about now is quantum-resistant algorithms that are likely to be even slower than SHA-3
SHA3-256 has c = 512 and output of 256 bits (128 bits of preimage resistance and ~85 bits of collision resistance on a quantum setting), while SHA3-512 has c = 1024 and output of 512 bits (256 bits of preimage resistance and ~170 bits of collision resistance on a quantum setting). I would say that both of the above sha3 versions are quantum resistant.
Most modern symmetric cryptography would safe in a post-quantum world, I would say that the only thing that is left is to adopt post-quantum asymmetric algorithms more widely.
You're right, Appendix A.1 of http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
Besides, even when using a "fast" hash function for password storage, you can always just increase the number of rounds to compensate.
Do not use SHA-3 for password storage!
Use a key-stretching password hash function e.g. bcrypt or scrypt.
(These take a fast hash or encryption function and apply it many many times, to make the total work be slow.)
PBKDF2 is the function that takes a fast hash function and applies it many times to make it slow.
You want hashes to be fast, and KDFs to be slow.
Shameless plug: https://patrickmn.com/security/storing-passwords-securely/#n...