robur-coop / ocaml-openpgp

WiP: RFC 4880 (OpenPGP) library and utilities in OCaml
GNU Affero General Public License v3.0
24 stars 4 forks source link

Represent signature subpackets in an ordered map #9

Open cfcs opened 7 years ago

cfcs commented 7 years ago

We only want one of each signature subpacket per signature, and we need to preserve ordering when parsing in order to compute correct hashes.

An ordered map of some sort would make this easier, and would get rid of the List.filter/List.for_all/List.exists mess. Typed functions to retrieve subpackets of a certain kind would also get rid of a lot of warnings.

TODO find some module that exposes a usable Map module, or write one.

hannesm commented 7 years ago

you mean ordering as "the binary data received"? I presume keeping the binary data around for hashing purposes might be a valid way to deal with that (but then, you have both subpackets which are parts of the signature and some which are not -- are they mixed?).

for the other topic "typed functions to retrieve subpackets" - I'd recommend to read up on the heterogenous map http://erratique.ch/software/hmap library (see an example usage in the test http://erratique.ch/repos/hmap/tree/test/test.ml), which allows you to have disjoint value (types) for each key.