[Libreoffice-commits] core.git: xmlsecurity/Library_xsec_xmlsec.mk xmlsecurity/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jul 19 07:02:19 UTC 2018


 xmlsecurity/Library_xsec_xmlsec.mk                              |    1 
 xmlsecurity/source/xmlsec/mscrypt/akmngr.cxx                    |  145 ++--------
 xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx |   21 -
 xmlsecurity/source/xmlsec/xmlsec_init.cxx                       |   29 --
 4 files changed, 44 insertions(+), 152 deletions(-)

New commits:
commit 27beb3211a595b70bc411cf5419ba7e1d9212a1a
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Wed Jul 18 21:44:53 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Thu Jul 19 09:01:55 2018 +0200

    xmlsecurity: stop linking to libxmlsec's mscrypto backend
    
    This was only useful when the mscrypto to mscng porting was in progress.
    
    Change-Id: I5a062cae744489e5ad311ab6b531d00ea21f4e0a
    Reviewed-on: https://gerrit.libreoffice.org/57699
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/xmlsecurity/Library_xsec_xmlsec.mk b/xmlsecurity/Library_xsec_xmlsec.mk
index cc4bbdb29fe7..8efb4911fbbb 100644
--- a/xmlsecurity/Library_xsec_xmlsec.mk
+++ b/xmlsecurity/Library_xsec_xmlsec.mk
@@ -90,7 +90,6 @@ $(eval $(call gb_Library_add_defs,xsec_xmlsec,\
 ))
 
 $(eval $(call gb_Library_add_libs,xsec_xmlsec,\
-	$(call gb_UnpackedTarball_get_dir,xmlsec)/win32/binaries/libxmlsec-mscrypto.lib \
 	$(call gb_UnpackedTarball_get_dir,xmlsec)/win32/binaries/libxmlsec-mscng.lib \
 	$(call gb_UnpackedTarball_get_dir,xmlsec)/win32/binaries/libxmlsec.lib \
 ))
diff --git a/xmlsecurity/source/xmlsec/mscrypt/akmngr.cxx b/xmlsecurity/source/xmlsec/mscrypt/akmngr.cxx
index 8918e1d80b24..aafd7d10a66c 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/akmngr.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/akmngr.cxx
@@ -24,9 +24,6 @@
 #include <xmlsec/transforms.h>
 #include <xmlsec/errors.h>
 
-#include <xmlsec/mscrypto/crypto.h>
-#include <xmlsec/mscrypto/keysstore.h>
-#include <xmlsec/mscrypto/x509.h>
 #include <xmlsec/mscng/crypto.h>
 #include <xmlsec/mscng/keysstore.h>
 #include <xmlsec/mscng/x509.h>
@@ -47,10 +44,7 @@ xmlSecKeysMngrPtr MSCryptoAppliedKeysMngrCreate()
     xmlSecKeysMngrPtr        keyMngr = nullptr ;
     xmlSecKeyStorePtr        keyStore = nullptr ;
 
-    if (!svl::crypto::isMSCng())
-        keyStore = xmlSecKeyStoreCreate(xmlSecMSCryptoKeysStoreId) ;
-    else
-        keyStore = xmlSecKeyStoreCreate(xmlSecMSCngKeysStoreId);
+    keyStore = xmlSecKeyStoreCreate(xmlSecMSCngKeysStoreId);
     if (keyStore == nullptr)
     {
         xmlSecError(XMLSEC_ERRORS_HERE,
@@ -102,33 +96,16 @@ xmlSecKeysMngrPtr MSCryptoAppliedKeysMngrCreate()
     /*-
      * Initialize crypto library specific data in keys manager
      */
-    if (!svl::crypto::isMSCng())
+    if (xmlSecMSCngKeysMngrInit(keyMngr) < 0)
     {
-        if (xmlSecMSCryptoKeysMngrInit(keyMngr) < 0)
-        {
-             xmlSecError(XMLSEC_ERRORS_HERE,
-                        nullptr,
-                        "xmlSecMSCryptoKeysMngrInit",
-                        XMLSEC_ERRORS_R_XMLSEC_FAILED,
-                        XMLSEC_ERRORS_NO_MESSAGE) ;
-
-            xmlSecKeysMngrDestroy(keyMngr) ;
-            return nullptr ;
-        }
-    }
-    else
-    {
-        if (xmlSecMSCngKeysMngrInit(keyMngr) < 0)
-        {
-             xmlSecError(XMLSEC_ERRORS_HERE,
-                        nullptr,
-                        "xmlSecMSCngKeysMngrInit",
-                        XMLSEC_ERRORS_R_XMLSEC_FAILED,
-                        XMLSEC_ERRORS_NO_MESSAGE);
-
-            xmlSecKeysMngrDestroy(keyMngr);
-            return nullptr;
-        }
+         xmlSecError(XMLSEC_ERRORS_HERE,
+                    nullptr,
+                    "xmlSecMSCngKeysMngrInit",
+                    XMLSEC_ERRORS_R_XMLSEC_FAILED,
+                    XMLSEC_ERRORS_NO_MESSAGE);
+
+        xmlSecKeysMngrDestroy(keyMngr);
+        return nullptr;
     }
 
     /*-
@@ -157,10 +134,7 @@ MSCryptoAppliedKeysMngrAdoptKeyStore(
     xmlSecAssert2(mngr != nullptr, -1) ;
     xmlSecAssert2(keyStore != nullptr, -1) ;
 
-    if (!svl::crypto::isMSCng())
-        x509Store = xmlSecKeysMngrGetDataStore(mngr, xmlSecMSCryptoX509StoreId) ;
-    else
-        x509Store = xmlSecKeysMngrGetDataStore(mngr, xmlSecMSCngX509StoreId);
+    x509Store = xmlSecKeysMngrGetDataStore(mngr, xmlSecMSCngX509StoreId);
     if (x509Store == nullptr)
     {
         xmlSecError(XMLSEC_ERRORS_HERE,
@@ -171,29 +145,14 @@ MSCryptoAppliedKeysMngrAdoptKeyStore(
         return -1 ;
     }
 
-    if (!svl::crypto::isMSCng())
+    if (xmlSecMSCngX509StoreAdoptKeyStore(x509Store, keyStore) < 0)
     {
-        if (xmlSecMSCryptoX509StoreAdoptKeyStore(x509Store, keyStore) < 0)
-        {
-            xmlSecError(XMLSEC_ERRORS_HERE,
-                        xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(x509Store)),
-                        "xmlSecMSCryptoX509StoreAdoptKeyStore",
-                        XMLSEC_ERRORS_R_XMLSEC_FAILED,
-                        XMLSEC_ERRORS_NO_MESSAGE) ;
-            return -1 ;
-        }
-    }
-    else
-    {
-        if (xmlSecMSCngX509StoreAdoptKeyStore(x509Store, keyStore) < 0)
-        {
-            xmlSecError(XMLSEC_ERRORS_HERE,
-                        xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(x509Store)),
-                        "xmlSecMSCngX509StoreAdoptKeyStore",
-                        XMLSEC_ERRORS_R_XMLSEC_FAILED,
-                        XMLSEC_ERRORS_NO_MESSAGE);
-            return -1;
-        }
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(x509Store)),
+                    "xmlSecMSCngX509StoreAdoptKeyStore",
+                    XMLSEC_ERRORS_R_XMLSEC_FAILED,
+                    XMLSEC_ERRORS_NO_MESSAGE);
+        return -1;
     }
 
     return 0 ;
@@ -210,10 +169,7 @@ MSCryptoAppliedKeysMngrAdoptTrustedStore(
     xmlSecAssert2(mngr != nullptr, -1) ;
     xmlSecAssert2(trustedStore != nullptr, -1) ;
 
-    if (!svl::crypto::isMSCng())
-        x509Store = xmlSecKeysMngrGetDataStore(mngr, xmlSecMSCryptoX509StoreId) ;
-    else
-        x509Store = xmlSecKeysMngrGetDataStore(mngr, xmlSecMSCngX509StoreId);
+    x509Store = xmlSecKeysMngrGetDataStore(mngr, xmlSecMSCngX509StoreId);
     if (x509Store == nullptr)
     {
         xmlSecError(XMLSEC_ERRORS_HERE,
@@ -224,29 +180,14 @@ MSCryptoAppliedKeysMngrAdoptTrustedStore(
         return -1 ;
     }
 
-    if (!svl::crypto::isMSCng())
+    if (xmlSecMSCngX509StoreAdoptTrustedStore(x509Store, trustedStore) < 0)
     {
-        if (xmlSecMSCryptoX509StoreAdoptTrustedStore(x509Store, trustedStore) < 0)
-        {
-            xmlSecError(XMLSEC_ERRORS_HERE,
-                        xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(x509Store)),
-                        "xmlSecMSCryptoX509StoreAdoptKeyStore",
-                        XMLSEC_ERRORS_R_XMLSEC_FAILED,
-                        XMLSEC_ERRORS_NO_MESSAGE) ;
-            return -1 ;
-        }
-    }
-    else
-    {
-        if (xmlSecMSCngX509StoreAdoptTrustedStore(x509Store, trustedStore) < 0)
-        {
-            xmlSecError(XMLSEC_ERRORS_HERE,
-                        xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(x509Store)),
-                        "xmlSecMSCngX509StoreAdoptKeyStore",
-                        XMLSEC_ERRORS_R_XMLSEC_FAILED,
-                        XMLSEC_ERRORS_NO_MESSAGE);
-            return -1;
-        }
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(x509Store)),
+                    "xmlSecMSCngX509StoreAdoptKeyStore",
+                    XMLSEC_ERRORS_R_XMLSEC_FAILED,
+                    XMLSEC_ERRORS_NO_MESSAGE);
+        return -1;
     }
 
     return 0 ;
@@ -263,10 +204,7 @@ MSCryptoAppliedKeysMngrAdoptUntrustedStore(
     xmlSecAssert2(mngr != nullptr, -1) ;
     xmlSecAssert2(untrustedStore != nullptr, -1) ;
 
-    if (!svl::crypto::isMSCng())
-        x509Store = xmlSecKeysMngrGetDataStore(mngr, xmlSecMSCryptoX509StoreId) ;
-    else
-        x509Store = xmlSecKeysMngrGetDataStore(mngr, xmlSecMSCngX509StoreId);
+    x509Store = xmlSecKeysMngrGetDataStore(mngr, xmlSecMSCngX509StoreId);
     if (x509Store == nullptr)
     {
         xmlSecError(XMLSEC_ERRORS_HERE,
@@ -277,29 +215,14 @@ MSCryptoAppliedKeysMngrAdoptUntrustedStore(
         return -1 ;
     }
 
-    if (!svl::crypto::isMSCng())
+    if (xmlSecMSCngX509StoreAdoptUntrustedStore(x509Store, untrustedStore) < 0)
     {
-        if (xmlSecMSCryptoX509StoreAdoptUntrustedStore(x509Store, untrustedStore) < 0)
-        {
-            xmlSecError(XMLSEC_ERRORS_HERE,
-                        xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(x509Store)),
-                        "xmlSecMSCryptoX509StoreAdoptKeyStore",
-                        XMLSEC_ERRORS_R_XMLSEC_FAILED,
-                        XMLSEC_ERRORS_NO_MESSAGE) ;
-            return -1 ;
-        }
-    }
-    else
-    {
-        if (xmlSecMSCngX509StoreAdoptUntrustedStore(x509Store, untrustedStore) < 0)
-        {
-            xmlSecError(XMLSEC_ERRORS_HERE,
-                        xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(x509Store)),
-                        "xmlSecMSCngX509StoreAdoptKeyStore",
-                        XMLSEC_ERRORS_R_XMLSEC_FAILED,
-                        XMLSEC_ERRORS_NO_MESSAGE);
-            return -1;
-        }
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(x509Store)),
+                    "xmlSecMSCngX509StoreAdoptKeyStore",
+                    XMLSEC_ERRORS_R_XMLSEC_FAILED,
+                    XMLSEC_ERRORS_NO_MESSAGE);
+        return -1;
     }
 
     return 0 ;
diff --git a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx
index f2df751addfb..ac5d6a3b0a3e 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx
@@ -23,7 +23,6 @@
 #include "securityenvironment_mscryptimpl.hxx"
 
 #include <xmlsec-wrapper.h>
-#include <xmlsec/mscrypto/app.h>
 #include <xmlsec/mscng/app.h>
 #include <com/sun/star/xml/crypto/SecurityEnvironment.hpp>
 #include <com/sun/star/xml/crypto/XMLSecurityContext.hpp>
@@ -71,10 +70,7 @@ uno::Reference< cssxc::XXMLSecurityContext > SAL_CALL
         n_hStoreHandle = nullptr ;
     }
 
-    if (!svl::crypto::isMSCng())
-        xmlSecMSCryptoAppInit( n_pCertStore ) ;
-    else
-        xmlSecMSCngAppInit(n_pCertStore);
+    xmlSecMSCngAppInit(n_pCertStore);
 
     try {
         /* Build Security Environment */
@@ -90,10 +86,7 @@ uno::Reference< cssxc::XXMLSecurityContext > SAL_CALL
                 CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ;
             }
 
-            if (!svl::crypto::isMSCng())
-                xmlSecMSCryptoAppShutdown() ;
-            else
-                xmlSecMSCngAppShutdown();
+            xmlSecMSCngAppShutdown();
             return nullptr;
         }
 
@@ -120,10 +113,7 @@ uno::Reference< cssxc::XXMLSecurityContext > SAL_CALL
             CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ;
         }
 
-        if (!svl::crypto::isMSCng())
-            xmlSecMSCryptoAppShutdown() ;
-        else
-            xmlSecMSCngAppShutdown();
+        xmlSecMSCngAppShutdown();
         return nullptr;
     }
 }
@@ -154,10 +144,7 @@ void SAL_CALL SEInitializer_MSCryptImpl::freeSecurityContext( const uno::Referen
     }
     */
 
-    if (!svl::crypto::isMSCng())
-        xmlSecMSCryptoAppShutdown() ;
-    else
-        xmlSecMSCngAppShutdown();
+    xmlSecMSCngAppShutdown();
 }
 
 /* XServiceInfo */
diff --git a/xmlsecurity/source/xmlsec/xmlsec_init.cxx b/xmlsecurity/source/xmlsec/xmlsec_init.cxx
index 552c1d481695..93dc49e6c126 100644
--- a/xmlsecurity/source/xmlsec/xmlsec_init.cxx
+++ b/xmlsecurity/source/xmlsec/xmlsec_init.cxx
@@ -15,7 +15,6 @@
 #include <xmlsec-wrapper.h>
 #include <svl/cryptosign.hxx>
 #ifdef XMLSEC_CRYPTO_MSCRYPTO
-#include <xmlsec/mscrypto/crypto.h>
 #include <xmlsec/mscng/crypto.h>
 #else
 #include <xmlsec/nss/crypto.h>
@@ -32,19 +31,9 @@ XSECXMLSEC_DLLPUBLIC void initXmlSec()
 
     //Init xmlsec crypto engine library
 #ifdef XMLSEC_CRYPTO_MSCRYPTO
-    if (!svl::crypto::isMSCng())
-    {
-        if( xmlSecMSCryptoInit() < 0 ) {
-            xmlSecShutdown() ;
-            throw RuntimeException() ;
-        }
-    }
-    else
-    {
-        if( xmlSecMSCngInit() < 0 ) {
-            xmlSecShutdown();
-            throw RuntimeException();
-        }
+    if( xmlSecMSCngInit() < 0 ) {
+        xmlSecShutdown();
+        throw RuntimeException();
     }
 #else
     if( xmlSecNssInit() < 0 ) {
@@ -56,12 +45,9 @@ XSECXMLSEC_DLLPUBLIC void initXmlSec()
     //Enable external stream handlers
     if( xmlEnableStreamInputCallbacks() < 0 ) {
 #ifdef XMLSEC_CRYPTO_MSCRYPTO
-        if (!svl::crypto::isMSCng())
-            xmlSecMSCryptoShutdown();
-        else
-            xmlSecMSCngShutdown();
+        xmlSecMSCngShutdown();
 #else
-       xmlSecNssShutdown();
+        xmlSecNssShutdown();
 #endif
         xmlSecShutdown() ;
         throw RuntimeException() ;
@@ -72,10 +58,7 @@ XSECXMLSEC_DLLPUBLIC void deInitXmlSec()
 {
     xmlDisableStreamInputCallbacks();
 #ifdef XMLSEC_CRYPTO_MSCRYPTO
-    if (!svl::crypto::isMSCng())
-        xmlSecMSCryptoShutdown();
-    else
-        xmlSecMSCngShutdown();
+    xmlSecMSCngShutdown();
 #else
     xmlSecNssShutdown();
 #endif


More information about the Libreoffice-commits mailing list