diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-12-21 11:23:24 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2023-12-21 13:12:26 +0100 |
commit | 9276d5338ef04209b007bbc705e4c023cf181456 (patch) | |
tree | 98a744d017a926fb4da1f3eaaec74e321badc9bc /xmlsecurity | |
parent | a1931610406d7f0431722612f55b3424e9dc4ad7 (diff) |
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.stahl@allotropia.de>
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/source/xmlsec/nss/ciphercontext.cxx | 14 |
1 files changed, 12 insertions, 2 deletions
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; |