added use_only_own_private_keys (testing)
authorEdouard Tisserant
Tue, 07 Jun 2016 18:13:46 +0200
changeset 720366250dab8c5
parent 719 74463e1265a1
child 721 caca7a254581
added use_only_own_private_keys (testing)
src/keymanagement.c
src/pEpEngine.c
src/pEp_internal.h
     1.1 --- a/src/keymanagement.c	Mon Jun 06 17:43:44 2016 +0200
     1.2 +++ b/src/keymanagement.c	Tue Jun 07 18:13:46 2016 +0200
     1.3 @@ -321,16 +321,19 @@
     1.4              for (_keylist = keylist; _keylist && _keylist->value; _keylist = _keylist->next) {
     1.5                  bool is_own = false;
     1.6                  
     1.7 -                status = own_key_is_listed(session, _keylist->value, &is_own);
     1.8 -                assert(status == PEP_STATUS_OK);
     1.9 -                if (status != PEP_STATUS_OK) {
    1.10 -                    free_stringlist(keylist);
    1.11 -                    return status;
    1.12 +                if (_session->use_only_own_private_keys)
    1.13 +                {
    1.14 +                    status = own_key_is_listed(session, _keylist->value, &is_own);
    1.15 +                    assert(status == PEP_STATUS_OK);
    1.16 +                    if (status != PEP_STATUS_OK) {
    1.17 +                        free_stringlist(keylist);
    1.18 +                        return status;
    1.19 +                    }
    1.20                  }
    1.21  
    1.22                  // TODO : also accept synchronized device group keys ?
    1.23                  
    1.24 -                if (is_own)
    1.25 +                if (!_session->use_only_own_private_keys || is_own)
    1.26                  {
    1.27                      PEP_comm_type _comm_type_key;
    1.28                      
     2.1 --- a/src/pEpEngine.c	Mon Jun 06 17:43:44 2016 +0200
     2.2 +++ b/src/pEpEngine.c	Tue Jun 07 18:13:46 2016 +0200
     2.3 @@ -414,6 +414,13 @@
     2.4  
     2.5      _session->passive_mode = false;
     2.6      _session->unencrypted_subject = false;
     2.7 +#ifdef ANDROID
     2.8 +    _session->use_only_own_private_keys = true;
     2.9 +#elif TARGET_OS_IPHONE
    2.10 +    _session->use_only_own_private_keys = true;
    2.11 +#else
    2.12 +    _session->use_only_own_private_keys = false;
    2.13 +#endif
    2.14  
    2.15      *session = _session;
    2.16      return PEP_STATUS_OK;
    2.17 @@ -505,6 +512,12 @@
    2.18      session->unencrypted_subject = enable;
    2.19  }
    2.20  
    2.21 +DYNAMIC_API void config_use_only_own_private_keys(PEP_SESSION session, bool enable)
    2.22 +{
    2.23 +    assert(session);
    2.24 +    session->use_only_own_private_keys = enable;
    2.25 +}
    2.26 +
    2.27  DYNAMIC_API PEP_STATUS log_event(
    2.28          PEP_SESSION session,
    2.29          const char *title,
     3.1 --- a/src/pEp_internal.h	Mon Jun 06 17:43:44 2016 +0200
     3.2 +++ b/src/pEp_internal.h	Tue Jun 07 18:13:46 2016 +0200
     3.3 @@ -133,6 +133,8 @@
     3.4  
     3.5      bool passive_mode;
     3.6      bool unencrypted_subject;
     3.7 +    bool use_only_own_private_keys;
     3.8 +    
     3.9  } pEpSession;
    3.10  
    3.11  PEP_STATUS init_transport_system(PEP_SESSION session, bool in_first);