~/bend-docscommunity

inst_rc4.bend checks

raw source on the hub · import bend-osdev-crypto@0.1.0.0/inst_rc4.bend as Inst_rc4

RC4 as a stream cipher: legacy-ciphers' RC4 (RFC 6229's description), and RC4-drop[n] (RFC 4345). RC4 is broken (RFC 7465 forbids it in TLS): it is here to read and write what already uses it. The instance: ~R.LcRc4State, ~R.LcRc4Out, ~CrRc4.start, ~R.LcRc4.update, ~R.LcRc4.out_state, ~R.LcRc4.out_data and with the first n keystream bytes dropped, ~CrRc4.start_drop(~n) in place of ~CrRc4.start.

6 imports
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B
import bend-osdev-legacy-ciphers@0.1.0.0/legacy_ciphers.bend as L
import bend-osdev-legacy-ciphers@0.1.0.0/rc4.bend as R
import ./crypto.bend as Cr
import ./inst_lc.bend as LC

Definitions

def cr.rc4.start source · line 15 · raw

@+n:Nat -> @r:Result<&2, &2, 0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcError, 0x7d16ec09f99b830428c8e2852af315f6/rc4.LcRc4State> -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, 0x7d16ec09f99b830428c8e2852af315f6/rc4.LcRc4State>

def CrRc4.start source · line 22 · raw

@key:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @iv:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, 0x7d16ec09f99b830428c8e2852af315f6/rc4.LcRc4State>

the state for a key of 1 to 256 bytes (CrBadKeyLength otherwise); RC4 has no IV, so the IV must be empty (CrBadIvLength otherwise)

Templates

template CrRc4.start_drop source · line 26 · raw

@-n:Nat -> @key:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @iv:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, 0x7d16ec09f99b830428c8e2852af315f6/rc4.LcRc4State>

the same, with the first n keystream bytes dropped (RC4-drop[n])