Hacker News new | ask | show | jobs
by charsii 1033 days ago
Crypto code should be written in assembly. Zero ambiguity, zero undefined behavior, 100% verifiable.
5 comments

ISAs regularly leave all kinds of behavior undefined when they think it doesn’t matter (such as the state of the arithmetic flags after operations that shouldn’t need to the tested).

(But this is also irrelevant: assembly can be completely wrong and exploitable while also being perfectly well defined.)

Readability suffers though, with negative impacts on maintainability and even verifiability (fewer people able/willing to examine the source code).
goto fail wasn't caused by ambiguity or undefined behavior. C's rules here are crystal clear, and conditional branches in assembly also do not make the following instructions condition (unless you're using delay slots à la SPARC).

Heartbleed also wasn't caused by ambiguity or undefined behavior, if you believe compiler writers.

Wouldn’t the low readability make it easier to slip a vulnerability in by splicing it out into several changes?
There's plenty of undefined behaviour at that level, just look at Spectre and Meltdown vulnerabilities for example.