-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check userids for validity. #1337
Conversation
e140acf
to
83e6b24
Compare
Single test is failing for ruby-rnp, it should be addressed via or together with rnpgp/ruby-rnp#69 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I suggest to use std::set
in places where we need to keep unique keys
src/tests/key-store-search.cpp
Outdated
@@ -82,23 +83,22 @@ TEST_F(rnp_tests, test_key_store_search) | |||
for (size_t i = 0; i < ARRAY_SIZE(testdata); i++) { | |||
pgp_key_id_t keyid = {}; | |||
assert_true(rnp_hex_decode(testdata[i].keyid, keyid.data(), keyid.size())); | |||
list seen_keys = NULL; | |||
std::vector<pgp_key_t *> seen_keys; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more convenient to use std::set
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rrrooommmaaa That would require to satisfy https://en.cppreference.com/w/cpp/named_req/Compare, and if I understand correctly, pgp_key_t will not. Given that it's just for tests I don't see the reason to spend time on implement that. And, actually, now it works the same way as it worked before. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ni4 Aren't we comparing pointers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rrrooommmaaa Oh, my fault, somehow mislooked (how?) pointerness, sorry. Fixed and force-pushed.
src/tests/key-store-search.cpp
Outdated
} | ||
// keyid search (by_name) | ||
for (size_t i = 0; i < ARRAY_SIZE(testdata); i++) { | ||
list seen_keys = NULL; | ||
pgp_key_t *key = NULL; | ||
std::vector<pgp_key_t *> seen_keys; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more convenient to use std::set here
src/tests/key-store-search.cpp
Outdated
pgp_key_t * key = NULL; | ||
const char *userid = testdata[i].userids[uidn]; | ||
key = rnp_tests_key_search(store, userid); | ||
std::vector<pgp_key_t *> seen_keys; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more convenient to use std::set
here
83e6b24
to
b916ada
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Seems that there are some failures with |
It looks like this changes the behavior of |
Yes. Also userid will not be marked as primary if it is considered as invalid.
Usage of non-signed userid (or one with invalid signature) should be considered as a security issue, so I think we should not allow it to be used by default. However, API user still able to list all userids and check their validities. |
Shouldn't we at least throw some documentation updates in here? |
Agree |
b916ada
to
0145ad8
Compare
Agree as well, just got lost with those CI issues. Update documentation and force-pushed. |
958ddb9
to
5be4730
Compare
@dewyatt Should we merge this now? As I checked, only the single ruby-rnp test is failed. And CIFuzz shots it's leg on the container building steps. |
May as well yes |
This PR adds userid validity checks.
Userid is now considered as valid when:
This changes behavior to the following:
Also it adds few more functions which allows to retrieve uid-related data via uid handle.
Fixes #1022
Fixes #1126