Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread jian zhang
Hi, Pedro I also need to write a program to send a SHA-1 hash from client to server, then return the signature from server to client. So, if you find a good solution, please send me a email. > Too bad jian zhang method of generating the hash and then applying RSA > doesnt work, my next step was g

Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread mkl
Pedro, P3d3r0s0 wrote: > Too bad jian zhang method of generating the hash and then applying RSA > doesnt work, my next step was going to be to apply this to a server-client > application and that separating RSA from SHA1 would end in less bytes to > send between both. > Theres no way of doing it,

Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread jian zhang
Hi, Suppose content->hash->signature there is already a SHA-1 hash *x*, signature *s = f(x, otherInfo)*, Is there a method *f * In iText or Bouncy Castle library? -- Best Regards, 张健 -- Nokia and AT&T present the 2010

Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread P3d3r0s0
Hey Michael, That makes a lot of sense (SHA1withRSA is a two-step algorithm), and thus i was going at it the wrong way by hashing it first and then rehashing and signing Too bad jian zhang method of generating the hash and then applying RSA doesnt work, my next step was going to be to apply

Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread mkl
Pedro, P3d3r0s0 wrote: > Also found out that something goes wrong when generating the digest. > [...] > if i generate a byte array from the inputstream and sign it afterwards, > adobe recognizes the signature and gives the glorious message that the > file wasnt altered after being signed. > [...]

Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread P3d3r0s0
Hello again, I got few small breakthroughs. For starters i now know i can upload files to nabble instead of filefactory(thanks Michael) :P i wasnt sure that people that used the mailing list would be able to see the files if i used nabble. Also found out that something goes wrong when generating

Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread mkl
Pedro, P3d3r0s0 wrote: > Im sure its possible to sign files with the portuguese citizen's > smartcard, i just used the pdfSignerDemo and signed this sample: > http://www.filefactory.com/file/b402157/n/_signed_pdf Which pdfSignerDemo? (This sample, BTW, uses the /SubFilter /adbe.pkcs7.sha1 which

Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread P3d3r0s0
Hey, looks like you are right Michael. When i selected a handler for the plugin im able to see that theres no hash algorithm and there are verification errors... Im sure its possible to sign files with the portuguese citizen's smartcard, i just used the pdfSignerDemo and signed this sample: http

Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread mkl
张健, jian zhang wrote: > Could you please give me a sample code for using DigestInfo then RSA to > generate a signature? > Use Bouncy Castle library? > I'm a newer in this security field. As mentioned before I merely have to cope with externally generated /adbe.pkcs7.detached signatures; therefor

Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread mkl
Pedro, P3d3r0s0 wrote: > I have no idea in what way PdfSignatureAppearance.VERISIGN_SIGNED differs > from PdfSignatureAppearance.SELF_SIGNED... > [...] > Heres is a sample of a signed document. > The signature isnt verified because i'd need to put the certificate in > adobe reader i think, not su

Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread jian zhang
Thanks Michael, Could you please give me a sample code for using DigestInfo then RSA to generate a signature? Use Bouncy Castle library? I'm a newer in this security field. The reason is that SHA1withRSA does not merely mean "take the SHA1 hash and > encrypt it using RSA". It actually means "tak

Re: [iText-questions] Another invalid signature thread

2010-10-27 Thread mkl
张健, jian zhang wrote: > my code is: > > byte[] signedHashValue1 = server.sha1_rsa(content); > > byte[] hash = server.sha1(content); > byte[] signedHashValue2=server.rsa(hash); > > when I use signedHashValue1, it's ok, I can get a valid signature in pdf; > but when I use signedHashValue2, get a

Re: [iText-questions] Another invalid signature thread

2010-10-26 Thread Andreas Kuehne
e tools to spy into the PDF bytes and get results more easily than trying to interpret a code snippet. Greetings Andreas - original Nachricht Betreff: Re: [iText-questions] Another invalid signature thread Gesendet: Mi, 27. Okt 2010 Von: jian zhang Hi,my code is: I

Re: [iText-questions] Another invalid signature thread

2010-10-26 Thread jian zhang
Hi, my code is: InputStream rs = appearance.getRangeStream(); byte[] content = streamToByteArray(rs, 1024); rs.close(); byte[] signedHashValue1 = server.sha1_rsa(content); //===sha1 then rsa= byte[] hash = server.sha1(content); byte[] signedHashValue2=server.rsa(hash); //

Re: [iText-questions] Another invalid signature thread

2010-10-26 Thread P3d3r0s0
Hey Michael, I have no idea in what way PdfSignatureAppearance.VERISIGN_SIGNED differs from PdfSignatureAppearance.SELF_SIGNED... According to Paulo Soares in another "thread" they are signing modes, why this one worked i really dont know... As for the digest loop, i dont really need to know the

Re: [iText-questions] Another invalid signature thread

2010-10-26 Thread P3d3r0s0
Hey, this was the key point for me: PdfSignatureAppearance.VERISIGN_SIGNED i had this previously: PdfSignatureAppearance.SELF_SIGNED and even tried PdfSignatureAppearance.WINCER_SIGNED but verisign was the only one that worked. In any case, what i placed here was the whole working(for me) code f

Re: [iText-questions] Another invalid signature thread

2010-10-26 Thread mkl
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: > // Proces

Re: [iText-questions] Another invalid signature thread

2010-10-26 Thread jian zhang
I met the same problem with yours. Where have you changed in the code? or could you tell me the key point? -- Best Regards, 张健 -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new ap

Re: [iText-questions] Another invalid signature thread

2010-10-26 Thread P3d3r0s0
Hello everyone, joy of joys, its working! Sorry for double posting, but just wanted to put what worked for me here. try{ // Initializes the Citizens Card CcMethods.init(); // Creates the test files and gets their stream

Re: [iText-questions] Another invalid signature thread

2010-10-26 Thread kuehne
rsa_sha1. But if your heading for a future proof version you may have to invest some time and dig into the PKCS7 world. Or you try to go for a ready-made solution that signs your PDF ... Good luck Andreas - original Nachricht Betreff: Re: [iText-questions] Another invalid signat

Re: [iText-questions] Another invalid signature thread

2010-10-26 Thread P3d3r0s0
Hey Andreas, about the ASN1 byte wrapper, i think im not using it when i use: PdfSignature dic1 = new PdfSignature(PdfName.ADOBE_PPKLITE, PdfName.ADBE_PKCS7_DETACHED); dic1.setDate(new PdfDate(appearance.getSignDate())); dic1.setName(PdfPKCS7.getSub

Re: [iText-questions] Another invalid signature thread

2010-10-26 Thread kuehne
de a DigestInfo structure but the very plain digest bytes. This may do the trick ... Greetings Andreas - original Nachricht Betreff: Re: [iText-questions] Another invalid signature thread Gesendet: Mo, 25. Okt 2010 Von: P3d3r0s0 > > Hello again, > > I did the detached metho

Re: [iText-questions] Another invalid signature thread

2010-10-25 Thread P3d3r0s0
Hello again, I did the detached method now, learned a few things on what works a little better but still gives an error (Error encountered while BER decoding:)... sample: http://www.filefactory.com/file/b3hcd3b/n/signed_pdf Key code samples that i believe might be the reason for the errors: Pdf

Re: [iText-questions] Another invalid signature thread

2010-10-25 Thread mkl
Pedro, P3d3r0s0 wrote: > this the file with the verified digest: > http://www.filefactory.com/file/b3hc38g/n/signed_pdf I'll have a look at your sample files later, but concerning: P3d3r0s0 wrote: > I suppose that in order to use the detached one you mentioned i would have > to use: > PdfSignat

Re: [iText-questions] Another invalid signature thread

2010-10-25 Thread P3d3r0s0
Good morning, this the file with the verified digest: http://www.filefactory.com/file/b3hc38g/n/signed_pdf i still get the invalid signature error. I have no specific reason to use the filter you (Michael) mentioned, in fact i didnt even know i was using it :) I suppose that in order to use the d

Re: [iText-questions] Another invalid signature thread

2010-10-23 Thread mkl
Pedro, P3d3r0s0 wrote: > Hey, i think i understand, so according to what you are saying Michael, > all i need to do now is(if i understood correctly): > sig.setExternalDigest(signedHash, null, "RSA"); > when i have the digest/hash signed. > this signedHash doesnt have those 3 bytes. > > weird th

Re: [iText-questions] Another invalid signature thread

2010-10-22 Thread P3d3r0s0
Hey, i think i understand, so according to what you are saying Michael, all i need to do now is(if i understood correctly): sig.setExternalDigest(signedHash, null, "RSA"); when i have the digest/hash signed. this signedHash doesnt have those 3 bytes. weird thing is... i was able to verify the sig

Re: [iText-questions] Another invalid signature thread

2010-10-22 Thread kuehne
Hi Michael, thanks for the instant explanation. This behaviour of the undelying PKCS11 implementation is a bit unexpected, isn't it ? From the JavaDoc you would expect an ASN.1 structure ... Greetings Andreas - original Nachricht Betreff: Re: [iText-questions] Another in

Re: [iText-questions] Another invalid signature thread

2010-10-22 Thread mkl
P3d3r0s0, P3d3r0s0 wrote: > I found out where the 131 bytes come from, apparently its from the > sig.getEncodedPKCS1() array. > This array is the same as the signedHash array (128 bytes) but with 3 > extra bytes ({4}{-127}{-128}), these bytes never change. > Is this normal behaviour? This byte[]

Re: [iText-questions] Another invalid signature thread

2010-10-22 Thread P3d3r0s0
First of all, sorry for double post, second thanks for Andreas for all your help. I found out where the 131 bytes come from, apparently its from the sig.getEncodedPKCS1() array. This array is the same as the signedHash array (128 bytes) but with 3 extra bytes ({4}{-127}{-128}), these bytes never

Re: [iText-questions] Another invalid signature thread

2010-10-21 Thread P3d3r0s0
Hello :) I can show you the code i use to initialize the builder i use to get the keystore, from what i understand it uses a pkcs11 library to get its provider and a handler that eventually asks for the smarcard's pin. code: private static void initBuilder(){ try {

Re: [iText-questions] Another invalid signature thread

2010-10-21 Thread kuehne
Nachricht Betreff: Re: [iText-questions] Another invalid signature thread Gesendet: Do, 21. Okt 2010 Von: P3d3r0s0 > > Thanks a lot for your reply, i thought the problem was either when i > generated the hash or when i sign it. The problem with the CcMethods > documentation is that

Re: [iText-questions] Another invalid signature thread

2010-10-21 Thread P3d3r0s0
Thanks a lot for your reply, i thought the problem was either when i generated the hash or when i sign it. The problem with the CcMethods documentation is that i made that class :P this is the code for the signing method: // Signs given hash public static byte[] sign(by

Re: [iText-questions] Another invalid signature thread

2010-10-21 Thread kuehne
f: Re: [iText-questions] Another invalid signature thread Gesendet: Do, 21. Okt 2010 Von: P3d3r0s0 > > Hey, i have a sample here: > http://www.filefactory.com/file/b3gd1ce/n/signed.pdf > > Im really out of ideas. > Regards > -- > View this message in context: >

Re: [iText-questions] Another invalid signature thread

2010-10-21 Thread P3d3r0s0
Hey, i have a sample here: http://www.filefactory.com/file/b3gd1ce/n/signed.pdf Im really out of ideas. Regards -- View this message in context: http://itext-general.2136553.n4.nabble.com/Another-invalid-signature-thread-tp3003710p3005238.html Sent from the iText - General mailing list archive

Re: [iText-questions] Another invalid signature thread

2010-10-20 Thread kuehne
Hi, interesting pictures, but a sample PDF would be more useful. Many reasons can cause these messages ... Greetings Andreas - original Nachricht Betreff: Re: [iText-questions] Another invalid signature thread Gesendet: Mi, 20. Okt 2010 Von: P3d3r0s0 > > this is a sample

Re: [iText-questions] Another invalid signature thread

2010-10-20 Thread P3d3r0s0
this is a sample of the signature on the pdf: http://itext-general.2136553.n4.nabble.com/file/n3003983/docAltered.jpg this show that the hash algorithm was found: http://itext-general.2136553.n4.nabble.com/file/n3003983/docAlgo.jpg if theres anymore information i can give just let me know, im

[iText-questions] Another invalid signature thread

2010-10-20 Thread P3d3r0s0
Hey, ive seen a lot of invalid signature threads, but none seems to fix my problem. Im signing a pdf using Itext (in java) but i always get the invalid signature error. Weird thing is, i can see the algorithm using for signing and the certificates used on the pdf's properties, the error message sa