[Libreoffice-commits] core.git: include/svl svl/source

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Aug 28 01:52:17 UTC 2017


 include/svl/sigstruct.hxx        |    3 +++
 svl/source/crypto/cryptosign.cxx |   18 +++++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

New commits:
commit 6d8598acb23bbecb55ac235c15b9e01885588ad7
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri Aug 25 13:45:32 2017 -0400

    svl: populate subject and date-time when verifying signature
    
    Change-Id: I50eeabf3e18176cac383f48797daa771ee9dc7e4
    Reviewed-on: https://gerrit.libreoffice.org/41591
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/include/svl/sigstruct.hxx b/include/svl/sigstruct.hxx
index ff6ee5e5d3a5..a7da2994664c 100644
--- a/include/svl/sigstruct.hxx
+++ b/include/svl/sigstruct.hxx
@@ -114,6 +114,9 @@ struct SignatureInformation
     /// For PDF: the byte range doesn't cover the whole document.
     bool bPartialDocumentSignature;
 
+    /// The certificate owner (aka subject).
+    OUString ouSubject;
+
     SignatureInformation( sal_Int32 nId )
     {
         nSecurityId = nId;
diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx
index dab47be4e5cc..44175c53961c 100644
--- a/svl/source/crypto/cryptosign.cxx
+++ b/svl/source/crypto/cryptosign.cxx
@@ -2031,10 +2031,12 @@ bool Signing::Verify(const std::vector<unsigned char>& aData,
         OUStringBuffer aBuffer;
         comphelper::Base64::encode(aBuffer, aDerCert);
         rInformation.ouX509Certificate = aBuffer.makeStringAndClear();
+        rInformation.ouSubject = OUString(pCertificate->subjectName, PL_strlen(pCertificate->subjectName), RTL_TEXTENCODING_UTF8);
     }
 
     PRTime nSigningTime;
-    // This may fail, in which case the date should be taken from the dictionary's "M" key.
+    // This may fail, in which case the date should be taken from the PDF's dictionary's "M" key,
+    // so not critical for PDF at least.
     if (NSS_CMSSignerInfo_GetSigningTime(pCMSSignerInfo, &nSigningTime) == SECSuccess)
     {
         // First convert the UTC UNIX timestamp to a tools::DateTime.
@@ -2044,6 +2046,20 @@ bool Signing::Verify(const std::vector<unsigned char>& aData,
         // Then convert to a local UNO DateTime.
         aDateTime.ConvertToLocalTime();
         rInformation.stDateTime = aDateTime.GetUNODateTime();
+        if (rInformation.ouDateTime.isEmpty())
+        {
+            OUStringBuffer rBuffer;
+            rBuffer.append((sal_Int32) aDateTime.GetYear());
+            rBuffer.append('-');
+            if (aDateTime.GetMonth() < 10)
+                rBuffer.append('0');
+            rBuffer.append((sal_Int32) aDateTime.GetMonth());
+            rBuffer.append('-');
+            if (aDateTime.GetDay() < 10)
+                rBuffer.append('0');
+            rBuffer.append((sal_Int32) aDateTime.GetDay());
+            rInformation.ouDateTime = rBuffer.makeStringAndClear();
+        }
     }
 
     // Check if we have a signing certificate attribute.


More information about the Libreoffice-commits mailing list