Browse Source

key_reset_trust() can reset trust_personal_key() only.

key_compromized() cannot be reset now, because this would require to undo key revocation

The "delete from" implementation in pEpEngine.c was not a good idea. It was deleting too much:
trust with p≡p is between a key and a key owner (user_id).
doc_update_sequoia
Volker Birk 6 years ago
parent
commit
afe4a07cd7
4 changed files with 12 additions and 52 deletions
  1. +11
    -4
      src/keymanagement.c
  2. +1
    -1
      src/keymanagement.h
  3. +0
    -32
      src/pEpEngine.c
  4. +0
    -15
      src/pEpEngine.h

+ 11
- 4
src/keymanagement.c View File

@ -344,15 +344,22 @@ DYNAMIC_API PEP_STATUS key_reset_trust(
assert(session);
assert(ident);
assert(!ident->me);
assert(!EMPTY(ident->fpr));
assert(!EMPTY(ident->address));
assert(!EMPTY(ident->user_id));
if (!(session && ident && ident->fpr))
if (!(session && ident && !ident->me && ident->fpr && ident->address &&
ident->user_id))
return PEP_ILLEGAL_VALUE;
if (ident->me)
revoke_key(session, ident->fpr, NULL);
status = reset_trust(session, ident->fpr);
status = update_identity(session, ident);
if (status != PEP_STATUS_OK)
return status;
ident->comm_type = PEP_ct_unknown;
status = set_identity(session, ident);
return status;
}


+ 1
- 1
src/keymanagement.h View File

@ -140,7 +140,7 @@ DYNAMIC_API PEP_STATUS trust_personal_key(
);
// key_reset_trust() - undo key_compromized or trust_personal_key
// key_reset_trust() - undo trust_personal_key
//
// parameters:
// session (in) session to use


+ 0
- 32
src/pEpEngine.c View File

@ -19,7 +19,6 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
static const char *sql_get_trust;
static const char *sql_least_trust;
static const char *sql_mark_as_compromized;
static const char *sql_reset_trust;
bool in_first = false;
assert(sqlite3_threadsafe());
@ -200,8 +199,6 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
sql_least_trust = "select min(comm_type) from trust where pgp_keypair_fpr = ?1 ;";
sql_mark_as_compromized = "update trust set comm_type = 15 where pgp_keypair_fpr = ?1 ;";
sql_reset_trust = "delete from trust where pgp_keypair_fpr = ?1 ;";
}
int_result = sqlite3_prepare_v2(_session->db, sql_log, strlen(sql_log),
@ -244,10 +241,6 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
strlen(sql_mark_as_compromized), &_session->mark_compromized, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_reset_trust,
strlen(sql_reset_trust), &_session->reset_trust, NULL);
assert(int_result == SQLITE_OK);
status = init_cryptotech(_session, in_first);
if (status != PEP_STATUS_OK)
goto pep_error;
@ -734,31 +727,6 @@ DYNAMIC_API PEP_STATUS mark_as_compromized(
return PEP_STATUS_OK;
}
DYNAMIC_API PEP_STATUS reset_trust(
PEP_SESSION session,
const char *fpr
)
{
int result;
assert(session);
assert(fpr && fpr[0]);
if (!(session && fpr && fpr[0]))
return PEP_ILLEGAL_VALUE;
sqlite3_reset(session->reset_trust);
sqlite3_bind_text(session->reset_trust, 1, fpr, -1,
SQLITE_STATIC);
result = sqlite3_step(session->reset_trust);
sqlite3_reset(session->reset_trust);
if (result != SQLITE_DONE)
return PEP_CANNOT_SET_IDENTITY;
return PEP_STATUS_OK;
}
void pEp_free(void *p)
{
free(p);


+ 0
- 15
src/pEpEngine.h View File

@ -458,21 +458,6 @@ DYNAMIC_API PEP_STATUS mark_as_compromized(
);
// reset_trust() - reset trust marking for that key (compromized or trusted)
//
// parameters:
// session (in) session handle
// fpr (in) fingerprint of key to mark
DYNAMIC_API PEP_STATUS reset_trust(
PEP_SESSION session,
const char *fpr
);
// generate_keypair() - generate a new key pair and add it to the key ring
//
// parameters:


Loading…
Cancel
Save