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

[iaik-jce] SignedDataStream.getCertificates()



Hello,

I generate a DER-encoded byte array by constructing an implicit
SignedDataStream and adding the certificates and SignerInfos.  When I
try to construct a new SignedDataStream from that byte array and then
get the certificates, I get a null array.  I have duplicated the
problem, using the demo.pkcs.PKCS7Stream class.  The code is presented
below.

Is there a different way to accomplish this task?  I want to read a
signed message and add another signer by extending the CertificateArray[
].

Thanks.

import java.io.IOException;
import java.io.ByteArrayInputStream;

import iaik.pkcs.PKCSException;
import iaik.pkcs.PKCSParsingException;
import iaik.pkcs.pkcs7.*;
import iaik.security.provider.IAIK;

import demo.keystore.IaikKeyStore;
import demo.pkcs.PKCS7Stream;

public class testSignedDataStream
{
  testSignedDataStream() throws IOException
  {
    byte[] message = new String("abcdefg").getBytes();
    byte[] signed_data_array = null;
    try{
      signed_data_array =
                  (new PKCS7Stream()).createSignedDataStream(message,
                                      SignedDataStream.IMPLICIT);
    }
    catch (PKCSException pke) {pke.toString();}
    ByteArrayInputStream is = new
                        ByteArrayInputStream(signed_data_array);
    SignedDataStream signed_data_2 = null;
    try{
      signed_data_2 = new SignedDataStream(is);
    }
    catch (PKCSParsingException pkpe) {
      pkpe.toString();
    }
    System.out.println("certs are " + signed_data_2.getCertificates());
  }
  public static void main(String argv[]) throws IOException
  {
    IAIK.addAsProvider(true);
    new testSignedDataStream();
  }
}



--
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