merge "default" into my branch roker-linux
authorRoker <roker@pep-project.org>
Thu, 30 Jun 2016 15:08:21 +0200
branchroker-linux
changeset 779cecbd66421f6
parent 778 2740958d5401
parent 776 c3428bcc5300
child 787 274c303a0c5a
merge "default" into my branch
     1.1 --- a/db/en.csv	Wed Jun 29 13:23:20 2016 +0200
     1.2 +++ b/db/en.csv	Thu Jun 30 15:08:21 2016 +0200
     1.3 @@ -31918,7 +31918,7 @@
     1.4  en,31917,NAMER,0
     1.5  en,31918,NAMESAKE,0
     1.6  en,31919,NAMIBIA,0
     1.7 -en,31920,XKCD,0
     1.8 +en,31920,TROUBADOUR,0
     1.9  en,31921,NAMING,0
    1.10  en,31922,NAN,0
    1.11  en,31923,NANA,0
    1.12 @@ -48229,7 +48229,7 @@
    1.13  en,48228,TROTTED,0
    1.14  en,48229,TROTTER,0
    1.15  en,48230,TROTTING,0
    1.16 -en,48231,TROUBADOUR,0
    1.17 +en,48231,NAMIBIAN,0
    1.18  en,48232,TROUBLE,0
    1.19  en,48233,TROUBLED,0
    1.20  en,48234,TROUBLER,0
     2.1 --- a/src/keymanagement.c	Wed Jun 29 13:23:20 2016 +0200
     2.2 +++ b/src/keymanagement.c	Thu Jun 30 15:08:21 2016 +0200
     2.3 @@ -56,7 +56,7 @@
     2.4      return ai == fpras && bi == fprbs;
     2.5  }
     2.6  
     2.7 -PEP_STATUS elect_key(
     2.8 +PEP_STATUS elect_pubkey(
     2.9          PEP_SESSION session, pEp_identity * identity
    2.10      )
    2.11  {
    2.12 @@ -165,7 +165,7 @@
    2.13              if (identity->fpr == NULL)
    2.14                  return PEP_OUT_OF_MEMORY;
    2.15              if (_comm_type_key < PEP_ct_unconfirmed_encryption) {
    2.16 -                PEP_STATUS status = elect_key(session, identity);
    2.17 +                PEP_STATUS status = elect_pubkey(session, identity);
    2.18                  if (status != PEP_STATUS_OK)
    2.19                      return status;
    2.20              }
    2.21 @@ -214,7 +214,7 @@
    2.22              identity->comm_type = _comm_type_key;
    2.23          }
    2.24          else /* EMPTYSTR(identity->fpr) */ {
    2.25 -            PEP_STATUS status = elect_key(session, identity);
    2.26 +            PEP_STATUS status = elect_pubkey(session, identity);
    2.27              if (status != PEP_STATUS_OK)
    2.28                  return status;
    2.29          }
    2.30 @@ -252,6 +252,81 @@
    2.31      return status;
    2.32  }
    2.33  
    2.34 +PEP_STATUS elect_ownkey(
    2.35 +        PEP_SESSION session, pEp_identity * identity
    2.36 +    )
    2.37 +{
    2.38 +    PEP_STATUS status;
    2.39 +    stringlist_t *keylist = NULL;
    2.40 +
    2.41 +    free(identity->fpr);
    2.42 +    identity->fpr = NULL;
    2.43 +
    2.44 +    status = find_keys(session, identity->address, &keylist);
    2.45 +    assert(status != PEP_OUT_OF_MEMORY);
    2.46 +    if (status == PEP_OUT_OF_MEMORY)
    2.47 +        return PEP_OUT_OF_MEMORY;
    2.48 +    
    2.49 +    if (keylist != NULL && keylist->value != NULL)
    2.50 +    {
    2.51 +        char *_fpr = NULL;
    2.52 +        identity->comm_type = PEP_ct_unknown;
    2.53 +
    2.54 +        stringlist_t *_keylist;
    2.55 +        for (_keylist = keylist; _keylist && _keylist->value; _keylist = _keylist->next) {
    2.56 +            bool is_own = false;
    2.57 +            
    2.58 +            if (session->use_only_own_private_keys)
    2.59 +            {
    2.60 +                status = own_key_is_listed(session, _keylist->value, &is_own);
    2.61 +                assert(status == PEP_STATUS_OK);
    2.62 +                if (status != PEP_STATUS_OK) {
    2.63 +                    free_stringlist(keylist);
    2.64 +                    return status;
    2.65 +                }
    2.66 +            }
    2.67 +
    2.68 +            // TODO : also accept synchronized device group keys ?
    2.69 +            
    2.70 +            if (!session->use_only_own_private_keys || is_own)
    2.71 +            {
    2.72 +                PEP_comm_type _comm_type_key;
    2.73 +                
    2.74 +                status = get_key_rating(session, _keylist->value, &_comm_type_key);
    2.75 +                assert(status != PEP_OUT_OF_MEMORY);
    2.76 +                if (status == PEP_OUT_OF_MEMORY) {
    2.77 +                    free_stringlist(keylist);
    2.78 +                    return PEP_OUT_OF_MEMORY;
    2.79 +                }
    2.80 +                
    2.81 +                if (_comm_type_key != PEP_ct_compromized &&
    2.82 +                    _comm_type_key != PEP_ct_unknown)
    2.83 +                {
    2.84 +                    if (identity->comm_type == PEP_ct_unknown ||
    2.85 +                        _comm_type_key > identity->comm_type)
    2.86 +                    {
    2.87 +                        identity->comm_type = _comm_type_key;
    2.88 +                        _fpr = _keylist->value;
    2.89 +                    }
    2.90 +                }
    2.91 +            }
    2.92 +        }
    2.93 +        
    2.94 +        if (_fpr)
    2.95 +        {
    2.96 +            identity->fpr = strdup(_fpr);
    2.97 +            assert(identity->fpr);
    2.98 +            if (identity->fpr == NULL)
    2.99 +            {
   2.100 +                free_stringlist(keylist);
   2.101 +                return PEP_OUT_OF_MEMORY;
   2.102 +            }
   2.103 +        }
   2.104 +        free_stringlist(keylist);
   2.105 +    }
   2.106 +    return PEP_STATUS_OK;
   2.107 +}
   2.108 +
   2.109  DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
   2.110  {
   2.111      pEp_identity *stored_identity;
   2.112 @@ -314,72 +389,10 @@
   2.113      }
   2.114      else
   2.115      {
   2.116 -        stringlist_t *keylist = NULL;
   2.117 -
   2.118 -        free(identity->fpr);
   2.119 -        identity->fpr = NULL;
   2.120 -
   2.121 -        status = find_keys(session, identity->address, &keylist);
   2.122 -        assert(status != PEP_OUT_OF_MEMORY);
   2.123 -        if (status == PEP_OUT_OF_MEMORY)
   2.124 -            return PEP_OUT_OF_MEMORY;
   2.125 -        
   2.126 -        if (keylist != NULL && keylist->value != NULL)
   2.127 -        {
   2.128 -            char *_fpr = NULL;
   2.129 -            identity->comm_type = PEP_ct_unknown;
   2.130 -
   2.131 -            stringlist_t *_keylist;
   2.132 -            for (_keylist = keylist; _keylist && _keylist->value; _keylist = _keylist->next) {
   2.133 -                bool is_own = false;
   2.134 -                
   2.135 -                if (session->use_only_own_private_keys)
   2.136 -                {
   2.137 -                    status = own_key_is_listed(session, _keylist->value, &is_own);
   2.138 -                    assert(status == PEP_STATUS_OK);
   2.139 -                    if (status != PEP_STATUS_OK) {
   2.140 -                        free_stringlist(keylist);
   2.141 -                        return status;
   2.142 -                    }
   2.143 -                }
   2.144 -
   2.145 -                // TODO : also accept synchronized device group keys ?
   2.146 -                
   2.147 -                if (!session->use_only_own_private_keys || is_own)
   2.148 -                {
   2.149 -                    PEP_comm_type _comm_type_key;
   2.150 -                    
   2.151 -                    status = get_key_rating(session, _keylist->value, &_comm_type_key);
   2.152 -                    assert(status != PEP_OUT_OF_MEMORY);
   2.153 -                    if (status == PEP_OUT_OF_MEMORY) {
   2.154 -                        free_stringlist(keylist);
   2.155 -                        return PEP_OUT_OF_MEMORY;
   2.156 -                    }
   2.157 -                    
   2.158 -                    if (_comm_type_key != PEP_ct_compromized &&
   2.159 -                        _comm_type_key != PEP_ct_unknown)
   2.160 -                    {
   2.161 -                        if (identity->comm_type == PEP_ct_unknown ||
   2.162 -                            _comm_type_key > identity->comm_type)
   2.163 -                        {
   2.164 -                            identity->comm_type = _comm_type_key;
   2.165 -                            _fpr = _keylist->value;
   2.166 -                        }
   2.167 -                    }
   2.168 -                }
   2.169 -            }
   2.170 -            
   2.171 -            if (_fpr)
   2.172 -            {
   2.173 -                identity->fpr = strdup(_fpr);
   2.174 -                assert(identity->fpr);
   2.175 -                if (identity->fpr == NULL)
   2.176 -                {
   2.177 -                    free_stringlist(keylist);
   2.178 -                    return PEP_OUT_OF_MEMORY;
   2.179 -                }
   2.180 -            }
   2.181 -            free_stringlist(keylist);
   2.182 +        status = elect_ownkey(session, identity);
   2.183 +        assert(status == PEP_STATUS_OK);
   2.184 +        if (status != PEP_STATUS_OK) {
   2.185 +            return status;
   2.186          }
   2.187      }
   2.188  
   2.189 @@ -388,8 +401,18 @@
   2.190      if (!EMPTYSTR(identity->fpr))
   2.191      {
   2.192          status = key_revoked(session, identity->fpr, &revoked);
   2.193 -        assert(status == PEP_STATUS_OK);
   2.194 -        if (status != PEP_STATUS_OK) {
   2.195 +
   2.196 +        // Forces re-election if key is missing and own-key-only not forced
   2.197 +        if (!session->use_only_own_private_keys && status == PEP_KEY_NOT_FOUND) 
   2.198 +        {
   2.199 +            status = elect_ownkey(session, identity);
   2.200 +            assert(status == PEP_STATUS_OK);
   2.201 +            if (status != PEP_STATUS_OK) {
   2.202 +                return status;
   2.203 +            }
   2.204 +        } 
   2.205 +        else if (status != PEP_STATUS_OK) 
   2.206 +        {
   2.207              return status;
   2.208          }
   2.209      }
     3.1 --- a/src/message_api.c	Wed Jun 29 13:23:20 2016 +0200
     3.2 +++ b/src/message_api.c	Thu Jun 30 15:08:21 2016 +0200
     3.3 @@ -1046,7 +1046,7 @@
     3.4          //     - App splits mails with BCC in multiple mails.
     3.5          //     - Each email is encrypted separately
     3.6          
     3.7 -        if(_il->next || src->to || src->cc)
     3.8 +        if(_il->next || (src->to && src->to->ident) || src->cc)
     3.9          {
    3.10              // Only one Bcc with no other recipient allowed for now
    3.11              return PEP_ILLEGAL_VALUE;
     4.1 --- a/src/pEpEngine.h	Wed Jun 29 13:23:20 2016 +0200
     4.2 +++ b/src/pEpEngine.h	Thu Jun 30 15:08:21 2016 +0200
     4.3 @@ -549,11 +549,16 @@
     4.4  //      session (in)            session handle
     4.5  //      key_data (in)           key data, i.e. ASCII armored OpenPGP key
     4.6  //      size (in)               amount of data to handle
     4.7 +//      private_keys (out)      list of private keys that have been imported
     4.8  //
     4.9  //  return value:
    4.10  //      PEP_STATUS_OK = 0       key was successfully imported
    4.11  //      PEP_OUT_OF_MEMORY       out of memory
    4.12  //      PEP_ILLEGAL_VALUE       there is no key data to import
    4.13 +//
    4.14 +//  caveat:
    4.15 +//      private_keys goes to the ownership of the caller
    4.16 +//      private_keys can be left NULL, it is then ignored
    4.17  
    4.18  DYNAMIC_API PEP_STATUS import_key(
    4.19          PEP_SESSION session,