PROOFPadded.pd.dc0: def of bend-osdev-cbc@0.1.0.0 Import: import bend-osdev-cbc@0.1.0.0/PROOF_padded.bend as PROOFPadded Lines 108-119 of bend-osdev-cbc@0.1.0.0/PROOF_padded.bend: https://jend.leeeet.dev/read.txt?path=bend-osdev-cbc@0.1.0.0/PROOF_padded.bend&start_line=108&end_line=119 import Base import bend-osdev-bytes@0.1.1.0/bytes.bend as B import bend-osdev-bytes@0.1.1.0/LAWS.bend as BL import bend-osdev-mode-core@0.1.0.0/mode_core.bend as M import bend-osdev-pkcs7@0.1.0.0/pkcs7.bend as P import bend-osdev-cbc@0.1.0.0/cbc.bend as C # an empty ciphertext cannot decrypt to M': its decryption is empty, and # unpadding the empty string is refused def pd.dc0(~K: Data, ~dec: K -> M.CmBlock -> M.CmBlock, +k: K, +iv: B.Octets, +mp: B.Octets, +m: B.Octets, e2: {P.Pkcs7.unpad(16n, mp) == Done{m} : Result<&2, &2, M.CmError, B.Octets>}, +c: B.Octets, eo: {Nat.is_lt(0n, B.Octets.len(c)) == False{} : Bool}, e1: {C.Cbc.decrypt(~K, ~dec, k, iv, c) == Done{mp} : Result<&2, &2, M.CmError, B.Octets>}) -> {C.Cbc.decrypt_padded(~K, ~dec, k, iv, c) == Done{m} : Result<&2, &2, M.CmError, B.Octets>}: # c is empty +z = pd.len0(B.Octets.len(c))(eo) +nl = pd.nil(B.Octets.to_list(c))(Equal.trans(Nat, B.len(B.Octets.to_list(c)), B.Octets.len(c), 0n, Equal.sym(Nat, B.Octets.len(c), B.len(B.Octets.to_list(c)), BL.octets_len_list(c)), z)) # so M' is empty +e3 = Equal.trans(Result<&2, &2, M.CmError, B.Octets>, C.cbc.d1.fast(~K, ~dec, k, C.cbc.iv(iv), Nil{}), C.Cbc.decrypt(~K, ~dec, k, iv, c), Done{mp}, Equal.cong(List<&2, U32>, Result<&2, &2, M.CmError, B.Octets>, l => C.cbc.d1.fast(~K, ~dec, k, C.cbc.iv(iv), l), Nil{}, B.Octets.to_list(c), Equal.sym(List<&2, U32>, B.Octets.to_list(c), Nil{}, nl)), e1) +z2 = pd.e0(~K, ~dec, k, C.cbc.iv(iv), mp)(e3) # and unpadding it is refused +e4 = Equal.trans(Result<&2, &2, M.CmError, B.Octets>, Fail{M.CmTooShort{0n}}, P.Pkcs7.unpad(16n, mp), Done{m}, Equal.cong(Nat, Result<&2, &2, M.CmError, B.Octets>, n => pk.ug(16n, mp, n, Nat.mod(n, 16n)), 0n, B.Octets.len(mp), Equal.sym(Nat, B.Octets.len(mp), 0n, z2)), e2) Empty.absurd({C.Cbc.decrypt_padded(~K, ~dec, k, iv, c) == Done{m} : Result<&2, &2, M.CmError, B.Octets>}, pd.fd(B.Octets, M.CmTooShort{0n}, m, e4)) Uses (28): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Empty.absurd https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.cong https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.sym https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.trans https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_lt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mod https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=bend-osdev-bytes@0.1.1.0/LAWS.bend&name=octets_len_list https://jend.leeeet.dev/definition.txt?path=bend-osdev-bytes@0.1.1.0/bytes.bend&name=Octets https://jend.leeeet.dev/definition.txt?path=bend-osdev-bytes@0.1.1.0/bytes.bend&name=Octets.len https://jend.leeeet.dev/definition.txt?path=bend-osdev-bytes@0.1.1.0/bytes.bend&name=Octets.to_list https://jend.leeeet.dev/definition.txt?path=bend-osdev-bytes@0.1.1.0/bytes.bend&name=len https://jend.leeeet.dev/definition.txt?path=bend-osdev-cbc@0.1.0.0/PROOF_padded.bend&name=pd.e0 https://jend.leeeet.dev/definition.txt?path=bend-osdev-cbc@0.1.0.0/PROOF_padded.bend&name=pd.fd https://jend.leeeet.dev/definition.txt?path=bend-osdev-cbc@0.1.0.0/PROOF_padded.bend&name=pd.len0 https://jend.leeeet.dev/definition.txt?path=bend-osdev-cbc@0.1.0.0/PROOF_padded.bend&name=pd.nil https://jend.leeeet.dev/definition.txt?path=bend-osdev-cbc@0.1.0.0/PROOF_padded.bend&name=pk.ug https://jend.leeeet.dev/definition.txt?path=bend-osdev-cbc@0.1.0.0/cbc.bend&name=Cbc.decrypt https://jend.leeeet.dev/definition.txt?path=bend-osdev-cbc@0.1.0.0/cbc.bend&name=Cbc.decrypt_padded https://jend.leeeet.dev/definition.txt?path=bend-osdev-cbc@0.1.0.0/cbc.bend&name=cbc.d1.fast https://jend.leeeet.dev/definition.txt?path=bend-osdev-cbc@0.1.0.0/cbc.bend&name=cbc.iv https://jend.leeeet.dev/definition.txt?path=bend-osdev-mode-core@0.1.0.0/mode_core.bend&name=CmBlock https://jend.leeeet.dev/definition.txt?path=bend-osdev-mode-core@0.1.0.0/mode_core.bend&name=CmError https://jend.leeeet.dev/definition.txt?path=bend-osdev-pkcs7@0.1.0.0/pkcs7.bend&name=Pkcs7.unpad