The examples assume 1024 long keys and that shows in things like "new 
byte[128]". Make sure that you make room for longer keys.

Paulo

----- Original Message ----- 
From: "Rene" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, April 25, 2007 1:53 PM
Subject: [iText-questions] Problem with signing PDFs when using 2048-bit key


> Hi,
>
> I am using iText 1.4.8 and try to sign PDFs with external generated 
> signatures.
>
> Up till know it works fine (using different SmartCards with 1024-bit key 
> lenght). Today I tried a new card with 2048-bit RSA key and I get a 
> problem when I try to copy the generated bytes into the PdfDictinary.
> The generated Data is to much (I think because of the 2048-bit key).
> I used the iText code example for inserting external signatures.
>
> Anyone a suggestion what to do to fix it? (with a SmartCard with a 
> 1024-bit key everything works fine...).
>
> In the following you will find the code where occures the problem.
>
> Thanks for your help.
>
> Best regards,
> rene
>
> --------------------------------------
>
> PdfSigGenericPKCS sg = sap.getSigStandard();
> PdfLiteral slit = (PdfLiteral) sg.get(PdfName.CONTENTS);
> byte[] outc = new byte[(slit.getPosLength() - 2) / 2];
> PdfPKCS7 sig = sg.getSigner();
>
> /*
> create hash and signature...
> */
>
> // Sets the generated signature and hash of the PDF part(!!!)
> sig.setExternalDigest(job.getSignatur(), hash, "RSA"); //$NON-NLS-1$
>
> // Creates the signedData-object and adds it into the temporary
> // PDF file.
> PdfDictionary dic = new PdfDictionary();
>
> byte[] ssig = sig.getEncodedPKCS7();
>
> System.arraycopy(ssig, 0, outc, 0, ssig.length); //sysout: 
> PDF.Signatur.ssig: 3081 bytes, outc: 3014 bytes
> dic.put(PdfName.CONTENTS, new PdfString(outc)
>      .setHexWriting(true));


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to