def pbkdf2_out_len

bend-osdev-crypto@0.1.0.0 · PROOF.bend:573

import bend-osdev-crypto@0.1.0.0/PROOF.bend as PROOF
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B
import bend-osdev-crypto@0.1.0.0/pbkdf2.bend as Pb

573# PBKDF2: the output generator gives n bytes, whatever the MAC (induction
574# on n), and its first n bytes are the same whatever comes after
575def pbkdf2_out_len(~K: Data, ~compute: K -> B.Octets -> B.Octets, n: Nat, cur: List<&2, U32>, +k: K, +salt: B.Octets, +c: Nat, +i: U32) -> {B.len(Pb.cr.pbkdf2.out(~K, ~compute, n, cur, k, salt, c, i)) == n : Nat}:
576  match n:
577    case 0n:
578      {==}
579    case 1n+p:
580      match cur:
581        case Con{h, t}:
582          %pbkdf2_out_len(~K, ~compute, p, t, k, salt, c, i) : {B.len(Pb.cr.pbkdf2.out(~K, ~compute, 1n+p, Con{h, t}, k, salt, c, i)) == 1n+_ : Nat}
583          {==}
584        case Nil{}:
585          %pbkdf2_out_len(~K, ~compute, p, Pb.cr.pbkdf2.tail(Pb.cr.pbkdf2.block(~K, ~compute, k, salt, c, U32.add(i, 1))), k, salt, c, U32.add(i, 1)) : {B.len(Pb.cr.pbkdf2.out(~K, ~compute, 1n+p, Nil{}, k, salt, c, i)) == 1n+_ : Nat}
586          {==}

Uses (9)

Used by (2)