TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Cryptographic Right Answers

340 pointsby louis-paulabout 7 years ago

29 comments

weinzierlabout 7 years ago
Here is a summary, roughly ordered from constant to changed the most.<p><pre><code> Percival Ptacek Latacora 2009 2015 2018 Online backups tarsnap tarsnap tarsnap Symmetric key length 256-bit 256-bit 256 bit Symmetric “Signatures” HMAC HMAC HMAC Random IDs 256-bit 256-bit 256-bit Hashing algorithm SHA256 (SHA-2) SHA-2 SHA-2 Password handling scrypt scrypt scrypt PBKDF2 bcrypt argon2 PBKDF2 bcrypt PBKDF2 Website security OpenSSL OpenSSL AWS ALB&#x2F;ELB BoringSSL OpenSSL AWS ELBs LetsEncrypt Client-server OpenSSL OpenSSL AWS ALB&#x2F;ELB app security BoringSSL OpenSSL AWS ELBs LetsEncrypt Asymmetric encryption [1] NaCl&#x2F;libsodium NaCl&#x2F;libsodium Asymmetric signatures [2] NaCl NaCl Ed25519 Ed25519 RFC6979 Diffie-Hellman [3] DH-2048 Nothing NaCl Curve25519 Encrypting Data: AES-CTR HMAC NaCl&#x2F;libsodium default KMS ChaCha20-Poly1305 XSalsa20+Poly1305 AES-GCM </code></pre> [1] RSAES-OAEP with SHA256 and MGF1+ SHA256 bart pop fssssssst exponent 65537<p>[2] RSASSA-PSS with SHA25 or MGF1+SHA256 in tricolor systemic silicate orientation<p>[3] 2048-bit Group #14 with a generator or 2
评论 #16751193 未加载
评论 #16749354 未加载
评论 #16752967 未加载
tptacekabout 7 years ago
Fight me.<p>I mean, happy to answer any questions.<p>By the way: if you&#x27;re interested in this, you might also be interested in the set of 9 (count them: 9) new cryptopals challenges we sold off to raise money for rural congressional races on Twitter:<p><a href="https:&#x2F;&#x2F;twitter.com&#x2F;search?f=tweets&amp;q=set%208%20from%3Atqbf&amp;src=typd" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;search?f=tweets&amp;q=set%208%20from%3Atqbf&amp;...</a><p>This is Cryptopals Set 8, before this weekend available only on request and after swearing a solemn oath not to share.
评论 #16752985 未加载
评论 #16752180 未加载
评论 #16750689 未加载
评论 #16753578 未加载
评论 #16750218 未加载
评论 #16749484 未加载
评论 #16750877 未加载
评论 #16749869 未加载
评论 #16754587 未加载
评论 #16750767 未加载
评论 #16748629 未加载
评论 #16748967 未加载
评论 #16750507 未加载
评论 #16752162 未加载
评论 #16754369 未加载
评论 #16749837 未加载
评论 #16754223 未加载
评论 #16749679 未加载
评论 #16755192 未加载
评论 #16748869 未加载
评论 #16749370 未加载
keithwinsteinabout 7 years ago
Would propose one amendment to &quot;Random IDs&quot;: if you can rely on it being available, getentropy() is preferable to &#x2F;dev&#x2F;urandom.<p>(1) It blocks if the system has just booted and the kernel has not yet collected enough entropy to initialize the entropy pool. (Good on VMs, embedded systems, etc., where there&#x27;s a risk that the initial state might be identical.) It would be nice if Linux had a file-based &#x2F;dev&#x2F;uxrandom that waited for the CSPRNG to be properly initialized and then behaved like &#x2F;dev&#x2F;urandom, but, it doesn&#x27;t.<p>(2) Unlike getrandom(), you don&#x27;t have to read the long section on &quot;Interruption by a signal handler&quot; or know about the special-casing for small buffers or even think about what to put in the flags argument -- getentropy() doesn&#x27;t have a flags argument.<p>(3) Performance is a bit better than opening &#x2F;dev&#x2F;urandom, reading some bytes, and closing the fd, and you don&#x27;t have to be careful about making sure the fd gets closed no matter the control flow. Performance is probably similar to keeping a persistent &#x2F;dev&#x2F;urandom fd open, except that has its own minor hygienic issues (especially in library code or multithreaded code). There are a lot fewer error-checking steps in one call to getentropy() than in opening, reading, and closing &#x2F;dev&#x2F;urandom.<p>(4) getentropy() and getrandom() are available even if &#x2F;dev isn&#x27;t available or whatever (like in a sandbox, etc.)
评论 #16748954 未加载
评论 #16749115 未加载
评论 #16749456 未加载
评论 #16749035 未加载
loup-vaillantabout 7 years ago
The longevity of Tarsnap is quite astonishing. Congrats to Colin Percival.<p>---<p><i>Edit: Note to self: don&#x27;t promote your home made crypto around famous people. (I&#x27;m way past home made at this point, but since there is no way to tell from the outside…)</i><p><i>Edit2: Seriously though, why? It can&#x27;t just be because I veered off topic.</i><p>---<p>Shameless plug: glad my own <a href="https:&#x2F;&#x2F;monocypher.org" rel="nofollow">https:&#x2F;&#x2F;monocypher.org</a> satisfies most of this, but we do have a couple departures:<p><i>Encrypting data:</i> Monocypher provides an XChacha20 + Poly1305 AEAD construction (copied straight from the RFC 7539). Why not XSalsa20? Because XChacha20 has a little bit more security margin, and is a little bit easier to optimise.<p><i>Symmetric &quot;signatures&quot;:</i> Monocypher provides Blake2b, which provides a keyed mode for this. Blake2b doesn&#x27;t need HMAC.<p><i>Hashing Algorithm:</i> Blake2b again, because it&#x27;s faster and immune to length extensions attacks. I&#x27;m not sure why they still recommend SHA-2. Isn&#x27;t Blake2 mature enough by now?<p><i>Password Handling:</i> Monocypher provides Argon2i. Close to the top of the list, but not quite.<p><i>Asymmetric encryption:</i> Monocypher doesn&#x27;t have a box-like construction, but it does have a key exchange function, which combined with AEAD does the same thing as NaCl&#x27;s crypto_box(). This makes the library more orthogonal, and I assumed combining key exchange and AEAD wasn&#x27;t error prone.<p><i>Asymmetric signatures:</i> Monocypher defaults to EdDSA, with curve25519 and Blake2b. Why no SHA-512 instead? Because I already have Blake2b, which is faster, and I didn&#x27;t want the bloat. (Ed25519 is provided as an option)<p>I hope those departures are boring enough.
weinzierlabout 7 years ago
Just for reference, here are the source URLs for the quotes from <i>Percival, 2009</i> [1] and <i>Ptacek, 2015</i> [2]. I&#x27;m not sure about the gist, but it is what I always refer to and it&#x27;s last revision is May 23, 2015.<p>[1] <a href="http:&#x2F;&#x2F;www.daemonology.net&#x2F;blog&#x2F;2009-06-11-cryptographic-right-answers.html" rel="nofollow">http:&#x2F;&#x2F;www.daemonology.net&#x2F;blog&#x2F;2009-06-11-cryptographic-rig...</a><p>[2] <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;tqbf&#x2F;be58d2d39690c3b366ad" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;tqbf&#x2F;be58d2d39690c3b366ad</a>
victork2about 7 years ago
Hey, thanks for putting that together, it&#x27;s a very insightful read. One thing I would mention in the section &quot;Encrypting Data&quot;:<p>KMS is great and very useful but there are limitations, for example the 4kb payload max. Another one is latency (back and forth is OK for a single decryption step, for 10.000 it might become problematic)<p>In case you have to go around these limitations they recommend a data key that you use to encrypt the data, encrypt the data key, store both encrypted blobs in your DB and throw away away the data key from the memory as quickly as possible.<p><a href="https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;kms&#x2F;latest&#x2F;developerguide&#x2F;programming-encryption.html" rel="nofollow">https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;kms&#x2F;latest&#x2F;developerguide&#x2F;progra...</a><p>Thoughts?
评论 #16748852 未加载
评论 #16748843 未加载
piracykillsabout 7 years ago
Curious - why is argon2 still second to scrypt on this list?<p>I&#x27;d also question the backup solution, I think Restic is a better option due to its flexibility, I can do cheap backups to B2 and fairly reputable people seem to be approving of its cryptography:<p><a href="https:&#x2F;&#x2F;blog.filippo.io&#x2F;restic-cryptography&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.filippo.io&#x2F;restic-cryptography&#x2F;</a><p>If anyone sees a reason why Tarsnap would be better (other than Percival&#x27;s brand), I&#x27;d be quite interested.
评论 #16751282 未加载
评论 #16755521 未加载
评论 #16750522 未加载
评论 #16750847 未加载
jstanleyabout 7 years ago
This article was worth writing, and I&#x27;m glad you wrote it. It is helpful. You might not realise it but:<p>&gt; If you could use KMS but encrypting is just a fun weekend project and you might be able to save some money by minimizing your KMS usage, use KMS. If you’re just encrypting secrets like API tokens for your application at startup, use SSM Parameter Store, which is KMS. You don’t have to understand how KMS works.<p>Paragraphs like this come across quite condescending, and the tone might have more to do with the lack of adoption of the ideas herein than the content does.<p>Security Professionals seem to have an unfortunate habit of talking down to everybody else.
评论 #16749249 未加载
评论 #16750832 未加载
ryan-cabout 7 years ago
Can we get work factor&#x2F;parameter recommendations for scrypt, pbkdf2, bcrypt and argon2?
jamesdsadlerabout 7 years ago
Can anyone recommend some good cryptography books&#x2F;links for someone that would like get up to speed on best practices for building secure systems? Ideally the full gamut of beginner to advanced.<p>What are the classic&#x2F;authoritative texts in this space?
评论 #16752822 未加载
Xeoncrossabout 7 years ago
&gt; Encrypting Data Percival, 2009: AES-CTR with HMAC.<p>I just found that AES-CTR + HMAC is very simple and doable in in languages like Go and Javascript for large objects which can&#x27;t (or shouldn&#x27;t) all be put into memory at the same time. In fact, a popular google drive client uses this: <a href="https:&#x2F;&#x2F;github.com&#x2F;odeke-em&#x2F;drive&#x2F;wiki&#x2F;End-to-End-Encryption" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;odeke-em&#x2F;drive&#x2F;wiki&#x2F;End-to-End-Encryption</a><p>(assuming standard secure key generation for both the AES-CTR stream and the HMAC - along with a unique IV)<p>However, reading this article it seems this might no longer be recommended.
评论 #16749831 未加载
评论 #16749582 未加载
vandotabout 7 years ago
&gt; If you can pay AWS not to care about this problem, we recommend you do that.<p>True for so many things.
raesene9about 7 years ago
Good stuff! One minor nit suggested by someone far smarter than myself is that &quot;it is incorrect to describe the polynomial evaluation MACs like Poly1305 and GHASH as ‘cryptographic CRC’. There _are_ cryptographic CRC-like MACs, but nobody uses them because they&#x27;re more of a pain than polynomial evaluation.&quot;<p>with <a href="https:&#x2F;&#x2F;crypto.stackexchange.com&#x2F;questions&#x2F;56448&#x2F;can-keyed-crc-be-used-as-a-mac&#x2F;56450#56450" rel="nofollow">https:&#x2F;&#x2F;crypto.stackexchange.com&#x2F;questions&#x2F;56448&#x2F;can-keyed-c...</a> as a reference :)
exabrialabout 7 years ago
Can you expand on the DSA&#x2F;ECDSA problems? One this I greatly dislike is having &quot;only one option&quot; of RSA. In my opinion, it&#x27;s better to have a variety of secure algorithms available and that are well studied, so if a new attack emerges we&#x27;re not completely hosed.<p>Also, while I don&#x27;t believe NIST is a mouthpiece for the NSA, I&#x27;m curious why they haven&#x27;t proposed some alternatives to P-256, given some of the difficultly implementing it correctly. Is anyone aware if they are working on this?
评论 #16755935 未加载
RcouF1uZ4gsCabout 7 years ago
&gt;Client-server application security &gt;Percival, 2009: Use OpenSSL.<p>Percival actually recommended not using SSL and shipping the server public key with the client.<p>From <a href="http:&#x2F;&#x2F;www.daemonology.net&#x2F;blog&#x2F;2009-06-11-cryptographic-right-answers.html" rel="nofollow">http:&#x2F;&#x2F;www.daemonology.net&#x2F;blog&#x2F;2009-06-11-cryptographic-rig...</a><p>&gt;Client-server application security: Distribute the server&#x27;s public RSA key with the client code, and do not use SSL.<p>What are your thoughts on that approach today.
评论 #16748806 未加载
评论 #16748666 未加载
technionabout 7 years ago
Where might people see the path forward as far as adoption of some of these &quot;right&quot; solutions in the larger side of the enterprise?<p>In September 2017 I had an executive pay Gartner a lot of money for a report on encryption and the result was I was directed to use Blowfish. This is obviously a ridiculous example but it&#x27;s nigh impossible to get libsodium past a marketing team because they want to hear the letters &quot;AES&quot;.
chmeabout 7 years ago
Why is this page not available over https? A bit ironic that we have to trust the connection between us and the server to get advice about security.
评论 #16756295 未加载
rphlxabout 7 years ago
&gt; Avoid: the OpenSSL RNG<p>Is that just historical - i.e. a tiny chance somebody is still using the broken Debian version from a decade ago - or is there actually something still insecure, or at least suspicious, even in 1.1.0+?<p>I ask only because getentropy() is not widely available in the Linux world yet, and getrandom() - and direct use of the &#x2F;dev files - do have some caveats of their own.
broheeabout 7 years ago
A bit tired with &quot;Just use HMAC&quot;. HMAC makes you pull a hash dependency, which is not much if you do software, but can be a waste of silicon if all you want is a MAC. If you already spent real estate on AES, then CMAC becomes a lot more attractive...<p>This is the reasons it&#x27;s at the core of SCP03, the smartcard world is very sensitive to transistor count...
评论 #16751415 未加载
评论 #16749960 未加载
charonn0about 7 years ago
&gt; Avoid: designing your own encrypted transport, which is a genuinely hard engineering problem; using TLS but in a default configuration, like, with “curl”; using “curl”, IPSEC.<p>I&#x27;m not sure what they&#x27;re saying here. Is there a problem with the way curl handles TLS?
exabrialabout 7 years ago
Also, any opinion on the Million Dollar Curve? <a href="https:&#x2F;&#x2F;cryptoexperts.github.io&#x2F;million-dollar-curve" rel="nofollow">https:&#x2F;&#x2F;cryptoexperts.github.io&#x2F;million-dollar-curve</a>
评论 #16756335 未加载
deeglesabout 7 years ago
Why is it better to use 256-bit IDs vs 128-bit IDs? I thought UUIDs were fine?
评论 #16749277 未加载
sametmaxabout 7 years ago
Can someone explain to a layman why you need to avoid RSA ? Is this only for the particular use case the article talks about or you should avoid it for other things, like encrypting a hard drive?
评论 #16755655 未加载
politipsabout 7 years ago
pgsodium is a postgres extension that adds libsodium integration to postgres, it exposes many of functions for patterns mentioned in the article, including box&#x2F;secretbox, hashing, password handling, asymmetric keys, diffie-hellman, etc.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;michelp&#x2F;pgsodium" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;michelp&#x2F;pgsodium</a>
Spooky23about 7 years ago
Any suggestions as far as the “most right” answers for those of us stuck with FIPS 140-2 due to upstream compliance requirements?
评论 #16750736 未加载
jedisct1about 7 years ago
I wish XChaChaPoly was more widely implemented.
评论 #16749049 未加载
loegabout 7 years ago
Two nits:<p>&gt; Don’t built elaborate password-hash-agility schemes.<p>build*<p>And what&#x27;s the asterisk on<p>&gt; Avoid: … IPSEC.*<p>?
评论 #16749799 未加载
abhishekjhaabout 7 years ago
Can somebody explain in layman terms what this article is about?<p>A few references would help.
zallarakabout 7 years ago
<i>Missing</i><p>1. Content security policy headers for web<p>2. &quot;strict&quot; Samesite cookie flags for CSRF and authentication tokens<p><i>Difference of opinion</i><p>Didn&#x27;t argon2 win the last password hashing competition?
评论 #16750747 未加载