[Cryptography] [FORGED] Re: How programming language design can help us write secure crypto code

Watson Ladd watsonbladd at gmail.com
Sun Nov 1 06:49:26 EST 2015


On Sun, Nov 1, 2015 at 12:57 AM, Bill Frantz <frantz at pwpconsult.com> wrote:
> On 10/31/15 at 8:57 PM, leichter at lrw.com (Jerry Leichter) wrote:
>
>> It appears the the gcc developers continue to operate in the world of the
>> 1970's.  Nice little utopia - unfortunately, hardly anyone actually lives
>> there.
>
>
> As a programmer from the 1970s, I never expect  the compiler to remove my
> paranoid tests as modern gcc seems to do. Of course, in the 1970s, most of
> my code was in assembler, where removal behind my back is much much less
> likely.
>
> I have always thought of C as a machine independent assembler. Having it
> remove code I have written completely blows that idea. And removing code is
> a poor way to trust the programmer.

Have you ever read Appel's compiler book? The myth of
"machine-independent assembler" ignores even the most basic of tricks
like register allocation.  For instance every assembler coder will
omit redundant loads and stores, and so will a compiler. But this
breaks the relation between stack locations and variables, in some
cases quite badly. There are lots of other examples, like instruction
scheduling, strength reduction, etc. A lot of the "machine independent
compiler myth" stems from the poor quality of C compilers.  Why do you
care what the assembly looks like, instead of what it does?

(And yes, this pass removes code. Assignments are completely
obliterated in an SSA transformation, and further munged by graph
coloring).

What you should do is think about the semantics of the programming
language, and realize compilers preserve those semantics. So what's
being called for is an introduction of 2's complement semantics for
signed integer overflow into C. Alternatively you could pick a
language that provides those semantics, or write a C compiler that
provides these semantics. But this whole complaint that "the compiler
doesn't do what I think it should" completely ignores what compilers
for some languages have *always* done.

>
> Cheers - Bill
>
> ---------------------------------------------------------------------------
> Bill Frantz        |"We used to quip that "password" is the most common
> 408-356-8506       | password. Now it's 'password1.' Who said users haven't
> www.pwpconsult.com | learned anything about security?" -- Bruce Schneier
>
>
> _______________________________________________
> The cryptography mailing list
> cryptography at metzdowd.com
> http://www.metzdowd.com/mailman/listinfo/cryptography



-- 
"Man is born free, but everywhere he is in chains".
--Rousseau.


More information about the cryptography mailing list