[cpp-xmltooling] branch master updated: CPPXT-136 tests for badly formed KeyInfo.

Rod Widdowson rdw at steadingsoftware.com
Tue Aug 7 10:25:28 EDT 2018


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch master
in repository cpp-xmltooling.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-xmltooling.git;a=commit;h=fd8bab68f5e92df3714fef695fa621fac6a9e0f0

The following commit(s) were added to refs/heads/master by this push:
       new  fd8bab6   CPPXT-136 tests for badly formed KeyInfo.
fd8bab6 is described below

commit fd8bab68f5e92df3714fef695fa621fac6a9e0f0
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Aug 7 15:24:56 2018 +0100

    CPPXT-136 tests for badly formed KeyInfo.
    
    https://issues.shibboleth.net/jira/browse/CPPXT-136
    
    Do something with the public key onces you've got it.  Then watch it fail.
---
 xmltoolingtest/BadKeyKeyInfoTest.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/xmltoolingtest/BadKeyKeyInfoTest.h b/xmltoolingtest/BadKeyKeyInfoTest.h
index 90e550d..9bc335a 100644
--- a/xmltoolingtest/BadKeyKeyInfoTest.h
+++ b/xmltoolingtest/BadKeyKeyInfoTest.h
@@ -24,6 +24,8 @@
 
 #include <xmltooling/security/KeyInfoResolver.h>
 #include <xmltooling/security/Credential.h>
+#include <xmltooling/encryption/Encrypter.h>
+#include <xmltooling/encryption/Encryption.h>
 #include <xmltooling/signature/KeyInfo.h>
 
 #include <xsec/framework/XSECException.hpp>
@@ -32,8 +34,11 @@
 #include <xsec/utils/XSECPlatformUtils.hpp>
 #include <xsec/enc/XSECCryptoKeyRSA.hpp>
 #include <xsec/enc/XSECCryptoKey.hpp>
+#include <xsec/enc/XSECCryptoException.hpp>
 
 using namespace xmlsignature;
+using namespace xmlencryption;
+
 
 class BadKeyInfoTest : public CxxTest::TestSuite {
     KeyInfoResolver* m_resolver;
@@ -85,6 +90,20 @@ private:
         TSM_ASSERT("Expected non-null Public Key", xsecCred->getPublicKey() != nullptr);
         TSM_ASSERT_EQUALS("Expected RSA key", xsecCred->getPublicKey()->getKeyType(), XSECCryptoKey::KEY_RSA_PUBLIC);
 
+        Encrypter encrypter;
+        Encrypter::EncryptionParams ep;
+        Encrypter::KeyEncryptionParams xsecKep(*xsecCred.get());
+        Encrypter::KeyEncryptionParams toolingKep(*toolingCred.get());
+        //
+        TSM_ASSERT_THROWS("Bad RSA key throws an assert", encrypter.encryptElement(doc->getDocumentElement(), ep, &xsecKep), EncryptionException);
+        /*    string xsecBuffer, toolingBuffer;
+        XMLHelper::serialize(xsecEncData->marshall(), xsecBuffer);
+        XMLHelper::serialize(toolingEncData->marshall(), toolingBuffer);
+        */
+        //        TSM_ASSERT_EQUALS("Encrytped Data differs", xsecBuffer, toolingBuffer);
+
+        TSM_ASSERT_THROWS("Bad RSA key throws an assert", encrypter.encryptElement(doc->getDocumentElement(), ep, &toolingKep), EncryptionException);
+
     }
 
 public:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list