[Libreoffice-commits] core.git: svl/source
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 10 17:07:04 UTC 2020
svl/source/crypto/cryptosign.cxx | 74 +--------------------------------------
1 file changed, 2 insertions(+), 72 deletions(-)
New commits:
commit a657514b032cd036a7a12cb54d87aa2ab8598cee
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Sep 10 16:48:10 2020 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Sep 10 19:06:22 2020 +0200
Remove some DBG_UTIL debug code
...that had originally started to get introduced with
159a4c3c75e3a7aecbf1656f3254331892098ba7 "tdf#84881: WiP: Fill in more fields of
the TimeStampReq" saying: "Temporarily, dump the TimeStampReq object to a file
for inspection in a DBG_UTIL build."
(I came across this when wondering why such PDFWRITER.cms.data and
PDFWRITER.hash.data files kept popping up in my source/build trees.)
Change-Id: I28beabe912beb112e1c71c8e3b559e161b22849b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102393
Reviewed-by: Tor Lillqvist <tml at collabora.com>
Tested-by: Jenkins
diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx
index 25120d7cd6e5..202d2d1ac42f 100644
--- a/svl/source/crypto/cryptosign.cxx
+++ b/svl/source/crypto/cryptosign.cxx
@@ -966,14 +966,6 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer)
digest.data = aHashResult.data();
digest.len = aHashResult.size();
-#ifdef DBG_UTIL
- {
- FILE *out = fopen("PDFWRITER.hash.data", "wb");
- fwrite(aHashResult.data(), SHA256_LENGTH, 1, out);
- fclose(out);
- }
-#endif
-
PRTime now = PR_Now();
NSSCMSSignedData *cms_sd;
NSSCMSSignerInfo *cms_signer;
@@ -1022,17 +1014,8 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer)
return false;
}
- // I have compared the ts_cms_output produced here with the cms_output produced below, with
- // the DONTCALLADDUNAUTHATTR env var set (i.e. without actually calling
- // my_NSS_CMSSignerInfo_AddUnauthAttr()), and they are identical.
-
-#ifdef DBG_UTIL
- {
- FILE *out = fopen("PDFWRITER.ts_cms.data", "wb");
- fwrite(ts_cms_output.data, ts_cms_output.len, 1, out);
- fclose(out);
- }
-#endif
+ // I have compared the ts_cms_output produced here with the cms_output produced below when
+ // not actually calling my_NSS_CMSSignerInfo_AddUnauthAttr()), and they are identical.
std::vector<unsigned char> aTsHashResult = comphelper::Hash::calculateHash(ts_cms_signer->encDigest.data, ts_cms_signer->encDigest.len, comphelper::HashType::SHA256);
SECItem ts_digest;
@@ -1040,14 +1023,6 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer)
ts_digest.data = aTsHashResult.data();
ts_digest.len = aTsHashResult.size();
-#ifdef DBG_UTIL
- {
- FILE *out = fopen("PDFWRITER.ts_hash.data", "wb");
- fwrite(aTsHashResult.data(), SHA256_LENGTH, 1, out);
- fclose(out);
- }
-#endif
-
unsigned char cOne = 1;
src.version.type = siUnsignedInteger;
src.version.data = &cOne;
@@ -1089,14 +1064,6 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer)
SAL_INFO("svl.crypto", "request length=" << timestamp_request->len);
-#ifdef DBG_UTIL
- {
- FILE *out = fopen("PDFWRITER.timestampreq.data", "wb");
- fwrite(timestamp_request->data, timestamp_request->len, 1, out);
- fclose(out);
- }
-#endif
-
// Send time stamp request to TSA server, receive response
CURL* curl = curl_easy_init();
@@ -1187,14 +1154,6 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer)
SAL_INFO("svl.crypto", "PDF signing: got response, length=" << response_buffer.getLength());
-#ifdef DBG_UTIL
- {
- FILE *out = fopen("PDFWRITER.reply.data", "wb");
- fwrite(response_buffer.getStr(), response_buffer.getLength(), 1, out);
- fclose(out);
- }
-#endif
-
curl_slist_free_all(slist);
curl_easy_cleanup(curl);
SECITEM_FreeItem(timestamp_request, PR_TRUE);
@@ -1251,11 +1210,6 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer)
timestamp.encoded = PR_TRUE; // ???
-#ifdef DBG_UTIL
- if (getenv("DONTCALLADDUNAUTHATTR"))
- ;
- else
-#endif
if (my_NSS_CMSSignerInfo_AddUnauthAttr(cms_signer, ×tamp) != SECSuccess)
{
SAL_WARN("svl.crypto", "NSS_CMSSignerInfo_AddUnauthAttr failed");
@@ -1360,14 +1314,6 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer)
return false;
}
-#ifdef DBG_UTIL
- {
- FILE *out = fopen("PDFWRITER.cms.data", "wb");
- fwrite(cms_output.data, cms_output.len, 1, out);
- fclose(out);
- }
-#endif
-
if (cms_output.len*2 > MAX_SIGNATURE_CONTENT_LENGTH)
{
SAL_WARN("svl.crypto", "Signature requires more space (" << cms_output.len*2 << ") than we reserved (" << MAX_SIGNATURE_CONTENT_LENGTH << ")");
@@ -1591,14 +1537,6 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer)
SAL_INFO("svl.crypto", "Time stamp size is " << pTsContext->cbEncoded << " bytes");
-#ifdef DBG_UTIL
- {
- FILE *out = fopen("PDFWRITER.tstoken.data", "wb");
- fwrite(pTsContext->pbEncoded, pTsContext->cbEncoded, 1, out);
- fclose(out);
- }
-#endif
-
// I tried to use CryptMsgControl() with CMSG_CTRL_ADD_SIGNER_UNAUTH_ATTR to add the
// timestamp, but that failed with "The parameter is incorrect". Probably it is too late to
// modify the message once its data has already been encoded as part of the
@@ -1680,14 +1618,6 @@ bool Signing::Sign(OStringBuffer& rCMSHexBuffer)
return false;
}
-#ifdef DBG_UTIL
- {
- FILE *out = fopen("PDFWRITER.signature.data", "wb");
- fwrite(pSig.get(), nSigLen, 1, out);
- fclose(out);
- }
-#endif
-
// Release resources
if (pTsContext)
CryptMemFree(pTsContext);
More information about the Libreoffice-commits
mailing list