News for hackers. Stuff that matters.
Re:BearSSL – Smaller SSL/TLS by mythz on Thursday November 03, 2016 @10:12AM (#12864051)
The last thing the world needs is another immature SSL/TLS implementation however this makes it very interesting:

> No dynamic allocation whatsoever. There is not a single malloc() call in all the library. In fact, the whole of BearSSL requires only memcpy(), memmove(), memcmp() and strlen() from the underlying C library. This makes it utterly portable even in the most special, OS-less situations. (On “big” systems, BearSSL will automatically use a couple more system calls to access the OS-provided clock and random number generator.)

> On big desktop and server OS, this feature still offers an interesting characteristic: immunity to memory leaks and memory-based DoS attacks. Outsiders cannot make BearSSL allocate megabytes of RAM since BearSSL does not actually know how to allocate RAM at all.

Edit: Just discovered what makes this an even more interesting one to watch, it's the work of this Wizard: http://security.stackexchange.com/users/655/thomas-pornin

Re:BearSSL – Smaller SSL/TLS by mioelnir on Thursday November 03, 2016 @03:16PM (#12867049)
> The last thing the world needs is another immature SSL/TLS implementation...

No, they world needs as many of those as it can get (if they are tagged as such). And then all the authors need to discuss with each other what they learned from the implementation. And then they compare their code with existing code bases and discuss differences. They review their patches, as well as patches from other projects.

They discuss the diffs, learn from others and bring in new ways too look at things.

All bugs are shallow given enough eyes, and yet one of our biggest mantra's sole purpose is to limit the number of eyes. We need people that are familiar with crypto codebases and its subtleties, because we need the reviewers for our established projects. And for this reason, we need people to write and publish crypto related code. Not so we can push another new, excitingly half-baked TLS stacks into a product, but to foster the code review process we all rely on.

Re:BearSSL – Smaller SSL/TLS by st3fan on Thursday November 03, 2016 @12:26PM (#12865385)
"The last thing the world needs is another immature SSL/TLS implementation"

Are you saying we should live forever with the established SSL libraries?

The only way software can mature, is to write it, release it, ship it, fix it, repeat.

Re:BearSSL – Smaller SSL/TLS by kakwa_ on Thursday November 03, 2016 @03:27PM (#12867152)
Implying you have the resources to do so correctly. Which was the issue with OpenSSL.

Completely unrelated but:

https://tls.mbed.org/

Another small footprint ssl/tls library, very readable code and a pleasure to work with.

Re:BearSSL – Smaller SSL/TLS by nailer on Friday November 04, 2016 @07:40AM (#12871792)
I'm not sure that was the issue with OpenSSL. According to the libressl folks the OpenSSL team were spending massive amounts of time on FIPS support at the expense of known serious issues the OpenBSD team had raised.
Re:BearSSL – Smaller SSL/TLS by skykooler on Thursday November 03, 2016 @11:24AM (#12864717)
And it seems the firewall here has made a clbuttic mistake, as that page is blocked due to the url containing "porn".
Re:BearSSL – Smaller SSL/TLS by StavrosK on Thursday November 03, 2016 @01:28PM (#12866022)
So you're pretty much out of luck if you want to visit a page that contains some analysis?
Re:BearSSL – Smaller SSL/TLS by andrewstuart2 on Thursday November 03, 2016 @02:47PM (#12866777)
Well, presumably, if the author's last name is Pornin and your spam filter is pretty basic (or overzealous).
Re:BearSSL – Smaller SSL/TLS by sjs382 on Thursday November 03, 2016 @03:11PM (#12867011)
"contains some analysis"
Re:BearSSL – Smaller SSL/TLS by isostatic on Thursday November 03, 2016 @03:07PM (#12866973)
I wonder how it would cope with Scunthorpe
Re:BearSSL – Smaller SSL/TLS by jamhan on Thursday November 03, 2016 @06:38PM (#12868699)
Or your name is "Olivia Gray". (True story, corporate mail filter blocked all that person's email)
Re:BearSSL – Smaller SSL/TLS by nailer on Friday November 04, 2016 @07:41AM (#12871796)
Why? 50 Shades? Something else?
Re:BearSSL – Smaller SSL/TLS by ConroyBumpus on Friday November 04, 2016 @08:55AM (#12872155)
Remove the space from her name and then look for a word in the middle that is commonly associated with spam emails.
Re:BearSSL – Smaller SSL/TLS by mcbain on Thursday November 03, 2016 @06:06PM (#12868431)
Re:BearSSL – Smaller SSL/TLS by captn3m0 on Thursday November 03, 2016 @02:48PM (#12866778)
security.se works over HTTPS, might bypass your firewall: https://security.stackexchange.com/users/655/thomas-pornin
Re:BearSSL – Smaller SSL/TLS by saosebastiao on Thursday November 03, 2016 @12:32PM (#12865446)
What sorts of applications are written for OS-less systems that require a TLS library?

EDIT: Thanks for the sincere responses. In retrospect my question might have appeared smarmy, but that wasn't my intent and I really appreciate the responses.

Re:BearSSL – Smaller SSL/TLS by jws on Thursday November 03, 2016 @12:59PM (#12865741)
Reasons for SSL:

• Security

• The server you speak with requires SSL

Reasons for no general purpose OS:

• Limited power (battery, solar)

• Extreme cost pressures (linux needs about $5 of hardware)

• Security (smaller code to audit)

• Extreme reliability requirements

So anything that ticks a bullet in each category is a candidate.

• Remote sensors

• Radio gateway, say LoRa to an internet server

• A device which keeps a secret for you and provides it to a server on command, perhaps something in a 2FA vein.

• Remotely triggerable actuators (door locks, parking lot lights)

Re:BearSSL – Smaller SSL/TLS by stavros on Thursday November 03, 2016 @01:30PM (#12866040)
I very badly need a TLS library in my embedded firmware so I can accept new firmware updates over HTTP.
Re:BearSSL – Smaller SSL/TLS by rthille on Thursday November 03, 2016 @02:06PM (#12866388)
You don't need TLS for that, you could simply use an HMAC and a shared secret, assuming you're not worried about people with physical access (and ability to get the secret) being able to create updates. Of course if you've got multiple instances of the device (not some hobby thing where they are all owned by you), then the secret for each device should be different so someone can't buy the device, determine the secret and then push updates to other people's devices.
Re:BearSSL – Smaller SSL/TLS by conradev on Thursday November 03, 2016 @02:13PM (#12866445)
Wouldn't signing each release with a private key be the simplest solution here?

(that can take many forms, but that general idea is how most software updates currently work)

Re:BearSSL – Smaller SSL/TLS by revelation on Thursday November 03, 2016 @07:09PM (#12868912)
RSA means big integer which means unhappy performance on devices that often don't even have floating point in hardware. I think elliptic curve could be faster?
Re:BearSSL – Smaller SSL/TLS by erichocean on Thursday November 03, 2016 @07:25PM (#12869030)
> I think elliptic curve could be faster?

Yes, EdDSA is faster, with 64 byte signatures. Recommended.

https://en.wikipedia.org/wiki/EdDSA

Re:BearSSL – Smaller SSL/TLS by adrianN on Thursday November 03, 2016 @04:28PM (#12867638)
Verifying a signature is not the simplest thing to do on hardware that doesn't even support a normal OS.
Re:BearSSL – Smaller SSL/TLS by conradev on Thursday November 03, 2016 @07:20PM (#12868999)
I see, that makes sense. Let's say you implement verification as:

1. Hashing the incoming data

2. Decrypting an attached signature

3. Verifying the decrypted and calculated hash are the same

Even though Step 2 would involve RSA or ECC, wouldn't Step 1 be the most expensive part regardless?

Re:BearSSL – Smaller SSL/TLS by baby on Thursday November 03, 2016 @05:15PM (#12868013)
Yup you are right.
Re:BearSSL – Smaller SSL/TLS by captn3m0 on Thursday November 03, 2016 @02:50PM (#12866804)
Not a very good idea, for the very reasons you point out. Signed releases with public keys, as conradev points out below is the far better approach.
Re:BearSSL – Smaller SSL/TLS by Matthias247 on Thursday November 03, 2016 @05:47PM (#12868308)
Besides of what was already mentioned:

Many automotive or industrial communication buses are currently unencrypted, but could surely benefit from encryption.

Re:BearSSL – Smaller SSL/TLS by tdb7893 on Thursday November 03, 2016 @12:37PM (#12865510)
probably could be useful in some small "internet of things" device
Re:BearSSL – Smaller SSL/TLS by throwaway2016a on Thursday November 03, 2016 @01:00PM (#12865747)
This. Internet of Things especially can benefit from adding TLS.
Re:BearSSL – Smaller SSL/TLS by Matthias247 on Thursday November 03, 2016 @05:33PM (#12868181)
However you would often want DTLS there, which is for example what CoAP (HTTP-like IoT protocol which is based on UDP) uses.
Re:BearSSL – Smaller SSL/TLS by novaleaf on Thursday November 03, 2016 @12:38PM (#12865518)
i would imagine as some sort of secure-boot or trusted hardware process.
Re:BearSSL – Smaller SSL/TLS by Florin_Andrei on Thursday November 03, 2016 @06:18PM (#12868524)
Lots of things with microcontrollers.
Re:BearSSL – Smaller SSL/TLS by _blrj on Thursday November 03, 2016 @12:18PM (#12865303)
> The last thing the world needs is another immature SSL/TLS implementation

Here's an interesting thought: you don't become mature without starting somewhere.

Re:BearSSL – Smaller SSL/TLS by stompin on Thursday November 03, 2016 @10:47AM (#12864349)
Is there any evidence that memcpy/memmove outperform malloc?
Re:BearSSL – Smaller SSL/TLS by mikeash on Thursday November 03, 2016 @03:21PM (#12867096)
That question doesn't make any sense. They don't do the same thing, so you can't compare their relative performance. What's faster: an Intel i7 or a BMW i8?

Malloc is potentially troublesome for two reasons. First, its performance is potentially unpredictable. It depends on the current state of the heap at the time of the call, which you can't know in advance except in some very rare situations. It can also fail entirely, and that is likewise unpredictable.

memcpy and memmove, ultimately being byte-copying loops, don't suffer from these problems. Their performance is consistent and they always succeed if your pointers and lengths are valid.

On PCs these days, the troubles of malloc don't matter much. You have so much performance margin that occasional slow calls don't matter, and virtual memory with a big address space means that it almost never fails. If it does fail, it's OK if the program crashes and you have to restart it. But many systems are much more constrained.

Re:BearSSL – Smaller SSL/TLS by bluejekyll on Thursday November 03, 2016 @10:49AM (#12864369)
I think the implication is that without malloc you will remove a slew of potential bugs related to memory management, making the software more stable.
Re:BearSSL – Smaller SSL/TLS by pilif on Thursday November 03, 2016 @11:22AM (#12864703)
IMHO you're converting your heap buffer overflows into stack buffer overflows which are even easier to exploit.
Re:BearSSL – Smaller SSL/TLS by thenewwazoo on Thursday November 03, 2016 @01:54PM (#12866285)
Stack usage is also much, much, much easier to characterize. In systems where stack depth is well-controlled (i.e. most embedded systems that don't have dynamic process/thread creation), very simple analysis will suffice to identify places where you blow your stack.
Re:BearSSL – Smaller SSL/TLS by usefulcat on Thursday November 03, 2016 @02:05PM (#12866376)
Not using the heap != everything is allocated on the stack. In situations where you want to avoid dynamic allocation, memory for most things that would otherwise have been dynamically allocated ends up being statically allocated at compile time.
Re:BearSSL – Smaller SSL/TLS by sigjuice on Thursday November 03, 2016 @03:41PM (#12867265)
Absolutely none of this is immune to buffer overflows.
Re:BearSSL – Smaller SSL/TLS by usefulcat on Thursday November 03, 2016 @04:49PM (#12867816)
No, but you're a lot more likely to be able to overwrite the return address via a stack-based buffer overflow, and that is generally a much more serious kind of attack.
Re:BearSSL – Smaller SSL/TLS by revelation on Thursday November 03, 2016 @07:15PM (#12868960)
Exploiting systems without dynamic memory is pretty meh.. that's some NSA level Stuxnet bespoke shit.

But no, judging from the code, you just give it one big fat I/O buffer that will usually come from .bss

Re:BearSSL – Smaller SSL/TLS by nwmcsween on Thursday November 03, 2016 @07:58PM (#12869257)
It depends, does malloc have some form of hardening? does the compiler insert stack canaries?
Re:BearSSL – Smaller SSL/TLS by stompin on Thursday November 03, 2016 @11:00AM (#12864483)
and moves and copies won't have potential for other memory management bugs? You'll still have memory management overhead and now additional complexity.
Re:BearSSL – Smaller SSL/TLS by moduspwnens14 on Thursday November 03, 2016 @11:12AM (#12864598)
At a high level, isn't this like implementing your own "malloc" and "free" that just pulls from your process's own memory pool instead of the OS? Or is there more to it than that?
Re:BearSSL – Smaller SSL/TLS by clarry on Thursday November 03, 2016 @11:15AM (#12864627)
No, it's just placing the appropriate structs and buffers on the stack (when not provided by the caller).

It does eliminate a certain couple classes of errors, and makes some others less likely.

I didn't read all the code, but I don't think it's using alloca or the like. So the stack allocation sizes are known at compile time, and bounded unless there's some recursion going on (which is unlikely).

Re:BearSSL – Smaller SSL/TLS by ajross on Thursday November 03, 2016 @11:07AM (#12864545)
Many real time systems and applications disallow heap usage, because they have formal verification requirements that can't be met with dynamic memory that may "run out" depending on run time state.
Re:BearSSL – Smaller SSL/TLS by reinar on Thursday November 03, 2016 @01:57PM (#12866305)
Exactly this.
Re:BearSSL – Smaller SSL/TLS by vvanders on Thursday November 03, 2016 @11:25AM (#12864725)
Almost always. Any sane implementation/system is going to need to zero memory so you're going to write 2x to it at a minimum.