[xmltooling] 05/24: CPPXT-110 Add test path for RSA loadXXXBigNums
Ferenc Wágner
wferi at moszumanska.debian.org
Fri Dec 16 11:56:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
wferi pushed a commit to branch master
in repository xmltooling.
commit a673915585ca04c71f8330857472ad8233dbe3ea
Author: Rod Widdowson <rdw at steadingsoftware.com>
Date: Tue Nov 1 16:35:27 2016 +0000
CPPXT-110 Add test path for RSA loadXXXBigNums
https://issues.shibboleth.net/jira/browse/CPPXT-110
This completes the code coervage tests for the OpenSSLCryptoKeyRSA
changes for OpenSSL 1.1
Add a test function to force the load of the RSA key from the
<ds:RSAKeyValue>, then cast it and the credential into the
base OpenSSL type.
Throw various OpenSSL incantations at these to extract the OpenSSL
struct and compare the two. This will need work when we move to
OpenSSL 1.1 (since the structures become opaque).
---
.../vc10/xmltoolingtest/xmltoolingtest.vcxproj | 6 +-
.../xmltoolingtest/xmltoolingtest.vcxproj.filters | 12 +++-
xmltoolingtest/InlineKeyResolverTest.h | 66 ++++++++++++++++++++++
3 files changed, 78 insertions(+), 6 deletions(-)
diff --git a/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj b/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj
index 8399157..bedca98 100644
--- a/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj
+++ b/Projects/vc10/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="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@@ -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;libeay32D.lib;ssleay32D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
@@ -452,4 +452,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj.filters b/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj.filters
index d099072..58cc379 100644
--- a/Projects/vc10/xmltoolingtest/xmltoolingtest.vcxproj.filters
+++ b/Projects/vc10/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">
@@ -62,6 +62,9 @@
<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">
@@ -120,8 +123,11 @@
<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>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/xmltoolingtest/InlineKeyResolverTest.h b/xmltoolingtest/InlineKeyResolverTest.h
index a499d6a..6418ec2 100644
--- a/xmltoolingtest/InlineKeyResolverTest.h
+++ b/xmltoolingtest/InlineKeyResolverTest.h
@@ -21,11 +21,29 @@
#include "XMLObjectBaseTestCase.h"
#include <fstream>
+
#include <xmltooling/security/X509Credential.h>
#include <xmltooling/security/KeyInfoResolver.h>
#include <xmltooling/signature/KeyInfo.h>
+
#include <xsec/enc/XSECCryptoKey.hpp>
+#include <xsec/dsig/DSIGReference.hpp>
+#include <xsec/dsig/DSIGSignature.hpp>
+extern "C" {
+#include <openssl/opensslv.h>
+}
+
+// Force XMLSEC to assume OpenSSL
+#define XSEC_HAVE_OPENSSL 1
+
+#include <xsec/enc/OpenSSL/OpenSSLCryptoX509.hpp>
+#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
+#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyEC.hpp>
+#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp>
+
+
+
using namespace xmlsignature;
class InlineKeyResolverTest : public CxxTest::TestSuite {
@@ -65,6 +83,54 @@ public:
TSM_ASSERT_EQUALS("Wrong CRL count.", cred->getCRLs().size(), 3);
}
+
+ void testOpenSSLRSA() {
+ string path=data_path + "KeyInfo1.xml";
+ ifstream fs(path.c_str());
+ DOMDocument* doc=XMLToolingConfig::getConfig().getValidatingParser().parse(fs);
+ TS_ASSERT(doc!=nullptr);
+ const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
+ TS_ASSERT(b!=nullptr);
+ auto_ptr<KeyInfo> kiObject(dynamic_cast<KeyInfo*>(b->buildFromDocument(doc)));
+ TS_ASSERT(kiObject.get()!=nullptr);
+
+ auto_ptr<X509Credential> cred(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get())));
+ auto_ptr<X509Credential> key(dynamic_cast<X509Credential*>(m_resolver->resolve(kiObject.get(), Credential::RESOLVE_KEYS)));
+
+ OpenSSLCryptoKeyRSA* sslCred = dynamic_cast<OpenSSLCryptoKeyRSA*>(cred->getPublicKey());
+ OpenSSLCryptoKeyRSA* sslKey = dynamic_cast<OpenSSLCryptoKeyRSA*>(key->getPublicKey());
+
+ RSA* rsaCred = sslCred->getOpenSSLRSA();
+ RSA* rsaKey = sslKey->getOpenSSLRSA();
+
+ BIGNUM* n = rsaCred->n;
+ BIGNUM* e = rsaCred->e;
+ BIGNUM* d = rsaCred->d;
+ BIGNUM* p = rsaCred->p;
+ BIGNUM* q = rsaCred->q;
+ BIGNUM* dmp1 = rsaCred->dmp1;
+ BIGNUM* dmq1 = rsaCred->dmq1;
+ BIGNUM* iqmp = rsaCred->iqmp;
+
+ BIGNUM* kn = rsaKey->n;
+ BIGNUM* ke = rsaKey->e;
+ BIGNUM* kd = rsaKey->d;
+ BIGNUM* kp = rsaKey->p;
+ BIGNUM* kq = rsaKey->q;
+ BIGNUM* kdmp1 = rsaKey->dmp1;
+ BIGNUM* kdmq1 = rsaKey->dmq1;
+ BIGNUM* kiqmp = rsaKey->iqmp;
+
+ TS_ASSERT(0 == BN_cmp(kn, n));
+ TS_ASSERT(0 == BN_cmp(ke, e));
+ TS_ASSERT(0 == BN_cmp(kd, d));
+ TS_ASSERT(0 == BN_cmp(kp, p));
+ TS_ASSERT(0 == BN_cmp(kq, q));
+ TS_ASSERT(0 == BN_cmp(kdmp1, dmp1));
+ TS_ASSERT(0 == BN_cmp(kdmq1, dmq1));
+ TS_ASSERT(0 == BN_cmp(kiqmp, iqmp));
+ }
+
void testDER() {
string path=data_path + "KeyInfo5.xml";
ifstream fs(path.c_str());
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/xmltooling.git
More information about the Pkg-shibboleth-devel
mailing list