doc_update_sequoia
vb 9 years ago
parent 6a6d2eb64f
commit 1369846eee

@ -37,30 +37,32 @@ DYNAMIC_API PEP_STATUS update_identity(
if (status == PEP_OUT_OF_MEMORY)
return PEP_OUT_OF_MEMORY;
PEP_comm_type _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)
return PEP_OUT_OF_MEMORY;
if (stored_identity) {
PEP_comm_type _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)
return PEP_OUT_OF_MEMORY;
if (EMPTY(identity->fpr)) {
identity->fpr = strdup(stored_identity->fpr);
assert(identity->fpr);
if (identity->fpr == NULL)
return PEP_OUT_OF_MEMORY;
identity->fpr_size = stored_identity->address_size;
if (_comm_type_key < PEP_ct_unconfirmed_encryption) {
identity->comm_type = _comm_type_key;
}
else {
identity->comm_type = stored_identity->comm_type;
}
}
else /* !EMPTY(identity->fpr) */ {
stringlist_t *keylist;
status = find_keys(session, identity->fpr, &keylist);
assert(status != PEP_OUT_OF_MEMORY);
if (status == PEP_OUT_OF_MEMORY)
return PEP_OUT_OF_MEMORY;
if (keylist && keylist->value) {
if (identity->comm_type == PEP_ct_unknown) {
if (_comm_type_key != PEP_ct_unknown) {
if (_comm_type_key < PEP_ct_unconfirmed_encryption) {
identity->comm_type = _comm_type_key;
}
else if (identity->comm_type == PEP_ct_unknown) {
if (strcmp(identity->fpr, stored_identity->fpr) == 0) {
identity->comm_type = stored_identity->comm_type;
}
@ -74,8 +76,6 @@ DYNAMIC_API PEP_STATUS update_identity(
}
else
identity->comm_type = PEP_ct_unknown;
free_stringlist(keylist);
}
if (EMPTY(identity->username)) {
@ -103,21 +103,7 @@ DYNAMIC_API PEP_STATUS update_identity(
}
}
else /* stored_identity == NULL */ {
if (identity->fpr && identity->user_id) {
if (identity->comm_type == PEP_ct_unknown) {
status = get_trust(session, identity);
assert(status != PEP_OUT_OF_MEMORY);
if (status == PEP_OUT_OF_MEMORY)
return PEP_OUT_OF_MEMORY;
}
if (identity->comm_type != PEP_ct_unknown && EMPTY(identity->username)) {
free(identity->username);
identity->username = strdup("anonymous");
identity->username_size = 10;
}
}
else
identity->comm_type = PEP_ct_unknown;
identity->comm_type = PEP_ct_unknown;
}
status = PEP_STATUS_OK;
@ -130,63 +116,6 @@ DYNAMIC_API PEP_STATUS update_identity(
return status;
}
DYNAMIC_API PEP_STATUS outgoing_comm_type(
PEP_SESSION session,
const stringlist_t *addresses,
PEP_comm_type *comm_type
)
{
const stringlist_t *l;
assert(session);
assert(addresses);
assert(addresses->value);
assert(comm_type);
*comm_type = PEP_ct_unknown;
for (l=addresses; l && l->value; l = l->next) {
PEP_STATUS _status;
pEp_identity *identity;
_status = get_identity(session, l->value, &identity);
assert(_status != PEP_OUT_OF_MEMORY);
if (identity == NULL) {
*comm_type = PEP_ct_no_encryption;
return PEP_STATUS_OK;
}
else if (identity->comm_type == PEP_ct_unknown) {
*comm_type = PEP_ct_no_encryption;
free_identity(identity);
return PEP_STATUS_OK;
}
else if (*comm_type == PEP_ct_unknown) {
*comm_type = identity->comm_type;
}
else if (*comm_type != identity->comm_type) {
PEP_comm_type min = MIN(*comm_type, identity->comm_type);
if (min < PEP_ct_unconfirmed_encryption) {
*comm_type = PEP_ct_no_encryption;
free_identity(identity);
return PEP_STATUS_OK;
}
else if (min < PEP_ct_unconfirmed_enc_anon)
*comm_type = PEP_ct_unconfirmed_encryption;
else if (min < PEP_ct_confirmed_encryption)
*comm_type = PEP_ct_unconfirmed_enc_anon;
else if (min < PEP_ct_confirmed_enc_anon)
*comm_type = PEP_ct_confirmed_encryption;
else
*comm_type = PEP_ct_confirmed_enc_anon;
}
free_identity(identity);
}
return PEP_STATUS_OK;
}
DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
{
PEP_STATUS status;

@ -20,21 +20,6 @@ DYNAMIC_API PEP_STATUS update_identity(
);
// outgoing_comm_type() - minimum comm_type for a list of addresses
//
// parameters:
// session (in) session to use
// addresses (in) list of addresses
// comm_type (out) comm_type which can be used to communicate with
// addresses
DYNAMIC_API PEP_STATUS outgoing_comm_type(
PEP_SESSION session,
const stringlist_t *addresses,
PEP_comm_type *comm_type
);
// myself() - ensures that the own identity is being complete
//
// parameters:

@ -749,7 +749,7 @@ DYNAMIC_API PEP_STATUS decrypt_and_verify(
switch (gpgme_error) {
case GPG_ERR_NO_ERROR:
{
gpgme_verify_result_t gpgme_verify_result;
gpgme_verify_result_t gpgme_verify_result;
char *_buffer = NULL;
size_t reading;
size_t length = _session->gpgme_data_seek(plain, 0, SEEK_END);
@ -837,8 +837,34 @@ DYNAMIC_API PEP_STATUS decrypt_and_verify(
break;
case GPG_ERR_BAD_PASSPHRASE:
NOT_IMPLEMENTED;
default:
result = PEP_CANNOT_DECRYPT_UNKNOWN;
default:
{
gpgme_decrypt_result_t gpgme_decrypt_result = _session->gpgme_op_decrypt_result(_session->ctx);
result = PEP_CANNOT_DECRYPT_UNKNOWN;
if (gpgme_decrypt_result != NULL) {
*keylist = new_stringlist(gpgme_decrypt_result->unsupported_algorithm);
assert(*keylist);
if (*keylist == NULL) {
result = PEP_OUT_OF_MEMORY;
break;
}
stringlist_t *_keylist = *keylist;
for (gpgme_recipient_t r = gpgme_decrypt_result->recipients; r != NULL; r = r->next) {
_keylist = stringlist_add(_keylist, r->keyid);
assert(_keylist);
if (_keylist == NULL) {
free_stringlist(*keylist);
*keylist = NULL;
result = PEP_OUT_OF_MEMORY;
break;
}
}
if (result == PEP_OUT_OF_MEMORY)
break;
}
}
}
break;
@ -1954,6 +1980,11 @@ DYNAMIC_API PEP_STATUS get_key_rating(
gpgme_error = _session->gpgme_op_keylist_next(_session->ctx, &key);
assert(gpgme_error != GPG_ERR_INV_VALUE);
if (key == NULL) {
_session->gpgme_op_keylist_end(_session->ctx);
return PEP_KEY_NOT_FOUND;
}
switch (key->protocol) {
case GPGME_PROTOCOL_OpenPGP:
case GPGME_PROTOCOL_DEFAULT:
@ -2019,4 +2050,4 @@ DYNAMIC_API PEP_STATUS get_key_rating(
_session->gpgme_op_keylist_end(_session->ctx);
return status;
}
}

@ -599,9 +599,10 @@ DYNAMIC_API void pEp_free(void *p);
// identity (inout) user_id and fpr to check as UTF-8 strings (in)
// user_id and comm_type as result (out)
//
// this function modifies the given identity struct; the struct remains in the
// ownership of the caller
// if the trust level cannot be determined identity->comm_type is set to PEP_ct_unknown
// this function modifies the given identity struct; the struct remains in
// the ownership of the caller
// if the trust level cannot be determined identity->comm_type is set
// to PEP_ct_unknown
DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity);
@ -613,13 +614,13 @@ DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity);
// fpr (in) unique identifyer for key as UTF-8 string
// comm_type (out) key rating
//
// if an error occurs, *comm_type is set to PEP_ct_unknown and an error status
// if an error occurs, *comm_type is set to PEP_ct_unknown and an error
// is returned
DYNAMIC_API PEP_STATUS get_key_rating(
PEP_SESSION session,
const char *fpr,
PEP_comm_type *comm_type
PEP_SESSION session,
const char *fpr,
PEP_comm_type *comm_type
);

@ -184,25 +184,6 @@ int main(int argc, char* argv[])
free_identity(identity);
// testing key management
stringlist_t *addresses = new_stringlist("leon.schumacher@digitalekho.com");
PEP_comm_type comm_type;
cout << "\nretrieving communication type for leon.schumacher@digitalekho.com\n";
PEP_STATUS oct_result = outgoing_comm_type(session, addresses, &comm_type);
cout << "communication type is " << comm_type << "\n";
free_stringlist(addresses);
assert(oct_result == PEP_STATUS_OK && comm_type == PEP_ct_pEp);
stringlist_t *addresses2 = new_stringlist("leon.schumacher@digitalekho.com");
stringlist_add(addresses2, "this.email@is.invalid");
cout << "\nretrieving communication type for an unknown address\n";
oct_result = outgoing_comm_type(session, addresses2, &comm_type);
cout << "communication type is " << comm_type << "\n";
cout << "status is " << oct_result << "\n";
free_stringlist(addresses2);
assert(oct_result == PEP_STATUS_OK && comm_type == PEP_ct_no_encryption);
cout << "\ngenerating key for testuser\n";
identity = new_identity(
"testuser@pibit.ch",

Loading…
Cancel
Save