fcrypt.bend checks
raw source on the hub · import bend-osdev-legacy-ciphers@0.1.0.0/fcrypt.bend as Fcrypt
FCrypt (T. Anderson, "Specification of FCrypt: Encryption for AFS Remote Procedure Calls", openafs-devel, December 2000): the 64-bit block cipher of AFS's rxkad, with a 64-bit key (56 bits used). It has DES's sixteen Feistel rounds (L, R) -> (R, L xor F(R, W_i)), with no initial or final permutation, its own round function F(R, K) = (S0[T<7:0>] | S1[T<15:8>] | S3[T<31:24>] | S2[T<23:16>]) >>> 5, T = R xor K (S0's byte the most significant), and its own key schedule: the key's 8 octets without their parity bits (bit 0) form a 56-bit value V, K[0] the most significant; W_i is V's low 32 bits, then V is rotated right by 11.
The rounds are legacy-ciphers.bend's Feistel rounds over F, so decryption (the rounds undone last to first, the specification's decryption) undoes encryption for every key and block whatever F is. The specification's PCBC mode is crypto's CrPcbc over this cipher.
4 imports
import Base import bend-osdev-bytes@0.1.0.0/bytes.bend as B import bend-osdev-word64@0.1.0.0/word64.bend as W import ./legacy_ciphers.bend as L
Types
type LcFcTabs source · line 164 · raw
Data
The four S-boxes, built once per key (internal)
LcFcTabs@s0:0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcTab -> @s1:0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcTab -> @s2:0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcTab -> @s3:0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcTab -> LcFcTabs
type LcFcRk source · line 171 · raw
Data
A round key: W_i and the S-boxes (internal)
LcFcRk@w:U32 -> @t:LcFcTabs -> LcFcRk
type LcFcryptKey source · line 205 · raw
Data
An FCrypt key: the sixteen round keys (opaque; built by LcFcrypt.key)
LcFcryptKey@rks:List<&2, LcFcRk> -> LcFcryptKey
Definitions
def fc.s0.list source · line 23 · raw
List<&2, U32>
BEGIN GENERATED by gen/tables.py: tables S0 (the FCrypt specification)
def fc.s1.list source · line 58 · raw
List<&2, U32>
S1 (the FCrypt specification)
def fc.s2.list source · line 93 · raw
List<&2, U32>
S2 (the FCrypt specification)
def fc.s3.list source · line 128 · raw
List<&2, U32>
S3 (the FCrypt specification)
def fc.tables source · line 167 · raw
LcFcTabs
def fc.f source · line 175 · raw
@k:LcFcRk -> @r:U32 -> U32
F(R, W_i)
def fc.v source · line 186 · raw
@xs:List<&2, U32> -> @v:0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64 -> 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64
the 56-bit value of the key bytes xs (parity bits dropped), onto v
def fc.rot11 source · line 194 · raw
@+v:0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64 -> 0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64
v rotated right by 11 within 56 bits
def fc.rks source · line 197 · raw
@n:Nat -> @+t:LcFcTabs -> @+v:0x44cf1401f78136bfc15c4c5be1cd20f0/word64.W64 -> List<&2, LcFcRk>
def fc.key.pick source · line 208 · raw
@ok:Bool -> @+xs:List<&2, U32> -> Result<&2, &2, 0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcError, LcFcryptKey>
def LcFcrypt.key source · line 218 · raw
@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcError, LcFcryptKey>
an 8-byte key (the parity bits are ignored)
def LcFcrypt.encrypt source · line 222 · raw
@k:LcFcryptKey -> @b:0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcBlock64 -> 0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcBlock64
def LcFcrypt.decrypt source · line 227 · raw
@k:LcFcryptKey -> @b:0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcBlock64 -> 0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcBlock64