COM-95: Expose key_reset_identity, key_reset_user, and key_reset_all_own_keys sync
authorThomas
Thu, 11 Apr 2019 12:14:17 +0200
branchsync
changeset 33692efa1696f20
parent 335 e451b820d247
child 337 27979fb306a5
COM-95: Expose key_reset_identity, key_reset_user, and key_reset_all_own_keys
CpEpEngine.cpp
CpEpEngine.h
pEpCOMServerAdapter.idl
     1.1 --- a/CpEpEngine.cpp	Wed Mar 27 07:34:28 2019 +0100
     1.2 +++ b/CpEpEngine.cpp	Thu Apr 11 12:14:17 2019 +0200
     1.3 @@ -654,7 +654,7 @@
     1.4      return S_OK;
     1.5  }
     1.6  
     1.7 -STDMETHODIMP CpEpEngine::KeyReset(BSTR fpr, struct pEpIdentity ident)
     1.8 +STDMETHODIMP CpEpEngine::KeyResetIdentity(struct pEpIdentity ident, BSTR fpr)
     1.9  {
    1.10  	::pEp_identity *_ident;
    1.11  
    1.12 @@ -670,7 +670,7 @@
    1.13  
    1.14  	string _fpr = utf8_string(fpr);
    1.15  
    1.16 -	PEP_STATUS status = ::key_reset(session(), _fpr.c_str(), _ident);
    1.17 +	PEP_STATUS status = ::key_reset_identity(session(), _ident, _fpr.c_str());
    1.18  
    1.19  	free_identity(_ident);
    1.20  
    1.21 @@ -681,7 +681,39 @@
    1.22  		return FAIL(L"key not found");
    1.23  
    1.24  	if (status != PEP_STATUS_OK)
    1.25 -		return FAIL(L"cannot reset key", status);
    1.26 +		return FAIL(L"cannot reset identity", status);
    1.27 +
    1.28 +	return S_OK;
    1.29 +}
    1.30 +
    1.31 +STDMETHODIMP CpEpEngine::KeyResetUser(BSTR userId, BSTR keyId)
    1.32 +{
    1.33 +	string _userId = utf8_string(userId);
    1.34 +	string _keyId = utf8_string(keyId);
    1.35 +
    1.36 +	PEP_STATUS status = ::key_reset_user(session(), _userId.c_str(), _keyId.c_str());
    1.37 +
    1.38 +	if (status == PEP_OUT_OF_MEMORY)
    1.39 +		return E_OUTOFMEMORY;
    1.40 +
    1.41 +	if (status == PEP_KEY_NOT_FOUND)
    1.42 +		return FAIL(L"key not found");
    1.43 +
    1.44 +	if (status != PEP_STATUS_OK)
    1.45 +		return FAIL(L"cannot reset user", status);
    1.46 +
    1.47 +	return S_OK;
    1.48 +}
    1.49 +
    1.50 +STDMETHODIMP CpEpEngine::KeyResetAllOwnKeys()
    1.51 +{
    1.52 +	PEP_STATUS status = ::key_reset_all_own_keys(session());
    1.53 +
    1.54 +	if (status == PEP_OUT_OF_MEMORY)
    1.55 +		return E_OUTOFMEMORY;
    1.56 +
    1.57 +	if (status != PEP_STATUS_OK)
    1.58 +		return FAIL(L"cannot reset all own keys", status);
    1.59  
    1.60  	return S_OK;
    1.61  }
     2.1 --- a/CpEpEngine.h	Wed Mar 27 07:34:28 2019 +0100
     2.2 +++ b/CpEpEngine.h	Thu Apr 11 12:14:17 2019 +0200
     2.3 @@ -201,7 +201,9 @@
     2.4      STDMETHOD(Myself)(struct pEpIdentity *ident, struct pEpIdentity *result);
     2.5      STDMETHOD(UpdateIdentity)(struct pEpIdentity *ident, struct pEpIdentity *result);
     2.6      STDMETHOD(KeyMistrusted)(struct pEpIdentity *ident);
     2.7 -	STDMETHOD(KeyReset)(BSTR keyId, pEpIdentity ident);
     2.8 +	STDMETHOD(KeyResetIdentity)(pEpIdentity ident, BSTR keyId);
     2.9 +	STDMETHOD(KeyResetUser)(BSTR userId, BSTR keyId);
    2.10 +	STDMETHOD(KeyResetAllOwnKeys)();
    2.11      STDMETHOD(KeyResetTrust)(struct pEpIdentity *ident);
    2.12      STDMETHOD(TrustPersonalKey)(struct pEpIdentity *ident, struct pEpIdentity *result);
    2.13      STDMETHOD(OwnIdentitiesRetrieve)(LPSAFEARRAY* ownIdentities);
     3.1 --- a/pEpCOMServerAdapter.idl	Wed Mar 27 07:34:28 2019 +0100
     3.2 +++ b/pEpCOMServerAdapter.idl	Thu Apr 11 12:14:17 2019 +0200
     3.3 @@ -452,7 +452,14 @@
     3.4  	[id(44)] HRESULT GetKeyRatingForUser([in] BSTR userId, [in] BSTR fpr, [out, retval] pEpRating *rating);
     3.5  
     3.6  	// Resets the database status for a key
     3.7 -	[id(45)] HRESULT KeyReset([in] BSTR fpr, [in] struct pEpIdentity ident);
     3.8 +	[id(45)] HRESULT KeyResetIdentity([in] struct pEpIdentity ident, [in] BSTR fpr);
     3.9 +
    3.10 +	// Resets the default database status for the user / keypair provided
    3.11 +	[id(46)] HRESULT KeyResetUser([in] BSTR userId, [in] BSTR fpr);
    3.12 +
    3.13 +	// revoke and mistrust all own keys, generate new keys for all own identities, and opportunistically communicate
    3.14 +	// key reset information to people we have recently contacted. 
    3.15 +	[id(47)] HRESULT KeyResetAllOwnKeys();
    3.16  };
    3.17  
    3.18  [