KEYSYNC: Merged in branch keysync-windows keysync
authorKrista Grothoff <krista@pep-project.org>
Wed, 05 Oct 2016 15:31:09 +0200
branchkeysync
changeset 1245d0c63eb5bfa6
parent 1244 e167eafb75e6
parent 1242 e7b0ff022963
child 1247 998021d725a1
child 1262 d6339a9c973e
KEYSYNC: Merged in branch keysync-windows
     1.1 --- a/.hgignore	Wed Oct 05 15:29:45 2016 +0200
     1.2 +++ b/.hgignore	Wed Oct 05 15:31:09 2016 +0200
     1.3 @@ -39,3 +39,4 @@
     1.4  Makefile.protocols
     1.5  test/msg_encrypt_for_self.asc
     1.6  tags
     1.7 +asn.1/pEpEngineASN1/pEpEngineASN1.vcxproj.user
     2.1 --- a/asn.1/pEpEngineASN1/pEpEngineASN1.vcxproj	Wed Oct 05 15:29:45 2016 +0200
     2.2 +++ b/asn.1/pEpEngineASN1/pEpEngineASN1.vcxproj	Wed Oct 05 15:31:09 2016 +0200
     2.3 @@ -54,7 +54,7 @@
     2.4        <WarningLevel>Level3</WarningLevel>
     2.5        <Optimization>Disabled</Optimization>
     2.6        <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     2.7 -	  <CompileAs>Default</CompileAs>
     2.8 +      <CompileAs>Default</CompileAs>
     2.9      </ClCompile>
    2.10      <Link>
    2.11        <SubSystem>Windows</SubSystem>
    2.12 @@ -100,6 +100,8 @@
    2.13      </Link>
    2.14      <PreBuildEvent>
    2.15        <Command>cd ..
    2.16 +del *.c
    2.17 +del *.h
    2.18  asn1c -gen-PER -fincludes-quoted -fcompound-names -pdu=PEP.Message pEp.asn1 devicegroup.asn1
    2.19  del converter-sample.c
    2.20  </Command>
    2.21 @@ -130,6 +132,7 @@
    2.22      <ClCompile Include="..\ber_tlv_length.c" />
    2.23      <ClCompile Include="..\ber_tlv_tag.c" />
    2.24      <ClCompile Include="..\BIT_STRING.c" />
    2.25 +    <ClCompile Include="..\BOOLEAN.c" />
    2.26      <ClCompile Include="..\constraints.c" />
    2.27      <ClCompile Include="..\constr_CHOICE.c" />
    2.28      <ClCompile Include="..\constr_SEQUENCE.c" />
    2.29 @@ -141,20 +144,21 @@
    2.30      <ClCompile Include="..\GroupKeys.c" />
    2.31      <ClCompile Include="..\HandshakeRequest.c" />
    2.32      <ClCompile Include="..\Hash.c" />
    2.33 -    <ClCompile Include="..\Header.c" />
    2.34      <ClCompile Include="..\Hex.c" />
    2.35      <ClCompile Include="..\Identity.c" />
    2.36 +    <ClCompile Include="..\IdentityList.c" />
    2.37      <ClCompile Include="..\INTEGER.c" />
    2.38      <ClCompile Include="..\ISO639-1.c" />
    2.39 -    <ClCompile Include="..\KeyList.c" />
    2.40      <ClCompile Include="..\NativeEnumerated.c" />
    2.41      <ClCompile Include="..\NativeInteger.c" />
    2.42 +    <ClCompile Include="..\NULL.c" />
    2.43      <ClCompile Include="..\OCTET_STRING.c" />
    2.44      <ClCompile Include="..\per_decoder.c" />
    2.45      <ClCompile Include="..\per_encoder.c" />
    2.46      <ClCompile Include="..\per_opentype.c" />
    2.47      <ClCompile Include="..\per_support.c" />
    2.48      <ClCompile Include="..\PrintableString.c" />
    2.49 +    <ClCompile Include="..\Sync-Protocols.c" />
    2.50      <ClCompile Include="..\UTF8String.c" />
    2.51      <ClCompile Include="..\Version.c" />
    2.52      <ClCompile Include="..\xer_decoder.c" />
    2.53 @@ -174,6 +178,7 @@
    2.54      <ClInclude Include="..\ber_tlv_length.h" />
    2.55      <ClInclude Include="..\ber_tlv_tag.h" />
    2.56      <ClInclude Include="..\BIT_STRING.h" />
    2.57 +    <ClInclude Include="..\BOOLEAN.h" />
    2.58      <ClInclude Include="..\constraints.h" />
    2.59      <ClInclude Include="..\constr_CHOICE.h" />
    2.60      <ClInclude Include="..\constr_SEQUENCE.h" />
    2.61 @@ -185,21 +190,21 @@
    2.62      <ClInclude Include="..\GroupKeys.h" />
    2.63      <ClInclude Include="..\HandshakeRequest.h" />
    2.64      <ClInclude Include="..\Hash.h" />
    2.65 -    <ClInclude Include="..\Header.h" />
    2.66      <ClInclude Include="..\Hex.h" />
    2.67      <ClInclude Include="..\Identity.h" />
    2.68 +    <ClInclude Include="..\IdentityList.h" />
    2.69      <ClInclude Include="..\INTEGER.h" />
    2.70      <ClInclude Include="..\ISO639-1.h" />
    2.71 -    <ClInclude Include="..\KeyList.h" />
    2.72      <ClInclude Include="..\NativeEnumerated.h" />
    2.73      <ClInclude Include="..\NativeInteger.h" />
    2.74 +    <ClInclude Include="..\NULL.h" />
    2.75      <ClInclude Include="..\OCTET_STRING.h" />
    2.76 -    <ClInclude Include="..\OwnKeys.h" />
    2.77      <ClInclude Include="..\per_decoder.h" />
    2.78      <ClInclude Include="..\per_encoder.h" />
    2.79      <ClInclude Include="..\per_opentype.h" />
    2.80      <ClInclude Include="..\per_support.h" />
    2.81      <ClInclude Include="..\PrintableString.h" />
    2.82 +    <ClInclude Include="..\Sync-Protocols.h" />
    2.83      <ClInclude Include="..\UTF8String.h" />
    2.84      <ClInclude Include="..\Version.h" />
    2.85      <ClInclude Include="..\xer_decoder.h" />
     3.1 --- a/asn.1/pEpEngineASN1/pEpEngineASN1.vcxproj.filters	Wed Oct 05 15:29:45 2016 +0200
     3.2 +++ b/asn.1/pEpEngineASN1/pEpEngineASN1.vcxproj.filters	Wed Oct 05 15:31:09 2016 +0200
     3.3 @@ -72,9 +72,6 @@
     3.4      <ClCompile Include="..\Hash.c">
     3.5        <Filter>Source Files</Filter>
     3.6      </ClCompile>
     3.7 -    <ClCompile Include="..\Header.c">
     3.8 -      <Filter>Source Files</Filter>
     3.9 -    </ClCompile>
    3.10      <ClCompile Include="..\Hex.c">
    3.11        <Filter>Source Files</Filter>
    3.12      </ClCompile>
    3.13 @@ -87,9 +84,6 @@
    3.14      <ClCompile Include="..\ISO639-1.c">
    3.15        <Filter>Source Files</Filter>
    3.16      </ClCompile>
    3.17 -    <ClCompile Include="..\KeyList.c">
    3.18 -      <Filter>Source Files</Filter>
    3.19 -    </ClCompile>
    3.20      <ClCompile Include="..\NativeEnumerated.c">
    3.21        <Filter>Source Files</Filter>
    3.22      </ClCompile>
    3.23 @@ -132,6 +126,18 @@
    3.24      <ClCompile Include="..\GroupKeys.c">
    3.25        <Filter>Source Files</Filter>
    3.26      </ClCompile>
    3.27 +    <ClCompile Include="..\BOOLEAN.c">
    3.28 +      <Filter>Source Files</Filter>
    3.29 +    </ClCompile>
    3.30 +    <ClCompile Include="..\IdentityList.c">
    3.31 +      <Filter>Source Files</Filter>
    3.32 +    </ClCompile>
    3.33 +    <ClCompile Include="..\NULL.c">
    3.34 +      <Filter>Source Files</Filter>
    3.35 +    </ClCompile>
    3.36 +    <ClCompile Include="..\Sync-Protocols.c">
    3.37 +      <Filter>Source Files</Filter>
    3.38 +    </ClCompile>
    3.39    </ItemGroup>
    3.40    <ItemGroup>
    3.41      <ClInclude Include="..\DeviceGroup-Protocol.h">
    3.42 @@ -200,9 +206,6 @@
    3.43      <ClInclude Include="..\Hash.h">
    3.44        <Filter>Header Files</Filter>
    3.45      </ClInclude>
    3.46 -    <ClInclude Include="..\Header.h">
    3.47 -      <Filter>Header Files</Filter>
    3.48 -    </ClInclude>
    3.49      <ClInclude Include="..\Hex.h">
    3.50        <Filter>Header Files</Filter>
    3.51      </ClInclude>
    3.52 @@ -215,9 +218,6 @@
    3.53      <ClInclude Include="..\ISO639-1.h">
    3.54        <Filter>Header Files</Filter>
    3.55      </ClInclude>
    3.56 -    <ClInclude Include="..\KeyList.h">
    3.57 -      <Filter>Header Files</Filter>
    3.58 -    </ClInclude>
    3.59      <ClInclude Include="..\NativeEnumerated.h">
    3.60        <Filter>Header Files</Filter>
    3.61      </ClInclude>
    3.62 @@ -227,9 +227,6 @@
    3.63      <ClInclude Include="..\OCTET_STRING.h">
    3.64        <Filter>Header Files</Filter>
    3.65      </ClInclude>
    3.66 -    <ClInclude Include="..\OwnKeys.h">
    3.67 -      <Filter>Header Files</Filter>
    3.68 -    </ClInclude>
    3.69      <ClInclude Include="..\per_decoder.h">
    3.70        <Filter>Header Files</Filter>
    3.71      </ClInclude>
    3.72 @@ -263,5 +260,17 @@
    3.73      <ClInclude Include="..\GroupKeys.h">
    3.74        <Filter>Header Files</Filter>
    3.75      </ClInclude>
    3.76 +    <ClInclude Include="..\BOOLEAN.h">
    3.77 +      <Filter>Header Files</Filter>
    3.78 +    </ClInclude>
    3.79 +    <ClInclude Include="..\IdentityList.h">
    3.80 +      <Filter>Header Files</Filter>
    3.81 +    </ClInclude>
    3.82 +    <ClInclude Include="..\NULL.h">
    3.83 +      <Filter>Header Files</Filter>
    3.84 +    </ClInclude>
    3.85 +    <ClInclude Include="..\Sync-Protocols.h">
    3.86 +      <Filter>Header Files</Filter>
    3.87 +    </ClInclude>
    3.88    </ItemGroup>
    3.89  </Project>
    3.90 \ No newline at end of file
     4.1 --- a/pEpEngine.vcxproj	Wed Oct 05 15:29:45 2016 +0200
     4.2 +++ b/pEpEngine.vcxproj	Wed Oct 05 15:31:09 2016 +0200
     4.3 @@ -65,7 +65,7 @@
     4.4      <Link>
     4.5        <SubSystem>Windows</SubSystem>
     4.6        <GenerateDebugInformation>true</GenerateDebugInformation>
     4.7 -      <AdditionalDependencies>$(TargetDir)\pEpEngineASN1.lib;%(AdditionalDependencies)</AdditionalDependencies>
     4.8 +      <AdditionalDependencies>$(TargetDir)\pEpEngineASN1.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
     4.9      </Link>
    4.10      <PreBuildEvent>
    4.11        <Command>
    4.12 @@ -84,13 +84,15 @@
    4.13        <TreatWarningAsError>false</TreatWarningAsError>
    4.14        <AdditionalIncludeDirectories>C:\Users\vb\share\asn1c;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    4.15        <CompileAs>Default</CompileAs>
    4.16 +      <MultiProcessorCompilation>true</MultiProcessorCompilation>
    4.17 +      <ControlFlowGuard>Guard</ControlFlowGuard>
    4.18      </ClCompile>
    4.19      <Link>
    4.20        <SubSystem>Windows</SubSystem>
    4.21        <GenerateDebugInformation>true</GenerateDebugInformation>
    4.22        <EnableCOMDATFolding>true</EnableCOMDATFolding>
    4.23        <OptimizeReferences>true</OptimizeReferences>
    4.24 -      <AdditionalDependencies>$(TargetDir)\pEpEngineASN1.lib;%(AdditionalDependencies)</AdditionalDependencies>
    4.25 +      <AdditionalDependencies>$(TargetDir)\pEpEngineASN1.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
    4.26      </Link>
    4.27      <PreBuildEvent>
    4.28        <Command>
    4.29 @@ -98,6 +100,7 @@
    4.30      </PreBuildEvent>
    4.31    </ItemDefinitionGroup>
    4.32    <ItemGroup>
    4.33 +    <ClCompile Include="src\asn1_helper.c" />
    4.34      <ClCompile Include="src\baseprotocol.c" />
    4.35      <ClCompile Include="src\blacklist.c" />
    4.36      <ClCompile Include="src\bloblist.c" />
    4.37 @@ -121,12 +124,14 @@
    4.38      <ClCompile Include="src\sync_actions.c" />
    4.39      <ClCompile Include="src\sync_driver.c" />
    4.40      <ClCompile Include="src\sync_fsm.c" />
    4.41 +    <ClCompile Include="src\sync_impl.c" />
    4.42      <ClCompile Include="src\sync_send_actions.c" />
    4.43      <ClCompile Include="src\timestamp.c" />
    4.44      <ClCompile Include="src\transport.c" />
    4.45      <ClCompile Include="src\trans_auto.c" />
    4.46    </ItemGroup>
    4.47    <ItemGroup>
    4.48 +    <ClInclude Include="src\asn1_helper.h" />
    4.49      <ClInclude Include="src\baseprotocol.h" />
    4.50      <ClInclude Include="src\blacklist.h" />
    4.51      <ClInclude Include="src\bloblist.h" />
    4.52 @@ -153,6 +158,7 @@
    4.53      <ClInclude Include="src\stringpair.h" />
    4.54      <ClInclude Include="src\sync.h" />
    4.55      <ClInclude Include="src\sync_fsm.h" />
    4.56 +    <ClInclude Include="src\sync_impl.h" />
    4.57      <ClInclude Include="src\timestamp.h" />
    4.58      <ClInclude Include="src\transport.h" />
    4.59      <ClInclude Include="src\trans_auto.h" />
     5.1 --- a/pEpEngine.vcxproj.filters	Wed Oct 05 15:29:45 2016 +0200
     5.2 +++ b/pEpEngine.vcxproj.filters	Wed Oct 05 15:31:09 2016 +0200
     5.3 @@ -96,6 +96,12 @@
     5.4      <ClCompile Include="src\openpgp_compat.c">
     5.5        <Filter>Quelldateien</Filter>
     5.6      </ClCompile>
     5.7 +    <ClCompile Include="src\asn1_helper.c">
     5.8 +      <Filter>Quelldateien</Filter>
     5.9 +    </ClCompile>
    5.10 +    <ClCompile Include="src\sync_impl.c">
    5.11 +      <Filter>Quelldateien</Filter>
    5.12 +    </ClCompile>
    5.13    </ItemGroup>
    5.14    <ItemGroup>
    5.15      <ClInclude Include="src\keymanagement.h">
    5.16 @@ -188,6 +194,12 @@
    5.17      <ClInclude Include="src\openpgp_compat.h">
    5.18        <Filter>Headerdateien</Filter>
    5.19      </ClInclude>
    5.20 +    <ClInclude Include="src\asn1_helper.h">
    5.21 +      <Filter>Headerdateien</Filter>
    5.22 +    </ClInclude>
    5.23 +    <ClInclude Include="src\sync_impl.h">
    5.24 +      <Filter>Headerdateien</Filter>
    5.25 +    </ClInclude>
    5.26    </ItemGroup>
    5.27    <ItemGroup>
    5.28      <Text Include="LICENSE.txt" />
     6.1 --- a/src/platform_unix.c	Wed Oct 05 15:29:45 2016 +0200
     6.2 +++ b/src/platform_unix.c	Wed Oct 05 15:31:09 2016 +0200
     6.3 @@ -98,7 +98,8 @@
     6.4      return buffer;
     6.5  }
     6.6  
     6.7 -void uuid_generate_random(uuid__t out)
     6.8 +// TODO: Check and possibly fix this function if necessary
     6.9 +void uuid_generate_random(pEpUUID out)
    6.10  {
    6.11      uuid_t *uuid;
    6.12      uuid_rc_t rc_create;
    6.13 @@ -107,7 +108,7 @@
    6.14          uuid_make(uuid, UUID_MAKE_V1) != UUID_RC_OK ||
    6.15          uuid_export(uuid, UUID_FMT_BIN, out, NULL) != UUID_RC_OK)
    6.16      {
    6.17 -        memset(out, 0, sizeof(uuid__t));
    6.18 +        memset(out, 0, sizeof(pEpUUID));
    6.19      }
    6.20  
    6.21      if (rc_create == UUID_RC_OK)
    6.22 @@ -116,7 +117,8 @@
    6.23      }
    6.24  }
    6.25  
    6.26 -void uuid_unparse_upper(uuid__t uu, uuid_string_t out)
    6.27 +// TODO: Check and possibly fix this function if necessary
    6.28 +void uuid_unparse_upper(pEpUUID uu, uuid_string_t out)
    6.29  {
    6.30      uuid_t *uuid;
    6.31      uuid_rc_t rc_create;
     7.1 --- a/src/platform_unix.h	Wed Oct 05 15:29:45 2016 +0200
     7.2 +++ b/src/platform_unix.h	Wed Oct 05 15:31:09 2016 +0200
     7.3 @@ -71,9 +71,11 @@
     7.4  #define UUID uuid_t
     7.5  
     7.6  #ifdef ANDROID
     7.7 -typedef char uuid__t[16];
     7.8 -void uuid_generate_random(uuid__t out);
     7.9 -void uuid_unparse_upper(uuid__t uu, uuid_string_t out);
    7.10 +typedef char pEpUUID[16];
    7.11 +void uuid_generate_random(pEpUUID out);
    7.12 +void uuid_unparse_upper(pEpUUID uu, uuid_string_t out);
    7.13 +#else
    7.14 +typedef uuid_t pEpUUID;
    7.15  #endif
    7.16  
    7.17  #ifdef __cplusplus
     8.1 --- a/src/platform_windows.cpp	Wed Oct 05 15:29:45 2016 +0200
     8.2 +++ b/src/platform_windows.cpp	Wed Oct 05 15:31:09 2016 +0200
     8.3 @@ -267,32 +267,32 @@
     8.4      return _open(pathname, _O_RDWR | _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE);
     8.5  }
     8.6  
     8.7 -void uuid_generate_random(uuid_t out)
     8.8 +void uuid_generate_random(pEpUUID out)
     8.9  {
    8.10      RPC_STATUS rpc_status = UuidCreate(out);
    8.11      assert(rpc_status == RPC_S_OK);
    8.12  }
    8.13  
    8.14 -int uuid_parse(char *in, uuid_t uu)
    8.15 +int uuid_parse(char *in, pEpUUID uu)
    8.16  {
    8.17      unsigned char *_in = (unsigned char *) in;
    8.18 -    RPC_STATUS rpc_status = UuidFromString(_in, &uu);
    8.19 +    RPC_STATUS rpc_status = UuidFromStringA(_in, uu);
    8.20      assert(rpc_status == RPC_S_OK);
    8.21      if (rpc_status == RPC_S_INVALID_STRING_UUID)
    8.22          return -1;
    8.23      return 0;
    8.24  }
    8.25  
    8.26 -void uuid_unparse_upper(uuid_t uu, uuid_string_t out)
    8.27 +void uuid_unparse_upper(pEpUUID uu, uuid_string_t out)
    8.28  {
    8.29 -    unsigned char *_out = out;
    8.30 +    unsigned char *_out = (unsigned char*)out;
    8.31      RPC_CSTR str;
    8.32 -    RPC_STATUS rpc_status = UuidToString(uu, &str);
    8.33 +    RPC_STATUS rpc_status = UuidToStringA(uu, &str);
    8.34      assert(rpc_status == RPC_S_OK);
    8.35      if (rpc_status == RPC_S_OK) {
    8.36          memcpy(out, str, 36);
    8.37          out[36] = 0;
    8.38 -        RpcStringFree(str);
    8.39 +        RpcStringFreeA(&str);
    8.40      }
    8.41      else { // if (rpc_status == RPC_S_OUT_OF_MEMORY)
    8.42          memset(out, 0, 37);
     9.1 --- a/src/platform_windows.h	Wed Oct 05 15:29:45 2016 +0200
     9.2 +++ b/src/platform_windows.h	Wed Oct 05 15:31:09 2016 +0200
     9.3 @@ -4,6 +4,14 @@
     9.4  
     9.5  #pragma warning(disable : 4996)
     9.6  
     9.7 +// We need to make sure winsock2 is included before windows.h, or we will get redefinitions of symbols
     9.8 +// as windows.h includes winsock1.h, so we will have duplicate symbols if windows.h is included first.
     9.9 +// It seems some of our code includes sync.h before including winsock.h, leading to the failure.
    9.10 +// Including winsock2.h here fixes the problem for now...
    9.11 +#ifdef WIN32 
    9.12 +#include <winsock2.h>
    9.13 +#endif // WIN32 
    9.14 +
    9.15  #include <Rpc.h>
    9.16  #include <string.h>
    9.17  #include <io.h>
    9.18 @@ -62,13 +70,13 @@
    9.19  long random(void);
    9.20  
    9.21  // on Windoze, uuid_t needs pointer semantics
    9.22 -typedef UUID *uuid_t;
    9.23 +typedef UUID pEpUUID[1];
    9.24  #define _UUID_STRING_T
    9.25  typedef char uuid_string_t[37];
    9.26  
    9.27 -void uuid_generate_random(uuid_t out);
    9.28 -int uuid_parse(char *in, uuid_t uu);
    9.29 -void uuid_unparse_upper(uuid_t uu, uuid_string_t out);
    9.30 +void uuid_generate_random(pEpUUID out);
    9.31 +int uuid_parse(char *in, pEpUUID uu);
    9.32 +void uuid_unparse_upper(pEpUUID uu, uuid_string_t out);
    9.33  
    9.34  #ifndef inline
    9.35  #define inline __inline
    10.1 --- a/src/sync_impl.c	Wed Oct 05 15:29:45 2016 +0200
    10.2 +++ b/src/sync_impl.c	Wed Oct 05 15:31:09 2016 +0200
    10.3 @@ -104,7 +104,9 @@
    10.4      return status;
    10.5  }
    10.6  
    10.7 -DYNAMIC_API void free_sync_msg(sync_msg_t *sync_msg)
    10.8 +// TODO: DYNAMIC_API was here, but broke the windows build. 
    10.9 +// We need to check whether it belongs here or it's a bug.
   10.10 +/* DYNAMIC_API */ void free_sync_msg(sync_msg_t *sync_msg)
   10.11  {
   10.12      assert(sync_msg);
   10.13      if (!(sync_msg))