]> git.ipfire.org Git - thirdparty/FORT-validator.git/commit
Remove the DER validator
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Wed, 15 May 2024 01:11:19 +0000 (19:11 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Wed, 15 May 2024 01:16:06 +0000 (19:16 -0600)
commitdeef7b7823f21914b17838f152a8bd510a348f54
tree371609a0cd840f7e82d16924669c567e76b81c51
parent295d0cf51934058036a7aca3c8f526ee5272a4d2
Remove the DER validator

rfc6488#3.1.l states we need to check "the signed object is DER
encoded." But that's not what this code was doing.

First, the validation was only kicking in specifically during the
decoding of the ContentInfo, which is just the outermost layer of the
signed object.

Second, the validation was incorrect. This seems to be the intended
algorithm in pseudocode:

boolean is_der_encoded(original_bytes):
der_bytes = der_encode(ber_decode(original_bytes));
return (original_bytes equal der_bytes);

This is what the code was actually doing:

boolean is_der_encoded(original_bytes):
der_bytes = der_encode(ber_decode(original_bytes));
return (original_bytes.length equals der_bytes.length);

These two quirks made the validation mostly a no-op.

There's also the issue that this implementation seems inefficient,
especially since Fort doesn't need to DER-encode anywhere else. By
checking the encoding while parsing, I would save a lot of memory
in addition to being able to delete that mess of encoding functions.

But I'm going to have to push that to the future. This is growing more
ambitious than I can afford during a release review, and given that the
code wasn't really doing anything productive in the first place, I'm not
losing much by simply axing it for now.
docs/incidence.md
src/asn1/content_info.c
src/asn1/decode.c
src/asn1/decode.h
src/asn1/signed_data.c
src/object/certificate.c
src/object/manifest.c
src/object/roa.c