pqc-thunderbird / rnp

Manual clone of the repository https://github.com/rnpgp/rnp
Other
0 stars 0 forks source link

v6 signature salt hashing #89

Open TJ-91 opened 6 days ago

TJ-91 commented 6 days ago

@ni4 I realized that we did not properly hash the v6 signature salt in all cases. For key signatures it was fine but not for messages. This commit fixes it: https://github.com/pqc-thunderbird/rnp/commit/fc367798a5c20f02da6c8713508379b4b852dfef (branch update-draft-05)

I have a few questions / comments.

1) When creating HashList elements, I introduce a new variant to create hashes and initialize it with the salt value. Are you ok with how this is done? I had to make sure that every time we start hashing signature stuff, we already have the salt hashed.

2) I also implemented v6 One Pass Signatures in the previous commit and finalized / fixed it in this commit.

3) As you can see, I have an outcommented test for RFC 9580's clear signed message test vector (test_ffi_verify_v2_seipd_cleartext_test_vector). This one doesn't work since I have to properly change the add_hash_for_sig() call in cleartext_parse_headers(). I'm not sure what the best way would be to implement that here. There is no easy way to get the salt at this point, I think. Do you have an idea?

ni4 commented 3 days ago

@TJ-91 Looks like v6 brings more problems than I thought before. It completely disables possibility to process cleartext-signed messages in one pass, and I don't see an easy solution to this at the moment. Probably it should be postponed until we have practical need for this, or do you have it already?

Regarding HashList - I would suggest to add class HashListSalted: public HashList, and add all the required functionality via it (and field hashes_v6 in pgp_source_signed_param_t), protected by #ifdef ENABLE_CRYPTO_REFRESH, this should look cleaner.

P.S. Within current codebase I don't see salt comparison in matches_onepass(), which effectively disables the whole salt purpose :)

TJ-91 commented 3 days ago

@ni4 thanks for the reply.

It completely disables possibility to process cleartext-signed messages in one pass

Yes, I fear that's true. If I remember correctly, it was discussed at one point to add a header for the salt. However, I think the WG does not like the CSF very much (for security reasons) and therefore would rather discontinue it. At least that's what I remember and it somewhat explains why they do not think one-pass processing is an important issue.

Probably it should be postponed until we have practical need for this, or do you have it already?

I have not worked this out yet. I will try to let RNP fail gracefully for v6 cleartext signatures.

Regarding HashList - I would suggest to add class HashListSalted: public HashList

Thanks for the idea.

P.S. Within current codebase I don't see salt comparison in matches_onepass(), which effectively disables the whole salt purpose :)

https://github.com/pqc-thunderbird/rnp/commit/fc367798a5c20f02da6c8713508379b4b852dfef#diff-d4350f37d2fcd50abb8a5df457b8cb831028d1ceaeddcd75897928142ecb53d9R1315

ni4 commented 3 days ago

fc36779#diff-d4350f37d2fcd50abb8a5df457b8cb831028d1ceaeddcd75897928142ecb53d9R1315

Thanks for pointing at, was looking through already merged code.

TJ-91 commented 2 days ago

I've made some improvements, see https://github.com/pqc-thunderbird/rnp/commit/4af70e5fc40df74d868521ea79e6a2ff7ac3ea9b (rebased commit).

Feel free to leave comments. Otherwise I'll presumably create a new PR soon so all the changes will come up there anyway.