Live data from Hacker News

TinySSH is a small SSH server using NaCl, TweetNaCl

tinyssh.org

41–50 of 64 posts

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

#41
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).

To be fair, OpenSSH's sshd doesn't have support for scp either. scp invokes ssh to connect to the target host and launches another scp instance there to talk to. There's no reason that wouldn't work with TinySSH too.

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

#42
post #32
post #3

Is TweetNaCl deliberately 32-bit or LLP64 only? One of the first lines is typedef unsigned long u32; but on 64-bit LP64 systems (like Linux), long is 64-bits. See http://tweetnacl.cr.yp.to/20140427/tweetnacl.c

They seem to mask u32 values just fine everywhere, so u32 being larger than it has to is no problem. ulong is as you know the smallest type that's always guaranteed to be at least 32 bits.

No it isn't. The only guarantees you have about the size of long are that it is at least as large as (greater than or equal) a normal int. And a normal int is greater than or equal as big as a short.

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

#43
post #3

Is TweetNaCl deliberately 32-bit or LLP64 only? One of the first lines is typedef unsigned long u32; but on 64-bit LP64 systems (like Linux), long is 64-bits. See http://tweetnacl.cr.yp.to/20140427/tweetnacl.c

The name is a little confusing. The way u32 is used in TweetNaCl, it doesn't have to be exactly 32 bits, only at least 32 bits.

typedef uint_least32_t u32;

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

#44
post #42
post #32

Earlier quoted context omitted.

They seem to mask u32 values just fine everywhere, so u32 being larger than it has to is no problem. ulong is as you know the smallest type that's always guaranteed to be at least 32 bits.

No it isn't. The only guarantees you have about the size of long are that it is at least as large as (greater than or equal) a normal int. And a normal int is greater than or equal as big as a short.

C99 standard [1], §5.2.4.2.1 says otherwise. Int must acommodate at least 16 bits, long 32 bits, and long long 64 bits. C89 [2], §2.2.4.2 says the same thing but omits long long, so tweetnacl's u64 may not exist (this was the case with MSVC not too long ago).

Additionally, char is required to be at least 8 bits by the C standard, but tweetnacl assumes exactly 8. Some oddball architectures have larger character types, but POSIX mandates 8.

[1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

[2] http://nepsweb.co.uk/langstand/isoC/gordon/ansi-c89w.txt

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

#45
post #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…

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

An awakening!

Is it really so terrible to have things compile quickly and without the usual ./configure nonsense? It seems there are an infinite number of ways an author can organise her project using ./configure; for every one I have to spend time figuring out what they have done.

One of my favourite aspects of djb's build approach (which is what is being used here) is that it's easier (than with the popular build systems) to change compiler and linker options and make static binaries: in most cases, simple edit the conf-* files. Thankfully, authors who use djb's approach usually do not vary much from the model. This means less time spent figuring out how things are organised.

I like (portable) open source software that compiles quickly and cleanly.

djb has continued to deliver on this point.

Nice to see someone discovering this build system for the first time.

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

#46

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

There is nothing particularly unauditable about that style.

To me, more code that you can get on a single screen/buffer, the better. My complaint is more about putting braces on a separate line all by themselves.

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

#47
post #44
post #42

Earlier quoted context omitted.

No it isn't. The only guarantees you have about the size of long are that it is at least as large as (greater than or equal) a normal int. And a normal int is greater than or equal as big as a short.

C99 standard [1], §5.2.4.2.1 says otherwise. Int must acommodate at least 16 bits, long 32 bits, and long long 64 bits. C89 [2], §2.2.4.2 says the same thing but omits long long, so tweetnacl's u64 may not exist (this was the case with MSVC not too long ago). Additionally, char is required to be at least 8 bits by the C standard, but tweetnacl assumes exactly 8. Some oddball architectures have larger character types,…

This code is attempting to be portable to C89, or why not just use C99's stdint.h? I don't believe your statement "C89 says the same thing," do you have a source to point to?

Do you have the section number in the latest freely available C99 working draft? The "Types" section (which 6.something in the draft) simply says what I said earlier about scalar rank. And 5.4.4.2.1 doesn't seem to exist in the draft.

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

#48
post #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. Th…

You may actually be underselling djb: He both knows how to write quality software, and is arguably the most productive cryptographer around.

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

#49
post #47
post #44

Earlier quoted context omitted.

C99 standard [1], §5.2.4.2.1 says otherwise. Int must acommodate at least 16 bits, long 32 bits, and long long 64 bits. C89 [2], §2.2.4.2 says the same thing but omits long long, so tweetnacl's u64 may not exist (this was the case with MSVC not too long ago). Additionally, char is required to be at least 8 bits by the C standard, but tweetnacl assumes exactly 8. Some oddball architectures have larger character types,…

This code is attempting to be portable to C89, or why not just use C99's stdint.h? I don't believe your statement "C89 says the same thing," do you have a source to point to? Do you have the section number in the latest freely available C99 working draft? The "Types" section (which 6.something in the draft) simply says what I said earlier about scalar rank. And 5.4.4.2.1 doesn't seem to exist in the draft.

Sorry, I mistyped the section number. Updated the parent comment with corrections and links.

I assume the intent of tweetnacl is to be C89-compatible, but due to the long long (and char, although that one's pretty pedantic) issue there's little guarantee of success.

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

#50
post #45
post #27

Earlier quoted context omitted.

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…

"You (presumably) and I have beaten ourselves into submission to the Linux style; the authors' haven't." An awakening! Is it really so terrible to have things compile quickly and without the usual ./configure nonsense? It seems there are an infinite number of ways an author can organise her project using ./configure; for every one I have to spend time figuring out what they have done. One of my favourite aspects of d…

I'm just curious, where does the parent post mention anything about the build system? The "Linux style" referred to there seems to be the Linux code style, not "configure".
Post reply on HN