1.1 --- a/.hgignore Sun Jun 26 18:04:25 2016 +0200
1.2 +++ b/.hgignore Thu Jun 30 16:11:51 2016 +0200
1.3 @@ -27,6 +27,7 @@
1.4 build-android/pEpEngine-android-1.zip
1.5 build-android/third-party
1.6 build-android/pEpEngine-android-1
1.7 +build-linux/*
1.8 *.dSYM*
1.9 *_test
1.10 msg4.asc
2.1 --- a/db/en.csv Sun Jun 26 18:04:25 2016 +0200
2.2 +++ b/db/en.csv Thu Jun 30 16:11:51 2016 +0200
2.3 @@ -31918,7 +31918,7 @@
2.4 en,31917,NAMER,0
2.5 en,31918,NAMESAKE,0
2.6 en,31919,NAMIBIA,0
2.7 -en,31920,XKCD,0
2.8 +en,31920,TROUBADOUR,0
2.9 en,31921,NAMING,0
2.10 en,31922,NAN,0
2.11 en,31923,NANA,0
2.12 @@ -48229,7 +48229,7 @@
2.13 en,48228,TROTTED,0
2.14 en,48229,TROTTER,0
2.15 en,48230,TROTTING,0
2.16 -en,48231,TROUBADOUR,0
2.17 +en,48231,NAMIBIAN,0
2.18 en,48232,TROUBLE,0
2.19 en,48233,TROUBLED,0
2.20 en,48234,TROUBLER,0
3.1 --- a/src/keymanagement.c Sun Jun 26 18:04:25 2016 +0200
3.2 +++ b/src/keymanagement.c Thu Jun 30 16:11:51 2016 +0200
3.3 @@ -56,7 +56,7 @@
3.4 return ai == fpras && bi == fprbs;
3.5 }
3.6
3.7 -PEP_STATUS elect_key(
3.8 +PEP_STATUS elect_pubkey(
3.9 PEP_SESSION session, pEp_identity * identity
3.10 )
3.11 {
3.12 @@ -165,7 +165,7 @@
3.13 if (identity->fpr == NULL)
3.14 return PEP_OUT_OF_MEMORY;
3.15 if (_comm_type_key < PEP_ct_unconfirmed_encryption) {
3.16 - PEP_STATUS status = elect_key(session, identity);
3.17 + PEP_STATUS status = elect_pubkey(session, identity);
3.18 if (status != PEP_STATUS_OK)
3.19 return status;
3.20 }
3.21 @@ -214,7 +214,7 @@
3.22 identity->comm_type = _comm_type_key;
3.23 }
3.24 else /* EMPTYSTR(identity->fpr) */ {
3.25 - PEP_STATUS status = elect_key(session, identity);
3.26 + PEP_STATUS status = elect_pubkey(session, identity);
3.27 if (status != PEP_STATUS_OK)
3.28 return status;
3.29 }
3.30 @@ -252,6 +252,81 @@
3.31 return status;
3.32 }
3.33
3.34 +PEP_STATUS elect_ownkey(
3.35 + PEP_SESSION session, pEp_identity * identity
3.36 + )
3.37 +{
3.38 + PEP_STATUS status;
3.39 + stringlist_t *keylist = NULL;
3.40 +
3.41 + free(identity->fpr);
3.42 + identity->fpr = NULL;
3.43 +
3.44 + status = find_keys(session, identity->address, &keylist);
3.45 + assert(status != PEP_OUT_OF_MEMORY);
3.46 + if (status == PEP_OUT_OF_MEMORY)
3.47 + return PEP_OUT_OF_MEMORY;
3.48 +
3.49 + if (keylist != NULL && keylist->value != NULL)
3.50 + {
3.51 + char *_fpr = NULL;
3.52 + identity->comm_type = PEP_ct_unknown;
3.53 +
3.54 + stringlist_t *_keylist;
3.55 + for (_keylist = keylist; _keylist && _keylist->value; _keylist = _keylist->next) {
3.56 + bool is_own = false;
3.57 +
3.58 + if (session->use_only_own_private_keys)
3.59 + {
3.60 + status = own_key_is_listed(session, _keylist->value, &is_own);
3.61 + assert(status == PEP_STATUS_OK);
3.62 + if (status != PEP_STATUS_OK) {
3.63 + free_stringlist(keylist);
3.64 + return status;
3.65 + }
3.66 + }
3.67 +
3.68 + // TODO : also accept synchronized device group keys ?
3.69 +
3.70 + if (!session->use_only_own_private_keys || is_own)
3.71 + {
3.72 + PEP_comm_type _comm_type_key;
3.73 +
3.74 + status = get_key_rating(session, _keylist->value, &_comm_type_key);
3.75 + assert(status != PEP_OUT_OF_MEMORY);
3.76 + if (status == PEP_OUT_OF_MEMORY) {
3.77 + free_stringlist(keylist);
3.78 + return PEP_OUT_OF_MEMORY;
3.79 + }
3.80 +
3.81 + if (_comm_type_key != PEP_ct_compromized &&
3.82 + _comm_type_key != PEP_ct_unknown)
3.83 + {
3.84 + if (identity->comm_type == PEP_ct_unknown ||
3.85 + _comm_type_key > identity->comm_type)
3.86 + {
3.87 + identity->comm_type = _comm_type_key;
3.88 + _fpr = _keylist->value;
3.89 + }
3.90 + }
3.91 + }
3.92 + }
3.93 +
3.94 + if (_fpr)
3.95 + {
3.96 + identity->fpr = strdup(_fpr);
3.97 + assert(identity->fpr);
3.98 + if (identity->fpr == NULL)
3.99 + {
3.100 + free_stringlist(keylist);
3.101 + return PEP_OUT_OF_MEMORY;
3.102 + }
3.103 + }
3.104 + free_stringlist(keylist);
3.105 + }
3.106 + return PEP_STATUS_OK;
3.107 +}
3.108 +
3.109 DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
3.110 {
3.111 pEp_identity *stored_identity;
3.112 @@ -314,72 +389,10 @@
3.113 }
3.114 else
3.115 {
3.116 - stringlist_t *keylist = NULL;
3.117 -
3.118 - free(identity->fpr);
3.119 - identity->fpr = NULL;
3.120 -
3.121 - status = find_keys(session, identity->address, &keylist);
3.122 - assert(status != PEP_OUT_OF_MEMORY);
3.123 - if (status == PEP_OUT_OF_MEMORY)
3.124 - return PEP_OUT_OF_MEMORY;
3.125 -
3.126 - if (keylist != NULL && keylist->value != NULL)
3.127 - {
3.128 - char *_fpr = NULL;
3.129 - identity->comm_type = PEP_ct_unknown;
3.130 -
3.131 - stringlist_t *_keylist;
3.132 - for (_keylist = keylist; _keylist && _keylist->value; _keylist = _keylist->next) {
3.133 - bool is_own = false;
3.134 -
3.135 - if (session->use_only_own_private_keys)
3.136 - {
3.137 - status = own_key_is_listed(session, _keylist->value, &is_own);
3.138 - assert(status == PEP_STATUS_OK);
3.139 - if (status != PEP_STATUS_OK) {
3.140 - free_stringlist(keylist);
3.141 - return status;
3.142 - }
3.143 - }
3.144 -
3.145 - // TODO : also accept synchronized device group keys ?
3.146 -
3.147 - if (!session->use_only_own_private_keys || is_own)
3.148 - {
3.149 - PEP_comm_type _comm_type_key;
3.150 -
3.151 - status = get_key_rating(session, _keylist->value, &_comm_type_key);
3.152 - assert(status != PEP_OUT_OF_MEMORY);
3.153 - if (status == PEP_OUT_OF_MEMORY) {
3.154 - free_stringlist(keylist);
3.155 - return PEP_OUT_OF_MEMORY;
3.156 - }
3.157 -
3.158 - if (_comm_type_key != PEP_ct_compromized &&
3.159 - _comm_type_key != PEP_ct_unknown)
3.160 - {
3.161 - if (identity->comm_type == PEP_ct_unknown ||
3.162 - _comm_type_key > identity->comm_type)
3.163 - {
3.164 - identity->comm_type = _comm_type_key;
3.165 - _fpr = _keylist->value;
3.166 - }
3.167 - }
3.168 - }
3.169 - }
3.170 -
3.171 - if (_fpr)
3.172 - {
3.173 - identity->fpr = strdup(_fpr);
3.174 - assert(identity->fpr);
3.175 - if (identity->fpr == NULL)
3.176 - {
3.177 - free_stringlist(keylist);
3.178 - return PEP_OUT_OF_MEMORY;
3.179 - }
3.180 - }
3.181 - free_stringlist(keylist);
3.182 + status = elect_ownkey(session, identity);
3.183 + assert(status == PEP_STATUS_OK);
3.184 + if (status != PEP_STATUS_OK) {
3.185 + return status;
3.186 }
3.187 }
3.188
3.189 @@ -388,8 +401,18 @@
3.190 if (!EMPTYSTR(identity->fpr))
3.191 {
3.192 status = key_revoked(session, identity->fpr, &revoked);
3.193 - assert(status == PEP_STATUS_OK);
3.194 - if (status != PEP_STATUS_OK) {
3.195 +
3.196 + // Forces re-election if key is missing and own-key-only not forced
3.197 + if (!session->use_only_own_private_keys && status == PEP_KEY_NOT_FOUND)
3.198 + {
3.199 + status = elect_ownkey(session, identity);
3.200 + assert(status == PEP_STATUS_OK);
3.201 + if (status != PEP_STATUS_OK) {
3.202 + return status;
3.203 + }
3.204 + }
3.205 + else if (status != PEP_STATUS_OK)
3.206 + {
3.207 return status;
3.208 }
3.209 }
4.1 --- a/src/message_api.c Sun Jun 26 18:04:25 2016 +0200
4.2 +++ b/src/message_api.c Thu Jun 30 16:11:51 2016 +0200
4.3 @@ -496,46 +496,53 @@
4.4 bloblist_t *_s = src->attachments;
4.5 bloblist_t *_d = dst->attachments;
4.6
4.7 - for (int n = 0; _s && _s->value; _s = _s->next) {
4.8 - size_t psize = _s->size;
4.9 - ptext = _s->value;
4.10 - status = encrypt_and_sign(session, keys, ptext, psize, &ctext,
4.11 - &csize);
4.12 - if (ctext) {
4.13 - char *filename = NULL;
4.14 -
4.15 - if (_s->filename) {
4.16 - size_t len = strlen(_s->filename);
4.17 - filename = calloc(1, len + 5);
4.18 - if (filename == NULL)
4.19 - goto enomem;
4.20 -
4.21 - strcpy(filename, _s->filename);
4.22 - strcpy(filename + len, ".pgp");
4.23 - }
4.24 - else {
4.25 - filename = calloc(1, 20);
4.26 - if (filename == NULL)
4.27 - goto enomem;
4.28 -
4.29 - ++n;
4.30 - n &= 0xffff;
4.31 - snprintf(filename, 20, "Attachment%d.pgp", n);
4.32 - }
4.33 -
4.34 - char *_ctext = malloc(csize);
4.35 - assert(_ctext);
4.36 - if (_ctext == NULL)
4.37 - goto enomem;
4.38 - memcpy(_ctext, ctext, csize);
4.39 -
4.40 - _d = bloblist_add(_d, _ctext, csize, "application/octet-stream",
4.41 - filename);
4.42 + for (int n = 0; _s; _s = _s->next) {
4.43 + if (_s->value == NULL && _s->size == 0) {
4.44 + _d = bloblist_add(_d, NULL, 0, _s->mime_type, _s->filename);
4.45 if (_d == NULL)
4.46 goto enomem;
4.47 }
4.48 else {
4.49 - goto pep_error;
4.50 + size_t psize = _s->size;
4.51 + ptext = _s->value;
4.52 + status = encrypt_and_sign(session, keys, ptext, psize, &ctext,
4.53 + &csize);
4.54 + if (ctext) {
4.55 + char *filename = NULL;
4.56 +
4.57 + if (_s->filename) {
4.58 + size_t len = strlen(_s->filename);
4.59 + filename = calloc(1, len + 5);
4.60 + if (filename == NULL)
4.61 + goto enomem;
4.62 +
4.63 + strcpy(filename, _s->filename);
4.64 + strcpy(filename + len, ".pgp");
4.65 + }
4.66 + else {
4.67 + filename = calloc(1, 20);
4.68 + if (filename == NULL)
4.69 + goto enomem;
4.70 +
4.71 + ++n;
4.72 + n &= 0xffff;
4.73 + snprintf(filename, 20, "Attachment%d.pgp", n);
4.74 + }
4.75 +
4.76 + char *_ctext = malloc(csize);
4.77 + assert(_ctext);
4.78 + if (_ctext == NULL)
4.79 + goto enomem;
4.80 + memcpy(_ctext, ctext, csize);
4.81 +
4.82 + _d = bloblist_add(_d, _ctext, csize, "application/octet-stream",
4.83 + filename);
4.84 + if (_d == NULL)
4.85 + goto enomem;
4.86 + }
4.87 + else {
4.88 + goto pep_error;
4.89 + }
4.90 }
4.91 }
4.92 }
4.93 @@ -1039,7 +1046,7 @@
4.94 // - App splits mails with BCC in multiple mails.
4.95 // - Each email is encrypted separately
4.96
4.97 - if(_il->next || src->to || src->cc)
4.98 + if(_il->next || (src->to && src->to->ident) || src->cc)
4.99 {
4.100 // Only one Bcc with no other recipient allowed for now
4.101 return PEP_ILLEGAL_VALUE;
4.102 @@ -1273,8 +1280,14 @@
4.103 }
4.104
4.105 bloblist_t *_s;
4.106 - for (_s = src->attachments; _s && _s->value; _s = _s->next) {
4.107 - if (is_encrypted_attachment(_s)) {
4.108 + for (_s = src->attachments; _s; _s = _s->next) {
4.109 + if (_s->value == NULL && _s->size == 0){
4.110 + _m = bloblist_add(_m, NULL, 0, _s->mime_type, _s->filename);
4.111 + if (_m == NULL)
4.112 + goto enomem;
4.113 +
4.114 + }
4.115 + else if (is_encrypted_attachment(_s)) {
4.116 stringlist_t *_keylist = NULL;
4.117 char *attctext;
4.118 size_t attcsize;
5.1 --- a/src/mime.c Sun Jun 26 18:04:25 2016 +0200
5.2 +++ b/src/mime.c Thu Jun 30 16:11:51 2016 +0200
5.3 @@ -693,8 +693,6 @@
5.4
5.5 bloblist_t *_a;
5.6 for (_a = msg->attachments; _a != NULL; _a = _a->next) {
5.7 - //assert(_a->value);
5.8 - //assert(_a->size);
5.9
5.10 status = mime_attachment(_a, &submime);
5.11 if (status != PEP_STATUS_OK)
6.1 --- a/src/pEpEngine.h Sun Jun 26 18:04:25 2016 +0200
6.2 +++ b/src/pEpEngine.h Thu Jun 30 16:11:51 2016 +0200
6.3 @@ -549,11 +549,16 @@
6.4 // session (in) session handle
6.5 // key_data (in) key data, i.e. ASCII armored OpenPGP key
6.6 // size (in) amount of data to handle
6.7 +// private_keys (out) list of private keys that have been imported
6.8 //
6.9 // return value:
6.10 // PEP_STATUS_OK = 0 key was successfully imported
6.11 // PEP_OUT_OF_MEMORY out of memory
6.12 // PEP_ILLEGAL_VALUE there is no key data to import
6.13 +//
6.14 +// caveat:
6.15 +// private_keys goes to the ownership of the caller
6.16 +// private_keys can be left NULL, it is then ignored
6.17
6.18 DYNAMIC_API PEP_STATUS import_key(
6.19 PEP_SESSION session,
7.1 --- a/test/Makefile Sun Jun 26 18:04:25 2016 +0200
7.2 +++ b/test/Makefile Thu Jun 30 16:11:51 2016 +0200
7.3 @@ -35,6 +35,9 @@
7.4 %_test_lldb : %_test
7.5 LD_LIBRARY_PATH=~/lib:../src lldb ./$<
7.6
7.7 +%_test_gdb : %_test
7.8 + LD_LIBRARY_PATH=~/lib:../src gdb ./$<
7.9 +
7.10 unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
7.11
7.12 install: