Hello World

Chris Angelico rosuav at gmail.com
Mon Dec 22 12:25:27 EST 2014


On Tue, Dec 23, 2014 at 3:23 AM, Grant Edwards <invalid at invalid.invalid> wrote:
>> Heh.  I once worked on a C++ project that included its own crypo code
>> (i.e. custom implementations of things like AES and SHA-1).
>
> Damn.  Should I ever start to do something like that (for a real
> product), I hereby officially request that somebody please try to slap
> some sense into me.

Likewise. And I'll happily do the slapping.

There's one exception. Writing your own crypto is a bad idea if that
means reimplementing AES... but if you want something that's effective
on completely different levels, sometimes it's best to write your own.
I had a project a while ago that needed some encryption work done, and
I implemented something that I described as "scarily effective". My
boss demanded that the debug code-execution feature be protected by a
password that would be strong even if someone could read the source
code, so I put together something that would hash the incoming
password, then check to see if the first two and last two bytes of the
hash were all the same byte value as the current hour-of-week (ranging
from 0 to 167). This is clearly more secure than simply embedding a
SHA256 hash in the source code, because you can't possibly
reverse-engineer it (since you don't even have the full hash). And
yes, this was 100% effective in convincing my boss that the code
executor was safely guarded. Since that was the goal, having several
lines of complex and opaque code was far better than a single line
that says "if hash(password)=='5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8':
do stuff", which is way too easy for someone to decode.

And it was, indeed, scarily effective. That lasted for a long time,
and any time there was a question about security, I could just point
to that and say "See? Safe."...

ChrisA



More information about the Python-list mailing list