xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx |    5 ++++-
 xmlsecurity/qa/unit/signing/signing.cxx       |    5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 71cc3516cc59d6449386e0fac6870baf277d3ca8
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Dec 17 13:41:33 2024 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Thu Jun 26 10:17:44 2025 +0200

    xmlsecurity: fix tests to run with system NSS on Fedora 40
    
    testDropMacroTemplateSignature fails printing this:
    
      
warn:xmlsecurity.xmlsec:3511616:3511616:xmlsecurity/source/xmlsec/errorcallback.cxx:53:
 signatures.c:599: xmlSecNssSignatureSetKey() 'rsa-sha1' 'VFY_CreateContext' 4 
'NSS error: -8011'
    
    because policy sets NSS_RSA_MIN_KEY_SIZE to 2048.
    
    testPDFGood fails printing this:
    
      warn:svl.crypto:3587940:3587940:svl/source/crypto/cryptosign.cxx:1941: 
ValidateSignature: message is not signed
      
warn:xmlsecurity.helper:3587940:3587940:xmlsecurity/source/helper/pdfsignaturehelper.cxx:482:
 failed to determine digest match
    
    because enabling SEC_OID_SHA1 for NSS_USE_ALG_IN_ANY_SIGNATURE doesn't
    enable it for SMIME signatures, so smime_allowed_by_policy() fails -
    obviously one has to use NSS_USE_ALG_IN_SIGNATURE to enable it in any
    signature.
    
    Change-Id: I59ffaf0994eee6b51362fd3296f61465d0fc7903
    (cherry picked from commit a7b7b00b78426bff8607c77106ea62dd213f0821)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187021
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx 
b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
index 238ab2f04b96..a96ddbf9461b 100644
--- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
+++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
@@ -13,6 +13,7 @@
 
 #if USE_CRYPTO_NSS
 #include <secoid.h>
+#include <nss.h>
 #endif
 
 #include <string_view>
@@ -81,7 +82,9 @@ void PDFSigningTest::setUp()
 #ifdef NSS_USE_ALG_IN_ANY_SIGNATURE
     // policy may disallow using SHA1 for signatures but unit test documents
     // have such existing signatures (call this after createSecurityContext!)
-    NSS_SetAlgorithmPolicy(SEC_OID_SHA1, NSS_USE_ALG_IN_ANY_SIGNATURE, 0);
+    NSS_SetAlgorithmPolicy(SEC_OID_SHA1, NSS_USE_ALG_IN_SIGNATURE, 0);
+    // the minimum is 2048 in Fedora 40
+    NSS_OptionSet(NSS_RSA_MIN_KEY_SIZE, 1024);
 #endif
 #endif
 }
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx 
b/xmlsecurity/qa/unit/signing/signing.cxx
index 84f60e65558f..4666ab82fb59 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -15,6 +15,7 @@
 
 #if USE_CRYPTO_NSS
 #include <secoid.h>
+#include <nss.h>
 #endif
 
 #include <test/unoapixml_test.hxx>
@@ -105,7 +106,9 @@ void SigningTest::setUp()
 #ifdef NSS_USE_ALG_IN_ANY_SIGNATURE
     // policy may disallow using SHA1 for signatures but unit test documents
     // have such existing signatures (call this after createSecurityContext!)
-    NSS_SetAlgorithmPolicy(SEC_OID_SHA1, NSS_USE_ALG_IN_ANY_SIGNATURE, 0);
+    NSS_SetAlgorithmPolicy(SEC_OID_SHA1, NSS_USE_ALG_IN_SIGNATURE, 0);
+    // the minimum is 2048 in Fedora 40
+    NSS_OptionSet(NSS_RSA_MIN_KEY_SIZE, 1024);
 #endif
 #endif
 }

Reply via email to