[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-jce] SignedData





Hi there...

I can't put the signedData to work... I saw the demos in the packages 
put I can=B4t put an example of myself working...

What I intend to do is simply verify the signedata, but it always 
lauchs SignatureException...

ERRO.Error verifying the signature:
java.security.SignatureException: Error verifying the signature:
        at iaik.pkcs.pkcs7.SignedDataStream.verify(Unknown Source)
        at Sig_Dat.init(Sig_Dat.java:69)
        at Sig_Dat.start(Sig_Dat.java:87)
        at Sig_Dat.main(Sig_Dat.java:174)



I have RSA 512 keys (private and public)
and A X509 Certificate, self sign with sha1WithRSAEncryption

I'm desperate, I can=B4t see what I doing wrong...
If anyone can send me a simple example how to create and verify... i 
would be most grateful


prvK=3DgetPrivateKey();
Cert=3DgetCertificate();
pubK=3DgetPublicKey();
X509Certificate[] cert=3DgetCertificates();

SignedData signed_data=3Dnew 
SignedData(mesg.getBytes(),SignedData.IMPLICIT);
debug("Setting 
certificate...");
signed_data.setCertificates(cert);
IssuerAndSerialNumber issuer_and_serialNr =3D new 
IssuerAndSerialNumber(cert[0]);
SignerInfo signer_info =3D new SignerInfo(issuer_and_serialNr, 
AlgorithmID.sha, prvK);
 try{
      signed_data.addSignerInfo(signer_info);
	  signed_data.verify(this.pubK,0);
 }catch(SignatureException e){
 System.out.println("ERRO. "+e.getMessage());
          e.printStackTrace();
 }catch(NoSuchAlgorithmException e)
 {
    System.out.println("ERRO II. "+e.getMessage());          		
	e.printStackTrace();


 }


--
Serafim Gomes
serafim@pobox.com           telm: +351 - 938421578  telf: +351-253548100
http://www.serafimgomes.com
--
Mailinglist-archive at http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content: UNSUBSCRIBE iaik-jce