Pedro,

P3d3r0s0 wrote:
> joy of joys, its working!

That's great, but I'm a bit surprised. You essentially switched from
PdfSignatureAppearance.SELF_SIGNED to PdfSignatureAppearance.VERISIGN_SIGNED
and in my eyes made the digest calculation very brittle:

P3d3r0s0 wrote:
>               // Process of hash/digest generation
>                   MessageDigest md = MessageDigest.getInstance("SHA-1");
>                   byte buf[] = new byte[8192];
>                   int n = 0;
>                   InputStream rs = appearance.getRangeStream();
>                   md.reset();
>                   while ((n = rs.read(buf)) != -1)
>                       md.update(buf);
>                   rs.close();
>               byte[] hashDig = md.digest();

Here in the loop you now completely ignore the number n of bytes actually
read when updating the MessageDigest object. This might work under
exceptional circumstances but is sure to fail in general. In that respect
your original hashing loop looked safer.

Regards,   Michael.

-- 
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Another-invalid-signature-thread-tp3003710p3013801.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to