xsha1-0.0.0: cryptanalysis of Blizzard's broken SHA-1 implementation.

Safe HaskellSafe-Infered

Numeric.Taint.Word32

Description

Arithmetic taint tracking.

Extension of Word32, that allows Unknown values to be used. Operations on known values are calculated as usual, while operations on unknowns are recorded in unsimplified form.

>>> let e = 1+5 `xor` U `lshift` 2
>>> e
X Xor (N 6) (X LShift U (N 2))
>>> pprint e
"(6^(?<<2))"
>>> 1+5 `xor` 0xBEEF `lshift` 2
N 195514

Intended for analysis of XSHA-1, so only supports the necessary primitives.

Synopsis

Documentation

data N Source

A numeric type extended to hold information about unknown values.

Constructors

N Word32

Numbers are still present.

U

Unknown values are marked with X.

X Op N N

Operations can be piled on top of them.

Instances

Eq N 
Data N 
Num N

Partial instance, since I only care about XSHA1 operations.

Ord N 
Show N 
Typeable N 
Arbitrary N

Just checking that it actually is an inverse...

Hm, this check kind of sucks - it didn't catch a negative sign bug. Welp.

Bits N

Partial instance, since I only care about XSHA1 operations.

data Op Source

Supported operators.

Constructors

LShift 
Xor 
Or 
And 
Add 
Sub 
Rot 

Instances

pprint :: N -> StringSource

Infix notation display of stored operations.

lshift :: N -> N -> NSource

The shift in the Bits class doesn't allow non-int shifts.

We'll be shifting by Unknown values, so have to use custom stuff.

Also we're following VC++ compiler behaviour, and shifting in modulo 32 for 32 bit unsigned numbers. This behaviour is undefined in the C standard.