ENGINE-137 (fixing side effect of optimization) update_identity: added key re-election when a key has been deleted from keyring. fixed test blacklist_accept_new_key_test using that feature

doc_update_sequoia
Edouard Tisserant 7 years ago
parent 38b6e9e090
commit 69a3d474ed

@ -151,37 +151,48 @@ DYNAMIC_API PEP_STATUS update_identity(
if (!dont_use_stored_fpr) {
temp_id->fpr = strdup(stored_identity->fpr);
assert(temp_id->fpr);
if (temp_id->fpr == NULL) {
status = PEP_OUT_OF_MEMORY;
goto exit_free;
}
/* Check stored comm_type */
PEP_comm_type _comm_type_key;
status = get_key_rating(session, temp_id->fpr, &_comm_type_key);
status = get_key_rating(session, stored_identity->fpr, &_comm_type_key);
assert(status != PEP_OUT_OF_MEMORY);
if (status == PEP_OUT_OF_MEMORY)
if (status == PEP_OUT_OF_MEMORY) {
goto exit_free;
if (_comm_type_key < PEP_ct_unconfirmed_encryption) {
/* if key not good anymore,
downgrade eventually trusted comm_type */
temp_id->comm_type = _comm_type_key;
}
if (status == PEP_KEY_NOT_FOUND){
/* stored key was deleted from keyring. any other candidate ?*/
status = elect_pubkey(session, temp_id);
if (status != PEP_STATUS_OK) {
goto exit_free;
} else {
_did_elect_new_key = 1;
}
} else {
/* otherwise take stored comm_type as-is */
temp_id->comm_type = stored_identity->comm_type;
if (temp_id->comm_type == PEP_ct_unknown) {
/* except if unknown */
temp_id->fpr = strdup(stored_identity->fpr);
assert(temp_id->fpr);
if (temp_id->fpr == NULL) {
status = PEP_OUT_OF_MEMORY;
goto exit_free;
}
if (_comm_type_key < PEP_ct_unconfirmed_encryption) {
/* if key not good anymore,
downgrade eventually trusted comm_type */
temp_id->comm_type = _comm_type_key;
} else {
/* otherwise take stored comm_type as-is */
temp_id->comm_type = stored_identity->comm_type;
if (temp_id->comm_type == PEP_ct_unknown) {
/* except if unknown */
temp_id->comm_type = _comm_type_key;
}
}
}
}
else {
status = elect_pubkey(session, temp_id);
if (status != PEP_STATUS_OK)
if (status != PEP_STATUS_OK){
goto exit_free;
else {
} else {
_did_elect_new_key = 1;
}
}

@ -89,10 +89,10 @@ int main() {
PEP_STATUS status13 = blacklist_delete(session, bl_fpr_1);
PEP_STATUS status14 = update_identity(session, blacklisted_identity);
status = delete_keypair(session, bl_fpr_1);
update_identity(session, blacklisted_identity);
status = delete_keypair(session, new_key);
update_identity(session, blacklisted_identity);
status = delete_keypair(session, bl_fpr_1);
update_identity(session, blacklisted_identity);
free_message(msg_ptr);
free_message(dest_msg);

Loading…
Cancel
Save