iText PdfStamper increase size of a signed pdf

后端 未结 1 1308
野的像风
野的像风 2021-01-25 20:34

Why PdfStamper increase the size of my signed pdfs every i use?

That\'s my code:

private static void test(String src, String pwd, String dest) throws Exc         


        
1条回答
  •  伪装坚强ぢ
    2021-01-25 21:04

    This is a strange question because it reveals that you don't understand the concept of a digital signature. When you sign a PDF, you want to make sure that the signature breaks as soon as someone changes a single byte. Every time you sign a document, you protect the bytes of the previous revision of the document by adding a signature dictionary of which the contents contain a signed hash of at least the bytes you want to protect.

    See the following figure that shows a schema of a PDF that is signed three times:

    Suppose that you would want to add a fourth signature, and you would want the resulting file to have the same size as before, you would have to change some of the bytes in the existing document. That would break at least one of the existing signatures.

    You mention LTV. LTV implies adding a Document Security Store (DSS) and a Timestamp signature. The same rules apply: you have to add extra bytes, because the moment you change existing bytes, you'll break an existing signature:

    Every time the certificate of the latest timestamp signature expires, you have to repeat the same procedure:

    The total file size will always increase.

    0 讨论(0)
提交回复
热议问题