Skip to content

Commit

Permalink
Mark newly generated key as valid and transfer validity in pgp_key_t …
Browse files Browse the repository at this point in the history
…constructor.
  • Loading branch information
ni4 committed Jan 24, 2022
1 parent f63f984 commit 21a0cb3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ pgp_generate_seckey(const rnp_keygen_crypto_params_t &crypto,
}
seckey.sec_protection.s2k.usage = PGP_S2KU_NONE;
seckey.material.secret = true;
seckey.material.validity.mark_valid();
/* fill the sec_data/sec_len */
if (encrypt_secret_key(&seckey, NULL, crypto.ctx->rng)) {
RNP_LOG("failed to fill sec_data");
Expand Down
2 changes: 2 additions & 0 deletions src/lib/pgp-key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,8 @@ pgp_key_t::pgp_key_t(const pgp_key_pkt_t &keypkt) : pkt_(keypkt)
RNP_LOG("failed to setup key fields");
throw rnp::rnp_exception(RNP_ERROR_BAD_PARAMETERS);
}
/* decryption resets validity */
pkt_.material.validity = keypkt.material.validity;
}
/* add rawpacket */
rawpkt_ = pgp_rawpacket_t(pkt_);
Expand Down

0 comments on commit 21a0cb3

Please sign in to comment.