Skip to content

tor-proto: Refactor the key derivation

Clara Engler requested to merge cve/arti:refactor-kdf into main

This commit refactors the key derivation, by applying the following:

  • The spaghetti slice creation with the hard-to-read boundaries got replaced by a closure, which accepts a length, advances the seed slice by n bytes as a side-effect, and returns the just advanced bytes
  • The use of .except got replaced by an .or, with the use of the already existing InvalidKDFOutputLength error, thereby removing a potential panic (probably not reachable in runtime though)
  • The conversion from a slice to a CircuitBinding got moved into a TryFrom trait of the appropriate data structure

Merge request reports

Loading