| |
| |
| |
| |
| |
|
|
| theory MixColumnsVerify |
|
|
| use int.Int |
| use int.EuclideanDivision |
|
|
| |
| type uint8 = int |
| predicate valid_byte (n : int) = 0 <= n /\ n <= 255 |
|
|
| |
| function gf_xor (a b : uint8) : uint8 = let r = (a + b) mod 256 in |
| |
| |
| r |
|
|
| |
| axiom xor_comm : forall a b : uint8. gf_xor a b = gf_xor b a |
| axiom xor_assoc : forall a b c : uint8. gf_xor (gf_xor a b) c = gf_xor a (gf_xor b c) |
| axiom xor_self : forall a : uint8. gf_xor a a = 0 |
| axiom xor_zero : forall a : uint8. gf_xor a 0 = a |
| axiom xor_valid : forall a b : uint8. valid_byte a -> valid_byte b -> valid_byte (gf_xor a b) |
|
|
| |
| function xtime (b : uint8) : uint8 = |
| let shifted = (b * 2) mod 256 in |
| if b >= 128 then gf_xor shifted 27 else shifted |
|
|
| lemma xtime_valid : forall b : uint8. valid_byte b -> valid_byte (xtime b) |
|
|
| |
| |
| lemma xtime_linear : |
| forall a b : uint8. valid_byte a -> valid_byte b -> |
| xtime (gf_xor a b) = gf_xor (xtime a) (xtime b) |
|
|
| |
| function mix_row_0 (a0 a1 a2 a3 : uint8) : uint8 = |
| let t = gf_xor (gf_xor (gf_xor a0 a1) a2) a3 in |
| gf_xor (gf_xor a0 t) (xtime (gf_xor a0 a1)) |
|
|
| |
| goal CanonicalTestVector : |
| mix_row_0 212 191 93 48 = 4 |
|
|
| |
| goal ZeroColumn : |
| mix_row_0 0 0 0 0 = 0 |
|
|
| |
| goal RepeatedByte : |
| forall k : uint8. valid_byte k -> mix_row_0 k k k k = k |
|
|
| end |
|
|