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

Re: [iaik-jce] SignedDataStream.getCertificates()



The SignedDataStream implementation is stream based. Since the certificates
field comes behind the content carrying ContentInfo field, you must read the
content from the stream -- as shown in the demo -- before accessing the
certificates. You alternatively may use the SignedData implementation which
is not stream based. For only sending certificates, use
iaik.pkcs.PKCS7CertList.

Dieter Bratko


----- Original Message -----
From: Alan Grenadir <alan@lexias.com>
To: IAIK <iaik-jce@iaik.tu-graz.ac.at>
Sent: Friday, February 04, 2000 1:49 AM
Subject: [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
>
>
>


smime.p7s