xmlsecurity/source/xmlsec/nss/ciphercontext.cxx |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

New commits:
commit 3dc7cd8459e76ec9f303e7ebda47e98d75dde2ce
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Dec 21 11:23:24 2023 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Dec 21 14:01:25 2023 +0100

    xmlsecurity: fix AES-GCM code to build with NSS < 3.52
    
    (regression from commit f0fda7ad2236f478fea396a23d4f982e5fc37e68)
    
    Change-Id: I42fda00eb37fb1939013b21158c931d47e4e8486
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161117
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 9276d5338ef04209b007bbc705e4c023cf181456)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161096

diff --git a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx 
b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
index e0ef3bbe4ea7..b053db901ccd 100644
--- a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
+++ b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
@@ -24,7 +24,14 @@
 #include <rtl/ref.hxx>
 #include <sal/log.hxx>
 
+#if defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wunused-macros"
+#endif
+// see TODO below
+#define NSS_PKCS11_2_0_COMPAT 1
+
 #include "ciphercontext.hxx"
+#include <nss.h> // for NSS_VMINOR
 #include <pk11pub.h>
 
 constexpr size_t nAESGCMIVSize = 12;
@@ -58,7 +65,10 @@ uno::Reference< xml::crypto::XCipherContext > 
OCipherContext::Create( CK_MECHANI
     {
         // TODO: when runtime requirements are raised to NSS 3.52, replace this
         // according to https://fedoraproject.org/wiki/Changes/NssGCMParams
-        xResult->m_pSecParam = SECITEM_AllocItem(nullptr, nullptr, 
sizeof(CK_NSS_GCM_PARAMS));
+#if NSS_VMINOR >= 52
+        static_assert(sizeof(CK_GCM_PARAMS) == sizeof(CK_NSS_GCM_PARAMS));
+#endif
+        xResult->m_pSecParam = SECITEM_AllocItem(nullptr, nullptr, 
sizeof(/*CK_NSS_GCM_PARAMS*/CK_GCM_PARAMS));
         if (!xResult->m_pSecParam)
         {
             SAL_WARN("xmlsecurity.nss", "SECITEM_AllocItem failed");
@@ -66,7 +76,7 @@ uno::Reference< xml::crypto::XCipherContext > 
OCipherContext::Create( CK_MECHANI
         }
         assert(aInitializationVector.getLength() == nAESGCMIVSize);
         xResult->m_AESGCMIV = aInitializationVector;
-        CK_NSS_GCM_PARAMS * pParams = 
reinterpret_cast<CK_NSS_GCM_PARAMS*>(xResult->m_pSecParam->data);
+        auto *const pParams = 
reinterpret_cast</*CK_NSS_GCM_PARAMS*/CK_GCM_PARAMS*>(xResult->m_pSecParam->data);
         pParams->pIv = const_cast<unsigned char*>(reinterpret_cast<const 
unsigned char*>(xResult->m_AESGCMIV.getConstArray()));
         pParams->ulIvLen = 
sal::static_int_cast<unsigned>(xResult->m_AESGCMIV.getLength());
         pParams->pAAD = nullptr;

Reply via email to