def bf.set_s

bend-osdev-legacy-ciphers@0.1.0.0 · blowfish.bend:276

import bend-osdev-legacy-ciphers@0.1.0.0/blowfish.bend as Blowfish
import Base
import bend-osdev-legacy-ciphers@0.1.0.0/legacy_ciphers.bend as L

276# entry j of the S-box k (0 to 3) set to v
277def bf.set_s(t: LcBfTabs, k: Nat, +j: U32, v: U32) -> LcBfTabs:
278  match t:
279    case LcBfTabs{s1, s2, s3, s4}:
280      match k:
281        case 0n:
282          LcBfTabs{L.lc.tab.set(8n, s1, j, v), s2, s3, s4}
283        case 1n+k1:
284          match k1:
285            case 0n:
286              LcBfTabs{s1, L.lc.tab.set(8n, s2, j, v), s3, s4}
287            case 1n+k2:
288              match k2:
289                case 0n:
290                  LcBfTabs{s1, s2, L.lc.tab.set(8n, s3, j, v), s4}
291                case 1n+k3:
292                  LcBfTabs{s1, s2, s3, L.lc.tab.set(8n, s4, j, v)}

Uses (4)

Used by (1)