Hi Victor,

I solved a similar problem by letting iText do signature creation, get the hash 
value create a signature on my own. Later on I filled in the newly ceated 
signature into the preserverd siganture space. You have to take care that the 
area is big enough ...

Btw. : I'm not fimiliar with the RSACryptoServiceProvider object. What does the 
SignDate method do ? There is a pregenerated hash involved and a hash algo 
name. Does the name marks the algo used to generate the hash ? Or is this the 
hash algo used internally for signature creation ?

Whether my mail helps or not, never mind to do a donation ;-)

Greetings

Andreas


----- Original Message ----
From: Victor <[email protected]>
To: [email protected]
Sent: Mon, April 26, 2010 1:48:46 PM
Subject: [iText-questions] Sign PDF using SHA 256

Hi,

Until now, I have used this code 
(http://itextpdf.sourceforge.net/howtosign.html#signextitextsharp2) to sign a 
PDF file using a digital certificate stored on Microsoft Store.

The code is great, there is no problem with it if SHA1 is used.

The problem is SignedCms class don't support SHA256 algorithm for smart cards 
or crypto tokens.

Anyway, a SHA256 signature can be made using RSACryptoServiceProvider.

RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider();
X509Certificate2 cert = GetCertificateFromMicrosoftStore();
rsaKey = cert.PrivateKey as RSACryptoServiceProvider;
byte[] signature = rsaKey.SignData(documentHash, "SHA256");

The question is this:

How I can add the RSA signature generated in advance by the 
RSACryptoServiceProvider to the PDF file in order to obtain a signed PDF.

I have tried to use this code 
(http://itextpdf.sourceforge.net/howtosign.html#signextstd) but with no 
success (the error is "At least one signature requires validating - Internal 
cyptographyc library error").

Another method to solve the problem could be: How a PKCS#7 signed message can 
be created by using the signed data provided by the RSACryptoServiceProvider.

If this will help the community, I am ready to make a PayPal donation for a 
solution. 

Thanks.
Victor ([email protected])




------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/


------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to