tdes.bend checks
raw source on the hub · import bend-osdev-legacy-ciphers@0.1.0.0/tdes.bend as Tdes
Triple DES, TDEA (NIST SP 800-67 Rev. 2, 2017): three DES keys, encryption E_K3(D_K2(E_K1(b))) and decryption D_K1(E_K2(D_K3(c))), with DES from des.bend. SP 800-67 Rev. 2 allows keying option 1 only (three distinct keys, 24 bytes); keying option 2 (K3 = K1, 16 bytes) is here for reading old data, as the kernel's des3_ede accepts it too. SP 800-67 also requires the keys to differ; that is not checked here.
4 imports
import Base import bend-osdev-bytes@0.1.0.0/bytes.bend as B import ./legacy_ciphers.bend as L import ./des.bend as D
Types
type LcTdesKey source · line 13 · raw
Data
A TDEA key bundle: three DES keys (opaque)
LcTdesKey@k1:0x7d16ec09f99b830428c8e2852af315f6/des.LcDesKey -> @k2:0x7d16ec09f99b830428c8e2852af315f6/des.LcDesKey -> @k3:0x7d16ec09f99b830428c8e2852af315f6/des.LcDesKey -> LcTdesKey
Definitions
def LcTdes.of_des source · line 17 · raw
@k1:0x7d16ec09f99b830428c8e2852af315f6/des.LcDesKey -> @k2:0x7d16ec09f99b830428c8e2852af315f6/des.LcDesKey -> @k3:0x7d16ec09f99b830428c8e2852af315f6/des.LcDesKey -> LcTdesKey
the bundle of three DES keys, in the order K1, K2, K3
def tdes.des_key source · line 20 · raw
@+xs:List<&2, U32> -> 0x7d16ec09f99b830428c8e2852af315f6/des.LcDesKey
def tdes.key3 source · line 23 · raw
@+xs:List<&2, U32> -> LcTdesKey
def tdes.key2 source · line 26 · raw
@+xs:List<&2, U32> -> LcTdesKey
def tdes.key.pick source · line 29 · raw
@three:Bool -> @two:Bool -> @+xs:List<&2, U32> -> Result<&2, &2, 0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcError, LcTdesKey>
def LcTdes.key3 source · line 39 · raw
@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcError, LcTdesKey>
keying option 1: K1, K2, K3 as 24 bytes
def LcTdes.key2 source · line 44 · raw
@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcError, LcTdesKey>
keying option 2: K1, K2 as 16 bytes, and K3 = K1
def LcTdes.key source · line 49 · raw
@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcError, LcTdesKey>
option 1 for 24 bytes, option 2 for 16
def LcTdes.encrypt source · line 54 · raw
@k:LcTdesKey -> @b:0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcBlock64 -> 0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcBlock64
def LcTdes.decrypt source · line 59 · raw
@k:LcTdesKey -> @b:0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcBlock64 -> 0x7d16ec09f99b830428c8e2852af315f6/legacy_ciphers.LcBlock64