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

[iaik-jce] Verifying Signature signed by Netscape Communicator 4.xx



Hi there,
 
I've got the following exception before verifying the signature WHEN USING IAIK-JCE 2.51:
 
java.io.IOException: Next ASN.1 object is no SEQUENCE!
        at iaik.asn1.DerInputStream.readSequence(Unknown Source)
        at iaik.pkcs.pkcs7.SignedDataStream.decode(Unknown Source)
        at SecureVerify.verify(SecureVerify.java, Compiled Code)
        at SecureVerify.main(SecureVerify.java:209)
 
or sometimes it results:
 
java.io.IOException: Next ASN.1 object is no INTEGER!
        at iaik.asn1.DerInputStream.readInteger(Unknown Source)
        at iaik.pkcs.pkcs7.SignedDataStream.decode(Unknown Source)
        at SecureVerify.verify(SecureVerify.java, Compiled Code)
        at SecureVerify.main(SecureVerify.java:209)
 
BUT it is quite odd that if I use IAIK-JCE 2.61, everything works fine.
Since I HAVE TO use IAIK-JCE 2.51, anyone can help solve my problem? It's very urgent...
 
Here is my code:
//********************************************
   String szContentInfoFile = "Base64 Encoded ContentInfo create by Netscape";
    byte[] message; // Original data
 
   FileInputStream fis = new FileInputStream(szContentInfoFile);
   Base64InputStream der = new Base64InputStream(fis);
   ContentInfoStream cis = new ContentInfoStream(der);
 
   //if (cis.getContentType().equals(ObjectID.pkcs7_signedData)) {
    AlgorithmID []  algIDs   = { AlgorithmID.sha1, AlgorithmID.md5 };
    SignedData signedData  = new SignedData( message, algIDs);
    signedData.decode(der);
 
    SignerInfo[] signerInfos = signedData.getSignerInfos();
 
    for (int i=0; i<signerInfos.length; i++) {
 
         X509Certificate signerCert = signedData.verify(i);
 
         System.out.println("SecureVerify: SIGNATURE OK from " + signerCert.getSubjectDN());
 
    }
   }
 
//********************************************
 
Thanks!
 
Calvin