[cpp-xmltooling] 02/02: CPPXT-110 Add tests for new XSEC code
Rod Widdowson
rdw at steadingsoftware.com
Wed Aug 17 11:47:46 EDT 2016
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch openssl1.1
in repository cpp-xmltooling.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-xmltooling.git;a=commit;h=0a0f5a06ec895a53b9b6abb705f8dbdfbb095945
commit 0a0f5a06ec895a53b9b6abb705f8dbdfbb095945
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Aug 17 16:44:26 2016 +0100
CPPXT-110 Add tests for new XSEC code
https://issues.shibboleth.net/jira/browse/CPPXT-110
A lot of new code was added into XSEC and XMLTOOLING as OpenSSL
made a lot of structures opaque. Suer easy to get this wrong so
we start to add code to explicitly capture the changes.
---
.../vc10/xmltoolingtest/xmltoolingtest.vcxproj | 23 +++--
.../xmltoolingtest/xmltoolingtest.vcxproj.filters | 14 +++-
.../vc14/xmltoolingtest/xmltoolingtest.vcxproj | 25 ++++--
.../xmltoolingtest/xmltoolingtest.vcxproj.filters | 7 +-
xmltoolingtest/Makefile.am | 1 +
xmltoolingtest/OpenSSL1_1Test.h | 98 ++++++++++++++++++++++
6 files changed, 154 insertions(+), 14 deletions(-)
diff --git a/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj b/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj
index 8399157..160c21d 100644
--- a/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj
+++ b/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj
@@ -66,7 +66,7 @@
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)\..\..\Build\VC10\$(Platform)\$(Configuration)\</OutDir>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\..\..\Build\VC10\$(Configuration)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)..\..\Build\VC10\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)..\..\Build\VC10\$(Configuration)\</OutDir>
@@ -97,7 +97,7 @@
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
- <AdditionalDependencies>xerces-c_3D.lib;xsec_1D.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>xerces-c_3D.lib;xsec_1D.lib;$(SSLLibD);%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -121,7 +121,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
- <AdditionalDependencies>xerces-c_3D.lib;xsec_1D.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>xerces-c_3D.lib;xsec_1D.lib;$(SSLLibD);%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
@@ -137,7 +137,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
- <AdditionalDependencies>xerces-c_3.lib;xsec_1.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>xerces-c_3.lib;xsec_1.lib;$(SSLLib);%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
@@ -160,7 +160,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
- <AdditionalDependencies>xerces-c_3.lib;xsec_1.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>xerces-c_3.lib;xsec_1.lib;$(SSLLib);%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
@@ -181,6 +181,7 @@
<ClCompile Include="MarshallingTest.cpp" />
<ClCompile Include="MemoryStorageServiceTest.cpp" />
<ClCompile Include="NonVisibleNamespaceTest.cpp" />
+ <ClCompile Include="OpenSSL1_1Test.cpp" />
<ClCompile Include="PKIXEngineTest.cpp" />
<ClCompile Include="SecurityHelperTest.cpp" />
<ClCompile Include="SignatureTest.cpp" />
@@ -342,6 +343,18 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild>
+ <CustomBuild Include="..\..\..\XMLToolingTest\OpenSSL1_1Test.h">
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"
+</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).cpp;%(Outputs)</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"
+</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).cpp;%(Outputs)</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"</Command>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).cpp;%(Outputs)</Outputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).cpp;%(Outputs)</Outputs>
+ </CustomBuild>
<CustomBuild Include="..\..\..\XMLToolingTest\PKIXEngineTest.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"
</Command>
diff --git a/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj.filters b/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj.filters
index d099072..18a0a6b 100644
--- a/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj.filters
+++ b/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj.filters
@@ -41,6 +41,9 @@
<ClCompile Include="NonVisibleNamespaceTest.cpp">
<Filter>Generated Code</Filter>
</ClCompile>
+ <ClCompile Include="OpenSSL1_1Test.cpp">
+ <Filter>Generated Code</Filter>
+ </ClCompile>
<ClCompile Include="PKIXEngineTest.cpp">
<Filter>Generated Code</Filter>
</ClCompile>
@@ -62,11 +65,17 @@
<ClCompile Include="SOAPTest.cpp">
<Filter>Generated Code</Filter>
</ClCompile>
+ <ClCompile Include="CloneInputStreamTest.cpp">
+ <Filter>Generated Code</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\XMLToolingTest\XMLObjectBaseTestCase.h">
<Filter>Unit Tests</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\xmltoolingtest\OpenSSL1_1Test.h">
+ <Filter>Unit Tests</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\XMLToolingTest\Makefile.am" />
@@ -120,7 +129,10 @@
<CustomBuild Include="..\..\..\XMLToolingTest\xmltoolingtest.h">
<Filter>Unit Tests</Filter>
</CustomBuild>
- <CustomBuild Include="..\..\..\XMLToolingTest\eSOAPTest.h">
+ <CustomBuild Include="..\..\..\XMLToolingTest\CloneInputStreamTest.h">
+ <Filter>Unit Tests</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\..\XMLToolingTest\SOAPTest.h">
<Filter>Unit Tests</Filter>
</CustomBuild>
</ItemGroup>
diff --git a/Projects/vc14/xmltoolingtest/xmltoolingtest.vcxproj b/Projects/vc14/xmltoolingtest/xmltoolingtest.vcxproj
index 9f7dc3f..dfd8a94 100644
--- a/Projects/vc14/xmltoolingtest/xmltoolingtest.vcxproj
+++ b/Projects/vc14/xmltoolingtest/xmltoolingtest.vcxproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@@ -102,7 +102,7 @@
<DisableSpecificWarnings>4275</DisableSpecificWarnings>
</ClCompile>
<Link>
- <AdditionalDependencies>xerces-c_3D.lib;xsec_1D.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>xerces-c_3D.lib;xsec_1D.lib;$(SSLLibD);%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -127,7 +127,7 @@
<DisableSpecificWarnings>4275</DisableSpecificWarnings>
</ClCompile>
<Link>
- <AdditionalDependencies>xerces-c_3D.lib;xsec_1D.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>xerces-c_3D.lib;xsec_1D.lib;$(SSLLibD);%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
@@ -144,7 +144,7 @@
<DisableSpecificWarnings>4275</DisableSpecificWarnings>
</ClCompile>
<Link>
- <AdditionalDependencies>xerces-c_3.lib;xsec_1.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>xerces-c_3.lib;xsec_1.lib;$(SSLLib);%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
@@ -168,7 +168,7 @@
<DisableSpecificWarnings>4275</DisableSpecificWarnings>
</ClCompile>
<Link>
- <AdditionalDependencies>xerces-c_3.lib;xsec_1.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>xerces-c_3.lib;xsec_1.lib;$(SSLLib);%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
@@ -189,6 +189,7 @@
<ClCompile Include="MarshallingTest.cpp" />
<ClCompile Include="MemoryStorageServiceTest.cpp" />
<ClCompile Include="NonVisibleNamespaceTest.cpp" />
+ <ClCompile Include="OpenSSL1_1Test.cpp" />
<ClCompile Include="PKIXEngineTest.cpp" />
<ClCompile Include="SecurityHelperTest.cpp" />
<ClCompile Include="SignatureTest.cpp" />
@@ -350,6 +351,18 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild>
+ <CustomBuild Include="..\..\..\XMLToolingTest\OpenSSL1_1Test.h">
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"
+</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).cpp;%(Outputs)</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"
+</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).cpp;%(Outputs)</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"</Command>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).cpp;%(Outputs)</Outputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).cpp;%(Outputs)</Outputs>
+ </CustomBuild>
<CustomBuild Include="..\..\..\XMLToolingTest\PKIXEngineTest.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">perl.exe -w $(CxxTestRoot)\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o "%(Filename)".cpp "%(FullPath)"
</Command>
@@ -460,4 +473,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/Projects/vc14/xmltoolingtest/xmltoolingtest.vcxproj.filters b/Projects/vc14/xmltoolingtest/xmltoolingtest.vcxproj.filters
index e9f6032..831d8f6 100644
--- a/Projects/vc14/xmltoolingtest/xmltoolingtest.vcxproj.filters
+++ b/Projects/vc14/xmltoolingtest/xmltoolingtest.vcxproj.filters
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Generated Code">
@@ -41,6 +41,9 @@
<ClCompile Include="NonVisibleNamespaceTest.cpp">
<Filter>Generated Code</Filter>
</ClCompile>
+ <ClCompile Include="OpenSSL1_1Test.cpp">
+ <Filter>Generated Code</Filter>
+ </ClCompile>
<ClCompile Include="PKIXEngineTest.cpp">
<Filter>Generated Code</Filter>
</ClCompile>
@@ -130,4 +133,4 @@
<Filter>Unit Tests</Filter>
</CustomBuild>
</ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/xmltoolingtest/Makefile.am b/xmltoolingtest/Makefile.am
index e96be98..abf60c1 100644
--- a/xmltoolingtest/Makefile.am
+++ b/xmltoolingtest/Makefile.am
@@ -37,6 +37,7 @@ xmltoolingtest_h = \
KeyInfoTest.h \
MarshallingTest.h \
NonVisibleNamespaceTest.h \
+ OpenSSL1_1Test.h \
SOAPTest.h \
UnmarshallingTest.h \
TemplateEngineTest.h \
diff --git a/xmltoolingtest/OpenSSL1_1Test.h b/xmltoolingtest/OpenSSL1_1Test.h
new file mode 100644
index 0000000..1aa440a
--- /dev/null
+++ b/xmltoolingtest/OpenSSL1_1Test.h
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
+ *
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
+ */
+
+#define XSEC_HAVE_OPENSSL 1
+
+#include "XMLObjectBaseTestCase.h"
+#include <xmltooling/security/SecurityHelper.h>
+
+#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp>
+
+# include <openssl/rsa.h>
+# include <openssl/evp.h>
+# include <openssl/bn.h>
+
+class OpenSSL1_1Test : public CxxTest::TestSuite {
+public:
+ void setUp() {
+ }
+
+ void tearDown() {
+ }
+
+ void testRSA() {
+ string pathname = data_path + "key.pem";
+ auto_ptr<OpenSSLCryptoKeyRSA> key1(dynamic_cast<OpenSSLCryptoKeyRSA*>(SecurityHelper::loadKeyFromFile(pathname.c_str())));
+
+ auto_ptr<OpenSSLCryptoKeyRSA> key2(dynamic_cast<OpenSSLCryptoKeyRSA*>(key1->clone()));
+ TSM_ASSERT("Cloned RSA Differs", deepEquals(key1.get(), key2.get()));
+ TSM_ASSERT("Public Matches", SecurityHelper::matches(*key1.get(), *key2.get()));
+
+#if 0 // This doesn't work - you cannot get private only RSA keys
+ RSA *rsa = RSA_new();
+ const BIGNUM *d;
+ RSA_get0_key(key1->getOpenSSLRSA(), NULL, NULL, &d);
+ BIGNUM *newD = BN_dup(d);
+
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+ rsa->d = newD;
+#else
+ RSA_set0_key(rsa, NULL, NULL, newD);
+#endif
+ EVP_PKEY *pkey = EVP_PKEY_new();
+ EVP_PKEY_assign_RSA(pkey, rsa);
+ auto_ptr<OpenSSLCryptoKeyRSA> privateOnly(new OpenSSLCryptoKeyRSA(pkey));
+ EVP_PKEY_free(pkey);
+
+ TSM_ASSERT("Private Matches", SecurityHelper::matches(*privateOnly.get(),*key1.get()));
+#endif
+ }
+
+private:
+
+ static bool deepEquals(OpenSSLCryptoKeyRSA * key1, OpenSSLCryptoKeyRSA *key2) {
+ if (key1->getKeyType() != key2->getKeyType())
+ return false;
+
+ RSA *rsa1 = key1->getOpenSSLRSA();
+ RSA *rsa2 = key2->getOpenSSLRSA();
+
+ const BIGNUM *e1, *e2, *d1, *d2, *n1, *n2;
+ RSA_get0_key(rsa1, &n1, &e1, &d1);
+ RSA_get0_key(rsa2, &n2, &e2, &d2);
+ if (BN_cmp(n1, n2) != 0 || BN_cmp(e1, e2) != 0 || BN_cmp(d1, d2) != 0)
+ return false;
+
+ const BIGNUM *dmp11, *dmq11, *iqmp1;
+ RSA_get0_crt_params(rsa1, &dmp11, &dmq11, &iqmp1);
+ const BIGNUM *dmp12, *dmq12, *iqmp2;
+ RSA_get0_crt_params(rsa2, &dmp12, &dmq12, &iqmp2);
+ if (BN_cmp(dmp11, dmp12) != 0 || BN_cmp(dmq11, dmq12) != 0 || BN_cmp(iqmp1, iqmp2) != 0)
+ return false;
+
+ const BIGNUM *p1, *p2, *q1, *q2;
+ RSA_get0_factors(rsa1, &p1, &q1);
+ RSA_get0_factors(rsa2, &p2, &q2);
+ if (BN_cmp(p1, p2) != 0 || BN_cmp(q1, q2) != 0 )
+ return false;
+
+ return true;
+ }
+};
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list