I'd like to double check how reliable is iText's signatureCoversWholeDocument()
.
I have a document with one signature, which returns false
for signatureCoversWholeDocument()
, but Adobe Acrobat Reader doesn't report anything wrong with the document.
iText's method seems to be to sum up the byte range it gets in getSignatureNames()
:
public ArrayList<String> getSignatureNames() {
.....
PdfArray ro = v.getAsArray(PdfName.BYTERANGE);
if (ro == null)
continue;
int rangeSize = ro.size();
if (rangeSize < 2)
continue;
int length = ro.getAsNumber(rangeSize - 1).intValue() + ro.getAsNumber(rangeSize - 2).intValue();
...and then compare it to the document's length:
public boolean signatureCoversWholeDocument(String name) {
getSignatureNames();
name = getTranslatedFieldName(name);
if (!sigNames.containsKey(name))
return false;
return sigNames.get(name)[0] == reader.getFileLength();
}
In my case the signature byte range is [0, 190, 33282, 382800]
which sums up to 382800 + 33282 = 416082, but the document size is 665186
If I open the PDF with a text editor I also see the same signature byte range inside [0, 190, 33282, 382800]
. If I look at PDFs that have byte ranges that add up perfectly to the file size, those get validated with iText no problem.
Another difference I see is that iText's
(AcroFields) fields.getTotalRevisions() = 2
But inside Acrobat Reader I only see one revision.
Our client is pretty convinced that their documents are signed properly, so I'm quite confused...
So basically my questions are
- Is this method that iText uses (summing up byte ranges) 100% reliable?
- What method does Acrobat Reader use to validate that the whole document is signed?
- Does Acrobat Reader show an error if the signature does not cover the whole document?