Skip to content

Commit

Permalink
Rename CertParams/BindingParams expiration property to key_expiration.
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Nov 10, 2024
1 parent 9051257 commit b5b6de2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/lib/keygen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,8 @@ CertParams::populate(pgp_userid_pkt_t &uid) const
void
CertParams::populate(pgp_signature_t &sig) const
{
if (expiration) {
sig.set_key_expiration(expiration);
if (key_expiration) {
sig.set_key_expiration(key_expiration);
}
if (primary) {
sig.set_primary_uid(true);
Expand Down
12 changes: 6 additions & 6 deletions src/lib/keygen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ class UserPrefs {

class CertParams {
public:
std::string userid; /* userid, required */
uint8_t flags{}; /* key flags */
uint32_t expiration{}; /* key expiration time (sec), 0 = no expiration */
UserPrefs prefs; /* user preferences, optional */
bool primary; /* mark this as the primary user id */
std::string userid; /* userid, required */
uint8_t flags{}; /* key flags */
uint32_t key_expiration{}; /* key expiration time (sec), 0 = no expiration */
UserPrefs prefs; /* user preferences, optional */
bool primary; /* mark this as the primary user id */

void check_defaults(const KeygenParams &params);

Expand All @@ -174,7 +174,7 @@ class CertParams {
class BindingParams {
public:
uint8_t flags{};
uint32_t expiration{};
uint32_t key_expiration{};

void check_defaults(const KeygenParams &params);
};
Expand Down
4 changes: 2 additions & 2 deletions src/lib/pgp-key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2579,8 +2579,8 @@ pgp_key_t::add_sub_binding(pgp_key_t & subsec,
pgp_signature_t sig;
sign_init(ctx.rng, sig, hash, ctx.time(), version());
sig.set_type(PGP_SIG_SUBKEY);
if (binding.expiration) {
sig.set_key_expiration(binding.expiration);
if (binding.key_expiration) {
sig.set_key_expiration(binding.key_expiration);
}
if (binding.flags) {
sig.set_key_flags(binding.flags);
Expand Down
18 changes: 9 additions & 9 deletions src/lib/rnp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4562,7 +4562,7 @@ parse_keygen_primary(rnp_ffi_t ffi,
return nullptr;

Check warning on line 4562 in src/lib/rnp.cpp

View check run for this annotation

Codecov / codecov/patch

src/lib/rnp.cpp#L4562

Added line #L4562 was not covered by tests
}
/* Parse common key/subkey fields */
if (!parse_keygen_common_fields(jso, cert.flags, cert.expiration, prot)) {
if (!parse_keygen_common_fields(jso, cert.flags, cert.key_expiration, prot)) {
return nullptr;

Check warning on line 4566 in src/lib/rnp.cpp

View check run for this annotation

Codecov / codecov/patch

src/lib/rnp.cpp#L4566

Added line #L4566 was not covered by tests
}
/* UserID */
Expand Down Expand Up @@ -4597,7 +4597,7 @@ parse_keygen_sub(rnp_ffi_t ffi,
return nullptr;
}
/* Parse common with primary key fields */
if (!parse_keygen_common_fields(jso, binding.flags, binding.expiration, prot)) {
if (!parse_keygen_common_fields(jso, binding.flags, binding.key_expiration, prot)) {
return nullptr;

Check warning on line 4601 in src/lib/rnp.cpp

View check run for this annotation

Codecov / codecov/patch

src/lib/rnp.cpp#L4601

Added line #L4601 was not covered by tests
}
/* Do not allow unknown extra fields */
Expand Down Expand Up @@ -4650,7 +4650,7 @@ gen_json_primary_key(rnp_ffi_t ffi,
bool protect)
{
rnp::CertParams cert;
cert.expiration = DEFAULT_KEY_EXPIRATION;
cert.key_expiration = DEFAULT_KEY_EXPIRATION;

auto keygen = parse_keygen_primary(ffi, jsoparams, cert, prot);
if (!keygen) {
Expand Down Expand Up @@ -4687,7 +4687,7 @@ gen_json_subkey(rnp_ffi_t ffi,
rnp::BindingParams binding;
rnp_key_protection_params_t prot = {};

binding.expiration = DEFAULT_KEY_EXPIRATION;
binding.key_expiration = DEFAULT_KEY_EXPIRATION;
auto keygen = parse_keygen_sub(ffi, jsoparams, binding, prot);
if (!keygen) {
return RNP_ERROR_BAD_PARAMETERS;
Expand Down Expand Up @@ -5101,7 +5101,7 @@ try {
*op = new rnp_op_generate_st(ffi, key_alg);
(*op)->primary = true;
(*op)->cert.flags = default_key_flags(key_alg, false);
(*op)->cert.expiration = DEFAULT_KEY_EXPIRATION;
(*op)->cert.key_expiration = DEFAULT_KEY_EXPIRATION;

return RNP_SUCCESS;
}
Expand Down Expand Up @@ -5134,7 +5134,7 @@ try {
*op = new rnp_op_generate_st(ffi, key_alg);
(*op)->primary = false;
(*op)->binding.flags = default_key_flags(key_alg, true);
(*op)->binding.expiration = DEFAULT_KEY_EXPIRATION;
(*op)->binding.key_expiration = DEFAULT_KEY_EXPIRATION;
(*op)->primary_sec = primary->sec;
(*op)->primary_pub = primary->pub;

Expand Down Expand Up @@ -5341,9 +5341,9 @@ try {
return RNP_ERROR_NULL_POINTER;
}
if (op->primary) {
op->cert.expiration = expiration;
op->cert.key_expiration = expiration;
} else {
op->binding.expiration = expiration;
op->binding.key_expiration = expiration;
}
return RNP_SUCCESS;
}
Expand Down Expand Up @@ -5704,7 +5704,7 @@ try {
rnp::CertParams info;
info.userid = uid;
info.flags = key_flags;
info.expiration = expiration;
info.key_expiration = expiration;
info.primary = primary;

/* obtain and unlok secret key */
Expand Down
4 changes: 2 additions & 2 deletions src/tests/key-add-userid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEST_F(rnp_tests, test_key_add_userid)
rnp::CertParams selfsig0;
selfsig0.userid = "added0";
selfsig0.flags = 0x2;
selfsig0.expiration = base_expiry;
selfsig0.key_expiration = base_expiry;
selfsig0.primary = false;
auto curtime = global_ctx.time();
global_ctx.set_time(curtime > SHA1_KEY_FROM ? SHA1_KEY_FROM - 100 : 0);
Expand Down Expand Up @@ -100,7 +100,7 @@ TEST_F(rnp_tests, test_key_add_userid)
rnp::CertParams selfsig1;
selfsig1.userid = "added1";
selfsig1.flags = 0xAB;
selfsig1.expiration = base_expiry + 1;
selfsig1.key_expiration = base_expiry + 1;
selfsig1.primary = 1;
key->add_uid_cert(selfsig1, PGP_HASH_SHA256, global_ctx);

Expand Down
4 changes: 2 additions & 2 deletions src/tests/key-validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ TEST_F(rnp_tests, test_key_expiry_direct_sig)
rnp::CertParams selfsig1 = {};
const char * boris = "Boris <boris@rnp>";
selfsig1.userid = boris;
selfsig1.expiration = 100;
selfsig1.key_expiration = 100;
selfsig1.primary = true;
key->add_uid_cert(selfsig1, PGP_HASH_SHA256, global_ctx);
key->revalidate(*secring);
Expand Down Expand Up @@ -704,7 +704,7 @@ TEST_F(rnp_tests, test_key_expiry_direct_sig)
/* add primary userid with 0 expiration */
selfsig1 = {};
selfsig1.userid = boris;
selfsig1.expiration = 0;
selfsig1.key_expiration = 0;
selfsig1.primary = true;
key->add_uid_cert(selfsig1, PGP_HASH_SHA256, global_ctx);
key->revalidate(*secring);
Expand Down

0 comments on commit b5b6de2

Please sign in to comment.