1 import Base 2 import bend-osdev-bytes@0.1.0.0/bytes.bend as B 3 import bend-osdev-cipher-modes@0.1.0.0/cipher_modes.bend as M 4 import bend-osdev-cipher-modes@0.1.0.0/cbc.bend as CB 5 import ./legacy_ciphers.bend as L 6 import ./des.bend as D 7 import ./tdes.bend as T 8 import ./sm4.bend as S 9 import ./camellia.bend as C 10 import ./serpent.bend as P 11 import ./twofish.bend as F 12 import ./rc4.bend as R 13 import ./modes64.bend as X 14 import ./aria.bend as A 15 import ./cast6.bend as C6 16 import ./blowfish.bend as BF 17 import ./cast5.bend as C5 18 import ./tea.bend as TE 19 import ./xtea.bend as XT 20 import ./fcrypt.bend as FC 21 22 # The specifications' vectors, both ways (each line: the ciphertext, then the 23 # plaintext decrypted back), the 64-bit modes, every 128-bit cipher through 24 # cipher-modes' CBC over 32 KB (Serpent over 4 KB) both ways, every newer 25 # 64-bit cipher through modes64.bend's CBC over 16 KB both ways, RC4's 26 # vectors from RFC 6229 at every offset it lists, and the refusals. TEA and 27 # XTEA have no published vectors: their lines are ref/model.py's values. 28 29 def 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 38 def 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 45 def 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 52 def b128(o: B.Octets) -> M.CmBlock: 53 b128.of(M.CmBlock.of_octets(o)) 54 55 def 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 62 def b64(o: B.Octets) -> L.LcBlock64: 63 b64.of(L.LcBlock64.of_octets(o)) 64 65 def 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 72 def des_key(o: B.Octets) -> D.LcDesKey: 73 key(~D.LcDesKey, D.LcDes.key(o), D.LcDesKey{Nil{}}) 74 75 def 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 80 def 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 84 def 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 89 def 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 94 def 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 98 def 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 101 def 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 104 def 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 107 def 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 110 def 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 114 def aria_key(k: B.Octets) -> A.LcAriaKey: 115 key(~A.LcAriaKey, A.LcAria.key(k), A.LcAriaKey{Nil{}}) 116 117 def cast6_key(k: B.Octets) -> C6.LcCast6Key: 118 key(~C6.LcCast6Key, C6.LcCast6.key(k), C6.LcCast6Key{Nil{}}) 119 120 def blowfish_key(k: B.Octets) -> BF.LcBlowfishKey: 121 key(~BF.LcBlowfishKey, BF.LcBlowfish.key_any(k), BF.LcBlowfishKey{Nil{}}) 122 123 def cast5_key(k: B.Octets) -> C5.LcCast5Key: 124 key(~C5.LcCast5Key, C5.LcCast5.key(k), C5.LcCast5Key{Nil{}}) 125 126 def 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 129 def 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 132 def fcrypt_key(k: B.Octets) -> FC.LcFcryptKey: 133 key(~FC.LcFcryptKey, FC.LcFcrypt.key(k), FC.LcFcryptKey{Nil{}}) 134 135 def aria(k: B.Octets, b: B.Octets) -> String: 136 both(~A.LcAriaKey, ~A.LcAria.encrypt, ~A.LcAria.decrypt, aria_key(k), b128(b)) 137 138 def cast6(k: B.Octets, b: B.Octets) -> String: 139 both(~C6.LcCast6Key, ~C6.LcCast6.encrypt, ~C6.LcCast6.decrypt, cast6_key(k), b128(b)) 140 141 def blowfish(k: B.Octets, b: B.Octets) -> String: 142 both64(~BF.LcBlowfishKey, ~BF.LcBlowfish.encrypt, ~BF.LcBlowfish.decrypt, blowfish_key(k), b64(b)) 143 144 def cast5(k: B.Octets, b: B.Octets) -> String: 145 both64(~C5.LcCast5Key, ~C5.LcCast5.encrypt, ~C5.LcCast5.decrypt, cast5_key(k), b64(b)) 146 147 def 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 150 def 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 153 def fcrypt(k: B.Octets, b: B.Octets) -> String: 154 both64(~FC.LcFcryptKey, ~FC.LcFcrypt.encrypt, ~FC.LcFcrypt.decrypt, fcrypt_key(k), b64(b)) 155 156 def rc4_state(k: B.Octets) -> R.LcRc4State: 157 key(~R.LcRc4State, R.LcRc4.start(k), R.LcRc4State{L.LcLeaf{0}, 0, 0}) 158 159 def rc4_ks(k: B.Octets, n: Nat) -> B.Octets: 160 R.LcRc4.out_data(R.LcRc4.keystream(rc4_state(k), n)) 161 162 # 48 keystream bytes in pieces of 5, 30 and 13 163 def 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 169 def 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 # n bytes, byte i = 7i + 3 (mod 256) 173 def 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 180 def big(n: Nat) -> B.Octets: 181 B.Octets.of_list(big.go(n, 0, Nil{})) 182 183 def 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 186 def 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 193 def verdict(b: Bool) -> String: 194 match b: 195 case True{}: 196 "ok" 197 case False{}: 198 "differs" 199 200 def 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 207 def 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 212 def 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 215 def 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 218 def 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 221 def 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 224 def aria_cbc(k: B.Octets, n: Nat) -> String: 225 cbc128(~A.LcAriaKey, ~A.LcAria.encrypt, ~A.LcAria.decrypt, aria_key(k), n) 226 227 def cast6_cbc(k: B.Octets, n: Nat) -> String: 228 cbc128(~C6.LcCast6Key, ~C6.LcCast6.encrypt, ~C6.LcCast6.decrypt, cast6_key(k), n) 229 230 def 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 237 def 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 244 def 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 250 def 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 255 def blowfish_cbc(k: B.Octets, n: Nat) -> String: 256 cbc64(~BF.LcBlowfishKey, ~BF.LcBlowfish.encrypt, ~BF.LcBlowfish.decrypt, blowfish_key(k), n) 257 258 def cast5_cbc(k: B.Octets, n: Nat) -> String: 259 cbc64(~C5.LcCast5Key, ~C5.LcCast5.encrypt, ~C5.LcCast5.decrypt, cast5_key(k), n) 260 261 def tea_cbc(k: B.Octets, n: Nat) -> String: 262 cbc64(~TE.LcTeaKey, ~TE.LcTea.encrypt, ~TE.LcTea.decrypt, tea_key(False{}, k), n) 263 264 def xtea_cbc(k: B.Octets, n: Nat) -> String: 265 cbc64(~XT.LcXteaKey, ~XT.LcXtea.encrypt, ~XT.LcXtea.decrypt, xtea_key(False{}, k), n) 266 267 def fcrypt_cbc(k: B.Octets, n: Nat) -> String: 268 cbc64(~FC.LcFcryptKey, ~FC.LcFcrypt.encrypt, ~FC.LcFcrypt.decrypt, fcrypt_key(k), n) 269 270 # BEGIN GENERATED by gen/vectors.py: check 271 def main() -> IO(Unit): 272 do IO: 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 #|95f8a5e5dd31d900 8000000000000000 347 #|dd7f121ca5015619 4000000000000000 348 #|2e8653104f3834ea 2000000000000000 349 #|95a8d72813daa94d 0000000000000000 350 #|0eec1487dd8c26d5 0000000000000000 351 #|a826fd8ce53b855fcce21c8112256fe668d5c05dd9b6b900 54686520717566636b2062726f776e20666f78206a756d70 352 #|a5c282bad0de3774becd2e04386b589fb5057d8552fc4336 54686520717566636b2062726f776e20666f78206a756d70 353 #|c44862f70cf2fbdc9077d0909fa91b884cabd61fc58e0cbb 54686520717566636b2062726f776e20666f78206a756d70 354 #|681edf34d206965e86b3e94f536e4246 0123456789abcdeffedcba9876543210 355 #|67673138549669730857065648eabe43 0123456789abcdeffedcba9876543210 356 #|b4993401b3e996f84ee5cee7d79b09b9 0123456789abcdeffedcba9876543210 357 #|9acc237dff16d76c20ef7c919e3a7509 0123456789abcdeffedcba9876543210 358 #|3620b17ae6a993d09618b8768266bae9 00000000000000000000000000000000 359 #|264e5481eff42a4606abda06c0bfda3d 00000000000000000000000000000000 360 #|9f589f5cf6122c32b6bfec2f2ae8c35a 00000000000000000000000000000000 361 #|cfd1d2e5a9be9cdf501f13b892bd2248 00000000000000000000000000000000 362 #|37527be0052334b89f0cfccae87cfa20 00000000000000000000000000000000 363 #|b2396305f03dc027ccc3524a0a1118a8 364 #|6982944f18fc82d589c403a47a0d0919 365 #|28cb1132c96ce286421dcaadb8b69eae 366 #|1cfcf62b03eddb641d77dfcf7f8d8c93 367 #|42b7d0cdd918a8a33dd51781c81f4041 368 #|6459844432a7da923cfb3eb4980661f6 369 #|ec10327bde2beefd18f9277680457e22 370 #|eb62638d4f0ba1fe9fca20e05bf8ff2b 371 #|45129048e6a0ed0b56b490338f078da5 372 #|30abbcc7c20b01609f23ee2d5f6bb7df 373 #|3294f744d8f9790507e70f62e5bbceea 374 #|d8729db41882259bee4f825325f5a130 375 #|1eb14a0c13b3bf47fa2a0ba93ad45b8b 376 #|cc582f8ba9f265e2b1be9112e975d2d7 377 #|f2e30f9bd102ecbf75aaade9bc35c43c 378 #|ec0e11c479dc329dc8da7968fe965681 379 #|068326a2118416d21f9d04b2cd1ca050 380 #|ff25b58995996707e51fbdf08b34d875 381 #|b2396305f03dc027ccc3524a0a1118a86982944f18fc82d589c403a47a0d0919b68f78c28d15d822234c6cb8c5f6c4ac 382 #|d8729db41882259bee4f825325f5a130 383 #|c7b0c049ff58ac26268bf935616df708 ok 384 #|01fbbba61e8bb08562d59ae3b7e70881 ok 385 #|4e94b3aaf79619126bdd205de807393f ok 386 #|e0796b397d2533fc445f5c7ede7475fc ok 387 #|546259b8de55036c ok 388 #|d718fbd6ab644c739da95f3be6451778 00112233445566778899aabbccddeeff 389 #|26449c1805dbe7aa25a468ce263a9e79 00112233445566778899aabbccddeeff 390 #|f92bd7c79fb72e2f2b8f80c1972d24fc 00112233445566778899aabbccddeeff 391 #|c842a08972b43d20836c91d1b7530f6b 00000000000000000000000000000000 392 #|1b386c0210dcadcbdd0e41aa08a7a7e8 00000000000000000000000000000000 393 #|4f6a2038286897b9c9870136553317fa 00000000000000000000000000000000 394 #|4ef997456198dd78 0000000000000000 395 #|51866fd5b85ecb8a ffffffffffffffff 396 #|0aceab0fc6a0a28d 0123456789abcdef 397 #|f9ad597c49db005e fedcba9876543210 398 #|e9c2b70a1bc65cf3 fedcba9876543210 399 #|05044b62fa52d080 fedcba9876543210 400 #|238b4fe5847e44b2 0123456789abcdef 401 #|eb6a711a2c02271b 0123456789abcdef 402 #|7ac816d16e9b302e 0123456789abcdef 403 #|0e0900c73ef7ed41 0000000000000000 404 #|d8ed787477ec0680 123456789abcdef0 405 #|6da901760c539dce 0001020304050607 406 #|256004e1f55bc0c7 0001020304050607 407 #|54d51b2bf3e47e12 0001020304050607 408 #|ffc52d10a010010b 0001020304050607 409 #|78d7ea7c6c947995b6180eeac7c72206 ok 410 #|9d178a01c3e61f0a53d8f7cc64e542c6 ok 411 #|d9e0b4045974d5f0 ok 412 #|1701cdf260449014 ok 413 #|772d6e49fc2ee76e ok 414 #|246f9fb82837f395 ok 415 #|9469aaeb22e401db ok 416 #|bad iv 7 417 #|not whole blocks 9 418 # END GENERATED: check