merged in default doxygen_doc
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 09 Sep 2020 00:23:04 +0200
branchdoxygen_doc
changeset 50435990dbcfb506
parent 5042 13df5515e514
parent 5039 5ab75ded6cdd
child 5044 680b4a5c2dc3
merged in default
src/baseprotocol.h
src/message_api.c
src/pEpEngine.h
src/pEp_internal.h
     1.1 --- a/.hgtags	Wed Sep 09 00:16:10 2020 +0200
     1.2 +++ b/.hgtags	Wed Sep 09 00:23:04 2020 +0200
     1.3 @@ -66,3 +66,9 @@
     1.4  b2c4237d4373c0332743ce50d1a4119ebb31b2df Release_2.1.0-RC26
     1.5  c3e10511c29e7b693fe58c796eb87700639050ba Release_2.1.0-RC27
     1.6  e4b00b4cff45deb4fe2866264132ac0965ea0684 Release_2.1.0-RC28
     1.7 +abb54fe3cc60b8e71f6cd54cb79515ddde7d3d3b Release_2.1.0-RC29
     1.8 +dec0e9ac47230e64aa88d1c5838597a10fc03b84 Release_2.1.0-RC30
     1.9 +13722f7b64d273c0a3f397d2a863238e95efe786 Release_2.1.0-RC31
    1.10 +1065ee6663cdbece3a0ed3272f97a7698df73ec8 Release_2.1.0-RC32
    1.11 +ad76ee3dce6b068d2ee2866e37d0e4c1f68ef3bf Release_2.1.0-RC33
    1.12 +c26bbd9bb479844d2fb9b35e9ba40b6bbbfb5bbc Release_2.1.0-RC34
     2.1 --- a/asn.1/pEp.asn1	Wed Sep 09 00:16:10 2020 +0200
     2.2 +++ b/asn.1/pEp.asn1	Wed Sep 09 00:23:04 2020 +0200
     2.3 @@ -1,7 +1,7 @@
     2.4  -- This file is under BSD License 2.0
     2.5  
     2.6  -- Sync protocol for p≡p
     2.7 --- Copyright (c) 2016, 2017 p≡p foundation
     2.8 +-- Copyright (c) 2016, 2010 p≡p foundation
     2.9  
    2.10  -- Written by Volker Birk
    2.11  
    2.12 @@ -12,7 +12,7 @@
    2.13  
    2.14  BEGIN
    2.15  
    2.16 -EXPORTS Identity, IdentityList, TID, Hash, Version;
    2.17 +EXPORTS Identity, IdentityList, TID, Hash, Version, Rating;
    2.18  
    2.19  ISO639-1 ::= PrintableString(FROM ("a".."z")) (SIZE(2))
    2.20  Hex ::= PrintableString(FROM ("A".."F") | FROM ("0".."9"))
    2.21 @@ -36,5 +36,31 @@
    2.22      minor INTEGER (0..255) DEFAULT 2
    2.23  }
    2.24  
    2.25 +Rating ::= ENUMERATED { 
    2.26 +    -- no color
    2.27 +
    2.28 +    cannot-decrypt (1),
    2.29 +    have-no-key (2),
    2.30 +    unencrypted (3),
    2.31 +    unreliable (5),
    2.32 +
    2.33 +    b0rken (-2),
    2.34 +
    2.35 +    -- yellow
    2.36 +
    2.37 +    reliable (6),
    2.38 +
    2.39 +    -- green
    2.40 +
    2.41 +    trusted (7),
    2.42 +    trusted-and-anonymized (8),
    2.43 +    fully-anonymous (9), 
    2.44 +
    2.45 +    -- red
    2.46 +
    2.47 +    mistrust (-1),
    2.48 +    under-attack (-3)
    2.49 +}
    2.50 +
    2.51  END
    2.52  
     3.1 --- a/build-mac/pEpEngine.xcodeproj/project.pbxproj	Wed Sep 09 00:16:10 2020 +0200
     3.2 +++ b/build-mac/pEpEngine.xcodeproj/project.pbxproj	Wed Sep 09 00:23:04 2020 +0200
     3.3 @@ -142,6 +142,10 @@
     3.4  		15B0381422B2B823002D664C /* asn_SEQUENCE_OF.h in Headers */ = {isa = PBXBuildFile; fileRef = 15B037A922B2B822002D664C /* asn_SEQUENCE_OF.h */; };
     3.5  		15B75BE223FA9F9D00DAE976 /* SynchronizeGroupKeys.c in Sources */ = {isa = PBXBuildFile; fileRef = 15B75BDC23FA9F9D00DAE976 /* SynchronizeGroupKeys.c */; };
     3.6  		15B75BE323FA9F9D00DAE976 /* SynchronizeGroupKeys.h in Headers */ = {isa = PBXBuildFile; fileRef = 15B75BE123FA9F9D00DAE976 /* SynchronizeGroupKeys.h */; };
     3.7 +		15EB7B7B250794D9004C176D /* ReceiverRating.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EB7B73250794D8004C176D /* ReceiverRating.h */; };
     3.8 +		15EB7B7C250794D9004C176D /* Rating.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EB7B78250794D8004C176D /* Rating.h */; };
     3.9 +		15EB7B7D250794D9004C176D /* Rating.c in Sources */ = {isa = PBXBuildFile; fileRef = 15EB7B79250794D8004C176D /* Rating.c */; };
    3.10 +		15EB7B7E250794D9004C176D /* ReceiverRating.c in Sources */ = {isa = PBXBuildFile; fileRef = 15EB7B7A250794D8004C176D /* ReceiverRating.c */; };
    3.11  		430BCC482015EE800077E998 /* pEp_string.h in Headers */ = {isa = PBXBuildFile; fileRef = 430BCC462015EE800077E998 /* pEp_string.h */; };
    3.12  		430BCC492015EE800077E998 /* pEp_string.c in Sources */ = {isa = PBXBuildFile; fileRef = 430BCC472015EE800077E998 /* pEp_string.c */; };
    3.13  		430D258B1C9ED75A00B94535 /* blacklist.c in Sources */ = {isa = PBXBuildFile; fileRef = 430D258A1C9ED75A00B94535 /* blacklist.c */; };
    3.14 @@ -396,6 +400,10 @@
    3.15  		15B037A922B2B822002D664C /* asn_SEQUENCE_OF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = asn_SEQUENCE_OF.h; path = ../asn.1/asn_SEQUENCE_OF.h; sourceTree = "<group>"; };
    3.16  		15B75BDC23FA9F9D00DAE976 /* SynchronizeGroupKeys.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SynchronizeGroupKeys.c; path = ../asn.1/SynchronizeGroupKeys.c; sourceTree = "<group>"; };
    3.17  		15B75BE123FA9F9D00DAE976 /* SynchronizeGroupKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SynchronizeGroupKeys.h; path = ../asn.1/SynchronizeGroupKeys.h; sourceTree = "<group>"; };
    3.18 +		15EB7B73250794D8004C176D /* ReceiverRating.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ReceiverRating.h; path = ../asn.1/ReceiverRating.h; sourceTree = "<group>"; };
    3.19 +		15EB7B78250794D8004C176D /* Rating.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Rating.h; path = ../asn.1/Rating.h; sourceTree = "<group>"; };
    3.20 +		15EB7B79250794D8004C176D /* Rating.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = Rating.c; path = ../asn.1/Rating.c; sourceTree = "<group>"; };
    3.21 +		15EB7B7A250794D8004C176D /* ReceiverRating.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ReceiverRating.c; path = ../asn.1/ReceiverRating.c; sourceTree = "<group>"; };
    3.22  		430BCC462015EE800077E998 /* pEp_string.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pEp_string.h; path = ../src/pEp_string.h; sourceTree = "<group>"; };
    3.23  		430BCC472015EE800077E998 /* pEp_string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pEp_string.c; path = ../src/pEp_string.c; sourceTree = "<group>"; };
    3.24  		430D258A1C9ED75A00B94535 /* blacklist.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = blacklist.c; path = ../src/blacklist.c; sourceTree = "<group>"; };
    3.25 @@ -552,6 +560,10 @@
    3.26  		6406CE811CE382F400C14D77 /* asn.1 */ = {
    3.27  			isa = PBXGroup;
    3.28  			children = (
    3.29 +				15EB7B79250794D8004C176D /* Rating.c */,
    3.30 +				15EB7B78250794D8004C176D /* Rating.h */,
    3.31 +				15EB7B7A250794D8004C176D /* ReceiverRating.c */,
    3.32 +				15EB7B73250794D8004C176D /* ReceiverRating.h */,
    3.33  				15B75BDC23FA9F9D00DAE976 /* SynchronizeGroupKeys.c */,
    3.34  				15B75BE123FA9F9D00DAE976 /* SynchronizeGroupKeys.h */,
    3.35  				4378C79023D1AF1700D1AF3F /* ElectGroupKeyResetLeader.c */,
    3.36 @@ -828,7 +840,9 @@
    3.37  				15B0380F22B2B823002D664C /* Sync.h in Headers */,
    3.38  				43C3778E246A8C0300962D22 /* internal_format.h in Headers */,
    3.39  				15B0380422B2B822002D664C /* constr_SET_OF.h in Headers */,
    3.40 +				15EB7B7C250794D9004C176D /* Rating.h in Headers */,
    3.41  				15B0381322B2B823002D664C /* asn_application.h in Headers */,
    3.42 +				15EB7B7B250794D9004C176D /* ReceiverRating.h in Headers */,
    3.43  				15B0380322B2B822002D664C /* OwnKeysRequester.h in Headers */,
    3.44  				154918AB22B940200091B6D6 /* fsm_common.h in Headers */,
    3.45  				15147EF3237E9EA7003989FE /* GroupKeysAndClose.h in Headers */,
    3.46 @@ -1083,6 +1097,7 @@
    3.47  				15B037B522B2B822002D664C /* OCTET_STRING.c in Sources */,
    3.48  				64A826831B455D0800EECAF0 /* platform_unix.c in Sources */,
    3.49  				15B0380D22B2B822002D664C /* CommitReject.c in Sources */,
    3.50 +				15EB7B7D250794D9004C176D /* Rating.c in Sources */,
    3.51  				15B0380B22B2B822002D664C /* NativeInteger.c in Sources */,
    3.52  				15147EF2237E9EA7003989FE /* GroupKeysAndClose.c in Sources */,
    3.53  				158FF95B23C49ED600CB1016 /* KeyReset.c in Sources */,
    3.54 @@ -1144,6 +1159,7 @@
    3.55  				430BCC492015EE800077E998 /* pEp_string.c in Sources */,
    3.56  				15B037EB22B2B822002D664C /* constr_SET_OF.c in Sources */,
    3.57  				15B037DD22B2B822002D664C /* Rollback.c in Sources */,
    3.58 +				15EB7B7E250794D9004C176D /* ReceiverRating.c in Sources */,
    3.59  				158FF96123C49ED600CB1016 /* Distribution.c in Sources */,
    3.60  				43F73C0B2166282C00AB4524 /* openpgp_compat.c in Sources */,
    3.61  				15B037F422B2B822002D664C /* ber_decoder.c in Sources */,
     4.1 --- a/build-windows/libpEpasn1/libpEpasn1.vcxproj	Wed Sep 09 00:16:10 2020 +0200
     4.2 +++ b/build-windows/libpEpasn1/libpEpasn1.vcxproj	Wed Sep 09 00:23:04 2020 +0200
     4.3 @@ -85,137 +85,10 @@
     4.4      <None Include="..\generate_code.cmd" />
     4.5    </ItemGroup>
     4.6    <ItemGroup>
     4.7 -    <ClCompile Include="..\..\asn.1\asn_codecs_prim.c" />
     4.8 -    <ClCompile Include="..\..\asn.1\asn_SEQUENCE_OF.c" />
     4.9 -    <ClCompile Include="..\..\asn.1\asn_SET_OF.c" />
    4.10 -    <ClCompile Include="..\..\asn.1\Beacon.c" />
    4.11 -    <ClCompile Include="..\..\asn.1\ber_decoder.c" />
    4.12 -    <ClCompile Include="..\..\asn.1\ber_tlv_length.c" />
    4.13 -    <ClCompile Include="..\..\asn.1\ber_tlv_tag.c" />
    4.14 -    <ClCompile Include="..\..\asn.1\BIT_STRING.c" />
    4.15 -    <ClCompile Include="..\..\asn.1\BOOLEAN.c" />
    4.16 -    <ClCompile Include="..\..\asn.1\Command.c" />
    4.17 -    <ClCompile Include="..\..\asn.1\Commands.c" />
    4.18 -    <ClCompile Include="..\..\asn.1\CommitAccept.c" />
    4.19 -    <ClCompile Include="..\..\asn.1\CommitAcceptForGroup.c" />
    4.20 -    <ClCompile Include="..\..\asn.1\CommitAcceptOfferer.c" />
    4.21 -    <ClCompile Include="..\..\asn.1\CommitAcceptRequester.c" />
    4.22 -    <ClCompile Include="..\..\asn.1\CommitReject.c" />
    4.23 -    <ClCompile Include="..\..\asn.1\constraints.c" />
    4.24 -    <ClCompile Include="..\..\asn.1\constr_CHOICE.c" />
    4.25 -    <ClCompile Include="..\..\asn.1\constr_SEQUENCE.c" />
    4.26 -    <ClCompile Include="..\..\asn.1\constr_SEQUENCE_OF.c" />
    4.27 -    <ClCompile Include="..\..\asn.1\constr_SET_OF.c" />
    4.28 -    <ClCompile Include="..\..\asn.1\constr_TYPE.c" />
    4.29 -    <ClCompile Include="..\..\asn.1\der_encoder.c" />
    4.30 -    <ClCompile Include="..\..\asn.1\Distribution.c" />
    4.31 -    <ClCompile Include="..\..\asn.1\ElectGroupKeyResetLeader.c" />
    4.32 -    <ClCompile Include="..\..\asn.1\GroupHandshake.c" />
    4.33 -    <ClCompile Include="..\..\asn.1\GroupKeysAndClose.c" />
    4.34 -    <ClCompile Include="..\..\asn.1\GroupKeysForNewMember.c" />
    4.35 -    <ClCompile Include="..\..\asn.1\GroupKeysUpdate.c" />
    4.36 -    <ClCompile Include="..\..\asn.1\GroupTrustThisKey.c" />
    4.37 -    <ClCompile Include="..\..\asn.1\Hash.c" />
    4.38 -    <ClCompile Include="..\..\asn.1\Hex.c" />
    4.39 -    <ClCompile Include="..\..\asn.1\Identity.c" />
    4.40 -    <ClCompile Include="..\..\asn.1\IdentityList.c" />
    4.41 -    <ClCompile Include="..\..\asn.1\InitUnledGroupKeyReset.c" />
    4.42 -    <ClCompile Include="..\..\asn.1\INTEGER.c" />
    4.43 -    <ClCompile Include="..\..\asn.1\ISO639-1.c" />
    4.44 -    <ClCompile Include="..\..\asn.1\KeyReset.c" />
    4.45 -    <ClCompile Include="..\..\asn.1\KeySync.c" />
    4.46 -    <ClCompile Include="..\..\asn.1\NativeEnumerated.c" />
    4.47 -    <ClCompile Include="..\..\asn.1\NativeInteger.c" />
    4.48 -    <ClCompile Include="..\..\asn.1\NegotiationOpen.c" />
    4.49 -    <ClCompile Include="..\..\asn.1\NegotiationRequest.c" />
    4.50 -    <ClCompile Include="..\..\asn.1\NegotiationRequestGrouped.c" />
    4.51 -    <ClCompile Include="..\..\asn.1\OCTET_STRING.c" />
    4.52 -    <ClCompile Include="..\..\asn.1\OwnKeysOfferer.c" />
    4.53 -    <ClCompile Include="..\..\asn.1\OwnKeysRequester.c" />
    4.54 -    <ClCompile Include="..\..\asn.1\pdu_collection.c" />
    4.55 -    <ClCompile Include="..\..\asn.1\per_decoder.c" />
    4.56 -    <ClCompile Include="..\..\asn.1\per_encoder.c" />
    4.57 -    <ClCompile Include="..\..\asn.1\per_opentype.c" />
    4.58 -    <ClCompile Include="..\..\asn.1\per_support.c" />
    4.59 -    <ClCompile Include="..\..\asn.1\PrintableString.c" />
    4.60 -    <ClCompile Include="..\..\asn.1\PString.c" />
    4.61 -    <ClCompile Include="..\..\asn.1\Rollback.c" />
    4.62 -    <ClCompile Include="..\..\asn.1\Sync.c" />
    4.63 -    <ClCompile Include="..\..\asn.1\SynchronizeGroupKeys.c" />
    4.64 -    <ClCompile Include="..\..\asn.1\TID.c" />
    4.65 -    <ClCompile Include="..\..\asn.1\UTF8String.c" />
    4.66 -    <ClCompile Include="..\..\asn.1\Version.c" />
    4.67 -    <ClCompile Include="..\..\asn.1\xer_decoder.c" />
    4.68 -    <ClCompile Include="..\..\asn.1\xer_encoder.c" />
    4.69 -    <ClCompile Include="..\..\asn.1\xer_support.c" />
    4.70 +    <ClCompile Include="..\..\asn.1\*.c" />
    4.71    </ItemGroup>
    4.72    <ItemGroup>
    4.73 -    <ClInclude Include="..\..\asn.1\asn_application.h" />
    4.74 -    <ClInclude Include="..\..\asn.1\asn_codecs.h" />
    4.75 -    <ClInclude Include="..\..\asn.1\asn_codecs_prim.h" />
    4.76 -    <ClInclude Include="..\..\asn.1\asn_internal.h" />
    4.77 -    <ClInclude Include="..\..\asn.1\asn_SEQUENCE_OF.h" />
    4.78 -    <ClInclude Include="..\..\asn.1\asn_SET_OF.h" />
    4.79 -    <ClInclude Include="..\..\asn.1\asn_system.h" />
    4.80 -    <ClInclude Include="..\..\asn.1\Beacon.h" />
    4.81 -    <ClInclude Include="..\..\asn.1\ber_decoder.h" />
    4.82 -    <ClInclude Include="..\..\asn.1\ber_tlv_length.h" />
    4.83 -    <ClInclude Include="..\..\asn.1\ber_tlv_tag.h" />
    4.84 -    <ClInclude Include="..\..\asn.1\BIT_STRING.h" />
    4.85 -    <ClInclude Include="..\..\asn.1\BOOLEAN.h" />
    4.86 -    <ClInclude Include="..\..\asn.1\Command.h" />
    4.87 -    <ClInclude Include="..\..\asn.1\Commands.h" />
    4.88 -    <ClInclude Include="..\..\asn.1\CommitAccept.h" />
    4.89 -    <ClInclude Include="..\..\asn.1\CommitAcceptForGroup.h" />
    4.90 -    <ClInclude Include="..\..\asn.1\CommitAcceptOfferer.h" />
    4.91 -    <ClInclude Include="..\..\asn.1\CommitAcceptRequester.h" />
    4.92 -    <ClInclude Include="..\..\asn.1\CommitReject.h" />
    4.93 -    <ClInclude Include="..\..\asn.1\constraints.h" />
    4.94 -    <ClInclude Include="..\..\asn.1\constr_CHOICE.h" />
    4.95 -    <ClInclude Include="..\..\asn.1\constr_SEQUENCE.h" />
    4.96 -    <ClInclude Include="..\..\asn.1\constr_SEQUENCE_OF.h" />
    4.97 -    <ClInclude Include="..\..\asn.1\constr_SET_OF.h" />
    4.98 -    <ClInclude Include="..\..\asn.1\constr_TYPE.h" />
    4.99 -    <ClInclude Include="..\..\asn.1\der_encoder.h" />
   4.100 -    <ClInclude Include="..\..\asn.1\Distribution.h" />
   4.101 -    <ClInclude Include="..\..\asn.1\ElectGroupKeyResetLeader.h" />
   4.102 -    <ClInclude Include="..\..\asn.1\GroupHandshake.h" />
   4.103 -    <ClInclude Include="..\..\asn.1\GroupKeysAndClose.h" />
   4.104 -    <ClInclude Include="..\..\asn.1\GroupKeysForNewMember.h" />
   4.105 -    <ClInclude Include="..\..\asn.1\GroupKeysUpdate.h" />
   4.106 -    <ClInclude Include="..\..\asn.1\GroupTrustThisKey.h" />
   4.107 -    <ClInclude Include="..\..\asn.1\Hash.h" />
   4.108 -    <ClInclude Include="..\..\asn.1\Hex.h" />
   4.109 -    <ClInclude Include="..\..\asn.1\Identity.h" />
   4.110 -    <ClInclude Include="..\..\asn.1\IdentityList.h" />
   4.111 -    <ClInclude Include="..\..\asn.1\InitUnledGroupKeyReset.h" />
   4.112 -    <ClInclude Include="..\..\asn.1\INTEGER.h" />
   4.113 -    <ClInclude Include="..\..\asn.1\ISO639-1.h" />
   4.114 -    <ClInclude Include="..\..\asn.1\KeyReset.h" />
   4.115 -    <ClInclude Include="..\..\asn.1\KeySync.h" />
   4.116 -    <ClInclude Include="..\..\asn.1\NativeEnumerated.h" />
   4.117 -    <ClInclude Include="..\..\asn.1\NativeInteger.h" />
   4.118 -    <ClInclude Include="..\..\asn.1\NegotiationOpen.h" />
   4.119 -    <ClInclude Include="..\..\asn.1\NegotiationRequest.h" />
   4.120 -    <ClInclude Include="..\..\asn.1\NegotiationRequestGrouped.h" />
   4.121 -    <ClInclude Include="..\..\asn.1\OCTET_STRING.h" />
   4.122 -    <ClInclude Include="..\..\asn.1\OwnKeysOfferer.h" />
   4.123 -    <ClInclude Include="..\..\asn.1\OwnKeysRequester.h" />
   4.124 -    <ClInclude Include="..\..\asn.1\per_decoder.h" />
   4.125 -    <ClInclude Include="..\..\asn.1\per_encoder.h" />
   4.126 -    <ClInclude Include="..\..\asn.1\per_opentype.h" />
   4.127 -    <ClInclude Include="..\..\asn.1\per_support.h" />
   4.128 -    <ClInclude Include="..\..\asn.1\PrintableString.h" />
   4.129 -    <ClInclude Include="..\..\asn.1\PString.h" />
   4.130 -    <ClInclude Include="..\..\asn.1\Rollback.h" />
   4.131 -    <ClInclude Include="..\..\asn.1\Sync.h" />
   4.132 -    <ClInclude Include="..\..\asn.1\SynchronizeGroupKeys.h" />
   4.133 -    <ClInclude Include="..\..\asn.1\TID.h" />
   4.134 -    <ClInclude Include="..\..\asn.1\UTF8String.h" />
   4.135 -    <ClInclude Include="..\..\asn.1\Version.h" />
   4.136 -    <ClInclude Include="..\..\asn.1\xer_decoder.h" />
   4.137 -    <ClInclude Include="..\..\asn.1\xer_encoder.h" />
   4.138 -    <ClInclude Include="..\..\asn.1\xer_support.h" />
   4.139 +    <ClInclude Include="..\..\asn.1\*.h" />
   4.140    </ItemGroup>
   4.141    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   4.142    <ImportGroup Label="ExtensionTargets" />
     5.1 --- a/src/message_api.c	Wed Sep 09 00:16:10 2020 +0200
     5.2 +++ b/src/message_api.c	Wed Sep 09 00:23:04 2020 +0200
     5.3 @@ -16,6 +16,7 @@
     5.4  #include "base64.h"
     5.5  #include "resource_id.h"
     5.6  #include "internal_format.h"
     5.7 +#include "sync_codec.h"
     5.8  
     5.9  #include <assert.h>
    5.10  #include <string.h>
    5.11 @@ -245,7 +246,86 @@
    5.12      }
    5.13  }
    5.14  
    5.15 +bool sync_message_attached(message *msg)
    5.16 +{
    5.17 +    if (!(msg && msg->attachments))
    5.18 +        return false;
    5.19 +
    5.20 +    for (bloblist_t *a = msg->attachments; a && a->value ; a = a->next) {
    5.21 +        if (a->mime_type && strcasecmp(a->mime_type, "application/pEp.sync") == 0)
    5.22 +            return true;
    5.23 +    }
    5.24 +
    5.25 +    return false;
    5.26 +}
    5.27 +
    5.28 +PEP_STATUS set_receiverRating(PEP_SESSION session, message *msg, PEP_rating rating)
    5.29 +{
    5.30 +    if (!(session && msg && rating))
    5.31 +        return PEP_ILLEGAL_VALUE;
    5.32 +
    5.33 +    if (!(msg->recv_by && msg->recv_by->fpr && msg->recv_by->fpr[0]))
    5.34 +        return PEP_SYNC_NO_CHANNEL;
    5.35 +
    5.36 +    // don't add a second sync message
    5.37 +    if (sync_message_attached(msg))
    5.38 +        return PEP_STATUS_OK;
    5.39 +
    5.40 +    Sync_t *res = new_Sync_message(Sync_PR_keysync, KeySync_PR_receiverRating);
    5.41 +    if (!res)
    5.42 +        return PEP_OUT_OF_MEMORY;
    5.43 +
    5.44 +    res->choice.keysync.choice.receiverRating.rating = (Rating_t) rating;
    5.45 +
    5.46 +    char *payload;
    5.47 +    size_t size;
    5.48 +    PEP_STATUS status = encode_Sync_message(res, &payload, &size);
    5.49 +    free_Sync_message(res);
    5.50 +    if (status)
    5.51 +        return status;
    5.52 +
    5.53 +    return base_decorate_message(session, msg, BASE_SYNC, payload, size, msg->recv_by->fpr);
    5.54 +}
    5.55 +
    5.56 +PEP_STATUS get_receiverRating(PEP_SESSION session, message *msg, PEP_rating *rating)
    5.57 +{
    5.58 +    if (!(session && msg && rating))
    5.59 +        return PEP_ILLEGAL_VALUE;
    5.60 +
    5.61 +    *rating = PEP_rating_undefined;
    5.62 +
    5.63 +    size_t size;
    5.64 +    const char *payload;
    5.65 +    char *fpr;
    5.66 +    PEP_STATUS status = base_extract_message(session, msg, BASE_SYNC, &size, &payload, &fpr);
    5.67 +    if (status)
    5.68 +        return status;
    5.69 +    if (!fpr)
    5.70 +        return PEP_SYNC_NO_CHANNEL;
    5.71 +
    5.72 +    bool own_key;
    5.73 +    status = is_own_key(session, fpr, &own_key);
    5.74 +    free(fpr);
    5.75 +    if (!own_key)
    5.76 +        return PEP_SYNC_NO_CHANNEL;
    5.77 +
    5.78 +    Sync_t *res;
    5.79 +    status = decode_Sync_message(payload, size, &res);
    5.80 +    if (status)
    5.81 +        return status;
    5.82 +
    5.83 +    if (!(res->present == Sync_PR_keysync && res->choice.keysync.present == KeySync_PR_receiverRating)) {
    5.84 +        free_Sync_message(res);
    5.85 +        return PEP_SYNC_NO_CHANNEL;
    5.86 +    }
    5.87 +
    5.88 +    *rating = res->choice.keysync.choice.receiverRating.rating;
    5.89 +    replace_opt_field(msg, "X-EncStatus", rating_to_string(*rating), true);
    5.90 +    return PEP_STATUS_OK;
    5.91 +}
    5.92 +
    5.93  void decorate_message(
    5.94 +    PEP_SESSION session,
    5.95      message *msg,
    5.96      PEP_rating rating,
    5.97      stringlist_t *keylist,
    5.98 @@ -258,8 +338,10 @@
    5.99      if (add_version)
   5.100          replace_opt_field(msg, "X-pEp-Version", PEP_VERSION, clobber);
   5.101  
   5.102 -    if (rating != PEP_rating_undefined)
   5.103 +    if (rating != PEP_rating_undefined) {
   5.104          replace_opt_field(msg, "X-EncStatus", rating_to_string(rating), clobber);
   5.105 +        set_receiverRating(session, msg, rating);
   5.106 +    }
   5.107  
   5.108      if (keylist) {
   5.109          char *_keylist = keylist_to_string(keylist);
   5.110 @@ -2609,7 +2691,7 @@
   5.111              attach_own_key(session, src);
   5.112              added_key_to_real_src = true;
   5.113          }
   5.114 -        decorate_message(src, PEP_rating_undefined, NULL, true, true);
   5.115 +        decorate_message(session, src, PEP_rating_undefined, NULL, true, true);
   5.116          return PEP_UNENCRYPTED;
   5.117      }
   5.118      else {
   5.119 @@ -2677,7 +2759,7 @@
   5.120      }
   5.121  
   5.122      if (msg) {
   5.123 -        decorate_message(msg, PEP_rating_undefined, NULL, true, true);
   5.124 +        decorate_message(session, msg, PEP_rating_undefined, NULL, true, true);
   5.125          if (_src->id) {
   5.126              msg->id = strdup(_src->id);
   5.127              assert(msg->id);
   5.128 @@ -3045,7 +3127,7 @@
   5.129              if (msg->id == NULL)
   5.130                  goto enomem;
   5.131          }
   5.132 -        decorate_message(msg, PEP_rating_undefined, NULL, true, true);
   5.133 +        decorate_message(session, msg, PEP_rating_undefined, NULL, true, true);
   5.134      }
   5.135  
   5.136      *dst = msg;
   5.137 @@ -4606,8 +4688,15 @@
   5.138  
   5.139      // Check for and deal with unencrypted messages
   5.140      if (src->enc_format == PEP_enc_none) {
   5.141 -
   5.142 -        *rating = PEP_rating_unencrypted;
   5.143 +        // if there is a valid receiverRating then return this rating else
   5.144 +        // return unencrypted
   5.145 +
   5.146 +        PEP_rating _rating = PEP_rating_undefined;
   5.147 +        status = get_receiverRating(session, src, &_rating);
   5.148 +        if (status == PEP_STATUS_OK && _rating)
   5.149 +            *rating = _rating;
   5.150 +        else
   5.151 +            *rating = PEP_rating_unencrypted;
   5.152  
   5.153          // We remove these from the outermost source message
   5.154          // if (keys_were_imported)
   5.155 @@ -4623,9 +4712,22 @@
   5.156          return PEP_UNENCRYPTED;
   5.157      }
   5.158  
   5.159 +    // if there is an own identity defined via this message is coming in
   5.160 +    // retrieve the details; in case there's no usuable own key make it
   5.161 +    // functional
   5.162 +    if (src->recv_by) {
   5.163 +        status = myself(session, src->recv_by);
   5.164 +        if (status) {
   5.165 +            free_stringlist(_imported_key_list);
   5.166 +            return status;
   5.167 +        }
   5.168 +    }
   5.169 +
   5.170      status = get_crypto_text(src, &ctext, &csize);
   5.171 -    if (status != PEP_STATUS_OK)
   5.172 +    if (status) {
   5.173 +        free_stringlist(_imported_key_list);
   5.174          return status;
   5.175 +    }
   5.176          
   5.177      /** Ok, we should be ready to decrypt. Try decrypt and verify first! **/
   5.178      status = decrypt_and_verify(session, ctext, csize, dsig_text, dsig_size,
   5.179 @@ -5076,7 +5178,13 @@
   5.180              dedup_stringlist(_keylist->next);
   5.181              
   5.182          /* add pEp-related status flags to header */
   5.183 -        decorate_message(msg, *rating, _keylist, false, true);
   5.184 +        if (src->recv_by) {
   5.185 +            free_identity(msg->recv_by);
   5.186 +            msg->recv_by = identity_dup(src->recv_by);
   5.187 +            if (!msg->recv_by)
   5.188 +                goto enomem;
   5.189 +        }
   5.190 +        decorate_message(session, msg, *rating, _keylist, false, true);
   5.191  
   5.192          // Maybe unnecessary
   5.193          // if (keys_were_imported)
     6.1 --- a/src/pEpEngine.h	Wed Sep 09 00:16:10 2020 +0200
     6.2 +++ b/src/pEpEngine.h	Wed Sep 09 00:23:04 2020 +0200
     6.3 @@ -28,7 +28,7 @@
     6.4  #define PEP_ENGINE_VERSION_MAJOR 2
     6.5  #define PEP_ENGINE_VERSION_MINOR 1
     6.6  #define PEP_ENGINE_VERSION_PATCH 0
     6.7 -#define PEP_ENGINE_VERSION_RC    29
     6.8 +#define PEP_ENGINE_VERSION_RC    35
     6.9  
    6.10  
    6.11  #define PEP_OWN_USERID "pEp_own_userId"
     7.1 --- a/src/pEp_internal.h	Wed Sep 09 00:16:10 2020 +0200
     7.2 +++ b/src/pEp_internal.h	Wed Sep 09 00:23:04 2020 +0200
     7.3 @@ -339,6 +339,7 @@
     7.4   *  
     7.5   */
     7.6  void decorate_message(
     7.7 +    PEP_SESSION session,
     7.8      message *msg,
     7.9      PEP_rating rating,
    7.10      stringlist_t *keylist,
     8.1 --- a/sync/gen_message_func.ysl2	Wed Sep 09 00:16:10 2020 +0200
     8.2 +++ b/sync/gen_message_func.ysl2	Wed Sep 09 00:23:04 2020 +0200
     8.3 @@ -296,7 +296,7 @@
     8.4      const "state" > «yml:lcase(ancestor::protocol/@name)»_state.«yml:lcase(ancestor::fsm/@name)»
     8.5  
     8.6      choose {
     8.7 -        when "func:basicType()" // copyable
     8.8 +        when "func:basicType() or @type='Rating'" // copyable
     8.9          ||
    8.10          msg->choice.«yml:lcase(../../@name)».choice.«$message_name».«@name»
    8.11                   = session->«$state».«@name»;
    8.12 @@ -380,7 +380,7 @@
    8.13  template "field", mode=update_state {
    8.14      param "message_name";
    8.15      choose {
    8.16 -        when "func:basicType()" // copyable
    8.17 +        when "func:basicType() or @type='Rating'" // copyable
    8.18          ||
    8.19          session->«yml:lcase(../../../@name)»_state.«yml:lcase(../../@name)».«@name» = msg->choice.«yml:lcase(../../@name)»
    8.20                  .choice.«$message_name».«@name»;
     9.1 --- a/sync/gen_messages.ysl2	Wed Sep 09 00:16:10 2020 +0200
     9.2 +++ b/sync/gen_messages.ysl2	Wed Sep 09 00:23:04 2020 +0200
     9.3 @@ -15,7 +15,7 @@
     9.4      include ./functions.ysl2
     9.5  
     9.6      function "pEp_imports"
     9.7 -        | IMPORTS Version, Identity, IdentityList, TID, Hash FROM PEP;
     9.8 +        | IMPORTS Version, Identity, IdentityList, TID, Hash, Rating FROM PEP;
     9.9  
    9.10      function "header"
    9.11      ||
    10.1 --- a/sync/gen_statemachine.ysl2	Wed Sep 09 00:16:10 2020 +0200
    10.2 +++ b/sync/gen_statemachine.ysl2	Wed Sep 09 00:23:04 2020 +0200
    10.3 @@ -585,7 +585,7 @@
    10.4                                  goto the_end;
    10.5                              }
    10.6                              attach_own_key(session, _m);
    10.7 -                            decorate_message(_m, PEP_rating_undefined, NULL, true, true);
    10.8 +                            decorate_message(session, _m, PEP_rating_undefined, NULL, true, true);
    10.9                              m = _m;
   10.10                              break;
   10.11  
   10.12 @@ -1349,7 +1349,7 @@
   10.13                  case Init:
   10.14                      return "Init";
   10.15          ||
   10.16 -        for "func:distinctName(state/event[not(@name='Init')])" {
   10.17 +        for "func:distinctName(state/event[not(@name='Init')]|message)" {
   10.18              |>> case «@name»:
   10.19              |>>> return "«@name»";
   10.20          }
    11.1 --- a/sync/sync.fsm	Wed Sep 09 00:16:10 2020 +0200
    11.2 +++ b/sync/sync.fsm	Wed Sep 09 00:23:04 2020 +0200
    11.3 @@ -679,5 +679,14 @@
    11.4  
    11.5          message SynchronizeGroupKeys 21, ratelimit=60 {
    11.6          }
    11.7 +
    11.8 +        // This could be part of TrustSync, but actually it does not matter.
    11.9 +        // This message will not be sent by the Sync thread. It is used by
   11.10 +        // decrypt_message() to mark a previously computed rating. It is only
   11.11 +        // valid when signed with an own key.
   11.12 +
   11.13 +        message ReceiverRating 22, security=unencrypted {
   11.14 +            field Rating rating;
   11.15 +        }
   11.16      }
   11.17  }
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/src/ReceiverRatingTest.cc	Wed Sep 09 00:23:04 2020 +0200
    12.3 @@ -0,0 +1,154 @@
    12.4 +#include <stdlib.h>
    12.5 +#include <string>
    12.6 +#include <cstring>
    12.7 +
    12.8 +#include "internal_format.h"
    12.9 +
   12.10 +#include "test_util.h"
   12.11 +#include "TestConstants.h"
   12.12 +#include "Engine.h"
   12.13 +
   12.14 +#include <gtest/gtest.h>
   12.15 +
   12.16 +extern "C" {
   12.17 +    PEP_STATUS set_receiverRating(PEP_SESSION session, message *msg, PEP_rating rating);
   12.18 +    PEP_STATUS get_receiverRating(PEP_SESSION session, message *msg, PEP_rating *rating);
   12.19 +}
   12.20 +
   12.21 +namespace {
   12.22 +
   12.23 +	//The fixture for ReceiverRatingTest
   12.24 +    class ReceiverRatingTest : public ::testing::Test {
   12.25 +        public:
   12.26 +            Engine* engine;
   12.27 +            PEP_SESSION session;
   12.28 +
   12.29 +        protected:
   12.30 +            // You can remove any or all of the following functions if its body
   12.31 +            // is empty.
   12.32 +            ReceiverRatingTest() {
   12.33 +                // You can do set-up work for each test here.
   12.34 +                test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->GTEST_SUITE_SYM();
   12.35 +                test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();
   12.36 +                test_path = get_main_test_home_dir() + "/" + test_suite_name + "/" + test_name;
   12.37 +            }
   12.38 +
   12.39 +            ~ReceiverRatingTest() override {
   12.40 +                // You can do clean-up work that doesn't throw exceptions here.
   12.41 +            }
   12.42 +
   12.43 +            // If the constructor and destructor are not enough for setting up
   12.44 +            // and cleaning up each test, you can define the following methods:
   12.45 +
   12.46 +            void SetUp() override {
   12.47 +                // Code here will be called immediately after the constructor (right
   12.48 +                // before each test).
   12.49 +
   12.50 +                // Leave this empty if there are no files to copy to the home directory path
   12.51 +                std::vector<std::pair<std::string, std::string>> init_files = std::vector<std::pair<std::string, std::string>>();
   12.52 +
   12.53 +                // Get a new test Engine.
   12.54 +                engine = new Engine(test_path);
   12.55 +                ASSERT_NE(engine, nullptr);
   12.56 +
   12.57 +                // Ok, let's initialize test directories etc.
   12.58 +                engine->prep(NULL, NULL, NULL, init_files);
   12.59 +
   12.60 +                // Ok, try to start this bugger.
   12.61 +                engine->start();
   12.62 +                ASSERT_NE(engine->session, nullptr);
   12.63 +                session = engine->session;
   12.64 +
   12.65 +                // Engine is up. Keep on truckin'
   12.66 +            }
   12.67 +
   12.68 +            void TearDown() override {
   12.69 +                // Code here will be called immediately after each test (right
   12.70 +                // before the destructor).
   12.71 +                engine->shut_down();
   12.72 +                delete engine;
   12.73 +                engine = NULL;
   12.74 +                session = NULL;
   12.75 +            }
   12.76 +
   12.77 +        private:
   12.78 +            const char* test_suite_name;
   12.79 +            const char* test_name;
   12.80 +            string test_path;
   12.81 +            // Objects declared here can be used by all tests in the ReceiverRatingTest suite.
   12.82 +
   12.83 +    };
   12.84 +
   12.85 +}  // namespace
   12.86 +
   12.87 +TEST_F(ReceiverRatingTest, check_internal_format) {
   12.88 +    // a message from me, Alice, to myself
   12.89 +
   12.90 +    const char* alice_fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
   12.91 +    PEP_STATUS status = read_file_and_import_key(session,
   12.92 +                "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   12.93 +    ASSERT_EQ(status , PEP_KEY_IMPORTED);
   12.94 +    status = set_up_ident_from_scratch(session,
   12.95 +                "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
   12.96 +                "pep.test.alice@pep-project.org", alice_fpr,
   12.97 +                PEP_OWN_USERID, "Alice in Wonderland", NULL, true
   12.98 +            );
   12.99 +    ASSERT_EQ(status , PEP_STATUS_OK);
  12.100 +
  12.101 +    message* msg = new_message(PEP_dir_outgoing);
  12.102 +    pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, NULL);
  12.103 +    status = myself(session, alice);
  12.104 +    ASSERT_EQ(status , PEP_STATUS_OK);
  12.105 +    pEp_identity* alice2 = identity_dup(alice);
  12.106 +
  12.107 +    msg->to = new_identity_list(identity_dup(alice));
  12.108 +    msg->from = identity_dup(alice);
  12.109 +    msg->shortmsg = strdup("Yo Mama!");
  12.110 +    msg->longmsg = strdup("Look at my hot new sender fpr field!");
  12.111 +
  12.112 +    // encrypt this message
  12.113 +
  12.114 +    message* enc_msg = NULL;
  12.115 +    status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PEP, 0);
  12.116 +    ASSERT_EQ(status , PEP_STATUS_OK);
  12.117 +    
  12.118 +    // decrypt this message
  12.119 +    
  12.120 +    message *dec_msg = NULL;
  12.121 +    stringlist_t *keylist = NULL;
  12.122 +    PEP_rating rating = PEP_rating_undefined;
  12.123 +    PEP_decrypt_flags_t flags = 0;
  12.124 +
  12.125 +    enc_msg->recv_by = identity_dup(alice);
  12.126 +    status = decrypt_message(session, enc_msg, &dec_msg, &keylist, &rating, &flags);
  12.127 +    ASSERT_EQ(status, PEP_STATUS_OK);
  12.128 +    ASSERT_STREQ(msg->shortmsg, dec_msg->shortmsg);
  12.129 +    ASSERT_STREQ(msg->longmsg, dec_msg->longmsg);
  12.130 +    ASSERT_EQ(rating, PEP_rating_trusted_and_anonymized);
  12.131 +    
  12.132 +    bloblist_t *as = dec_msg->attachments;
  12.133 +    ASSERT_STREQ(as->mime_type, "application/pEp.sync");
  12.134 +
  12.135 +    // test if receiver rating can be evaluated
  12.136 +    free_stringlist(keylist);
  12.137 +    message *dec_msg2 = NULL;
  12.138 +    dec_msg->recv_by = identity_dup(alice);
  12.139 +    status = decrypt_message(session, dec_msg, &dec_msg2, &keylist, &rating, &flags);
  12.140 +    ASSERT_EQ(status, PEP_UNENCRYPTED);
  12.141 +    ASSERT_EQ(rating, PEP_rating_trusted_and_anonymized);
  12.142 +
  12.143 +    // this must be repeatable
  12.144 +    free_stringlist(keylist);
  12.145 +    dec_msg->recv_by = identity_dup(alice);
  12.146 +    status = decrypt_message(session, dec_msg, &dec_msg2, &keylist, &rating, &flags);
  12.147 +    ASSERT_EQ(status, PEP_UNENCRYPTED);
  12.148 +    ASSERT_EQ(rating, PEP_rating_trusted_and_anonymized);
  12.149 +
  12.150 +    free_stringlist(keylist);
  12.151 +    free_identity(alice);
  12.152 +    free_message(msg);
  12.153 +    free_message(enc_msg);
  12.154 +    free_message(dec_msg);
  12.155 +    free_message(dec_msg2);
  12.156 +}
  12.157 +