Live data from Hacker News

TinySSH is a small SSH server using NaCl, TweetNaCl

tinyssh.org

21–30 of 64 posts

Re: TinySSH is a small SSH server using NaCl, TweetNaCl

#21

How is code like below "easily auditable"? keydir = *++argv; if (!keydir) die_usage(); or if (*x == 'v') { if (flagverbose >= 2) flagverbose = 3; else flagverbose = 2; continue; } why put multiple statements on the same line if you have nothing to hide?[1] [1] https://www.kernel.org/doc/Documentation/CodingStyle

[deleted]

Re: TinySSH is a small SSH server using NaCl, TweetNaCl

#22
post #13
post #6

Earlier quoted context omitted.

Yes, TweetNaCl is. TweetNaCl's goal is to be auditable, not to be portable. On the other hand, TinySSH actually includes a configuration mechanism to detect integer sizes, and modifies TweetNaCl accordingly, so TinySSH is not 32-bit/LLP64 only.

I wonder why not just use stdint.h, it's got what you need. ..

[deleted]

Re: TinySSH is a small SSH server using NaCl, TweetNaCl

#23
post #19

What use is an sshd that doesn't support SCP? I think to most people that is a core feature, I'd be surprised if it wasn't a requirement for git for example. It sounds like it's small enough perhaps for a direct port to a safe language like rust, that would be interesting (to me at least).

Use this as a poor man's scp:

tar c path/to/files | ssh host tar x

Re: TinySSH is a small SSH server using NaCl, TweetNaCl

#24
Outstanding! Not only are the slightly mysterious authors of this project not inventing their own crypto, they rely on djb's[0] much acclaimed NaCL/TweetNaCl. The codebase is accordingly small:

  $ wc -l source/*/*c | tail -n1
   11308 total
  $ wc -l source/crypto/*c | tail -n1
   1293 total
The first line suggests a measure of total code ballast, whereas the second incantation might hint at the amount of core crypto code. The latter might be a good starting point for any auditing endeavours.

Incidentally, I am impressed by the spirit of organisation that the source tree permeates. Both crypto/ and tinyssh/ source trees sport corresponding -test directories and a debian/ tree has already been added.

Initially, I felt irritation by the consistent lack of documentation (no README, no AUTHORS, almost no comments, it seems). Browsing the source, however, I grow convinced that this from a conviction that out-dated or redundant documentation is the greater evil.

[0] Daniel J Bernstein - author of qmail, daemontools and long-time promoter of full disclosure. https://en.wikipedia.org/wiki/Daniel_J._Bernstein

Re: TinySSH is a small SSH server using NaCl, TweetNaCl

#25
post #22
post #13

Earlier quoted context omitted.

I wonder why not just use stdint.h, it's got what you need. ..

[deleted]

Yes, I did see that post. The multiple statements per line thing is really fishy for a security critical piece of infrastructure.

Re: TinySSH is a small SSH server using NaCl, TweetNaCl

#26
post #15
post #8

I find use of TweetNaCl curious. For curve25519, why wouldn't one use http://code.google.com/p/curve25519-donna/ instead? djb's cryptography is great, but djb's implementations leave something to be desired.

The usual problem with DJB's implementations is not that they're incorrect or slow or insecure -- far from it! -- but that they're awkward to integrate with the rest of the world, may require weird build configurations, and are hard for anybody else to modify. Well, TweetNaCl is really easy to integrate with the rest of the world, since it's just a single portable .c file, and the speed is surprisingly good, and its…

I see 3 alternatives: use the original NaCl, use the unofficial fork libsodium, or use TweetNaCl. The latter shares the same authors as the original NaCl, with the advantage of being much smaller.

I don't like the fact that TinySSH modified TweetNaCl, and added back MD5:

  /*
  Based on tweetnacl 20140427 (http://tweetnacl.cr.yp.to   software.html)
  - updated int/uint types to crypto_int/crypto_uint
  - added crypto_stream_chacha20
  - added crypto_hash_sha256
  - added crypto_hash_md5
  */
I mean they use TweetNaCl because it has "state-of-the-art crypto", but then they add back MD5. Something is wrong here ...

Re: TinySSH is a small SSH server using NaCl, TweetNaCl

#27

How is code like below "easily auditable"? keydir = *++argv; if (!keydir) die_usage(); or if (*x == 'v') { if (flagverbose >= 2) flagverbose = 3; else flagverbose = 2; continue; } why put multiple statements on the same line if you have nothing to hide?[1] [1] https://www.kernel.org/doc/Documentation/CodingStyle

The answer seems to me quite simple: because they have a different coding style. Just as no one is bound to K&R or the GNU style, nothing suggests that crypto code needs to follow Linux kernel conventions.

Value consistency above everything.

Honestly, I am not convinced that the peculiar if-style isn't actually helping readability and refactoring. Note, that a Apple-style "goto break" bug might be harder to construct, when your one-line if's look like this:

   some_code;
   if (something) die(message);
   other_code;
Now the surrounding indentation does not suggest that there's an extendable block where there in fact isn't, as with Kernel style:

   some_code;
   if (something)
       die(message);
   other_code;
To be perfectly honest, the authors' style reminds me a bit of my younger self's style: keep logically connected pieces of code tightly together.

You (presumably) and I have beaten ourselves into submission to the Linux style; the authors' haven't.

On a side note: your second example even seems to suggest that the authors made some effort at additional readability by refraining from using the ternary operator construct.

Re: TinySSH is a small SSH server using NaCl, TweetNaCl

#28

How is code like below "easily auditable"? keydir = *++argv; if (!keydir) die_usage(); or if (*x == 'v') { if (flagverbose >= 2) flagverbose = 3; else flagverbose = 2; continue; } why put multiple statements on the same line if you have nothing to hide?[1] [1] https://www.kernel.org/doc/Documentation/CodingStyle

> why put multiple statements on the same line if you have nothing to hide?

Because it's more readable.

Do

you

truly

find having

only a few

words per line

more

readable?

Does

it aid

with

comprehension?

I find having a high word density to be the most "readable", and it doesn't seem to matter whether it's C or English.

The TinySSH source code is small enough that I was able to read it in about 25 minutes and I learned about the SSH protocol along the way.

Re: TinySSH is a small SSH server using NaCl, TweetNaCl

#29
post #15

Earlier quoted context omitted.

The usual problem with DJB's implementations is not that they're incorrect or slow or insecure -- far from it! -- but that they're awkward to integrate with the rest of the world, may require weird build configurations, and are hard for anybody else to modify. Well, TweetNaCl is really easy to integrate with the rest of the world, since it's just a single portable .c file, and the speed is surprisingly good, and its…

I see 3 alternatives: use the original NaCl, use the unofficial fork libsodium, or use TweetNaCl. The latter shares the same authors as the original NaCl, with the advantage of being much smaller. I don't like the fact that TinySSH modified TweetNaCl, and added back MD5: /* Based on tweetnacl 20140427 (http://tweetnacl.cr.yp.to software.html) - updated int/uint types to crypto_int/crypto_uint - added crypto_stream_ch…

Not sure why they added that back but the website states that

  no older cryptographic primitives - rsa, dsa, classic diffie-hellman, md5, sha1, 3des, arcfour, ...
It is actually used in the code though. I didn't look into for what it was used though.

Re: TinySSH is a small SSH server using NaCl, TweetNaCl

#30
post #19

What use is an sshd that doesn't support SCP? I think to most people that is a core feature, I'd be surprised if it wasn't a requirement for git for example. It sounds like it's small enough perhaps for a direct port to a safe language like rust, that would be interesting (to me at least).

This should work perfectly well with rsync -e ssh. Which is what you should use anyway.
Post reply on HN