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

Re: [iaik-jce]



The setupCipher(java.security.Key key) method only may be used when the
content encryption AlgorithmID includes an IV parameter (see Javadoc). Since
you are using PBE encryption, please use the setupCipher(Key key,
AlgorithmParameterSpec params) method for explicitly specifying the
PBEParameterSpec to setup the cipher for decryption.

Furthermore you cannot use the EncryptedContentInfo(ObjectID contentType,
byte[] content) constructor for parsing an already existing
EncryptedContentInfo. Rather you shall use the
EncryptedContentInfo(ASN1Object obj) or EncryptedContentInfo(InputStream is)
constructor for supplying the EncryptedContentInfo as ASN1Object or DER
encoded from an input stream, e.g.:

ASN1Object asn1Object = eci.toASN1Object();

EncryptedContentInfo eci1 = new EncryptedContentInfo(asn1Object);
eci1.setupCipher( pbeKey, param ); // for decryption
byte[] content = eci1.getContent();

However, we currently are thinking about an updated way for handling
AlgorithmIDs, since there are some problems with the current
implementation - as you already has pointed out in a previous mail.

Dieter Bratko

-----Ursprüngliche Nachricht-----
Von: Vito Ingrassia <ingrassi@cefriel.it>
An: IAIK <iaik-jce@iaik.tu-graz.ac.at>
Gesendet: Montag, 31. Mai 1999 16:25
Betreff: [iaik-jce]


> (iaik.pkcs.pkcs7.EncryptedContentInfp  and PBE
> In this example code, after
>
> Random random = new Random();
>             byte[] salt = new byte[8];
>             random.nextBytes(salt);
>             byte[] data =.......................
>             PBEParameterSpec param = new PBEParameterSpec( salt,  1 );
>             PBEKey pbeKey = new PBEKey( "password" );
>             EncryptedContentInfo eci = new EncryptedContentInfo(
> ObjectID.pkcs7_data,  data );
>             eci.setupCipher( AlgorithmID.pbeWithMD5AndDES_CBC , pbeKey,
> param );
>             byte[] encoding = eci.getEncoded();
>
> I continue with
>
>             EncryptedContentInfo eci1 = new EncryptedContentInfo(
> ObjectID.pkcs7_data, encoding );
> (*) eci1.setupCipher( pbeKey ); // for decryption
>
> and i cacth in (*)
>
> iaik.pkcs.PKCSException: Unable to get algorithm parameter!
>
> If  I  try also to get AgorithmID  from eci1 with
>
> AlgorithmID aid = eci1.getContentEncryptionAlgorithm();
>
> I  have    aid == null;
>
>
>
> Have you suggestions?
>
> Thanks in advance
> Vito
> --
> Mailinglist-archive at
http://jcewww.iaik.tu-graz.ac.at/mailarchive/iaik-jce/maillist.html
>
> To unsubscribe send an email to listserv@iaik.tu-graz.ac.at with the
folowing content: UNSUBSCRIBE iaik-jce
>
>
>


smime.p7s