fact stringlengths 5 19.5k | statement stringlengths 5 19.5k | proof stringlengths 0 4.29k | type stringclasses 7
values | symbolic_name stringlengths 0 36 | library stringclasses 13
values | filename stringclasses 71
values | imports listlengths 0 23 | deps listlengths 0 14 | docstring stringclasses 0
values | line_start int64 1 1.24k | line_end int64 1 1.24k | has_proof bool 2
classes | source_url stringclasses 1
value | commit stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dkatest : {ks, bs, n} (fin bs)
=> (Cipher ks bs, [n]([ks],[bs],[bs])) -> [n]([bs], Bit)
dkatest (cipher, kaKPCTs) =
[ (PT', PT' == PT) where PT' = cipher.decrypt Key CT
| (Key, PT, CT) <- kaKPCTs ] | dkatest : {ks, bs, n} (fin bs)
=> (Cipher ks bs, [n]([ks],[bs],[bs])) -> [n]([bs], Bit) | dkatest (cipher, kaKPCTs) =
[ (PT', PT' == PT) where PT' = cipher.decrypt Key CT
| (Key, PT, CT) <- kaKPCTs ] | function | dkatest | examples | examples/Test.cry | [
"Cipher"
] | [
"==",
"Bit",
"Cipher",
"Key",
"fin",
"ks"
] | null | 41 | 42 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
x : [8]
x = length (252 : [8]) | x : [8] | x = length (252 : [8]) | function | x | examples | examples/width.cry | [] | [
"length"
] | null | 1 | 1 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
roundtrip k ip = decrypt k (encrypt k ip) == ip | roundtrip k ip = decrypt k (encrypt k ip) == ip | property | roundtrip | examples | examples/xor_cipher.cry | [] | [
"==",
"decrypt",
"encrypt"
] | null | 7 | 7 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
encrypt : {a}(fin a) => [8] -> [a][8] -> [a][8]
encrypt key plaintext = [pt ^ key | pt <- plaintext ] | encrypt : {a}(fin a) => [8] -> [a][8] -> [a][8] | encrypt key plaintext = [pt ^ key | pt <- plaintext ] | function | encrypt | examples | examples/xor_cipher.cry | [] | [
"fin"
] | null | 1 | 1 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
decrypt : {a}(fin a) => [8] -> [a][8] -> [a][8]
decrypt key ciphertext = [ct ^ key | ct <- ciphertext ] | decrypt : {a}(fin a) => [8] -> [a][8] -> [a][8] | decrypt key ciphertext = [ct ^ key | ct <- ciphertext ] | function | decrypt | examples | examples/xor_cipher.cry | [] | [
"fin"
] | null | 4 | 4 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
xprop v = x v == 0 | xprop v = x v == 0 | property | xprop | examples | examples/zero_weird.cry | [] | [
"=="
] | null | 4 | 4 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
yprop v w = y v w == 0 | yprop v w = y v w == 0 | property | yprop | examples | examples/zero_weird.cry | [] | [
"=="
] | null | 9 | 9 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
x : {a}() => a -> [16]
x v = zero v | x : {a}() => a -> [16] | x v = zero v | function | x | examples | examples/zero_weird.cry | [] | [
"zero"
] | null | 1 | 1 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
y : [12] -> [4] -> [17]
y a b = zero a b | y : [12] -> [4] -> [17] | y a b = zero a b | function | y | examples | examples/zero_weird.cry | [] | [
"zero"
] | null | 6 | 6 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
t1 = x 13 | t1 = x 13 | function | t1 | examples | examples/zero_weird.cry | [] | [] | null | 11 | 11 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
t2 = y 2 3 | t2 = y 2 3 | function | t2 | examples | examples/zero_weird.cry | [] | [] | null | 12 | 12 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
N = 128 | N = 128 | type | N | examples.contrib | examples/contrib/A51.cry | [] | [] | null | 18 | 18 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
A51_correct = (A51(iv1, iv2, iv3)) == test_keystream | A51_correct = (A51(iv1, iv2, iv3)) == test_keystream | property | A51_correct | examples.contrib | examples/contrib/A51.cry | [] | [
"==",
"A51",
"iv3",
"test_keystream"
] | null | 52 | 52 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
A51_search x y z = A51(x,y,z) == test_keystream | A51_search x y z = A51(x,y,z) == test_keystream | property | A51_search | examples.contrib | examples/contrib/A51.cry | [] | [
"==",
"A51",
"test_keystream"
] | null | 53 | 53 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
A51_stream : [19] -> [22] -> [23] -> [inf]
A51_stream R1 R2 R3 = R1s ^ R2s ^ R3s
where
(R1s, R1f) = lfsrki <| x^^19 + x^^18 + x^^17 + x^^14 + 1 |> R1c R1
(R2s, R2f) = lfsrki <| x^^22 + x^^21 + 1 |> R2c R2
(R3s, R3f) = lfsrki <| x^^23 + x^^22 + x^^21 + x^^8 + 1 |> R3c R3
majvs = [ m... | A51_stream : [19] -> [22] -> [23] -> [inf] | A51_stream R1 R2 R3 = R1s ^ R2s ^ R3s
where
(R1s, R1f) = lfsrki <| x^^19 + x^^18 + x^^17 + x^^14 + 1 |> R1c R1
(R2s, R2f) = lfsrki <| x^^22 + x^^21 + 1 |> R2c R2
(R3s, R3f) = lfsrki <| x^^23 + x^^22 + x^^21 + x^^8 + 1 |> R3c R3
majvs = [ majv (r1@8) (r2@10) (r3@10) | r1 <- R1f | r2... | function | A51_stream | examples.contrib | examples/contrib/A51.cry | [] | [
"==",
"R1",
"R2",
"R3",
"lfsrki",
"majv"
] | null | 7 | 7 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
A51 : ([19], [22], [23]) -> [N]Bit
A51(reg1, reg2, reg3) = keystream
where
keystream = take`{N} (A51_stream reg1 reg2 reg3) | A51 : ([19], [22], [23]) -> [N]Bit | A51(reg1, reg2, reg3) = keystream
where
keystream = take`{N} (A51_stream reg1 reg2 reg3) | function | A51 | examples.contrib | examples/contrib/A51.cry | [] | [
"A51_stream"
] | null | 19 | 19 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
lfsrki_step : {d} (fin d, d >=1) => [d+1] -> Bit -> [d] -> [d]
lfsrki_step poly cond fill = fill'
where
feedback_bit = if(poly@0) then prefix (^) (reverse([False]#fill) && poly)
else error "polynomial does not have high-bit set."
fill' = if cond then [feedback_bit]#(take fill) else f... | lfsrki_step : {d} (fin d, d >=1) => [d+1] -> Bit -> [d] -> [d] | lfsrki_step poly cond fill = fill'
where
feedback_bit = if(poly@0) then prefix (^) (reverse([False]#fill) && poly)
else error "polynomial does not have high-bit set."
fill' = if cond then [feedback_bit]#(take fill) else fill | function | lfsrki_step | examples.contrib | examples/contrib/A51.cry | [] | [
"&&",
"Bit",
"error",
"fin",
"prefix",
"reverse",
"take"
] | null | 24 | 24 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
lfsrki : {d} (fin d, d >=1) => [d+1] -> [inf] -> [d] -> ([inf], [inf][d])
lfsrki poly conds init = (stream, fills)
where
lfsrki' = lfsrki_step poly
fills = [init] # [ lfsrki' c f | c <- conds | f <- fills]
stream = [ f!0 | f <- fills ] | lfsrki : {d} (fin d, d >=1) => [d+1] -> [inf] -> [d] -> ([inf], [inf][d]) | lfsrki poly conds init = (stream, fills)
where
lfsrki' = lfsrki_step poly
fills = [init] # [ lfsrki' c f | c <- conds | f <- fills]
stream = [ f!0 | f <- fills ] | function | lfsrki | examples.contrib | examples/contrib/A51.cry | [] | [
"fin",
"lfsrki_step"
] | null | 31 | 31 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
prefix f xs = ys!0
where ys = [xs@0] # [ f y x | y <- ys | x <- tail xs ] | prefix f xs = ys!0
where ys = [xs@0] # [ f y x | y <- ys | x <- tail xs ] | function | prefix | examples.contrib | examples/contrib/A51.cry | [] | [
"tail",
"xs"
] | null | 39 | 40 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
majv a b c = (a && b) || (a && c) || (b && c)
/***********************************************************************/ | majv a b c = (a && b) || (a && c) || (b && c)
/***********************************************************************/ | function | majv | examples.contrib | examples/contrib/A51.cry | [] | [
"&&",
"||"
] | null | 42 | 44 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
iv1 = 0b1010111011101011101 | iv1 = 0b1010111011101011101 | function | iv1 | examples.contrib | examples/contrib/A51.cry | [] | [] | null | 46 | 46 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
iv2 = 0b1010111011101010101110 | iv2 = 0b1010111011101010101110 | function | iv2 | examples.contrib | examples/contrib/A51.cry | [] | [] | null | 47 | 47 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
iv3 = 0b10100000111100110011011 | iv3 = 0b10100000111100110011011 | function | iv3 | examples.contrib | examples/contrib/A51.cry | [] | [] | null | 48 | 48 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
test_keystream = 0b00100100111010001110101110101100010100110111110101000101110000011101000111110101010000010011001111110101110001011010100000010001 | test_keystream = 0b00100100111010001110101110101100010100110111110101000101110000011101000111110101010000010011001111110101110001011010100000010001 | function | test_keystream | examples.contrib | examples/contrib/A51.cry | [] | [] | null | 50 | 50 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
passesTests = [test_B1_1, test_B1_2, test_B1_3] == ~zero | passesTests = [test_B1_1, test_B1_2, test_B1_3] == ~zero | property | passesTests | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"=="
] | null | 457 | 457 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
CAST128 : Cipher 128 64
CAST128 =
{ encrypt key pt = cast5_16 pt (expandKey key)
, decrypt key ct = cast5_16 ct (bireverse (expandKey key))
} | CAST128 : Cipher 128 64 | CAST128 =
{ encrypt key pt = cast5_16 pt (expandKey key)
, decrypt key ct = cast5_16 ct (bireverse (expandKey key))
} | function | CAST128 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"Cipher",
"bireverse",
"cast5_16",
"decrypt",
"encrypt",
"expandKey"
] | null | 9 | 9 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
CAST5_80 : Cipher 80 64
CAST5_80 =
{ encrypt key pt = cast5_12 pt (expandKey key)
, decrypt key ct = cast5_12 ct (bireverse (expandKey key))
} | CAST5_80 : Cipher 80 64 | CAST5_80 =
{ encrypt key pt = cast5_12 pt (expandKey key)
, decrypt key ct = cast5_12 ct (bireverse (expandKey key))
} | function | CAST5_80 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"Cipher",
"bireverse",
"cast5_12",
"decrypt",
"encrypt",
"expandKey"
] | null | 15 | 15 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
CAST5_64 : Cipher 64 64
CAST5_64 =
{ encrypt key pt = cast5_12 pt (expandKey key)
, decrypt key ct = cast5_12 ct (bireverse (expandKey key))
} | CAST5_64 : Cipher 64 64 | CAST5_64 =
{ encrypt key pt = cast5_12 pt (expandKey key)
, decrypt key ct = cast5_12 ct (bireverse (expandKey key))
} | function | CAST5_64 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"Cipher",
"bireverse",
"cast5_12",
"decrypt",
"encrypt",
"expandKey"
] | null | 21 | 21 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
CAST5_40 : Cipher 40 64
CAST5_40 =
{ encrypt key pt = cast5_12 pt (expandKey key)
, decrypt key ct = cast5_12 ct (bireverse (expandKey key))
} | CAST5_40 : Cipher 40 64 | CAST5_40 =
{ encrypt key pt = cast5_12 pt (expandKey key)
, decrypt key ct = cast5_12 ct (bireverse (expandKey key))
} | function | CAST5_40 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"Cipher",
"bireverse",
"cast5_12",
"decrypt",
"encrypt",
"expandKey"
] | null | 27 | 27 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
blockEncrypt : {k} (16 >= k, k >= 5) => ([k*8],[64]) -> [64]
blockEncrypt (k,plaintext) = if wid k > 80 then cast5_16 plaintext key else cast5_12 plaintext key
where wid (x:[w]_) = `w
key = expandKey k | blockEncrypt : {k} (16 >= k, k >= 5) => ([k*8],[64]) -> [64] | blockEncrypt (k,plaintext) = if wid k > 80 then cast5_16 plaintext key else cast5_12 plaintext key
where wid (x:[w]_) = `w
key = expandKey k | function | blockEncrypt | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
">=",
"cast5_12",
"cast5_16",
"expandKey"
] | null | 99 | 99 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
f1, f2, f3 : ([32],[32],[5]) -> [32] | f1, f2, f3 : ([32],[32],[5]) -> [32] | function | f1, | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"f3"
] | null | 104 | 104 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
expandKey : {k} (16 >= k, k >= 5) => [k*8] -> ([16][32],[16][5])
expandKey key = (firstHalf, secondHalf) where
(firstHalf, newkey) = halfKeySchedule paddedKey
secondHalf = [x@@[27..31] | x <- fst (halfKeySchedule newkey)]
fst (x, y) = x
paddedKey = key#zero | expandKey : {k} (16 >= k, k >= 5) => [k*8] -> ([16][32],[16][5]) | expandKey key = (firstHalf, secondHalf) where
(firstHalf, newkey) = halfKeySchedule paddedKey
secondHalf = [x@@[27..31] | x <- fst (halfKeySchedule newkey)]
fst (x, y) = x
paddedKey = key#zero | function | expandKey | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
">=",
"halfKeySchedule"
] | null | 117 | 117 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
halfKeySchedule : [128] -> ([16][32],[128])
halfKeySchedule key = ([K1,K2,K3,K4,K5,K6,K7,K8,K9,K10,K11,K12,K13,K14,K15,K16],newkey) where
[x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,xA,xB,xC,xD,xE,xF] = split key
[z0,z1,z2,z3] = split ((x0#x1#x2#x3) ^ s5@xD ^ s6@xF ^ s7@xC ^ s8@xE ^ s7@x8)
[z4,z5,z6,z7] = split ((x8#x9#... | halfKeySchedule : [128] -> ([16][32],[128]) | halfKeySchedule key = ([K1,K2,K3,K4,K5,K6,K7,K8,K9,K10,K11,K12,K13,K14,K15,K16],newkey) where
[x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,xA,xB,xC,xD,xE,xF] = split key
[z0,z1,z2,z3] = split ((x0#x1#x2#x3) ^ s5@xD ^ s6@xF ^ s7@xC ^ s8@xE ^ s7@x8)
[z4,z5,z6,z7] = split ((x8#x9#xA#xB) ^ s5@z0 ^ s6@z2 ^ s7@z1 ^ s8@z3 ^ s8@... | function | halfKeySchedule | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"s5",
"s6",
"s7",
"s8",
"split"
] | null | 124 | 124 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
s1, s2, s3, s4, s5, s6, s7, s8 : [256][32] | s1, s2, s3, s4, s5, s6, s7, s8 : [256][32] | function | s1, | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"s8"
] | null | 162 | 162 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
Key1 : [128]
Key1 = 0x0123456712345678234567893456789A | Key1 : [128] | Key1 = 0x0123456712345678234567893456789A | function | Key1 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 438 | 438 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
Key2 : [80]
Key2 = 0x01234567123456782345 | Key2 : [80] | Key2 = 0x01234567123456782345 | function | Key2 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 440 | 440 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
Key3 : [40]
Key3 = 0x0123456712 | Key3 : [40] | Key3 = 0x0123456712 | function | Key3 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 442 | 442 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
Plaintext : [64]
Plaintext = 0x0123456789ABCDEF | Plaintext : [64] | Plaintext = 0x0123456789ABCDEF | function | Plaintext | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 445 | 445 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
C1, C2, C3 : [64] | C1, C2, C3 : [64] | function | C1, | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"C3"
] | null | 448 | 448 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
bireverse (x,y) = (reverse x, reverse y) | bireverse (x,y) = (reverse x, reverse y) | function | bireverse | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"reverse"
] | null | 33 | 33 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
cast5_16 pt (km,kr) = result where
result = R16#L16
[L0,R0] = split pt
L1 = R0
R1 = L0 ^ f1 (R0, km@0, kr@0)
L2 = R1
R2 = L1 ^ f2 (R1, km@1, kr@1)
L3 = R2
R3 = L2 ^ f3 (R2, km@2, kr@2)
L4 = R3
R4 = L3 ^ f1 (R3, km@3, kr@3)
L5 = R4
R5 = ... | cast5_16 pt (km,kr) = result where
result = R16#L16
[L0,R0] = split pt
L1 = R0
R1 = L0 ^ f1 (R0, km@0, kr@0)
L2 = R1
R2 = L1 ^ f2 (R1, km@1, kr@1)
L3 = R2
R3 = L2 ^ f3 (R2, km@2, kr@2)
L4 = R3
R4 = L3 ^ f1 (R3, km@3, kr@3)
L5 = R4
R5 = ... | function | cast5_16 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"R1",
"R2",
"R3",
"R4",
"f1",
"f2",
"f3",
"split"
] | null | 35 | 69 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
cast5_12 pt (km,kr) = result where
result = R12#L12
[L0,R0] = split pt
L1 = R0
R1 = L0 ^ f1 (R0, km@0, kr@0)
L2 = R1
R2 = L1 ^ f2 (R1, km@1, kr@1)
L3 = R2
R3 = L2 ^ f3 (R2, km@2, kr@2)
L4 = R3
R4 = L3 ^ f1 (R3, km@3, kr@3)
L5 = R4
R5 = ... | cast5_12 pt (km,kr) = result where
result = R12#L12
[L0,R0] = split pt
L1 = R0
R1 = L0 ^ f1 (R0, km@0, kr@0)
L2 = R1
R2 = L1 ^ f2 (R1, km@1, kr@1)
L3 = R2
R3 = L2 ^ f3 (R2, km@2, kr@2)
L4 = R3
R4 = L3 ^ f1 (R3, km@3, kr@3)
L5 = R4
R5 = ... | function | cast5_12 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"R1",
"R2",
"R3",
"R4",
"f1",
"f2",
"f3",
"split"
] | null | 71 | 97 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
f1 (d, kmi, kri) = ((s1@ia ^ s2@ib) - s3@ic) + s4@id where
[ia,ib,ic,id] = split i
i = (kmi + d) <<< kri | f1 (d, kmi, kri) = ((s1@ia ^ s2@ib) - s3@ic) + s4@id where
[ia,ib,ic,id] = split i
i = (kmi + d) <<< kri | function | f1 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"<<<",
"id",
"s1",
"s2",
"s3",
"s4",
"split"
] | null | 105 | 107 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
f2 (d, kmi, kri) = ((s1@ia - s2@ib) + s3@ic) ^ s4@id where
[ia,ib,ic,id] = split i
i = (kmi ^ d) <<< kri | f2 (d, kmi, kri) = ((s1@ia - s2@ib) + s3@ic) ^ s4@id where
[ia,ib,ic,id] = split i
i = (kmi ^ d) <<< kri | function | f2 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"<<<",
"id",
"s1",
"s2",
"s3",
"s4",
"split"
] | null | 109 | 111 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
f3 (d, kmi, kri) = ((s1@ia + s2@ib) ^ s3@ic) - s4@id where
[ia,ib,ic,id] = split i
i = (kmi - d) <<< kri | f3 (d, kmi, kri) = ((s1@ia + s2@ib) ^ s3@ic) - s4@id where
[ia,ib,ic,id] = split i
i = (kmi - d) <<< kri | function | f3 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"<<<",
"id",
"s1",
"s2",
"s3",
"s4",
"split"
] | null | 113 | 115 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
s1 = [
0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, 0x9c004dd3, 0x6003e540, 0xcf9fc949,
0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0, 0x15c361d2, 0xc2e7661d, 0x22d4ff8e,
0x28683b6f, 0xc07fd059, 0xff2379c8, 0x775f50e2, 0x43c340d3, 0xdf2f8656, 0x887ca41a, 0xa2d2bd2d,
... | s1 = [
0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, 0x9c004dd3, 0x6003e540, 0xcf9fc949,
0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0, 0x15c361d2, 0xc2e7661d, 0x22d4ff8e,
0x28683b6f, 0xc07fd059, 0xff2379c8, 0x775f50e2, 0x43c340d3, 0xdf2f8656, 0x887ca41a, 0xa2d2bd2d,
... | function | s1 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 163 | 196 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
s2 = [
0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, 0xeec5207a, 0x55889c94, 0x72fc0651,
0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef, 0x5f0c0794, 0x18dcdb7d, 0xa1d6eff3,
0xa0b52f7b, 0x59e83605, 0xee15b094, 0xe9ffd909, 0xdc440086, 0xef944459, 0xba83ccb3, 0xe0c3cdfb,
... | s2 = [
0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, 0xeec5207a, 0x55889c94, 0x72fc0651,
0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef, 0x5f0c0794, 0x18dcdb7d, 0xa1d6eff3,
0xa0b52f7b, 0x59e83605, 0xee15b094, 0xe9ffd909, 0xdc440086, 0xef944459, 0xba83ccb3, 0xe0c3cdfb,
... | function | s2 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 197 | 230 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
s3 = [
0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, 0x369fe44b, 0x8c1fc644, 0xaececa90,
0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806, 0xf0ad0548, 0xe13c8d83, 0x927010d5,
0x11107d9f, 0x07647db9, 0xb2e3e4d4, 0x3d4f285e, 0xb9afa820, 0xfade82e0, 0xa067268b, 0x8272792e,
... | s3 = [
0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, 0x369fe44b, 0x8c1fc644, 0xaececa90,
0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806, 0xf0ad0548, 0xe13c8d83, 0x927010d5,
0x11107d9f, 0x07647db9, 0xb2e3e4d4, 0x3d4f285e, 0xb9afa820, 0xfade82e0, 0xa067268b, 0x8272792e,
... | function | s3 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 231 | 264 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
s4 = [
0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, 0x64ad8c57, 0x85510443, 0xfa020ed1,
0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43, 0x6497b7b1, 0xf3641f63, 0x241e4adf,
0x28147f5f, 0x4fa2b8cd, 0xc9430040, 0x0cc32220, 0xfdd30b30, 0xc0a5374f, 0x1d2d00d9, 0x24147b15,
... | s4 = [
0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, 0x64ad8c57, 0x85510443, 0xfa020ed1,
0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43, 0x6497b7b1, 0xf3641f63, 0x241e4adf,
0x28147f5f, 0x4fa2b8cd, 0xc9430040, 0x0cc32220, 0xfdd30b30, 0xc0a5374f, 0x1d2d00d9, 0x24147b15,
... | function | s4 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 265 | 298 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
s5 = [
0x7ec90c04, 0x2c6e74b9, 0x9b0e66df, 0xa6337911, 0xb86a7fff, 0x1dd358f5, 0x44dd9d44, 0x1731167f,
0x08fbf1fa, 0xe7f511cc, 0xd2051b00, 0x735aba00, 0x2ab722d8, 0x386381cb, 0xacf6243a, 0x69befd7a,
0xe6a2e77f, 0xf0c720cd, 0xc4494816, 0xccf5c180, 0x38851640, 0x15b0a848, 0xe68b18cb, 0x4caadeff,
... | s5 = [
0x7ec90c04, 0x2c6e74b9, 0x9b0e66df, 0xa6337911, 0xb86a7fff, 0x1dd358f5, 0x44dd9d44, 0x1731167f,
0x08fbf1fa, 0xe7f511cc, 0xd2051b00, 0x735aba00, 0x2ab722d8, 0x386381cb, 0xacf6243a, 0x69befd7a,
0xe6a2e77f, 0xf0c720cd, 0xc4494816, 0xccf5c180, 0x38851640, 0x15b0a848, 0xe68b18cb, 0x4caadeff,
... | function | s5 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 299 | 332 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
s6 = [
0xf6fa8f9d, 0x2cac6ce1, 0x4ca34867, 0xe2337f7c, 0x95db08e7, 0x016843b4, 0xeced5cbc, 0x325553ac,
0xbf9f0960, 0xdfa1e2ed, 0x83f0579d, 0x63ed86b9, 0x1ab6a6b8, 0xde5ebe39, 0xf38ff732, 0x8989b138,
0x33f14961, 0xc01937bd, 0xf506c6da, 0xe4625e7e, 0xa308ea99, 0x4e23e33c, 0x79cbd7cc, 0x48a14367,
... | s6 = [
0xf6fa8f9d, 0x2cac6ce1, 0x4ca34867, 0xe2337f7c, 0x95db08e7, 0x016843b4, 0xeced5cbc, 0x325553ac,
0xbf9f0960, 0xdfa1e2ed, 0x83f0579d, 0x63ed86b9, 0x1ab6a6b8, 0xde5ebe39, 0xf38ff732, 0x8989b138,
0x33f14961, 0xc01937bd, 0xf506c6da, 0xe4625e7e, 0xa308ea99, 0x4e23e33c, 0x79cbd7cc, 0x48a14367,
... | function | s6 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 333 | 366 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
s7 = [
0x85e04019, 0x332bf567, 0x662dbfff, 0xcfc65693, 0x2a8d7f6f, 0xab9bc912, 0xde6008a1, 0x2028da1f,
0x0227bce7, 0x4d642916, 0x18fac300, 0x50f18b82, 0x2cb2cb11, 0xb232e75c, 0x4b3695f2, 0xb28707de,
0xa05fbcf6, 0xcd4181e9, 0xe150210c, 0xe24ef1bd, 0xb168c381, 0xfde4e789, 0x5c79b0d8, 0x1e8bfd43,
... | s7 = [
0x85e04019, 0x332bf567, 0x662dbfff, 0xcfc65693, 0x2a8d7f6f, 0xab9bc912, 0xde6008a1, 0x2028da1f,
0x0227bce7, 0x4d642916, 0x18fac300, 0x50f18b82, 0x2cb2cb11, 0xb232e75c, 0x4b3695f2, 0xb28707de,
0xa05fbcf6, 0xcd4181e9, 0xe150210c, 0xe24ef1bd, 0xb168c381, 0xfde4e789, 0x5c79b0d8, 0x1e8bfd43,
... | function | s7 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 367 | 400 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
s8 = [
0xe216300d, 0xbbddfffc, 0xa7ebdabd, 0x35648095, 0x7789f8b7, 0xe6c1121b, 0x0e241600, 0x052ce8b5,
0x11a9cfb0, 0xe5952f11, 0xece7990a, 0x9386d174, 0x2a42931c, 0x76e38111, 0xb12def3a, 0x37ddddfc,
0xde9adeb1, 0x0a0cc32c, 0xbe197029, 0x84a00940, 0xbb243a0f, 0xb4d137cf, 0xb44e79f0, 0x049eedfd,
... | s8 = [
0xe216300d, 0xbbddfffc, 0xa7ebdabd, 0x35648095, 0x7789f8b7, 0xe6c1121b, 0x0e241600, 0x052ce8b5,
0x11a9cfb0, 0xe5952f11, 0xece7990a, 0x9386d174, 0x2a42931c, 0x76e38111, 0xb12def3a, 0x37ddddfc,
0xde9adeb1, 0x0a0cc32c, 0xbe197029, 0x84a00940, 0xbb243a0f, 0xb4d137cf, 0xb44e79f0, 0x049eedfd,
... | function | s8 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 401 | 436 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
C1 = 0x238B4FE5847E44B2 | C1 = 0x238B4FE5847E44B2 | function | C1 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 449 | 449 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
C2 = 0xEB6A711A2C02271B | C2 = 0xEB6A711A2C02271B | function | C2 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 450 | 450 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
C3 = 0x7AC816D16E9B302E | C3 = 0x7AC816D16E9B302E | function | C3 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [] | null | 451 | 451 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
test_B1_1 = blockEncrypt (Key1, Plaintext) == C1 | test_B1_1 = blockEncrypt (Key1, Plaintext) == C1 | function | test_B1_1 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"==",
"C1",
"Plaintext",
"blockEncrypt"
] | null | 453 | 453 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
test_B1_2 = blockEncrypt (Key2, Plaintext) == C2 | test_B1_2 = blockEncrypt (Key2, Plaintext) == C2 | function | test_B1_2 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"==",
"C2",
"Plaintext",
"blockEncrypt"
] | null | 454 | 454 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
test_B1_3 = blockEncrypt (Key3, Plaintext) == C3 | test_B1_3 = blockEncrypt (Key3, Plaintext) == C3 | function | test_B1_3 | examples.contrib | examples/contrib/CAST5.cry | [
"Cipher"
] | [
"==",
"C3",
"Plaintext",
"blockEncrypt"
] | null | 455 | 455 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
is_a_permutation a = (unique a) /\ (leq a (length(a)-1))
// Main> is_a_permutation (F:[10][4])
// True
/** Calculate F inverse */ | is_a_permutation a = (unique a) /\ (leq a (length(a)-1))
// Main> is_a_permutation (F:[10][4])
// True
/** Calculate F inverse */ | property | is_a_permutation | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
"/\\",
"length",
"leq",
"unique"
] | null | 12 | 16 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
is_inverse_permutation x a a' = ((x@@a)@@a') == x
// Main> is_inverse_permutation ([0..9]:[_][4]) (F:[10]_) (F':[10]_)
// True
/**
* The encryption (or cryptogram) E_K(M) of a message M in {0,1}^n by
* the key K = <K_1, K_2>, is performed by E
*/ | is_inverse_permutation x a a' = ((x@@a)@@a') == x
// Main> is_inverse_permutation ([0..9]:[_][4]) (F:[10]_) (F':[10]_)
// True
/**
* The encryption (or cryptogram) E_K(M) of a message M in {0,1}^n by
* the key K = <K_1, K_2>, is performed by E
*/ | property | is_inverse_permutation | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
"=="
] | null | 19 | 26 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
E_and_D_are_inverses K M = (D K (E K M)) == M
/******* Utilities *******/ | E_and_D_are_inverses K M = (D K (E K M)) == M
/******* Utilities *******/ | property | E_and_D_are_inverses | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
"=="
] | null | 41 | 44 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
E : {n} (fin n, n >= 1, width n >= width(n-1)) => ([n], [n]) -> [n] -> [n]
E (K1, K2) M = (M^K1)@@F ^ K2
/**
* The decryption of a cryptogram C in {0,1}^n, is performed by D
*/ | E : {n} (fin n, n >= 1, width n >= width(n-1)) => ([n], [n]) -> [n] -> [n] | E (K1, K2) M = (M^K1)@@F ^ K2
/**
* The decryption of a cryptogram C in {0,1}^n, is performed by D
*/ | function | E | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
">=",
"fin",
"width"
] | null | 27 | 27 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
D : {n} (fin n, n >= 1, width n >= width(n-1)) => ([n], [n]) -> [n] -> [n]
D (K1, K2) C = (C^K2)@@F' ^ K1
/**
* It is easy to verify that for every M in {0,1}^n and K in {0,1}^2n,
* the following identity holds D_K(E_K(M)) = M, i.e. D_K decrypts
* messages that were encrypted using E_K.
*/ | D : {n} (fin n, n >= 1, width n >= width(n-1)) => ([n], [n]) -> [n] -> [n] | D (K1, K2) C = (C^K2)@@F' ^ K1
/**
* It is easy to verify that for every M in {0,1}^n and K in {0,1}^2n,
* the following identity holds D_K(E_K(M)) = M, i.e. D_K decrypts
* messages that were encrypted using E_K.
*/ | function | D | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
">=",
"F'",
"fin",
"width"
] | null | 33 | 33 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
swap : {a, b} (fin a, a >= 1) => [a]b -> [width(a-1)] -> [width(a-1)] -> [a]b
swap xs a b = [ if(i == a) then xs@b
|(i == b) then xs@a
else xs@i
| i <- [0 .. a-1] ] | swap : {a, b} (fin a, a >= 1) => [a]b -> [width(a-1)] -> [width(a-1)] -> [a]b | swap xs a b = [ if(i == a) then xs@b
|(i == b) then xs@a
else xs@i
| i <- [0 .. a-1] ] | function | swap | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
"==",
">=",
"fin",
"xs"
] | null | 46 | 46 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
generate_random_permutation : {a} (fin a, a >= 1, width a >= width(a-1)) => [256] -> [a][width(a-1)]
generate_random_permutation seed = pss!0
where
indices = [ take `{width(a-1)} (b % `a) | b <- (random seed) : [a][width a] ]
pss = [ [0 .. a-1] ] # [ swap ps a b | ps <- pss | a <- [0 .. a-1] | b <- indices ] | generate_random_permutation : {a} (fin a, a >= 1, width a >= width(a-1)) => [256] -> [a][width(a-1)] | generate_random_permutation seed = pss!0
where
indices = [ take `{width(a-1)} (b % `a) | b <- (random seed) : [a][width a] ]
pss = [ [0 .. a-1] ] # [ swap ps a b | ps <- pss | a <- [0 .. a-1] | b <- indices ] | function | generate_random_permutation | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
">=",
"fin",
"random",
"swap",
"take",
"width"
] | null | 52 | 52 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
unique : {a, b} (fin a, fin b, a>=1) => [a][b] -> Bit
unique xs = [ exist x (i+1) | x <- xs | i <- [0...] ] == 0
where exist : [b] -> [width a] -> Bit
exist x i = if(i>=`a) then False
else if(x==(xs@i)) then True
else exist x (i+1) | unique : {a, b} (fin a, fin b, a>=1) => [a][b] -> Bit | unique xs = [ exist x (i+1) | x <- xs | i <- [0...] ] == 0
where exist : [b] -> [width a] -> Bit
exist x i = if(i>=`a) then False
else if(x==(xs@i)) then True
else exist x (i+1) | function | unique | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
"==",
"Bit",
"False",
"True",
"fin",
"xs"
] | null | 58 | 58 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
index_of : {a, b} (fin a, a>=1, Cmp b) => [a]b -> b -> [width(a-1)]
index_of xs a = (ret!0).1
where ret = [(False, 0)] # [ if(xs@i == a) then (True, i) else r
| i <- [0 .. a-1 ]
| r <- ret ] | index_of : {a, b} (fin a, a>=1, Cmp b) => [a]b -> b -> [width(a-1)] | index_of xs a = (ret!0).1
where ret = [(False, 0)] # [ if(xs@i == a) then (True, i) else r
| i <- [0 .. a-1 ]
| r <- ret ] | function | index_of | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
"==",
"Cmp",
"fin",
"xs"
] | null | 67 | 67 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
inverse_permutation : {a} (fin a, a >= 1) => [a][width(a-1)] -> [a][width(a-1)]
inverse_permutation perm = [ index_of perm i | i <- [0 .. a-1 ] ] | inverse_permutation : {a} (fin a, a >= 1) => [a][width(a-1)] -> [a][width(a-1)] | inverse_permutation perm = [ index_of perm i | i <- [0 .. a-1 ] ] | function | inverse_permutation | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
">=",
"fin",
"index_of"
] | null | 73 | 73 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
F = (generate_random_permutation 1942611697) | F = (generate_random_permutation 1942611697) | function | F | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
"generate_random_permutation"
] | null | 10 | 10 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
F' = inverse_permutation F | F' = inverse_permutation F | function | F' | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
"inverse_permutation"
] | null | 17 | 17 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
leq xs a = [ x <= a | x <- xs ] == ~0 | leq xs a = [ x <= a | x <- xs ] == ~0 | function | leq | examples.contrib | examples/contrib/EvenMansour.cry | [] | [
"<=",
"==",
"xs"
] | null | 65 | 65 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
testMisty1Encrypt = [ misty1Encrypt block EK
| block <- plaintext
] == ciphertext
where EK = keySchedule key
key = [0x00, 0x11 .. 0xff]
plaintext = [0x0123456789abcdef, 0xfedcba9876543210]
ciphertext = [0x8b1da5f... | testMisty1Encrypt = [ misty1Encrypt block EK
| block <- plaintext
] == ciphertext
where EK = keySchedule key
key = [0x00, 0x11 .. 0xff]
plaintext = [0x0123456789abcdef, 0xfedcba9876543210]
ciphertext = [0x8b1da5f... | property | testMisty1Encrypt | examples.contrib | examples/contrib/MISTY1.cry | [] | [
"==",
"keySchedule",
"misty1Encrypt"
] | null | 236 | 242 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
misty1Correct pt key = misty1Decrypt (misty1Encrypt pt EK) EK == pt
where EK = keySchedule key | misty1Correct pt key = misty1Decrypt (misty1Encrypt pt EK) EK == pt
where EK = keySchedule key | property | misty1Correct | examples.contrib | examples/contrib/MISTY1.cry | [] | [
"==",
"keySchedule",
"misty1Decrypt",
"misty1Encrypt"
] | null | 244 | 245 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
keySchedule : [16][8] -> [32][16]
keySchedule K = EK_1 # EK_2 # EK_3 # EK_4
where EK_1 = split (join K)
EK_2 = [ FI ek_1 ek_1_shifted
| ek_1 <- EK_1
| ek_1_shifted <- EK_1 <<< 1
]
EK_3 = [extend (drop`{7} ek_2) | ek_2 <- EK_2]
... | keySchedule : [16][8] -> [32][16] | keySchedule K = EK_1 # EK_2 # EK_3 # EK_4
where EK_1 = split (join K)
EK_2 = [ FI ek_1 ek_1_shifted
| ek_1 <- EK_1
| ek_1_shifted <- EK_1 <<< 1
]
EK_3 = [extend (drop`{7} ek_2) | ek_2 <- EK_2]
EK_4 = [extend (take`{7} ek_2) | e... | function | keySchedule | examples.contrib | examples/contrib/MISTY1.cry | [] | [
"<<<",
"FI",
"join",
"split"
] | null | 14 | 14 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
FO : [32] -> [8] -> [32][16] -> [32]
FO FO_IN k EK = (FO_OUT ! 0).1 # (FO_OUT ! 0).0
where FO_OUT = [(take FO_IN, drop FO_IN)] # [ f t0 t1
| f <- funcs
| (t0, t1) <- FO_OUT
... | FO : [32] -> [8] -> [32][16] -> [32] | FO FO_IN k EK = (FO_OUT ! 0).1 # (FO_OUT ! 0).0
where FO_OUT = [(take FO_IN, drop FO_IN)] # [ f t0 t1
| f <- funcs
| (t0, t1) <- FO_OUT
]
// t0, t1 as 16-b... | function | FO | examples.contrib | examples/contrib/MISTY1.cry | [] | [
"FI",
"drop",
"t1",
"take"
] | null | 28 | 28 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
FI : [16] -> [16] -> [16]
FI FI_IN FI_KEY = (FI_OUT ! 0).1 # (FI_OUT ! 0).0
where FI_OUT = [(take FI_IN, drop FI_IN)] # [ f d9 d7
| f <- funcs
| (d9, d7) <- FI_OUT
]... | FI : [16] -> [16] -> [16] | FI FI_IN FI_KEY = (FI_OUT ! 0).1 # (FI_OUT ! 0).0
where FI_OUT = [(take FI_IN, drop FI_IN)] # [ f d9 d7
| f <- funcs
| (d9, d7) <- FI_OUT
]
// d9 as 9-bit ... | function | FI | examples.contrib | examples/contrib/MISTY1.cry | [] | [
">>",
"S7",
"S9",
"drop",
"extend",
"take"
] | null | 48 | 48 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
S7 : [_][7]
S7 = [27, 50, 51, 90, 59, 16, 23, 84, 91, 26, 114, 115, 107,
44, 102, 73, 31, 36, 19, 108, 55, 46, 63, 74, 93, 15,
64, 86, 37, 81, 28, 4, 11, 70, 32, 13, 123, 53, 68,
66, 43, 30, 65, 20, 75, 121, 21, 111, 14, 85, 9, 54,
116, 12, 103, 83, 40... | S7 : [_][7] | S7 = [27, 50, 51, 90, 59, 16, 23, 84, 91, 26, 114, 115, 107,
44, 102, 73, 31, 36, 19, 108, 55, 46, 63, 74, 93, 15,
64, 86, 37, 81, 28, 4, 11, 70, 32, 13, 123, 53, 68,
66, 43, 30, 65, 20, 75, 121, 21, 111, 14, 85, 9, 54,
116, 12, 103, 83, 40, 10, 126, ... | function | S7 | examples.contrib | examples/contrib/MISTY1.cry | [] | [] | null | 64 | 64 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
S9 : [_][9]
S9 = [451, 203, 339, 415, 483, 233, 251, 53, 385, 185, 279, 491, 307,
9, 45, 211, 199, 330, 55, 126, 235, 356, 403, 472, 163, 286,
85, 44, 29, 418, 355, 280, 331, 338, 466, 15, 43, 48, 314,
229, 273, 312, 398, 99, 227, 200, 500, 27, 1, 157, 248, 416,
365, 499, 28, 326... | S9 : [_][9] | S9 = [451, 203, 339, 415, 483, 233, 251, 53, 385, 185, 279, 491, 307,
9, 45, 211, 199, 330, 55, 126, 235, 356, 403, 472, 163, 286,
85, 44, 29, 418, 355, 280, 331, 338, 466, 15, 43, 48, 314,
229, 273, 312, 398, 99, 227, 200, 500, 27, 1, 157, 248, 416,
365, 499, 28, 326, 125, 209, ... | function | S9 | examples.contrib | examples/contrib/MISTY1.cry | [] | [] | null | 76 | 76 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
FL : [32] -> [8] -> [32][16] -> [32]
FL FL_IN k EK =
if isEven k then
d0_even # d1_even
where d1_even = d1 ^ (d0 && (EK @ (k / 2)))
d0_even = d0 ^ (d1_even || (EK @ ((k / 2 + 6) % 8 + 8)))
else
d0_odd # d1_odd
where d1_odd = d1 ^ (d0 && (EK @ (((k - 1) / 2 + 2) % 8 ... | FL : [32] -> [8] -> [32][16] -> [32] | FL FL_IN k EK =
if isEven k then
d0_even # d1_even
where d1_even = d1 ^ (d0 && (EK @ (k / 2)))
d0_even = d0 ^ (d1_even || (EK @ ((k / 2 + 6) % 8 + 8)))
else
d0_odd # d1_odd
where d1_odd = d1 ^ (d0 && (EK @ (((k - 1) / 2 + 2) % 8 + 8)))
d0_odd = d0 ^ (d... | function | FL | examples.contrib | examples/contrib/MISTY1.cry | [] | [
"&&",
"drop",
"isEven",
"take",
"||"
] | null | 118 | 118 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
FLINV : [32] -> [8] -> [32][16] -> [32]
FLINV FL_IN k EK =
if isEven k then
d0_even # d1_even
where d0_even = d0 ^ (d1 || (EK @ ((k / 2 + 6) % 8 + 8)))
d1_even = d1 ^ (d0_even && (EK @ (k / 2)))
else
d0_odd # d1_odd
where d0_odd = d0 ^ (d1 || (EK @ (((k - 1) / 2 + 4... | FLINV : [32] -> [8] -> [32][16] -> [32] | FLINV FL_IN k EK =
if isEven k then
d0_even # d1_even
where d0_even = d0 ^ (d1 || (EK @ ((k / 2 + 6) % 8 + 8)))
d1_even = d1 ^ (d0_even && (EK @ (k / 2)))
else
d0_odd # d1_odd
where d0_odd = d0 ^ (d1 || (EK @ (((k - 1) / 2 + 4) % 8)))
d1_odd = d1 ^ (d0... | function | FLINV | examples.contrib | examples/contrib/MISTY1.cry | [] | [
"&&",
"drop",
"isEven",
"take",
"||"
] | null | 135 | 135 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
misty1Encrypt : [64] -> [32][16] -> [64]
misty1Encrypt P EK = (C ! 0).1 # (C ! 0).0
where
// 64-bit plaintext P is divided into the leftmost 32-bit D0 and the
// rightmost 32-bit D1
C = [(take P, drop P)] # [ f D0 D1
| f <- funcs
... | misty1Encrypt : [64] -> [32][16] -> [64] | misty1Encrypt P EK = (C ! 0).1 # (C ! 0).0
where
// 64-bit plaintext P is divided into the leftmost 32-bit D0 and the
// rightmost 32-bit D1
C = [(take P, drop P)] # [ f D0 D1
| f <- funcs
| (D0, D1) <- C
... | function | misty1Encrypt | examples.contrib | examples/contrib/MISTY1.cry | [] | [
"FL",
"FO",
"drop",
"take"
] | null | 156 | 156 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
misty1Decrypt : [64] -> [32][16] -> [64]
misty1Decrypt C EK = (P ! 0).0 # (P ! 0).1
where P = [(drop C, take C)] # [ f D0 D1
| f <- funcs
| (D0, D1) <- P
]
funcs : [_]([32] -> [32] -> ([32], [32... | misty1Decrypt : [64] -> [32][16] -> [64] | misty1Decrypt C EK = (P ! 0).0 # (P ! 0).1
where P = [(drop C, take C)] # [ f D0 D1
| f <- funcs
| (D0, D1) <- P
]
funcs : [_]([32] -> [32] -> ([32], [32]))
funcs = [\D0 D1 -> (FLINV D... | function | misty1Decrypt | examples.contrib | examples/contrib/MISTY1.cry | [] | [
"FLINV",
"FO",
"drop",
"take"
] | null | 195 | 195 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
extend : {total, n} (fin total, fin n, total >= n) => [n] -> [total]
extend n = zero # n | extend : {total, n} (fin total, fin n, total >= n) => [n] -> [total] | extend n = zero # n | function | extend | examples.contrib | examples/contrib/MISTY1.cry | [] | [
">=",
"fin",
"zero"
] | null | 226 | 226 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
isEven : {a} (fin a) => [a] -> Bool
isEven n = ~(n ! 0)
//
// Examples
// | isEven : {a} (fin a) => [a] -> Bool | isEven n = ~(n ! 0)
//
// Examples
// | function | isEven | examples.contrib | examples/contrib/MISTY1.cry | [] | [
"Bool",
"fin"
] | null | 229 | 229 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
Seg = [0x80] | Seg = [0x80] | type | Seg | examples.contrib | examples/contrib/mkrand.cry | [] | [] | null | 57 | 57 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
Field = [0x80]Seg
/* Canonical seed - a segment with a single True bit in the center */ | Field = [0x80]Seg
/* Canonical seed - a segment with a single True bit in the center */ | type | Field | examples.contrib | examples/contrib/mkrand.cry | [] | [] | null | 58 | 60 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
otp_encdec =
randXOR seedUnit "Deus Ex Machina" == c
/\ randXOR seedUnit c == "Deus Ex Machina"
where c = [ 0x28, 0x2b, 0x2c, 0xfa
, 0x92, 0xca, 0xb3, 0xcb
, 0xed, 0x50, 0xc2, 0x1b
, 0x11, 0x0e, 0x70] | otp_encdec =
randXOR seedUnit "Deus Ex Machina" == c
/\ randXOR seedUnit c == "Deus Ex Machina"
where c = [ 0x28, 0x2b, 0x2c, 0xfa
, 0x92, 0xca, 0xb3, 0xcb
, 0xed, 0x50, 0xc2, 0x1b
, 0x11, 0x0e, 0x70] | property | otp_encdec | examples.contrib | examples/contrib/mkrand.cry | [] | [
"/\\",
"==",
"randXOR",
"seedUnit"
] | null | 108 | 114 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
otp_involutive_32 msg = otp_involutive (msg : String 32) | otp_involutive_32 msg = otp_involutive (msg : String 32) | property | otp_involutive_32 | examples.contrib | examples/contrib/mkrand.cry | [] | [
"String",
"otp_involutive"
] | null | 119 | 119 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
seedUnit:Seg | seedUnit:Seg | function | seedUnit:Seg | examples.contrib | examples/contrib/mkrand.cry | [] | [] | null | 61 | 61 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
field: Seg -> [inf]Seg | field: Seg -> [inf]Seg | function | field: | examples.contrib | examples/contrib/mkrand.cry | [] | [
"Seg"
] | null | 68 | 68 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
sha30: Seg -> Seg | sha30: Seg -> Seg | function | sha30: | examples.contrib | examples/contrib/mkrand.cry | [] | [
"Seg"
] | null | 81 | 81 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
rands : Seg -> [inf]Seg
rands s = rest
where
rand p = p ^ (sha30 p)
rest = [rand s] # [rand x | x <- rest]
/* Break segments into bytes */ | rands : Seg -> [inf]Seg | rands s = rest
where
rand p = p ^ (sha30 p)
rest = [rand s] # [rand x | x <- rest]
/* Break segments into bytes */ | function | rands | examples.contrib | examples/contrib/mkrand.cry | [] | [
"Seg",
"sha30"
] | null | 88 | 88 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
randBytes : Seg -> [inf][8]
randBytes s = groupBy`{8} (join (rands s))
/* XOR a byte string into a random byte string, using the given seed */ | randBytes : Seg -> [inf][8] | randBytes s = groupBy`{8} (join (rands s))
/* XOR a byte string into a random byte string, using the given seed */ | function | randBytes | examples.contrib | examples/contrib/mkrand.cry | [] | [
"Seg",
"join",
"rands"
] | null | 96 | 96 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
randXOR : {n} Seg -> String n -> String n
randXOR seed src = [s ^ r | s <- src
| r <- randBytes seed
]
/* OTP example */ | randXOR : {n} Seg -> String n -> String n | randXOR seed src = [s ^ r | s <- src
| r <- randBytes seed
]
/* OTP example */ | function | randXOR | examples.contrib | examples/contrib/mkrand.cry | [] | [
"Seg",
"String",
"randBytes"
] | null | 101 | 101 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
otp_involutive : {len} (fin len) => String len -> Bit
otp_involutive msg = randXOR seedUnit (randXOR seedUnit msg) == msg | otp_involutive : {len} (fin len) => String len -> Bit | otp_involutive msg = randXOR seedUnit (randXOR seedUnit msg) == msg | function | otp_involutive | examples.contrib | examples/contrib/mkrand.cry | [] | [
"==",
"Bit",
"String",
"fin",
"randXOR",
"seedUnit"
] | null | 116 | 116 | true | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
seedUnit = (0 :[63]) # (1:[1]) # (0:[64])
/*
* Field - Unfold an application of Rule 30 to a seed
*/ | seedUnit = (0 :[63]) # (1:[1]) # (0:[64])
/*
* Field - Unfold an application of Rule 30 to a seed
*/ | function | seedUnit | examples.contrib | examples/contrib/mkrand.cry | [] | [] | null | 62 | 67 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
field s = new
where
new = [s] # [ rule30 row | row <- new]
rule30 r = [ a ^ (b || c) | a <- r >>> 1
| b <- r
| c <- r <<< 1
]
/* SHA30 - Use the input segment as the seed, generate two square fields,
* keep the center column of the ... | field s = new
where
new = [s] # [ rule30 row | row <- new]
rule30 r = [ a ^ (b || c) | a <- r >>> 1
| b <- r
| c <- r <<< 1
]
/* SHA30 - Use the input segment as the seed, generate two square fields,
* keep the center column of the ... | function | field | examples.contrib | examples/contrib/mkrand.cry | [] | [
"<<<",
">>>",
"||"
] | null | 69 | 80 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
sha30 s = take`{0x80} (drop`{0x80} [ r @ ((((length r) / 2)-1):[8]) | r <- field s])
/*
* RAND - Seed XOR (SHA30 Seed)
*/ | sha30 s = take`{0x80} (drop`{0x80} [ r @ ((((length r) / 2)-1):[8]) | r <- field s])
/*
* RAND - Seed XOR (SHA30 Seed)
*/ | function | sha30 | examples.contrib | examples/contrib/mkrand.cry | [] | [
"field",
"length"
] | null | 82 | 87 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
test1 = take (ks "Key") == [0xEB,0x9F,0x77,0x81,0xB7,0x34,0xCA,0x72,0xA7,0x19] | test1 = take (ks "Key") == [0xEB,0x9F,0x77,0x81,0xB7,0x34,0xCA,0x72,0xA7,0x19] | property | test1 | examples.contrib | examples/contrib/RC4.cry | [] | [
"==",
"ks",
"take"
] | null | 38 | 38 | false | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.