Better HN
topnewbestaskshowjobs
Log inSign up

CiPHPerCoder

6,663 karma · joined Feb 25, 2016 (10y ago) · 1,775 submissions

My name is Scott. I do a lot of open source security research, and cryptography.

Previously AWS Cryptography (2019 - 2023).

Unless otherwise stated, my opinions are my own and do not reflect my employer.

https://scottarc.blog/about/

Submissions

comment 7y ago · link · parent

S2V for XChaCha20-Poly1305 has actually been discussed on the CFRG mailing list (and a little bit off-list between myself and others interested in this topic). The only question that hasn't been addressed at the time of the last email was, where does it fit?

XChaCha20 uses HChaCha20 to derive a 256-bit subkey between the 256-bit key and first 128 bits of the nonce. Then it uses ChaCha20 with the subkey and the remaining 64 bits of the nonce. ChaCha20 has an internal counter that goes between 0 and 2^64 - 1.

AEAD_XChaCha20_Poly1305 uses the first 32 bytes of the XChaCha20 keystream to determine the Poly1305 key for that message, then begins the encryption starting at the next block. (The remaining 32 bytes of block_counter = 0 are discarded in XChaCha20, but not in XSalsa20; this is a subtle difference that probably only makes streaming APIs easier to design and has no significant security considerations.)

With that in mind: XChaCha20 is already deriving a key from the key and (extended) nonce. And it already has an internal block counter (which side-steps counter/nonce wrapping issue that was addressed with AES-CTR in the AES-GCM-SIV design).

The simplest solution is to, instead of just trusting your CSPRNG, do this:

  function crypto_aead_xchacha20poly1305siv_encrypt(msg, key) {
    let nonce = Buffer.alloc(24);
    sodium.randombytes_buf(nonce);
    
    // Synthetic nonce here:
    s2v(nonce, msg);

    let cipher = Buffer.alloc(msg.length + 16);
    sodium.crypt_aead_xchacha20poly1305_ietf_encrypt(cipher, msg, nonce, key);
    return [nonce, cipher];
  }
But this would be, strictly speaking, indistinguishable from XChaCha20-Poly1305 without SIV.

For context: I authored the XChaCha20 RFC draft, implemented it in pure-PHP (twice; the second time was to support 32-bit systems).

comment 7y ago · link · parent

Death, sickness, and financial windfalls each bring out the worst in most of us.

Don't take it personally, the failure here isn't yours.

comment 7y ago · link · parent

> Who are these people? I never know this dark side of humanity exist and it horrifies me.

Here you go: https://nymag.com/intelligencer/2016/07/kiwi-farms-the-webs-...

They're terrible people who largely manage to avoid doing illegal (merely unethical) things as a hobby.

comment 7y ago · link · parent

> Well, I asked the question, and I consider his response an answer.

It's non sequitur at best, but technically an answer, sure.

I'm more interested in something tangible and (hopefully) universifiable than "delete Facebook".

comment 7y ago · link · parent

If Facebook was Thanos snapped out of existence right now, the overarching problem would still exist. It's not constrained to the borders of a single Mountain View, CA company.

How would you address the problem itself, rather than a single instance of it?

comment 7y ago · link · parent

"Not using Facebook" doesn't solve address the problem which exists outside of Facebook, so no, it wasn't answered.

comment 7y ago · link · parent

It was promptly shared on horrible sites like 8chan and KiwiFarms, and then a Torrent was shared to alleviate the bandwidth pressure on those websites.

It was in full force before I even heard about the shooting.

comment 7y ago · link · parent

So... you propose nothing, then?

Or at least, you didn't really answer the question that was asked.

What would you suggest as a solution to the problems stated? These problems are larger than just Facebook.

comment 7y ago · link · parent

AES-CBC-HMAC-SHA2-ETM is fine as a last resort, assuming you have a secure compare function and a CSPRNG so your IVs never repeat for a given key and are unpredictable.

TLS's AES-CBC is MTE not ETM, and that distinction matters [1]. You shouldn't use CBC mode in SSL/TLS. (You also shouldn't be supporting SSL; only TLS.)

But an application-layer AE construction [2] as described in the article is fine.

[1] https://moxie.org/blog/the-cryptographic-doom-principle

[2] https://github.com/defuse/php-encryption/blob/b87737b2eec06b...

comment 7y ago · link · parent

What the NSA appears to recommend or not doesn't cause me any significant concern.

This could happen if they're relaxing their recommendations to double down on post-quantum cryptography.

This could happen if they had a mathematical breakthrough that invalidated all ECDLP security estimates.

I'll never know which it is. The pragmatic thing is to research PQCrypto and make sure the next generation of asymmetric primitives are as good as they can be.

comment 7y ago · link · parent

Hmm, no, I can't.

This was something I had observed in practice over the years (i.e. several orders of magnitude performance difference between AES-128 and AES-256 from my PHP implementations), and "your CPU only supports AES-NI for 128-bit keys" was the explanation I was given at the time. I haven't observed this recently, and I'm on newer hardware, so the explanation made sense.

In attempting to identify which CPUs were affected by this limitation, I've discovered that I was grossly misinformed about this. I'm going to update the article to redact this, ASAP.

UPDATE: Redaction applied.

comment 7y ago · link · parent

> The problem I have with this kind of thing is that if you can get away with the idiosyncratic recommendations (XChaCha, GCM-SIV), you're not interoperating, and so you can almost by definition just use libsodium box and secret-box.

I absolutely am in favor of just using libsodium box/secretbox instead of having to understand this sort of nuance.

> Who is a laddered recommendation of different signing algorithms really helping?

People who ask me nitpicky questions about whether or not they should opt for 3072-bit RSA keys instead of 2048-bit RSA keys. The main purpose of the post was the first half (the "it doesn't matter" point).

comment 7y ago · link · parent

> For instance, most CPUs nowadays support 256-bit AES without resorting to bitslicing.

If you have the advantage of only working with newer hardware, this is true. But it's not immediately obvious whether or not your CPU supports 256-bit AES-NI without e.g. benchmarking OpenSSL.

The point isn't "AES-256 almost never supports AES-NI" (although that used to be true). It's that naively saying "biggest rock is best rock" doesn't always hold true.

> If you have to use RSA for some reason is there any scenario where you wouldn't also want 4096-bit keys?

You're sacrificing performance for a hypothetical security gain that probably won't matter. If 2048-bit RSA gets implicated by some new attack, it's more likely that 256-bit ECC will save you than 4096-bit RSA.

> https://latacora.micro.blog/2018/04/03/cryptographic-right-a... is an alternate, arguably better, source of information.

When people are asking for a guide on Cryptographic Right Answers, I always point people to that page.

The questions I wanted to address are about key size. And the point I wanted to stress was, "There are usually other factors that are far more important to consider than just the size of the key."

If I see a system that uses RSA to encrypt, I care more about it not using textbook RSA or poorly-implemented PKCS#1v1.5 padding than I do about 2048-bit vs 4096-bit keys.

comment 7y ago · link · parent

There's no contradiction.

It doesn't really matter which you use under most threat models.

AES-128 gets you guaranteed AES-NI on virtually all processors sold in the past decade. AES-256 gets you better assurance against quantum attackers, should they ever become a real threat.

You can side-step both of these by just using a ChaPoly ciphersuite which is constant-time and fast on all platforms, without hardware acceleration. (If you ecide to just use libsodium's box/secretbox, as Thomas said in another comment, you're doing this side-step... which is thematically appropriate for a cipher named after a Latin dance).

495.

2019 Guide to Cryptographic Key Sizes and Algorithm Recommendations(paragonie.com ↗)

126 points · by CiPHPerCoder · 7y ago · 19 comments

comment 7y ago · link · parent

> True, but I feel I would still feel shame

Please keep your shame to yourself. Your other comments in this thread sound like you're trying to invoke your shame upon others for declaring bankruptcy.

If your intention was consistently "I would still feel shame" rather than "You should feel shame", that's fine, but please make that clearer.

comment 7y ago · link · parent

How do you plan to accommodate NoScript users?

comment 7y ago · link · parent

> I'm still not entirely sure why Apple cares about porn

FOSTA and SESTA.

comment 7y ago · link · parent

> In the Metro Atlanta area that almost universally means a solo person with the possible unstated thought that he/she is living off his/her spouses income.

In the rest of the business world, consultant means "freelancer, but professional".

If you choose to let the local stereotypes hold you back in life, then you won't succeed. End of.

500.

Searchable Encryption Doesn't Have to Be Bitter(paragonie.com ↗)

1 points · by CiPHPerCoder · 7y ago · discuss

comment 7y ago · link · parent

I often quote Avi Douglen here:

"Security at the expense of usability, comes at the expense of security."

Misuse-resistant cryptography API design is a particular hobby horse of mine. (My other hobby horse is software update security.)

A lot of the arguments in favor of cipher agility (a.k.a. runtime negotiation and risk of downgrade attacks) come from well-intended people who haven't internalized the past few decades of real world cryptographic failures.

I liken it to building a brick wall that's expected to hold up a roof.

Would you rather have a wall made by carefully placing bricks and mortar in place once, and if need be, rebuild the brick wall later with better materials?

Or would a lattice of mortar that lets you hot-swap bricks as needed be a preferable design?

The first one is versioned protocols. The latter is what keeps people typing AES into their code.

502.

Searchable Encryption Doesn't Have to Be Bitter(paragonie.com ↗)

2 points · by CiPHPerCoder · 7y ago · discuss

503.

CipherSweet: Searchable Encryption Doesn't Have to Be Bitter(paragonie.com ↗)

2 points · by CiPHPerCoder · 7y ago · discuss

504.

PHP Security in 2019(paragonie.com ↗)

3 points · by CiPHPerCoder · 7y ago · discuss

505.

PHP Security Roadmap for the Year 2019(paragonie.com ↗)

1 points · by CiPHPerCoder · 7y ago · discuss

comment 7y ago · link · parent

https://en.wikipedia.org/wiki/Gell-Mann_amnesia_effect

comment 7y ago · link · parent

> I mean, your homepage is pretty damn lacking

Do you honestly believe cybersecurity decisions should come down to how snazzy a homepage is, rather than a company's reputation?

> and you even put something like this without putting any sources

That article being discussed in this thread in particular quotes:

1. The opinions of other security experts

2. RFC 7515, section 4.1.1

3. The auth0 article about RS256/HS256 confusion

4. RFC 7518

5. The Adobe attack on ECDH-ES

What additional kind of sources do you need? The arguments should be sufficiently supported by the material available.

> This just looks like a poor attempt at making something 'better'.

By what metrics could we make this attempt less "poor"? What specific changes do you need to see?

508.

PHP Security Roadmap for the Year 2019(paragonie.com ↗)

3 points · by CiPHPerCoder · 7y ago · discuss

comment 7y ago · link · parent

You might be happy to see the PASETO spec, which (for v2) uses XChaCha20-Poly1305 for encryption, Ed25519 for signatures, separates the two logically, and doesn't allow for runtime ciphersuite negotiation. (v1 achieves a similar result with AES-CTR+HMAC-SHA384-EtM and RSASSA-PSS.)

https://github.com/paragonie/paseto/tree/master/docs/01-Prot...

It's similar to the advice given above, but also caters to that itch that some project managers have to only implement industry standards (which PASETO is slowly becoming).

comment 7y ago · link · parent

> Comes from a PHP consulting firm, promoting their own alternative proposal (which hardly anyone else seems to discuss or use). So I think #1 above is really about drawing eyeballs and selling services, more so than providing clear information for a newcomer to follow.

There was a recent (November 2018) talk at London Gophers about JWT Alternatives (slides here: https://speakerdeck.com/hako/exploring-alternatives-to-json-...).

Keep in mind that PASETO didn't exist until the middle of 2018, so the main reason "hardly anyone else" seems to use it is precisely because it takes time for standards to be adopted.

If you take a look at https://paseto.io, you'll see that there are implementations of PASETO (our proposed alternative) in multiple programming languages by other companies and individuals. All of these implementations are open source and under very permissive licenses (MIT or ISC).

Additionally, a great deal of time and effort went into the PASETO documentation, so that developers can understand not only how to implement it themselves, but also why it was designed the way it is. https://github.com/paragonie/paseto/tree/master/docs

Given all of the above, is it really fair to write PASETO off as an attempt to sell services?

Claiming that the original article is meant to sell services doesn't make sense either: If developers keep using unsafe tools, they will continue to be less secure and I'll have an easier time selling "make your products/services more secure" services to developers. The best thing to do, to meet such an incentive, is to say nothing publicly and let the easy money keep rolling in.

So one of two things is happening:

1. You don't correctly understand our intentions.

2. We're really bad at understanding our own incentives, and it's a miracle we've been in business for 4 years.

1
161718
60