News for hackers. Stuff that matters.
Re:How I implemented my own crypto by seanwilson on Thursday August 03, 2017 @07:11AM (#14918548)
> It was a fun read, except when all the C bugs were listed. It's getting tiresome to hear about folks writing nominally Important software in a language where it is extraordinarily difficult to get things absolutely correct, with paltry excuses such as "it needs to be fast" or "it needs to be portable [0] to a VAX-11/750."

Are there any practical alternatives when that kind of portability is needed?

What about transpiling to C? I know Haskell and OCaml can be made to compile their code into C code that you can then pass on to a C compiler.

Re:How I implemented my own crypto by w8rbt on Thursday August 03, 2017 @07:54AM (#14918740)
Yes, C++. It's the only practical, safe alternative to C.
Re:How I implemented my own crypto by wuch on Thursday August 03, 2017 @10:41AM (#14919986)
In C++, you can for example:

1. Manage resources with RAII (though, in C you could use non-portable attribute cleanup in similar manner).

2. Use type safe wrappers around builtin types like in [0] and [1].

3. Use containers with more extensive bounds checking and iteration validity checks [1].

This could help detect some of those bugs at runtime, or even possibly prevent them from being written in the first place. Use of uninitialized value could be prevented with types that require explicit initialization or have default one (Bug 1). Left shifting a negative value could have been caught at runtime (Bug 2). Bounds check could prevent uninitialized memory read (Bug 3) Type safe wrappers could prevent an accidental promotion from being written in the first place (Bug 5).

Though, you need to go out of your way to actually do all those things, not to mention that your code would integrate poorly with existing library ecosystem. IMHO choosing C++ alone doesn't improve safety of your programs compared to ones written in C all that much.

[0] https://github.com/foonathan/type_safe

[1] https://github.com/duneroadrunner/SaferCPlusPlus

Re:How I implemented my own crypto by seanwilson on Thursday August 03, 2017 @08:05AM (#14918803)
It's easier to write safer code in C++ but there's still many pitfalls and it's still a lot of effort. There's really nothing even remotely close to being practical?
Re:How I implemented my own crypto by dsacco on Thursday August 03, 2017 @08:55AM (#14919094)
Can you clarify what you mean by "practical"?