0
$\begingroup$

Consider this question:

https://stackoverflow.com/questions/56186844/generating-hchacha20-internal-state-with-existant-chacha20-implementation

How is that question off topic when reusing blowfish algorithm to implement bcrypt isn't? Does the fact that I include code samples mean it's automatically off topic?

Migrating crypto questions like that to stackoverflow is basically a death knell for those questions. The question is about how to make an existant ChaCha20 implementation give the same result as HChaCha20. There's a chacha tag on crypto.stackexchange.com - there isn't one on stackoverflow.com. There's an openssl tag, sure, but just because you know how to use openssl doesn't mean you know anything about the internal structure of ChaCha20 vs HChaCha20.

More than that, the problem is one that should be duplicatable in any language. That I posted my code samples in PHP is irrelevant because the question is language agnostic. Would the question have been on-topic if I had posted the same code in 10 different languages to prove how language agnostic the question is? And if the question is, ultimately, language agnostic, I contend that that is further evidence that the question is on topic here and off topic on stackoverflow.

And not only do I contend it's language agnostic - I also contend that it's library agnostic - that this "issue" is duplicatable in any ChaCha20 implementation, be it OpenSSL's, libsodium's, BouncyCastle's, etc.

Of course there are certain practical considerations when posting code samples in 10 different languages using ten different libraries. ie. the longer the question the less likely people are to read it. Posting a question is a delicate balance of making it succinct enough so that people read it yet detailed enough so people actually understand what you're talking about.

I suppose I could have omitted code samples all together but tbh I think that would have made for a question that would have been nigh impossible to understand. Maybe if I'm only going to post code samples in one language PHP isn't the best language to be posting them in. Python is taken more seriously in the crypto community than PHP (as evidenced by the fact that the code samples in the Ed25519 RFC are in Python) but, sadly, I know PHP better than I do Python. And tbh dismissing PHP on the basis that it's PHP is just prejudice on everyone's part.

Consider https://stackoverflow.com/q/32161720/569976 . That's a crypto question that's on stackoverflow but that question belongs there because it is not language agnostic. The question I posted - that I contend was naively migrated - is language agnostic.

Another example that crypto related questions / answers receive far less attention on stackoverflow than crypto.stackexchange.com: https://crypto.stackexchange.com/a/21104/4520 vs https://stackoverflow.com/a/21289989/569976 . The former quotes the latter. It links directly to the latter. The latter was posted before the former. And yet the former has 34 upvotes whereas the latter has 4. Language agnostic crypto questions on stackoverflow do not at all receive attention like they do here and if y'all are going to migrate language agnostic crypto questions to stackoverflow then y'all might as well just close them all together because, barring a bounty, migrating them to stackoverflow is a death knell.

$\endgroup$
4
$\begingroup$

We should make an effort to isolate a cryptography question from a coding question if it's unclear, before we irreversibly migrate the question to a forum that is ill-suited to answering cryptography questions.

The question generating HChaCha20 internal state with existant ChaCha20 implementation is a little long-winded and involves a good deal of PHP code to translate between different formats of data and the awful OpenSSL API to do cryptographic operations, but it seems to me there are two questions buried in here:

  1. What is the relation of HChaCha, as specified in draft-arciszewski-xchacha-03, to ChaCha, as widely used on the internet for the past decade?
  2. How do I use the OpenSSL API as exposed in PHP to generate the test vectors, and why doesn't this code I already wrote work to do it?

I don't think anyone would dispute that question (1) is on-topic here. However, the question as written appears to be mainly question (2). I think we should have made more of an effort to isolate question (1) instead of asking stackoverflow.com to explain how HChaCha and ChaCha are related (and, perhaps, why)—which is a common question, essentially answered only deep inside the XSalsa20 paper in a security theorem that is a little obscure if you're not familiar with what's going on, and which is unlikely to be answered adequately on stackoverflow.com.

$\endgroup$
  • $\begingroup$ I disagree with #2. As my orig post stated, I'm 95% confident the issue is present with any ChaCha20 implementation where the counter can be set. ie. I'm 95% confident the "issue" is language agnostic. In other words, I should be able to do the same thing in PHP, Python, Ruby, node.js, Java, C++, etc. Do I need to post code samples in every language under the sun to demonstrate that it's language agnostic? And working under the assumption that it's language agnostic then it seems to me that the crypto SE is the appropriate place to post the question. $\endgroup$ – neubert May 17 at 19:45
  • 2
    $\begingroup$ @neubert What I'm saying is that someone reading your post could interpret it as (1) or (2), and I think we should make an effort to clarify the (1) question before deciding it is a (2) question and migrating it irreversibly to stackoverflow as a moderator apparently did. Personally I think executable code can be an excellent way to illustrate a computational idea, but there was also a lot of code not related to ChaCha or HChaCha there but rather string parsing and regular expressions which obscured the question about ChaCha and HChaCha. $\endgroup$ – Squeamish Ossifrage May 17 at 21:31
  • $\begingroup$ The additional code was to make it so that the formatting matched the formatting in the RFC. ie. four lines with each line containing four blocks of eight hex characters. It's hard to see whether or not the outputs match what's in the RFC (or IETF draft) at a glance without that formatting. $\endgroup$ – neubert May 18 at 1:11
3
$\begingroup$

About this particular question

The code you published is an attempt to replicate test vectors, and failing. Most likely this is because of an implementation mistake or a error in trying to convert the algorithm to code. To read the question you need to be able to parse the code, so I do not agree that this is only a code sample to show the problem.

About your reasons

Migrating crypto questions like that to stackoverflow is basically a death knell for those questions.

Yes, this is a problem of StackOverflow although many good questions do get the required attention (even if they are not necessarily answered). However, that doesn't mean that those questions suddenly become on topic on crypto.

I'm not sure that it isn't a problem on crypto as well though - you need a pretty deep understanding of both algorithms to answer your question.

Note that migrated questions still leave a ghost, and that you may always try and get attention in the side channel (something I do with some regularity).

More than that, the problem is one that should be duplicatable in any language.

This doesn't mean that this isn't about implementation. Most crypto implementation issues on StackOverflow can be replicated in any language, just because the techniques are all language agnostic.

I suppose I could have omitted code samples all together but tbh I think that would have made for a question that would have been nigh impossible to understand.

It should be possible to understand the question without intricate understanding of the programming language, in my opinion. Personally I'm not convinced that this is the case here.

About indicating other questions

It will always be possible to point out Q's that are questionably on-topic or not. However, that's no reason for other questions to be allowed, it is rather a good reason to take another look at the other questions.

And yes, there are a lot of off-topic questions on SE sites, if just because they become off-topic when other sites are introduced or shift focus.

$\endgroup$
  • $\begingroup$ "a error in trying to understand the algorithm" That would make the crypto SE the best place for the question, would it not? $\endgroup$ – neubert May 17 at 17:07
  • $\begingroup$ I agree that was probably not the best sentence. But I'll adjust it to show what I meant. $\endgroup$ – Maarten - reinstate Monica May 17 at 23:06
2
$\begingroup$

I'm 95% confident the issue is present with any ChaCha20 implementation where the counter can be set. ie. I'm 95% confident the "issue" is language agnostic. In other words, I should be able to do the same thing in PHP, Python, Ruby, node.js, Java, C++, etc...

Sure, we can concede that (some) bugs are language agnostic and could happen in any programming language. A failing unit test is certainly language agnostic. It's even subject agnostic - any kind of program in any language can have a failing unit test.

But that doesn't change the fact that bugs and failing unit tests are programming problems.

A failing unit test is not really an issue with or discussion about (X)ChaCha itself. (Other than perhaps poor documentation, not to say that is necessarily the case here)

Questions about:

  • how much data can you encrypt with (X)ChaCha under a given key
  • why was (X)ChaCha designed in such and such a way
  • what is the security contract provided by (X)ChaCha
  • etc

These are the types of questions that are certainly appropriate for our site. They are questions about the abstract algorithm itself, rather than a specific implementation of it.

These questions are independent of the very existence of programming languages. These questions could be asked even if programming languages did not exist.*.

This is not the same thing as language agnostic.

this "issue" is duplicatable in any ChaCha20 implementation

"implementation" is the key word here. We are basically a mathematics site.

Sure, programming uses mathematics, and a program could even be exclusively about math (e.g. a library for linear algebra).

But that doesn't make bugs in a linear algebra program on-topic for mathoverflow. The same applies to a bug in a ChaCha implementation**.

* It would be a bit silly to design algorithms in a world where you cannot realistically use them, but that is beside the point

** If that bug is an exploitable vulnerability in a widely used library, than things change a little. But that is not the case here. Even then, such discussions are arguably more on-topic for security stackexchange

Aside

I agree with Squeamish Ossifrage that we should make an effort to salvage questions before migration, if possible. If there is a question about (X)ChaCha itself, then an attempt should have been made to separate it from the coding aspect of the question. I suspect they would have happily answered that question for you.

Otherwise, I also agree with Maarten's answer.

If you find inappropriate programming questions on crypto.se, then flag them for migration. If they are too old, then there's nothing anyone can do about it. That doesn't make them appropriate for our site. But it does mean we're stuck with them anyways.

Find a way to ask it without code

Having one question migrated doesn't mean you can never ask any more questions. If you can find a way to ask the question that doesn't involve code and failing unit tests, then feel free to ask it.

Needless to say, but: please do not re-post the exact same question with a slightly modified body and php code.

If in doubt, then ask for advice on how to phrase it in The Side Channel.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .