EldoS | Feel safer!

Software components for data protection, secure storage and transfer

PDF Signing + PDF Validation

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#29616
Posted: 05/28/2014 04:53:56
by Dmytro Bogatskyy (EldoS Corp.)

Hello,
Quote
What is the original document you are talking about? The signed one? The one we are checking for the signature?

The document that you have opened and verifying.
#29617
Posted: 05/28/2014 05:10:12
by glinttgs sousa (Basic support level)
Joined: 02/27/2014
Posts: 51

So, how do exactly I do that verification?

Something like:

Code

            TElPDFDocument doc = new TElPDFDocument();

            FileStream fstream;
            try
            {
                fstream = new FileStream(document, FileMode.Open, FileAccess.ReadWrite);

            }
            catch (Exception)
            {
                Console.WriteLine("This document is being used by another process");
                return false;
            }

            doc.Open(fstream);

            TElPDFSignature sig = (TElPDFSignature)doc.get_Signatures(0); //only 1 signature

             if (sig.Validate(true))
                {
                    if (!sig.IsDocumentSigned())
                    {
                        Console.WriteLine("The selected signature does not cover the entire document");
                        return false;
                    }

                    MemoryStream ms = new MemoryStream();

                    sig.GetSignedVersion(ms);

                 }


Then what? Do I compare ms.Length with fstream.Length? Does this checks for any possible data append?
#29620
Posted: 05/28/2014 09:43:31
by Dmytro Bogatskyy (EldoS Corp.)

Hello,
Quote
Do I compare ms.Length with fstream.Length? Does this checks for any possible data append?

If lengths match, then whole document is signed. You don't need to compare data as it is copied from the original stream.
There could be cases when a document has whitespace characters at the end of document and those characters are not signed. In this case, you should check if data from position ms.Length till the end of the original pdf document contains whitespace characters (CR, LF, Space...), if it is so, then you can say that a whole document is signed too.
#29621
Posted: 05/28/2014 09:44:21
by glinttgs sousa (Basic support level)
Joined: 02/27/2014
Posts: 51

Ok. Thank you for all your support.

Best regards.

Reply

Statistics

Topic viewed 3238 times

Number of guests: 2, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!