Skip to content
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

Update FFI API with key certification and signature customization functions. #2270

Merged
merged 8 commits into from
Sep 30, 2024
8 changes: 6 additions & 2 deletions include/rekey/rnp_key_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,20 @@ class KeyStore {

/**
* @brief Add signature of the specific key to the keystore, revalidating and refresing
* key's data. Currently supports only direct-key or subkey binding signature.
* key's data.
*
* @param keyfp key's fingerprint.
* @param sig signature packet.
* @param uid userid to which signature should be attached. If NULL then signature will be
* attached directly to the key.
* @param front set to true if signature should be added to the beginning of the signature
* list.
* @return pointer to the newly added signature or NULL if failed.
* @return pointer to the newly added signature or nullptr if error occurred (key not
* found, whatever else).
*/
pgp_subsig_t *add_key_sig(const pgp_fingerprint_t &keyfp,
const pgp_signature_t & sig,
const pgp_userid_pkt_t * uid,
bool front);

/**
Expand Down
355 changes: 354 additions & 1 deletion include/rnp/rnp.h

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/lib/pgp-key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,17 @@
return false;
}

uint32_t
pgp_key_t::uid_idx(const pgp_userid_pkt_t &uid) const
{
for (uint32_t idx = 0; idx < uids_.size(); idx++) {
if (uids_[idx].pkt == uid) {
return idx;
}
}
return PGP_UID_NONE;

Check warning on line 1075 in src/lib/pgp-key.cpp

View check run for this annotation

Codecov / codecov/patch

src/lib/pgp-key.cpp#L1075

Added line #L1075 was not covered by tests
}

void
pgp_key_t::del_uid(size_t idx)
{
Expand Down
1 change: 1 addition & 0 deletions src/lib/pgp-key.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ struct pgp_key_t {
size_t get_uid_idx(const pgp_userid_pkt_t &uid) const;
pgp_userid_t & add_uid(const pgp_transferable_userid_t &uid);
bool has_uid(const std::string &uid) const;
uint32_t uid_idx(const pgp_userid_pkt_t &uid) const;
void del_uid(size_t idx);
bool has_primary_uid() const;
uint32_t get_primary_uid() const;
Expand Down
Loading