COM-41: Preliminary fix for the exception althouhg we still have
authorMarkus Schaber <markus@pep-security.net>
Sat, 12 Nov 2016 00:29:25 +0100
changeset 20421b7749b5beb
parent 203 b398e3da1b99
child 205 db006c43bb2a
COM-41: Preliminary fix for the exception althouhg we still have
some discussion ongoing.
CpEpEngine.cpp
     1.1 --- a/CpEpEngine.cpp	Fri Nov 11 15:51:31 2016 +0100
     1.2 +++ b/CpEpEngine.cpp	Sat Nov 12 00:29:25 2016 +0100
     1.3 @@ -715,8 +715,19 @@
     1.4  	if (status == PEP_OUT_OF_MEMORY)
     1.5  		return E_OUTOFMEMORY;
     1.6  
     1.7 +	// COM-41: Enhanced PEP status handling
     1.8 +	if ((status > PEP_STATUS_OK && status < PEP_UNENCRYPTED) ||
     1.9 +		status < PEP_STATUS_OK ||
    1.10 +		status >= PEP_TRUSTWORD_NOT_FOUND)
    1.11 +		return FAIL("Failure to encrypt message", status);
    1.12 +
    1.13 +	// Statii like PEP_UNENCRYPTED due to no private key
    1.14 +	// should not be a catastrophic failure here. Using S_FALSE
    1.15 +	// still allows clients to differentiate with S_OK,
    1.16 +	// although this does not work out of the box with
    1.17 +	// the standard .NET mapping of COM.
    1.18  	if (status != PEP_STATUS_OK)
    1.19 -		return FAIL("Failure to encrypt message", status);
    1.20 +		return S_FALSE;
    1.21  
    1.22  	return S_OK;
    1.23  }