Slashdot Mirror


OpenSSH Has a New Cipher — Chacha20-poly1305 — from D.J. Bernstein

First time accepted submitter ConstantineM writes "Inspired by a recent Google initiative to adopt ChaCha20 and Poly1305 for TLS, OpenSSH developer Damien Miller has added a similar protocol to ssh, chacha20-poly1305@openssh.com, which is based on D. J. Bernstein algorithms that are specifically optimised to provide the highest security at the lowest computational cost, and not require any special hardware at doing so. Some further details are in his blog, and at undeadly. The source code of the protocol is remarkably simple — less than 100 lines of code!"

140 comments

  1. lame name by X0563511 · · Score: 0

    Why would you name an algorithm after what appears to be a support email address?

    --
    For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
    1. Re:lame name by gstoddart · · Score: 1

      Really? I get a dance reference, and a reference to polynomials (Cha-cha/Poly).

      --
      Lost at C:>. Found at C.
    2. Re:lame name by X0563511 · · Score: 1

      I'm talking about "chacha20-poly1305@openssh.com" rather than the chacha20 or poly1305 parts :)

      --
      For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
    3. Re:lame name by Anonymous Coward · · Score: 5, Informative

      SSH extensions are all specified by ASCII names. Standard extensions have names like "shell", "x11", and "port-forward", while vendor-specific extensions use names like "foo@openssh.com" or "bar@putty.org" so there's no naming collision risk.

    4. Re:lame name by Anonymous Coward · · Score: 0

      Because they already HAVE a MAC using an @ symbol so why not a cypher as well?

      umac-64@openssh.com

    5. Re:lame name by Virtucon · · Score: 1

      chacha20 is a variant of Salsa20. There's also XSalsa20 that uses 192 bit IV.

      ChaCha20 is great, I've been using it for the past year and with it being proposed for TLS with the IETF, it's very good for all of us. The world is waking up to the NSA bullshit and we're seeing some of these other standards getting some attention, especially away from anything NIST related or US Government standards related. Salsa20 was submitted and was a finalist in the EU encryption standard. I don't think we'll see the death of AES anytime soon but at least this gives us some alternatives. I'm going to wait for the code to stabilize a bit and start turning it on in my Apache configurations...

      --
      Harrison's Postulate - "For every action there is an equal and opposite criticism"
    6. Re:lame name by X0563511 · · Score: 1

      I'm not talking about the 'chacha' part, but rather the '@openssh.com' part.

      --
      For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
    7. Re:lame name by MichaelSmith · · Score: 1

      The world is waking up to the NSA bullshit

      . I am sure the NSA approached DJB about this and I am pretty sure the conversation would have been interesting to hear. I bet the NSA guy walked away shrugging his shoulders asking himself what the hell happened.

    8. Re:lame name by Virtucon · · Score: 1

      Well we need more folks who are willing to push the edges of encryption algorithms and not bow to government pressure. The amount of exposure that the NSA has wrought on all of us, whether it's using TOR or just doing online shopping or banking is enormous and I hope there's some accountability at the end of all of this, I doubt that now but I do have hope. For now I'll just put my faith in algorithms that are strong mathematically and aren't under NIST's hands and have more open, scholarly analysis. ChaCha20 is one of those .

      --
      Harrison's Postulate - "For every action there is an equal and opposite criticism"
  2. 100 lines is meaningless by Guspaz · · Score: 4, Insightful

    The referenced source file has no actual implementation of the encryption in it, so claiming 100 lines is a bit silly...

    1. Re:100 lines is meaningless by Anonymous Coward · · Score: 1, Interesting

      It's just as well. If you'd ever looked at the qmail source code you'd have realized that DJB is not a programmer. That stuff looks like dog vomit. Neither is it efficient. Six or seven years back I converted a half dozen email systems from qmail to Postfix. For the exact same mail volume on the exact same hardware Postfix runs about a third the load average of qmail.

    2. Re:100 lines is meaningless by c0lo · · Score: 2

      The referenced source file has no actual implementation of the encryption in it, so claiming 100 lines is a bit silly...

      Yeap. The rest is in about 200 lines of code.

      --
      Questions raise, answers kill. Raise questions to stay alive.
    3. Re:100 lines is meaningless by Etcetera · · Score: 2

      For the exact same mail volume on the exact same hardware Postfix runs about a third the load average of qmail.

      Then you were probably doing it wrong.

      NB: Qmail is a PITA to set up, and configure, and generally understand... but when tuned and customized properly it's incredibly efficient. Even more efficient if you're on underpowered hardware.

    4. Re:100 lines is meaningless by hawguy · · Score: 5, Insightful

      The referenced source file has no actual implementation of the encryption in it, so claiming 100 lines is a bit silly...

      Using their metric of excluding the function calls that do the real work, OpenSSL only needs one line of source code to encrypt a file:


      #!/bin/bash

      openssl enc -aes-256-cbc -salt -in somefile.txt -out somefile.txt.enc

    5. Re:100 lines is meaningless by lgw · · Score: 4, Funny

      And being DJB, surely some of that 300 lines is comments insulting all his fellow cryptographers, the users, and generally complaining that the world is full of idiots?

      --
      Socialism: a lie told by totalitarians and believed by fools.
    6. Re:100 lines is meaningless by punman · · Score: 4, Interesting

      I read through the implementation presented and the additional ~200 lines of code for each of the authentication (poly1305) and encryption (chacha.c) pieces of this protocol. Coming from the perspective of an experienced coder but relative crypto novice this just looks like a very sophisticated shifting algorithm (like ROT13, on steroids) keyed on the TCP sequence number. Is this considered acceptable security for a data stream? I'm honestly curious, I haven't played around with crypto functions very much.

    7. Re:100 lines is meaningless by SuneSpeg · · Score: 0

      Line 74 in source = Clue #1 he isnt a programmer: 74 goto out;

    8. Re:100 lines is meaningless by Anonymous Coward · · Score: 1

      I can see two bugs in it straight away.

      Has this stuff been audited by a professional cryptographer?

    9. Re:100 lines is meaningless by Anonymous Coward · · Score: 5, Informative

      That's how you do a try...finally block in C.

    10. Re:100 lines is meaningless by Anonymous Coward · · Score: 0

      I had a similar experience, but you shouldn't take some Anonymous Coward's word for it. Try it for yourself. Or you could just do a Google search and see what turns up.

    11. Re:100 lines is meaningless by bunratty · · Score: 1

      I was about to say it had no comments, but then I found this gem:
      /* stopping at 2^70 bytes per nonce is user's responsibility */
      That'll come in handy as soon as someone wants to encrypt more than 2^70 bytes!

      --
      What a fool believes, he sees, no wise man has the power to reason away.
    12. Re:100 lines is meaningless by icebike · · Score: 1

      And being DJB, surely some of that 300 lines is comments insulting all his fellow cryptographers, the users, and generally complaining that the world is full of idiots?

      Or, you could click the link and find out how wrong you are....

      --
      Sig Battery depleted. Reverting to safe mode.
    13. Re:100 lines is meaningless by ebno-10db · · Score: 1

      On Slashdot, literalism knows no bounds.

    14. Re:100 lines is meaningless by Anonymous Coward · · Score: 0

      Not to mention he's talking about line 74 in Miller's ssh implementation not DJB's chacha/poly.

    15. Re:100 lines is meaningless by punman · · Score: 1

      When you don't understand encryption, it all looks like ROT13.
      Best leave that to the big boys.

      If you can't explain it, just say so. Thanks anyway though.

    16. Re:100 lines is meaningless by Anonymous Coward · · Score: 0

      You're starting in the wrong place. Go implement RC4 and come back when you understand it. Really, I'm serious. RC4 is a great introduction to the basics of stream ciphers and different sorts of attacks. You can hand-write the code for an implementation on the back of a business card.

    17. Re:100 lines is meaningless by Anonymous Coward · · Score: 0

      That's what happens when you bring C++ programming practices back to C.

    18. Re:100 lines is meaningless by NekoXP · · Score: 1

      And the other ~150

    19. Re:100 lines is meaningless by Z00L00K · · Score: 1

      A good encryption is beautiful and simple while still completely unpredictable unless you have the right key.

      The less code that you have to use to perform the encryption the better.

      --
      If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
    20. Re:100 lines is meaningless by Anonymous Coward · · Score: 0

      I know. When I see someone say "WHOOSH," I wonder if at least one person looks because of how literal some people take things.

    21. Re:100 lines is meaningless by Virtucon · · Score: 1
      --
      Harrison's Postulate - "For every action there is an equal and opposite criticism"
    22. Re:100 lines is meaningless by DMUTPeregrine · · Score: 2

      Damien Miller wrote this implementation, not DJB. DJB designed the ciphers and wrote the reference implementations. DJM and DJB are two different people.

      --
      Not a sentence!
    23. Re:100 lines is meaningless by lgw · · Score: 2

      Ah, well, that explains the missing rant then. :)

      --
      Socialism: a lie told by totalitarians and believed by fools.
    24. Re:100 lines is meaningless by Anonymous Coward · · Score: 0

      The Practice Effect?

    25. Re:100 lines is meaningless by Anonymous Coward · · Score: 0

      No, you do a try...finally block by using setjmp, and longjmp out of a signal handler (or vectored exception handler in Windows).

    26. Re:100 lines is meaningless by Anonymous Coward · · Score: 0

      djm has maintained OpenSSH for the past 10 years. What's your contribution?

    27. Re:100 lines is meaningless by Dahamma · · Score: 1

      There is absolutely nothing wrong with goto if used in a way that is procedurally correct and readable. A C compiler effectively compiles conditionals down to a bunch of ASM goto (aka "jump") statements anyway, so if it's MORE readable to use goto in C than if/else gymnastics and repeated code/extra functions, why not?

    28. Re:100 lines is meaningless by Dahamma · · Score: 1

      No, the code link in the post you replied to is for Chacha itself from DJB, not the DJM code that *used* it (which was linked in the article).

      Not only it it free of rants, it's free of ANY useful comments, which IMO for mostly inscrutable crypto code based largely on C macros is worse than ranting.

    29. Re:100 lines is meaningless by complete+loony · · Score: 3, Insightful

      It's a stream cipher, the tcp sequence number tells you the byte offset in the session's psudo-random bit stream to xor against. Remember that TCP packets could arrive in any order, and multiple small packets might be aggregated when they are retransmitted.

      --
      09F91102 no, 455FE104 nope, F190A1E8 uh-uh, 7A5F8A09 that's not it, C87294CE no. Ah! 452F6E403CDF10714E41DFAA257D313F.
    30. Re:100 lines is meaningless by JigJag · · Score: 1

      you'd be surprised then to learn the Linux kernel has a truckload of it. It's a valid construct with specific application. You can even read Mr. Torvalds' opinion about GOTO statements

      --
      "The hallmark of humanity is the ability to move beyond sensory inputs" - Mary Helen Immordino-Yang
    31. Re:100 lines is meaningless by Anonymous Coward · · Score: 0

      Best not use "if" statements, they're just goto(jmp) on the back-end.

    32. Re:100 lines is meaningless by Anonymous Coward · · Score: 0

      Exactly! I tried running it and all it did was output garbage. Clearly a buggy POS.

    33. Re:100 lines is meaningless by punman · · Score: 1

      ...the tcp sequence number tells you the byte offset in the session's psudo-random bit stream to xor against.

      Perfect explanation. I get it now. Thanks!

  3. Pastebin mirror of code by Anonymous Coward · · Score: 5, Informative
    1. Re:Pastebin mirror of code by damaki · · Score: 4, Informative

      Wow it's less 100 lines (excluding chacha_ivsetup, chacha_encrypt_bytes AND poly1305_auth). So I guess it's not 100 lines...

      --
      Stupidity is the root of all evil.
    2. Re:Pastebin mirror of code by Anonymous Coward · · Score: 0

      Look, I can do it in only 1 line of code:

                int chachapoly_call_the_rest_of_the_code( struct chachapoly_ctx *ctx, const u_char *key, u_int keylen )

      That IS a very simple algorythm....

    3. Re:Pastebin mirror of code by axehind · · Score: 1

      Correct! Look at chacha_private.h

  4. slashdotted by callmebill · · Score: 1

    Guess I'll never know what it looks like.

    1. Re:slashdotted by ConstantineM · · Score: 1

      The nginx on BXR had a soft FD limit of 128 (:openfiles-cur=128:) through the default login.conf(5), which it doesn't seem to increase automatically, and which it was hitting at 17:59 (if not earlier) as per fstat(1), and which applies to internet sockets, too, so, during some time between 17:52 and 18:03, when nginx was manually restarted with the increased soft limit, BXR was indeed slashdotted!

      BTW, this was probably due to the HTTP keep-alive feature, and not the raw number of requests, which are all served up very quickly due to mfs and good caching. No other problems to report since then; even the search is still very fast, as it should be.

      Recent `fstat | fgrep nginx` runs indicate the highest FD is around 200 now, but it did quickly jump to around 400 right after the 128 limit was lifted (within ten minutes of the story being published).

  5. Not less than 100 lines by Anonymous Coward · · Score: 2, Informative

    What on earth gave the submitter the idea that it was less than 100 lines? That file linked to is the interface, not the actual core implementation. I count 113 lines in that file, and 218-223 lines depending on which version of DJB's chacha-merged.c you look at (incorporated as chacha_private.h, several versions, several subdirectories).

    1. Re:Not less than 100 lines by ConstantineM · · Score: 2

      Those other files are the libraries, the protocol itself is about 100 lines of commented code.

    2. Re:Not less than 100 lines by K.+S.+Kyosuke · · Score: 1

      Rewrite it in proper Forth, and it will be something like three screens or so. :-)

      --
      Ezekiel 23:20
  6. Does DJB insist that the library ... by fishnuts · · Score: 3, Insightful

    Does DJB insist that his crypto library gets installed under /var/lib? He's always insisted that his qmail binaries get installed under /var/qmail, and had everyone I know in the unix admin/engineering field shaking their heads, knowing that having executables and libraries on the /var filesystem is retarded and dangerous.

    1. Re:Does DJB insist that the library ... by Njovich · · Score: 2

      What's so dangerous about having executables and libraries in /var? It seems pretty common practice? (I have no particular like for qmail, but I'm curious why this part is an issue)

    2. Re:Does DJB insist that the library ... by mrchaotica · · Score: 1

      */bin is normally read-only but /var is not, and/or it prevents you from setting /var to no-execute?

      --

      "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

    3. Re:Does DJB insist that the library ... by Anonymous Coward · · Score: 5, Informative

      /var is meant for variable content. Such as the mail spool and tmp directory. Data on this filesystem often comes from external sources such as email. It is recommended for this file system to be mounted with noexecute flag to reduce the likelihood of a downloaded data to be executed.

      Having binaries on /var means that this filesystem can not be mounted with this option and therefor reduces security a bit.

    4. Re:Does DJB insist that the library ... by Anonymous Coward · · Score: 1

      Because mounting /var as noexec is a reasonable (though possibly not common) security control. Since applications need to write to /var for logs, etc, making /var noexec is a safeguard in case the application gets compromised. If you have to put libraries and executables under /var, that prevents this control from being used.

      It also fucks up and goes against every other system of organizing executables & libraries in linux, which makes it stupid on its face.

    5. Re:Does DJB insist that the library ... by Anonymous Coward · · Score: 0

      How about mounting /var as noexec?
      But these days I guess that during installation everybody clicks the "I'm totally n00b/lazy. Just dump the whole damn thing in a single partition." option.

    6. Re:Does DJB insist that the library ... by psmears · · Score: 3, Informative

      He's always insisted that his qmail binaries get installed under /var/qmail,

      Not true. He used to, but he has since placed qmail in the public domain, so you can do whatever you want.

    7. Re:Does DJB insist that the library ... by Aighearach · · Score: 5, Informative

      Because on production servers it is common to have var on it's own partition, and that is the filesystem that holds the logs, which an attacker can cause data to be written to. Also it has to be writable by the running services, and allowing services to write and execute new binaries is a step in many attacks. So it is a typical thing a sysadmin wants to do, to prevent executing code there.

      That said, the distro I'm using puts the executables under /usr regardless of where the upstream developer wants them to go. That isn't a decision for the app, it is one for the distro.

    8. Re:Does DJB insist that the library ... by TheCarp · · Score: 1

      In addition to the other answers, I will mention the FHS or Filesystem Hierarchy Standard: http://www.pathname.com/fhs/pub/fhs-2.3.html

      Note its descriptions of /bin /usr/bin /var and /var/lib

      Particularly:
      "/var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files."

      and /var/lib:
      "This hierarchy holds state information pertaining to an application or the system. State information is data that programs modify while they run, and that pertains to one specific host. Users must never need to modify files in /var/lib to configure a package's operation."

      So it is just the wrong place entirely; and there are at least 3 potential correct places, /usr/(lib|bin), /opt/XXX or debatably /(bin|lib).... however even the last one is likely incorrect as those must be on the root filesystem and thus should only contain files that would be required during the boot process, before other filesystems (like /usr) might be available.

      The only reason I could see for wanting this stuff in /var would be if the program ran in a chroot and needed to be able to dynamically load libraries. Even that is likely not the best approach.

      --
      "I opened my eyes, and everything went dark again"
    9. Re:Does DJB insist that the library ... by GuB-42 · · Score: 1

      /var meant to be both writable and persistent. That makes it very sensitive and a good target for attackers. This is the reason why it is a good idea to avoid putting executable files in there. In fact the less you rely on /var, the better.

      /usr, /bin, /lib and /etc can be mounted read-only in production. That's the case of Android for example. As a result, it is a much safer place for executables and libraries.

    10. Re:Does DJB insist that the library ... by DarkOx · · Score: 1

      Its not uncommon for that very reason to mount /var noexec

      --
      Repeal the 17th Amendment TODAY! Also Please Read http://www.gnu.org/philosophy/right-to-read.html
    11. Re:Does DJB insist that the library ... by buchner.johannes · · Score: 1

      Why not separate every process from each other one ... it's called SELinux and much finer grained than making partitions

      --
      NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
    12. Re:Does DJB insist that the library ... by Anonymous Coward · · Score: 0

      It's public domain, you can do whatever you want with it.

    13. Re:Does DJB insist that the library ... by Gothmolly · · Score: 1

      Caring about what goes in what filesystem is neck-beardy.

      Who mounts /var noexec by default? How many people have already dispensed with a separate /var ?

      --
      I want to delete my account but Slashdot doesn't allow it.
    14. Re:Does DJB insist that the library ... by Anonymous Coward · · Score: 0

      Defense in depth, my friend. As long as processes are running on the machine, there is always a chance that they could break through protection and do something bad. Noexec is an easy way to prevent execution and doesn't rely on anything else. As an aside, there is another benefit to having separate partitions, a bomb may fill up your /var but won't bring your system to its knees nearly as easily.

    15. Re:Does DJB insist that the library ... by tqk · · Score: 1

      Caring about what goes in what filesystem is neck-beardy.

      Using "neck-beardy" as an epithet is far worse, !@#hole.

      How many people have already dispensed with a separate /var ?

      You've never run Debian; gotcha. See /var/cache/apt/archives/

      --
      "Tongue tied and twisted, just an Earth bound misfit ..." -- Pink Floyd.
    16. Re:Does DJB insist that the library ... by Anonymous Coward · · Score: 0

      Lol, he made a neckbeard angry! Grrr, neckbeard smash!

    17. Re:Does DJB insist that the library ... by Anonymous Coward · · Score: 0

      "That said, the distro I'm using puts the executables under /usr regardless of where the upstream developer wants them to go. That isn't a decision for the app, it is one for the distro."

      To be fair, the app probably doesnt even know or care since if everything is under /usr then everything ELSE that was at the root, probably is just a symlink to /usr/$WHATEVER. Which isn't an issue. He's talking about one specific program demanding that it be put under /var/ which is totally asinine. /opt? Maybe, fine. /bin? normal, great. ~/bin? Still fine. but /var? thats just weird

    18. Re:Does DJB insist that the library ... by Bacon+Bits · · Score: 2

      SELinux has a higher administrative burden. Mounting /, /boot, /usr, /usr/share, /usr/local, /var, and /tmp all with 'ro', 'noexec', 'nodev', etc. as appropriate means you prevent many types of attacks and you don't have to write a custom SELinux policy, and maintain it, and debug all the issues. Increased granularity = increased complexity. Options in mount = KISS.

      --
      The road to tyranny has always been paved with claims of necessity.
    19. Re:Does DJB insist that the library ... by ConstantineM · · Score: 1
      Actually, he now insists that you should not install it as a separate library, but should include the code with your own programme — http://cr.yp.to/mac.html:

      My fast poly1305aes library is in the public domain. You can and should include it in your own programs, rather than going to the effort of linking to a shared library; the compiled code is between 6 and 10 kilobytes, depending on the CPU.

      Of course, it being in the public domain, this is merely a suggestion, and, as a developer, one could basically use it in whatever way one sees fit (although djb's advice does seem quite reasonable).

    20. Re:Does DJB insist that the library ... by higuita · · Score: 1

      10+ too late, postfix have since steamroller qmail in all fields

      --
      Higuita
    21. Re:Does DJB insist that the library ... by Gothmolly · · Score: 1

      Citing the existence of a directory /var/cache/apt/archive does not demonstrate that it's a separate filesystem.

      Therefore, you fail.

      --
      I want to delete my account but Slashdot doesn't allow it.
    22. Re:Does DJB insist that the library ... by tqk · · Score: 1

      Citing the existence of a directory /var/cache/apt/archive does not demonstrate that it's a separate filesystem.

      I was answering his, "How many people have already dispensed with a separate /var ?" Besides, your comment is irrelevant. Lots of stuff *can* be in a separate fs; doesn't mean they either have to, or should be. Lots of people don't see any need for separate filesystems at all, given they've got obscene amounts of free disk space to work with these days.
       
      /var/cache/apt/archive is where the Debian installer dumps debs that it's downloaded prior to installing/upgrading them. I've filled the root fs during upgrades when /var wasn't separate. It's easy to recover from, but why waste time needlessly?

      --
      "Tongue tied and twisted, just an Earth bound misfit ..." -- Pink Floyd.
    23. Re:Does DJB insist that the library ... by Anonymous Coward · · Score: 0

      Isn't SELinux the one the NSA came up with?

  7. FTFT by fisted · · Score: 1

    --- cipher-chachapoly.c    2013-11-21 03:50:00.000000000 +0100
    +++ cipher-chachapoly.2.c    2013-12-11 14:07:54.000000000 +0100
    @@ -57,11 +57,11 @@
          * Run ChaCha20 once to generate the Poly1305 key. The IV is the
          * packet sequence number.
          */
    -    bzero(poly_key, sizeof(poly_key));
    +    bzero(poly_key, sizeof poly_key);
         put_u64(seqbuf, seqnr);
         chacha_ivsetup(&ctx->main_ctx, seqbuf, NULL);
         chacha_encrypt_bytes(&ctx->main_ctx,
    -        poly_key, poly_key, sizeof(poly_key));
    +        poly_key, poly_key, sizeof poly_key);
         /* Set Chacha's block counter to 1 */
         chacha_ivsetup(&ctx->main_ctx, seqbuf, one);

    @@ -89,9 +89,9 @@
         r = 0;

      out:
    -    bzero(expected_tag, sizeof(expected_tag));
    -    bzero(seqbuf, sizeof(seqbuf));
    -    bzero(poly_key, sizeof(poly_key));
    +    bzero(expected_tag, sizeof expected_tag);
    +    bzero(seqbuf, sizeof seqbuf);
    +    bzero(poly_key, sizeof poly_key);
         return r;
    }

    1. Re:FTFT by Anonymous Coward · · Score: 0

      So you saw no problems with the IV being the sequence number.....

      Seems glaring to me that the IV is predictable.

    2. Re:FTFT by Sun · · Score: 1

      I have not analyzed this cypher, but generally speaking, the IV is not considered secret. In fact, under the common block cyphers, it is considered completely okay to actually publish it.

      Shachar

    3. Re:FTFT by Anonymous Coward · · Score: 0

      As long as keys are never re-used it doesn't matter if the IV is predictable or not. This is the same tradeoff as when using block ciphers in counter mode.

    4. Re:FTFT by Anonymous Coward · · Score: 0

      So you saw no problems with the IV being the sequence number.....

      This is a stream cypher which is operated in CTR mode. The keys are randomized per connection. Predictable IV is immaterial and actually a feature of the system.

      http://en.wikipedia.org/wiki/ChaCha20#ChaCha_variant

    5. Re:FTFT by kasperd · · Score: 1

      As long as keys are never re-used it doesn't matter if the IV is predictable or not.

      That depends a lot on the mode. CBC mode is vulnerable to plenty of attacks, if the IV is predictable. And what predictability means in this context has taken some people by surprise. If the end of the stream of data is not set in stone once you start encrypting, does that mean the IV is predictable? The way CBC has been used in SSL did have a weakness because of that. The cipher blocks sent across the network are used as IV for successive blocks. But once you have sent a cipher block, it is no longer unpredictable. And if the adversary can influence the next data block once he has seen the previous cipher block, CBC can be exploited.

      This is the same tradeoff as when using block ciphers in counter mode.

      It is true that counter mode is one of those modes, that do not require unpredictable IVs. In fact you can just use a counter to generate your IV. But if you do not choose IVs carefully, counter mode is one of the weakest modes, you can choose. If you ever reuse an IV, you have effectively reduced the encryption to a multi-time pad. CBC mode with a constant IV would be more secure than that.

      The thing is, that counter mode is actually a stream cipher, which operates by generating a stream of bits, which is XORed with the message. All ciphers constructed in this way are vulnerable, if the IV is reused. That is exactly the problem with WEP.

      I have seen at least one published article recommending the use of counter mode for storage encryption. It did not explicitly say you should use the sector number as IV, but it was hinting, that's what you were expected to do. Additionally using sector number as IV has been common practice in storage encryptions. Any storage encryption following that practice would be broken if an adversary was able to get the data which has existed at one logical sector number at two different points in time. Ways that could happen includes:

      • Wear levelling on a flash/SSD medium.
      • Remapped sectors on a harddrive.
      • Access to earlier versions due to slight difference in alignment of write head.
      • Encrypted data stored on an untrusted host or accessed over an untrusted communication path.
      • Adversary with physical access to copy the encrypted media more than once.
      --

      Do you care about the security of your wireless mouse?
    6. Re:FTFT by kasperd · · Score: 1

      the IV is not considered secret.

      Of course not. After all, most cipher modes sent the IV directly on the wire. However it is only sent once the data has been encrypted. If the adversary knew the IV before you encrypted the data, the adversary could influence the content of the data based on her knowledge about the IV, and break the encryption that way. If you are using a cipher mode, which requires the IV to be random, then you must choose a random IV after the data to be encrypted has been set in stone, and no sooner than that. SSL was broken due to encrypting data in CBC mode, where the data was not yet known, when the IV was chosen.

      --

      Do you care about the security of your wireless mouse?
    7. Re:FTFT by Anonymous Coward · · Score: 0

      Aren't those the type-of calling of sizeof and therefore needs parenthesis?

    8. Re:FTFT by kasperd · · Score: 1

      Aren't those the type-of calling of sizeof and therefore needs parenthesis?

      To me even asking that question is indication, that you should include parenthesis. If the author or any of the readers are unsure if parenthesis is required or not, it is better to use parenthesis more often than strictly required. In other words, you can omit the parenthesis only if you know for sure, it will work and that everybody who will read it, also understand the rules.

      --

      Do you care about the security of your wireless mouse?
  8. Thank you Damien by flyingfsck · · Score: 4, Funny

    This is great news.

    --
    Excuse me, but please get off my Pennisetum Clandestinum, eh!
  9. What about HPN? by Vesvvi · · Score: 3, Insightful

    This is all well and good, but what's the status of seeing HPN-SSH or similar incorporated? FreeBSD has incorporated it, but it's still messy on Linux systems.

  10. Dear Editors by mythosaz · · Score: 0

    less than 100 lines of code!

    Fewer.

    1. Re:Dear Editors by Anonymous Coward · · Score: 0

      Eye thawed aye cud knot think fewer of Slashdot editors butt it seams ai Cannes.

    2. Re:Dear Editors by aardvarkjoe · · Score: 1

      Unfortunately, the actual correction should be "more."

      --

      How can we continue to believe in a just universe and freedom to eat crackers if we have no ale?
    3. Re: Dear Editors by bazmonkey · · Score: 1

      Unfortunately, it's "greater". The code is greater than 100 lines. There are more than 100 lines in it. If you're talking about the lines, there's more. If you're talking about the container itself, it is greater.

    4. Re: Dear Editors by Anonymous Coward · · Score: 0

      I've seen it, it's not that great.

  11. nginx doesn't increase soft limits by ConstantineM · · Score: 1

    The nginx had a soft limit of 128 file descriptors through daemon: :openfiles-cur=128: in login.conf(5), which it apparently doesn't increase automatically, and which were quickly exhausted for internet stream FDs, as per fstat(1). But it's been resolved at 10:03 PT / 18:03 GMT, and there were no known problems since then.

  12. Also support for ED25519 keys... by Anonymous Coward · · Score: 0

    Support for ED25519 keys and Curve25519 key exchange is also welcome. Along with the ChaCha cipher and Poly1305 MAC, they are all excellent crypto primitives.

  13. Re:knowing DJB, I don't trust it by Anonymous Coward · · Score: 1

    That's the magic of peer review - you don't have to trust the creator. The grandparent of Chacha, Salsa, was one of the winners of the eSTREAM cipher competition so it has seen plenty of review.

  14. new stream cipher competition from NIST by Anonymous Coward · · Score: 1

    Bruce Schneier has been suggesting that NIST call a competition for a new stream cipher like they did with AES and SHA-3. RC-4 is on its last legs, and there's isn't much of a consesus on what to replace it with.

    Even if you don't completely trust NIST anymore (after the Snowden documents), at the very least such a competition would concenrate a lot of people's efforts on the problem, and you could look at the final candidate list and have a good number of choices in addition to the final winner.

    There were the eSTREAM/NESSIE/CRYPTREC programs, but they don't seem to get as much press as the NIST competition.

    1. Re:new stream cipher competition from NIST by Virtucon · · Score: 1

      RC-4 is on its last legs, and there's isn't much of a consesus on what to replace it with.

      Not to mention patent trolls lurking wanting to sue you if you use TLS with RC4.

      --
      Harrison's Postulate - "For every action there is an equal and opposite criticism"
  15. Re:knowing DJB, I don't trust it by Anonymous Coward · · Score: 1

    The "grandparent"? Rule #1 for cryptography and random number generation: improving a well-tested expert algorithm creates a non-well-tested non-expert algorithm.

  16. Hachachachacha! by Culture20 · · Score: 1

    Encryption scheme names have always been strange. Blowfish, triple-DES, RC4... Now take this new cipher's name. Please!

    1. Re:Hachachachacha! by maxwell+demon · · Score: 1

      I can't see anything strange about "triple-DES". "triple-DES" is exactly what the name suggsts: three times DES. And DES is just the abbreviation of Data Encryption Standard.

      RC4 sounds like an abbreviation as well (probably version 4 of something), but I have no idea of what and am too lazy to look now. Anyway, nothing strange about that one, either.

      OTOH, I cannot imagine how "Blowfish" came to its name.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    2. Re:Hachachachacha! by Burz · · Score: 1

      What I want to know is, do the interactive aspects of this new cipher actually resemble two computers doing the cha-cha?

      And, is poly begging for a cracker?

    3. Re:Hachachachacha! by Forever+Wondering · · Score: 1

      RC4 comes from Ron Rivest [of RSA fame] and stands for either "Rivest Cipher 4" or "Ron's Code 4" http://en.wikipedia.org/wiki/RC4

      --
      Like a good neighbor, fsck is there ...
  17. Re:knowing DJB, I don't trust it by Anonymous Coward · · Score: 0

    Yeah, as another commenter said, I don't care if the "grandfather" algorithm Salsa was a finalist in eSTREAM, since this guy has touched it, I'll be adding it to my disabled ciphers list for my openssh server unless/until someone like Bruce Schneier says it looks good.

  18. Has it ever been tested? by Anonymous Coward · · Score: 0

    Anyone can come up with a cipher that encrypts and decrypts data, but is it really secure or does it suffer from fatal flaws?

    1. Re:Has it ever been tested? by Virtucon · · Score: 1

      All Cryptography algorithms go through Cryptoanalysis at some point.

      Certainly there's already enough documentation out there on all encryption algorithms and mathematically speaking Salsa20/ChaCha20 are extremely strong.

      --
      Harrison's Postulate - "For every action there is an equal and opposite criticism"
    2. Re:Has it ever been tested? by slew · · Score: 1

      In the abstract, the main measure of encryption that matters is that it has passed enough scruitiny based on currently known attack techniques. You really have to get your stuff out there before you know how good it is.

      To this end, this person isn't a fly-by-night encryption designer, but somone who has a stream cipher accepted into the eSTREAM portfolio. AFAIK, ChaCha is a derivative of the Salsa20 stream cipher and can be used similarly to RC-4 (although the similarities are only superficial to RC-4).

      Poly1305 is really a just a MAC (message authentication code) technique which relies on an underlying cipher (usually AES). It's more sophisticated than the standardized CMAC (cipher-based MAC) but more simiilar to GMAC (the galois-field MAC that is part of the GCM encryption technique used by WiGig).

  19. Re:knowing DJB, I don't trust it by Anonymous Coward · · Score: 0

    The algorithm is virtually identical, with a minor tweak of the matrix and round function to improve diffusion and map better onto SIMD operations.

  20. Re:knowing DJB, I don't trust it by Anonymous Coward · · Score: 0

    The algorithm is fundamentally identical to salsa, just rearranged a bit. It is so simple, that it doesn't take a cryptographer to see there is little room for deception here. It would be glaringly obvious to anyone skilled in the art.

  21. But NOT des(des(des())). Don't do that! by raymorris · · Score: 2

    > I can't see anything strange about "triple-DES". "triple-DES" is exactly what the name suggests: three times DES.

    True for the purpose for which you posted it, but let me take this opportunity to point out something that
    some programmers naively think makes encryption more secure. 3DES does not encrypt with DES three times.
    So don't do that. Repeating encryption makes it WEAKER, not stronger, unless other sophisticated
    stuff is done between the rounds of encryption.

    Repeating the SAME encryption allows for a meet in the middle attack, used by rainbow tables.
    Layering DIFFERENT types of encryption, or especially hashing, is no more secure than the weakest layer.
    That's trivially provable without any math knowledge in the case of hashing.

    3DES, in it's recommended form*, uses three different keys and first ENCRYPTS with key1, then DECRYPTS with key2, then ENCRYPTS with key3, so it's not three encryptions, but two rather encrypt, decrypt, encrypt.

    * It's legal 3DES to set k1 and k3 the same, which results in exactly the same output as weak old DES, it's just a waste of cycles. It was allowed for backward compatibility.

    1. Re:But NOT des(des(des())). Don't do that! by maxwell+demon · · Score: 1

      While different hashes on top of each other are quite obviously just as good as the weakest, I don't see why this should be the case for encryption.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    2. Re:But NOT des(des(des())). Don't do that! by Anonymous Coward · · Score: 0

      Try the following silly exercise, which is meant to be reminiscent of RSA:

      Take an array of numbers, A, say 1 to 10000000. Plot the histogram of B=A mod(107*5). Now plot the histogram of C=B mod(257*2). Contrast C to the histogram of A mod (257*2).

      That is, iterating modulus concentrates a uniform distribution toward small numbers. This is a contraction of the cipherspace which can't be good.

      captcha: "nonsense". lol.

    3. Re:But NOT des(des(des())). Don't do that! by Anonymous Coward · · Score: 1

      * It's legal 3DES to set k1 and k3 the same, which results in exactly the same output as weak old DES, it's just a waste of cycles. It was allowed for backward compatibility.

      I was with you up to this point. E(K1, PT) -> CTe1. D(K2, CTe1) -> CTd2 (Something which since it was not decrypted with K1 is definitely not PT). E(K1, CTd2) -> CTe3 (which since PT != CTd2, is definitely not the same as CTe1). Whereas DES E(K1, PT) -> CTe1.
      So 3DES((K1,K2,K1), PT) != DES(K1, PT)

    4. Re:But NOT des(des(des())). Don't do that! by Anonymous Coward · · Score: 0

      That is, there's a mathematical study of the (relatively) simple patterns which emerge when you iterate a function repeatedly. Since simple patterns are what you want to avoid in a ciphertext, it's probably not a good idea to iterate encryption.

    5. Re:But NOT des(des(des())). Don't do that! by maxwell+demon · · Score: 1

      You calculated hashes. I said for hashes it is clear.

      But the statement for encryption basically states that if I encrypt my text with rot13 (weak encryption) and then send it through ssh (thus applying strong encryption on top of the weak rot13), the ssh data stream (which is now encrypted with two different algorithms) would be no harder to crack than the weaker of the two encryptions (which clearly is rot13). That is what I don't buy.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    6. Re:But NOT des(des(des())). Don't do that! by maxwell+demon · · Score: 2

      Repeated iteration of functions certainly is relevant for the des(des(des())) situation mentioned in the title and the first paragraph of raymorris' post. I didn't question that part. I did question the part where he claimed that layering different types of encryption on top of each other makes the encrytion as weak as the weakest one. It is true for hashes (which I explicitly acknowledged), but I strongly doubt that I have to fear that data I'm sending through an SSH link is highly insecure just because I've run a rot13 on it before sending.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    7. Re:But NOT des(des(des())). Don't do that! by Anonymous Coward · · Score: 0

      It seems to me you are making the GP's point (with a confusing notation for mod, I might add).

      Encryption should map onto extremely large spaces, and so adding multiple remappings shouldn't lead to a "contraction of the cipherspace". Seems to me that multiple different encryptions would be better than any one alone, in all ways except for resource usage and key management, which are reasons enough to not do it.

    8. Re:But NOT des(des(des())). Don't do that! by Anonymous Coward · · Score: 0

      Strictly speaking, RSA is a hash.

      It was a heuristic argument about iterating the same (family of) encryption repeatedly. I wish that I could give you (and myself) a better example.

      Yes, obviously SSH will protect ROT13 just as well as it will protect plaintext. Taken literally, raymorris is definitely wrong. Even when iterating does introduce weakness, the weakness is not necessarily going to be "the weakest link"-type.

    9. Re:But NOT des(des(des())). Don't do that! by amorsen · · Score: 2

      Combining two encryption methods using separate keys can never be weaker than the inner encryption. Proof: if the combined method IS weaker, the attacker could just use the outer method as an attack with a small constant complexity on the inner method, which means the inner method is exactly as strong as the combined method (times a small constant). Unfortunately the same does not apply to the outer method, it is possible for a weak inner method to defeat the security of a strong outer method (e.g. if the inner method always starts its output with a known pattern, it can really mess up your outer method). Therefore, always encrypt FIRST with the algorithm you trust most, and NEVER use the same key for both methods.

      --
      Finally! A year of moderation! Ready for 2019?
  22. Re:knowing DJB, I don't trust it by Anonymous Coward · · Score: 0

    Did he design torque then? They seem to love /var/spool/

  23. I prefer my ciphers by Anonymous Coward · · Score: 0

    from DJ Jazzy Jeff.

  24. Yo by Anonymous Coward · · Score: 0

    ...DJ Bernstein, drop me a funky fresh cipher. umph umph

  25. Re:knowing DJB, I don't trust it by amorsen · · Score: 2

    Before DES became the practically universal standard, there were multiple very similar algorithms in use, with the most significant difference being the S-boxes. At least one of them turned out to be breakable with 2^2 effort. Even s2des (I would do a superscript 2 but Slashdot is stuck in the 90's) which was specifically designed to be more resistant to differential attacks turned out to be MORE vulnerable to those attacks.

    Minor tweaks are worrying.

    --
    Finally! A year of moderation! Ready for 2019?
  26. yes, the other keying option == DES by raymorris · · Score: 3, Interesting

    Indeed I misspoke. It's the allowed keying option K1=K2=K3 that's strictly equivalent to DES.

    The keying option K1=K3 is slightly more secure than DES.

  27. yes, I misspoke. Still, be careful chaining encryp by raymorris · · Score: 1

    You're right, of course. Unlike hashes (md5, sha, etc), it's possible to chain different encryption without reducing security. Your rot13 & ssh example demonstrates that nicely.

  28. two examples where combined weaker than inner by raymorris · · Score: 1

    > Combining two encryption methods using separate keys can never be weaker than the inner encryption.

    Here are two trivial cases which each prove that false.
    F1 is the inner encryption. It's flaw is something like multiplying by some X where X can be zero. Any flaw where one step in the method sometimes nullifies the earlier key-dependant step qualifies. That means that in those cases, some part of the key actually doesn't matter.

    F2, the outer algorithm, is inverse of F1.

    Thus, in those cases where the non-identical part of the key doesn't effect the output, the following holds:
    ciphertext == F2(F1) == 'F1(F1) == plaintext

    Obviously ciphertext == plaintext is a little weak.

    Another case follows. F1, the inner encryption, is inspired by steganography. C code for F1c, which encrypts one character of the plaintext:

    char * f1c(char chr, int key, char * randstr) {
          randstr[key] = chr;
          return randstr;
    }

    Oops, sorry I gotta run but I bet you can come up with F2 from there.

    1. Re:two examples where combined weaker than inner by amorsen · · Score: 1

      The attacker knows the algorithms in use. The attacker can just run F2 himself, it costs only a small constant time. If F2 exposes a flaw in F1, that flaw was already there from the start.

      --
      Finally! A year of moderation! Ready for 2019?
  29. Pig Latin + Caesar Cypher! by Anonymous Coward · · Score: 0

    This is why I translate plaintext into Pig Latin and then apply a Caesar Cypher. Ha! The NSA will never figure that one out!

  30. Some people prefer Java naming conventions by tepples · · Score: 1

    If the @ sign burns your eyes, try reading it backwards like a Java package name: com.openssh.foo or org.putty.bar.

  31. Nothing wrong with clear goto code by tepples · · Score: 1

    Not that there's anything wrong with simulating good C++ practice in C, so long as it's clear. Compare early C++ compilers such as Cfront, which compiled C++ to C.

    1. Re:Nothing wrong with clear goto code by module0000 · · Score: 1

      I second this - `goto' in C is not the hacky technique kids in QBasic use. If you ever look at the kernel source, you'll find plenty of sane `goto' statements there. It's when you improperly use them than sanity begins to ebb away.

      --
      Trackball users will be first against the wall.
    2. Re:Nothing wrong with clear goto code by Anonymous Coward · · Score: 0

      Indeed:

      http://en.wikiquote.org/wiki/Edsger_W._Dijkstra

      He who wrote "The Go To Statement Considered Harmful", or as he originally titled it, "A Case Against the Goto Statement", later wrote:

      Please don't fall into the trap of believing that I am terribly dogmatic about [the go to statement]. I have the uncomfortable feeling that others are making a religion out of it, as if the conceptual problems of programming could be solved by a simple trick, by a simple form of coding discipline!

      Dijkstra (1973) in personal communication to Donald Knuth , quoted in Knuth's "Structured Programming with go to Statements"

  32. Counter mode by tepples · · Score: 1

    Wouldn't running a block cipher like AES or a hash function like SHA-3 in counter mode produce a suitable stream cipher?

  33. Re:knowing DJB, I don't trust it by Anonymous Coward · · Score: 0

    He's ten times as smart as the average brogrammer, in fact

    FTFY.

  34. Qmail really is a sendmail replacement! by Anonymous Coward · · Score: 1

    Qmail is a PITA to set up, andconfigure, and generally understand... but when tuned and customized properly it's incredibly efficient. Even more efficient if you're on underpowered hardware.

    So it truly is a sendmail replacement, then; it's got exactly the same pros and cons!

    Oh, wait... whenever a sendmail flaw gets discovered it's fixed in about two hours - without having to spend a week arguing with Dan over whether it's actually a flaw or not first.

    Let's face it, if ease of configuration and use is important, postfix is the best. If you just want pure power and efficiency, go with sendmail and hurt your brain a lot on the learning curve. Sendmail's got more patched bugs than any other mailserver, so it's honed by evolution, and once you've mastered tuning it (good luck with that) sendmail scales better than anything else.

  35. attacker may by raymorris · · Score: 1

    > If F2 exposes a flaw in F1, that flaw was already there from the start.

    Flaws exist. Turning a possible flaw into plaintext counts.
    Take for example a leaked database of 10 million encrypted credit card numbers. 99.99% of those look exactly like you'd expect encrypted text to look, random bytes. Of the 10 million, a few look exactly like credit card numbers, because those are the cases with the "multiply by zero" issue.

    Yes, without F2, the attacker COULD do their own cryptanalysis and devise F2 themselves, then run it 10 million times. That's harder than not doing cryptanalysis because the developer already ran F2 for them.

    Is it ridiculous to think that someone might run what ends up being the inverse of F1? That's almost what 3DES does by design.

    1. Re:attacker may by amorsen · · Score: 1

      The attack has no complexity. All you save the attacker by not running F2 for them is obscurity, the attacker does not have to spend any computational resources, they just have to know F2.

      The security of modern cryptosystems is in the key, not in the obscurity of the algorithms or (at least not intentionally) the attacks.

      --
      Finally! A year of moderation! Ready for 2019?
  36. That's fine if no attacks exist by raymorris · · Score: 1

    > The security of modern cryptosystems is in the key, not in the obscurity of the algorithms or (at least not intentionally) the attacks.

    Normally, we don't intentionally create attacks, but security absolutely DOES rely on there being easy attacks that
    are well known - the obscurity of the attack. If there is an attack (and there's ALWAYS an attack), you're better of not
    performing the attack yourself, but forcing the bad guy to first find, then carry out the attack.

    An example from the physical world make it crystal clear:

    Approximately all locks can be picked. Still, it is _more_ secure to lock your door than to not lock it.
    You are arguing that it's just as secure for you to lock it, then pick your own lock and leave it unlocked.
    "The bad guy could pick the lock himself", you say. That's true, he could, but requiring the bad guy
    to pick the lock before he can get in is more secure than picking it yourself and leaving the door unlocked.

    Let's do a select some specific values for your original claim, which was:

    > Proof: if [the combined method] IS weaker, the attacker could just [use the outer method as an attack] ...
    > on [the inner method], which means [the inner method] is exactly as strong as [the
    > combined method]

    If [leaving the door unlocked] IS weaker, the attacker could just [pick the lock] ... on the [locked door],
    which means that the [locked door] is exactly as strong as [leaving he door unlocked]

    The ellipses is where you said "with a small constant complexity". The complexity of F2 is not guaranteed to be constant.
    Nor F2 guaranteed to return the plaintext. If it SOMETIMES returns the plaintext, because that timer tick happened
    to have a zero as the least significant 32 bits, finding that 1 in 4,294,967,295 for them reduces their burden.

  37. First sentence missing the word "not" by raymorris · · Score: 1

    The first sentence should read "security absolutely DOES rely on there NOT being easy attacks that
    are well known - the obscurity of any attack".