check.bend
bend-osdev-legacy-ciphers@0.1.0.0 · 418 lines · 59 definitions
1import Base
2import bend-osdev-bytes@0.1.0.0/bytes.bend as B
3import bend-osdev-cipher-modes@0.1.0.0/cipher_modes.bend as M
4import bend-osdev-cipher-modes@0.1.0.0/cbc.bend as CB
5import bend-osdev-legacy-ciphers@0.1.0.0/legacy_ciphers.bend as L
6import bend-osdev-legacy-ciphers@0.1.0.0/des.bend as D
7import bend-osdev-legacy-ciphers@0.1.0.0/tdes.bend as T
8import bend-osdev-legacy-ciphers@0.1.0.0/sm4.bend as S
9import bend-osdev-legacy-ciphers@0.1.0.0/camellia.bend as C
10import bend-osdev-legacy-ciphers@0.1.0.0/serpent.bend as P
11import bend-osdev-legacy-ciphers@0.1.0.0/twofish.bend as F
12import bend-osdev-legacy-ciphers@0.1.0.0/rc4.bend as R
13import bend-osdev-legacy-ciphers@0.1.0.0/modes64.bend as X
14import bend-osdev-legacy-ciphers@0.1.0.0/aria.bend as A
15import bend-osdev-legacy-ciphers@0.1.0.0/cast6.bend as C6
16import bend-osdev-legacy-ciphers@0.1.0.0/blowfish.bend as BF
17import bend-osdev-legacy-ciphers@0.1.0.0/cast5.bend as C5
18import bend-osdev-legacy-ciphers@0.1.0.0/tea.bend as TE
19import bend-osdev-legacy-ciphers@0.1.0.0/xtea.bend as XT
20import bend-osdev-legacy-ciphers@0.1.0.0/fcrypt.bend as FC
21
22
23
24
25
26
27
28
29def err(e: L.LcError) -> String:
30 match e:
31 case L.LcBadKeyLength{n}:
32 "bad key " ++ Nat.show(n)
33 case L.LcBadIvLength{n}:
34 "bad iv " ++ Nat.show(n)
35 case L.LcNotBlockMultiple{n}:
36 "not whole blocks " ++ Nat.show(n)
37
38def show(r: Result<&2, &2, L.LcError, B.Octets>) -> String:
39 match r:
40 case Fail{e}:
41 err(e)
42 case Done{o}:
43 B.Octets.hex(o)
44
45def b128.of(m: Maybe<&2, M.CmBlock>) -> M.CmBlock:
46 match m:
47 case None{}:
48 M.CmBlock.zero()
49 case Some{b}:
50 b
51
52def b128(o: B.Octets) -> M.CmBlock:
53 b128.of(M.CmBlock.of_octets(o))
54
55def b64.of(m: Maybe<&2, L.LcBlock64>) -> L.LcBlock64:
56 match m:
57 case None{}:
58 L.LcBlock64.zero()
59 case Some{b}:
60 b
61
62def b64(o: B.Octets) -> L.LcBlock64:
63 b64.of(L.LcBlock64.of_octets(o))
64
65def key(~K: Data, r: Result<&2, &2, L.LcError, K>, d: K) -> K:
66 match r:
67 case Fail{e}:
68 d
69 case Done{k}:
70 k
71
72def des_key(o: B.Octets) -> D.LcDesKey:
73 key(~D.LcDesKey, D.LcDes.key(o), D.LcDesKey{Nil{}})
74
75def des(k: B.Octets, +b: B.Octets) -> String:
76 +dk = des_key(k)
77 +c = D.LcDes.encrypt(dk, b64(b))
78 L.LcBlock64.hex(c) ++ " " ++ L.LcBlock64.hex(D.LcDes.decrypt(dk, c))
79
80def tdes_key(o: B.Octets) -> T.LcTdesKey:
81 +z = {D.LcDesKey{Nil{}} : D.LcDesKey}
82 key(~T.LcTdesKey, T.LcTdes.key(o), T.LcTdes.of_des(z, z, z))
83
84def tdes_ecb(k: B.Octets, m: B.Octets) -> String:
85 +tk = tdes_key(k)
86 +c = X.Lc64.ecb_encrypt(~T.LcTdesKey, ~T.LcTdes.encrypt, tk, m)
87 show(c) ++ " " ++ show(Result.bind(&2, &2, L.LcError, B.Octets, B.Octets, c, x => X.Lc64.ecb_decrypt(~T.LcTdesKey, ~T.LcTdes.decrypt, tk, x)))
88
89def tdes_cbc(k: B.Octets, +iv: B.Octets, m: B.Octets) -> String:
90 +tk = tdes_key(k)
91 +c = X.Lc64.cbc_encrypt(~T.LcTdesKey, ~T.LcTdes.encrypt, tk, iv, m)
92 show(c) ++ " " ++ show(Result.bind(&2, &2, L.LcError, B.Octets, B.Octets, c, x => X.Lc64.cbc_decrypt(~T.LcTdesKey, ~T.LcTdes.decrypt, tk, iv, x)))
93
94def both(~K: Data, ~enc: K -> M.CmBlock -> M.CmBlock, ~dec: K -> M.CmBlock -> M.CmBlock, +k: K, b: M.CmBlock) -> String:
95 +c = enc(k, b)
96 M.CmBlock.hex(c) ++ " " ++ M.CmBlock.hex(dec(k, c))
97
98def sm4(k: B.Octets, b: B.Octets) -> String:
99 both(~S.LcSm4Key, ~S.LcSm4.encrypt, ~S.LcSm4.decrypt, key(~S.LcSm4Key, S.LcSm4.key(k), S.LcSm4Key{L.LcLeaf{0}, Nil{}}), b128(b))
100
101def camellia(k: B.Octets, b: B.Octets) -> String:
102 both(~C.LcCamelliaKey, ~C.LcCamellia.encrypt, ~C.LcCamellia.decrypt, key(~C.LcCamelliaKey, C.LcCamellia.key(k), C.LcCamelliaKey{Nil{}}), b128(b))
103
104def serpent(k: B.Octets, b: B.Octets) -> String:
105 both(~P.LcSerpentKey, ~P.LcSerpent.encrypt, ~P.LcSerpent.decrypt, key(~P.LcSerpentKey, P.LcSerpent.key(k), P.LcSerpentKey{Nil{}}), b128(b))
106
107def twofish(k: B.Octets, b: B.Octets) -> String:
108 both(~F.LcTwofishKey, ~F.LcTwofish.encrypt, ~F.LcTwofish.decrypt, key(~F.LcTwofishKey, F.LcTwofish.key(k), F.LcTwofishKey{Nil{}}), b128(b))
109
110def both64(~K: Data, ~enc: K -> L.LcBlock64 -> L.LcBlock64, ~dec: K -> L.LcBlock64 -> L.LcBlock64, +k: K, b: L.LcBlock64) -> String:
111 +c = enc(k, b)
112 L.LcBlock64.hex(c) ++ " " ++ L.LcBlock64.hex(dec(k, c))
113
114def aria_key(k: B.Octets) -> A.LcAriaKey:
115 key(~A.LcAriaKey, A.LcAria.key(k), A.LcAriaKey{Nil{}})
116
117def cast6_key(k: B.Octets) -> C6.LcCast6Key:
118 key(~C6.LcCast6Key, C6.LcCast6.key(k), C6.LcCast6Key{Nil{}})
119
120def blowfish_key(k: B.Octets) -> BF.LcBlowfishKey:
121 key(~BF.LcBlowfishKey, BF.LcBlowfish.key_any(k), BF.LcBlowfishKey{Nil{}})
122
123def cast5_key(k: B.Octets) -> C5.LcCast5Key:
124 key(~C5.LcCast5Key, C5.LcCast5.key(k), C5.LcCast5Key{Nil{}})
125
126def tea_key(be: Bool, k: B.Octets) -> TE.LcTeaKey:
127 key(~TE.LcTeaKey, TE.LcTea.key_with(Bool.not(be), 32n, k), TE.LcTeaKey{Nil{}})
128
129def xtea_key(be: Bool, k: B.Octets) -> XT.LcXteaKey:
130 key(~XT.LcXteaKey, XT.LcXtea.key_with(Bool.not(be), 32n, k), XT.LcXteaKey{Nil{}})
131
132def fcrypt_key(k: B.Octets) -> FC.LcFcryptKey:
133 key(~FC.LcFcryptKey, FC.LcFcrypt.key(k), FC.LcFcryptKey{Nil{}})
134
135def aria(k: B.Octets, b: B.Octets) -> String:
136 both(~A.LcAriaKey, ~A.LcAria.encrypt, ~A.LcAria.decrypt, aria_key(k), b128(b))
137
138def cast6(k: B.Octets, b: B.Octets) -> String:
139 both(~C6.LcCast6Key, ~C6.LcCast6.encrypt, ~C6.LcCast6.decrypt, cast6_key(k), b128(b))
140
141def blowfish(k: B.Octets, b: B.Octets) -> String:
142 both64(~BF.LcBlowfishKey, ~BF.LcBlowfish.encrypt, ~BF.LcBlowfish.decrypt, blowfish_key(k), b64(b))
143
144def cast5(k: B.Octets, b: B.Octets) -> String:
145 both64(~C5.LcCast5Key, ~C5.LcCast5.encrypt, ~C5.LcCast5.decrypt, cast5_key(k), b64(b))
146
147def tea(be: Bool, k: B.Octets, b: B.Octets) -> String:
148 both64(~TE.LcTeaKey, ~TE.LcTea.encrypt, ~TE.LcTea.decrypt, tea_key(be, k), b64(b))
149
150def xtea(be: Bool, k: B.Octets, b: B.Octets) -> String:
151 both64(~XT.LcXteaKey, ~XT.LcXtea.encrypt, ~XT.LcXtea.decrypt, xtea_key(be, k), b64(b))
152
153def fcrypt(k: B.Octets, b: B.Octets) -> String:
154 both64(~FC.LcFcryptKey, ~FC.LcFcrypt.encrypt, ~FC.LcFcrypt.decrypt, fcrypt_key(k), b64(b))
155
156def rc4_state(k: B.Octets) -> R.LcRc4State:
157 key(~R.LcRc4State, R.LcRc4.start(k), R.LcRc4State{L.LcLeaf{0}, 0, 0})
158
159def rc4_ks(k: B.Octets, n: Nat) -> B.Octets:
160 R.LcRc4.out_data(R.LcRc4.keystream(rc4_state(k), n))
161
162
163def rc4_pieces(k: B.Octets) -> String:
164 +o1 = R.LcRc4.keystream(rc4_state(k), 5n)
165 +o2 = R.LcRc4.keystream(R.LcRc4.out_state(o1), 30n)
166 +o3 = R.LcRc4.keystream(R.LcRc4.out_state(o2), 13n)
167 B.Octets.hex(B.Octets.append(R.LcRc4.out_data(o1), B.Octets.append(R.LcRc4.out_data(o2), R.LcRc4.out_data(o3))))
168
169def rc4_drop(k: B.Octets) -> String:
170 B.Octets.hex(R.LcRc4.out_data(R.LcRc4.keystream(key(~R.LcRc4State, R.LcRc4.start_drop(k, 1536n), R.LcRc4State{L.LcLeaf{0}, 0, 0}), 16n)))
171
172
173def big.go(n: Nat, +i: U32, acc: List<&2, U32>) -> List<&2, U32>:
174 match n:
175 case 0n:
176 B.rev(acc)
177 case 1n+p:
178 big.go(p, U32.add(i, 1), Con{U32.and(255, U32.add(U32.mul(i, 7), 3)), acc})
179
180def big(n: Nat) -> B.Octets:
181 B.Octets.of_list(big.go(n, 0, Nil{}))
182
183def iv16() -> B.Octets:
184 B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
185
186def last16(r: Result<&2, &2, M.CmError, B.Octets>) -> String:
187 match r:
188 case Fail{e}:
189 "fail"
190 case Done{+o}:
191 B.Octets.hex(B.Octets.drop(Nat.sub(B.Octets.len(o), 16n), o))
192
193def verdict(b: Bool) -> String:
194 match b:
195 case True{}:
196 "ok"
197 case False{}:
198 "differs"
199
200def same(r: Result<&2, &2, M.CmError, B.Octets>, +m: B.Octets) -> String:
201 match r:
202 case Fail{e}:
203 "fail"
204 case Done{o}:
205 verdict(B.Octets.is_eq(o, m))
206
207def cbc128(~K: Data, ~enc: K -> M.CmBlock -> M.CmBlock, ~dec: K -> M.CmBlock -> M.CmBlock, +k: K, n: Nat) -> String:
208 +m = big(n)
209 +c = CB.Cbc.encrypt(~K, ~enc, k, iv16(), m)
210 last16(c) ++ " " ++ same(Result.bind(&2, &2, M.CmError, B.Octets, B.Octets, c, x => CB.Cbc.decrypt(~K, ~dec, k, iv16(), x)), m)
211
212def sm4_cbc(k: B.Octets, n: Nat) -> String:
213 cbc128(~S.LcSm4Key, ~S.LcSm4.encrypt, ~S.LcSm4.decrypt, key(~S.LcSm4Key, S.LcSm4.key(k), S.LcSm4Key{L.LcLeaf{0}, Nil{}}), n)
214
215def camellia_cbc(k: B.Octets, n: Nat) -> String:
216 cbc128(~C.LcCamelliaKey, ~C.LcCamellia.encrypt, ~C.LcCamellia.decrypt, key(~C.LcCamelliaKey, C.LcCamellia.key(k), C.LcCamelliaKey{Nil{}}), n)
217
218def twofish_cbc(k: B.Octets, n: Nat) -> String:
219 cbc128(~F.LcTwofishKey, ~F.LcTwofish.encrypt, ~F.LcTwofish.decrypt, key(~F.LcTwofishKey, F.LcTwofish.key(k), F.LcTwofishKey{Nil{}}), n)
220
221def serpent_cbc(k: B.Octets, n: Nat) -> String:
222 cbc128(~P.LcSerpentKey, ~P.LcSerpent.encrypt, ~P.LcSerpent.decrypt, key(~P.LcSerpentKey, P.LcSerpent.key(k), P.LcSerpentKey{Nil{}}), n)
223
224def aria_cbc(k: B.Octets, n: Nat) -> String:
225 cbc128(~A.LcAriaKey, ~A.LcAria.encrypt, ~A.LcAria.decrypt, aria_key(k), n)
226
227def cast6_cbc(k: B.Octets, n: Nat) -> String:
228 cbc128(~C6.LcCast6Key, ~C6.LcCast6.encrypt, ~C6.LcCast6.decrypt, cast6_key(k), n)
229
230def last8(r: Result<&2, &2, L.LcError, B.Octets>) -> String:
231 match r:
232 case Fail{e}:
233 err(e)
234 case Done{+o}:
235 B.Octets.hex(B.Octets.drop(Nat.sub(B.Octets.len(o), 8n), o))
236
237def same64(r: Result<&2, &2, L.LcError, B.Octets>, +m: B.Octets) -> String:
238 match r:
239 case Fail{e}:
240 err(e)
241 case Done{o}:
242 verdict(B.Octets.is_eq(o, m))
243
244def tdes_cbc_big(k: B.Octets) -> String:
245 +tk = tdes_key(k)
246 +m = big(16384n)
247 +c = X.Lc64.cbc_encrypt(~T.LcTdesKey, ~T.LcTdes.encrypt, tk, B.Octets.zeros(8n), m)
248 last8(c) ++ " " ++ same64(Result.bind(&2, &2, L.LcError, B.Octets, B.Octets, c, x => X.Lc64.cbc_decrypt(~T.LcTdesKey, ~T.LcTdes.decrypt, tk, B.Octets.zeros(8n), x)), m)
249
250def cbc64(~K: Data, ~enc: K -> L.LcBlock64 -> L.LcBlock64, ~dec: K -> L.LcBlock64 -> L.LcBlock64, +k: K, n: Nat) -> String:
251 +m = big(n)
252 +c = X.Lc64.cbc_encrypt(~K, ~enc, k, B.Octets.zeros(8n), m)
253 last8(c) ++ " " ++ same64(Result.bind(&2, &2, L.LcError, B.Octets, B.Octets, c, x => X.Lc64.cbc_decrypt(~K, ~dec, k, B.Octets.zeros(8n), x)), m)
254
255def blowfish_cbc(k: B.Octets, n: Nat) -> String:
256 cbc64(~BF.LcBlowfishKey, ~BF.LcBlowfish.encrypt, ~BF.LcBlowfish.decrypt, blowfish_key(k), n)
257
258def cast5_cbc(k: B.Octets, n: Nat) -> String:
259 cbc64(~C5.LcCast5Key, ~C5.LcCast5.encrypt, ~C5.LcCast5.decrypt, cast5_key(k), n)
260
261def tea_cbc(k: B.Octets, n: Nat) -> String:
262 cbc64(~TE.LcTeaKey, ~TE.LcTea.encrypt, ~TE.LcTea.decrypt, tea_key(False{}, k), n)
263
264def xtea_cbc(k: B.Octets, n: Nat) -> String:
265 cbc64(~XT.LcXteaKey, ~XT.LcXtea.encrypt, ~XT.LcXtea.decrypt, xtea_key(False{}, k), n)
266
267def fcrypt_cbc(k: B.Octets, n: Nat) -> String:
268 cbc64(~FC.LcFcryptKey, ~FC.LcFcrypt.encrypt, ~FC.LcFcrypt.decrypt, fcrypt_key(k), n)
269
270
271def main() -> IO(Unit):
272 do IO<Unit>:
273 IO.print(des(B.Octets.of_list([1, 1, 1, 1, 1, 1, 1, 1]), B.Octets.of_list([128, 0, 0, 0, 0, 0, 0, 0])))
274 IO.print(des(B.Octets.of_list([1, 1, 1, 1, 1, 1, 1, 1]), B.Octets.of_list([64, 0, 0, 0, 0, 0, 0, 0])))
275 IO.print(des(B.Octets.of_list([1, 1, 1, 1, 1, 1, 1, 1]), B.Octets.of_list([32, 0, 0, 0, 0, 0, 0, 0])))
276 IO.print(des(B.Octets.of_list([128, 1, 1, 1, 1, 1, 1, 1]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0])))
277 IO.print(des(B.Octets.of_list([64, 1, 1, 1, 1, 1, 1, 1]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0])))
278 IO.print(tdes_ecb(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 35, 69, 103, 137, 171, 205, 239, 1, 69, 103, 137, 171, 205, 239, 1, 35]), B.Octets.of_list([84, 104, 101, 32, 113, 117, 102, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112])))
279 IO.print(tdes_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 35, 69, 103, 137, 171, 205, 239, 1, 69, 103, 137, 171, 205, 239, 1, 35]), B.Octets.of_list([246, 159, 36, 69, 223, 79, 155, 23]), B.Octets.of_list([84, 104, 101, 32, 113, 117, 102, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112])))
280 IO.print(tdes_ecb(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 35, 69, 103, 137, 171, 205, 239, 1]), B.Octets.of_list([84, 104, 101, 32, 113, 117, 102, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112])))
281 IO.print(sm4(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]), B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16])))
282 IO.print(camellia(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]), B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16])))
283 IO.print(camellia(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16, 0, 17, 34, 51, 68, 85, 102, 119]), B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16])))
284 IO.print(camellia(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16, 0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255]), B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16])))
285 IO.print(serpent(B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])))
286 IO.print(serpent(B.Octets.of_list([128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])))
287 IO.print(twofish(B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])))
288 IO.print(twofish(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16, 0, 17, 34, 51, 68, 85, 102, 119]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])))
289 IO.print(twofish(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16, 0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])))
290 IO.print(B.Octets.hex(B.Octets.slice(0n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
291 IO.print(B.Octets.hex(B.Octets.slice(16n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
292 IO.print(B.Octets.hex(B.Octets.slice(240n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
293 IO.print(B.Octets.hex(B.Octets.slice(256n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
294 IO.print(B.Octets.hex(B.Octets.slice(496n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
295 IO.print(B.Octets.hex(B.Octets.slice(512n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
296 IO.print(B.Octets.hex(B.Octets.slice(752n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
297 IO.print(B.Octets.hex(B.Octets.slice(768n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
298 IO.print(B.Octets.hex(B.Octets.slice(1008n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
299 IO.print(B.Octets.hex(B.Octets.slice(1024n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
300 IO.print(B.Octets.hex(B.Octets.slice(1520n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
301 IO.print(B.Octets.hex(B.Octets.slice(1536n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
302 IO.print(B.Octets.hex(B.Octets.slice(2032n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
303 IO.print(B.Octets.hex(B.Octets.slice(2048n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
304 IO.print(B.Octets.hex(B.Octets.slice(3056n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
305 IO.print(B.Octets.hex(B.Octets.slice(3072n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
306 IO.print(B.Octets.hex(B.Octets.slice(4080n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
307 IO.print(B.Octets.hex(B.Octets.slice(4096n, 16n, rc4_ks(B.Octets.of_list([1, 2, 3, 4, 5]), 4112n))))
308 IO.print(rc4_pieces(B.Octets.of_list([1, 2, 3, 4, 5])))
309 IO.print(rc4_drop(B.Octets.of_list([1, 2, 3, 4, 5])))
310 IO.print(sm4_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]), 32768n))
311 IO.print(camellia_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]), 32768n))
312 IO.print(twofish_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]), 32768n))
313 IO.print(serpent_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]), 4096n))
314 IO.print(tdes_cbc_big(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 35, 69, 103, 137, 171, 205, 239, 1, 69, 103, 137, 171, 205, 239, 1, 35])))
315 IO.print(aria(B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]), B.Octets.of_list([0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255])))
316 IO.print(aria(B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]), B.Octets.of_list([0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255])))
317 IO.print(aria(B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]), B.Octets.of_list([0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255])))
318 IO.print(cast6(B.Octets.of_list([35, 66, 187, 158, 250, 56, 84, 44, 10, 247, 86, 71, 242, 159, 97, 93]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])))
319 IO.print(cast6(B.Octets.of_list([35, 66, 187, 158, 250, 56, 84, 44, 190, 208, 172, 131, 148, 10, 194, 152, 186, 199, 122, 119, 23, 148, 40, 99]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])))
320 IO.print(cast6(B.Octets.of_list([35, 66, 187, 158, 250, 56, 84, 44, 190, 208, 172, 131, 148, 10, 194, 152, 141, 124, 71, 206, 38, 73, 8, 70, 28, 193, 181, 19, 122, 230, 182, 4]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])))
321 IO.print(blowfish(B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0])))
322 IO.print(blowfish(B.Octets.of_list([255, 255, 255, 255, 255, 255, 255, 255]), B.Octets.of_list([255, 255, 255, 255, 255, 255, 255, 255])))
323 IO.print(blowfish(B.Octets.of_list([254, 220, 186, 152, 118, 84, 50, 16]), B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239])))
324 IO.print(blowfish(B.Octets.of_list([240]), B.Octets.of_list([254, 220, 186, 152, 118, 84, 50, 16])))
325 IO.print(blowfish(B.Octets.of_list([240, 225, 210]), B.Octets.of_list([254, 220, 186, 152, 118, 84, 50, 16])))
326 IO.print(blowfish(B.Octets.of_list([240, 225, 210, 195, 180, 165, 150, 135, 120, 105, 90, 75, 60, 45, 30, 15, 0, 17, 34, 51, 68, 85, 102, 119]), B.Octets.of_list([254, 220, 186, 152, 118, 84, 50, 16])))
327 IO.print(cast5(B.Octets.of_list([1, 35, 69, 103, 18, 52, 86, 120, 35, 69, 103, 137, 52, 86, 120, 154]), B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239])))
328 IO.print(cast5(B.Octets.of_list([1, 35, 69, 103, 18, 52, 86, 120, 35, 69]), B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239])))
329 IO.print(cast5(B.Octets.of_list([1, 35, 69, 103, 18]), B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239])))
330 IO.print(fcrypt(B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0]), B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0])))
331 IO.print(fcrypt(B.Octets.of_list([17, 68, 119, 170, 221, 0, 51, 102]), B.Octets.of_list([18, 52, 86, 120, 154, 188, 222, 240])))
332 IO.print(tea(False{}, B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]), B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7])))
333 IO.print(xtea(False{}, B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]), B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7])))
334 IO.print(tea(True{}, B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]), B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7])))
335 IO.print(xtea(True{}, B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]), B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7])))
336 IO.print(aria_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]), 32768n))
337 IO.print(cast6_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]), 32768n))
338 IO.print(blowfish_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239]), 16384n))
339 IO.print(cast5_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]), 16384n))
340 IO.print(tea_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]), 16384n))
341 IO.print(xtea_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]), 16384n))
342 IO.print(fcrypt_cbc(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239]), 16384n))
343 IO.print(show(X.Lc64.cbc_encrypt(~D.LcDesKey, ~D.LcDes.encrypt, des_key(B.Octets.of_list([1, 1, 1, 1, 1, 1, 1, 1])), B.Octets.zeros(7n), B.Octets.zeros(8n))))
344 IO.print(show(X.Lc64.ecb_encrypt(~D.LcDesKey, ~D.LcDes.encrypt, des_key(B.Octets.of_list([1, 1, 1, 1, 1, 1, 1, 1])), B.Octets.zeros(9n))))
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418