Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Detached signature with sha256 digest
  FAQ FAQ  Forum Search   Register Register  Login Login

Detached signature with sha256 digest

 Post Reply Post Reply
Author
Message
pinozzy View Drop Down
Beginner
Beginner
Avatar

Joined: 22 Mar 16
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote pinozzy Quote  Post ReplyReply Direct Link To This Post Topic: Detached signature with sha256 digest
    Posted: 02 Jan 17 at 6:00PM
Hello, i'm trying to add a visual sha-256 detached signature to my pdf.


I did it successfully with this example: http://www.debenu.com/kb/advanced-options-signing-pdf-files/

I edited this method

private byte[] SignData(byte[] inputData, X509Certificate2 cert)
        {
            // Create an SHA-1 hash of the file data
            SHA1 sha = new SHA1CryptoServiceProvider();
            byte[] sha1Result = sha.ComputeHash(inputData);

            // Sign the hash using the certificate
            // This could be changed to use a hardware device (eg. smartcard)
            ContentInfo content = new ContentInfo(sha1Result);
            SignedCms signedCms = new SignedCms(content);
            CmsSigner cmsSigner = new CmsSigner(cert);
            signedCms.ComputeSignature(cmsSigner);
            return signedCms.Encode();
        }

this way:

private byte[] SignData(byte[] inputData, X509Certificate2 cert)
    {
      // Create an SHA-1 hash of the file data
      var sha = new SHA256CryptoServiceProvider();
      byte[] sha1Result = sha.ComputeHash(inputData);

      // Sign the hash using the certificate
      // This could be changed to use a hardware device (eg. smartcard)

      var oid = new Oid("2.16.840.1.101.3.4.2.1");
      var content = new ContentInfo(oid, sha1Result);
      var signedCms = new SignedCms(content, true);

      var cmsSigner = new CmsSigner(cert);
      cmsSigner.DigestAlgorithm = oid;


      signedCms.ComputeSignature(cmsSigner);
      return signedCms.Encode();
    }

And i just added this: DPL.SetSignProcessSubFilter(signProcessID, 2);

For the detached signature.

I got an error from adobe reader, the document signature is visible but with red X and the message of damaged signature.

Does anyone have a working example of Detached sha-256 signature?

Many thanks all.



Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 02 Jan 17 at 11:14PM
Hi,

perhaps here you can learn more about sha256:
https://msdn.microsoft.com/de-de/library/system.security.cryptography.sha256cryptoserviceprovider(v=vs.110).aspx

Cheers,
Ingo

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store