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

[iaik-jce] Ciphers exceptions



Hello,

I'm working with  iaik.pkcs.pkcs7.EnvelopedDataStream  class.
I'm able to crate an EnvelopedDataStream  and to retrieve from it
the encrypted content for each recipients. In my code I use AlgorithmID
objects
for these ciphers: DES, 3DES IDEA (ECB and CBC), RC2 (ECB and CBC), RC4 ,
CAST5.
I created AlgorithmID objects when AlgorithmID class not supply them.
In case of IDEA CBC , for instance,
new AlgorithmID("1.3.6.1.4.1.188.7.1.1.2", "IDEA_CBC",
"IDEA/CBC/PKCS5Padding");
My code includes:

AlgorithmID algorithm = (I try it for each above cipher )
algorithm.setParameter( new OCTET_STRING( bytes ) );
EnvelopedDataStream enveloped_data = new EnvelopedDataStream(is, algorithm);
enveloped_data.setRecipientInfos(recipients);

This code don't give me any problem and also on the recipient side I work
fine.
But this is true only for DES, IDEA, 3DES (ECB and CBC mode);

With RC2, RC4, CAST5  I catch    these exceptions  in EnvelopedDataStream
contructor.

RC2_CBC
java.lang.ArrayIndexOutOfBoundsException: -1
        at iaik.security.cipher.h.a(Unknown Source)
        at iaik.security.cipher.h.engineInit(Unknown Source)
        at iaik.security.cipher.v.engineInit(Unknown Source)
        at javax.crypto.Cipher.init(Unknown Source)
        at iaik.pkcs.pkcs7.EncryptedContentInfoStream.setupCipher(Unknown
Source)
        at iaik.pkcs.pkcs7.EncryptedContentInfoStream.setupCipher(Unknown
Source)
        at iaik.pkcs.pkcs7.EnvelopedDataStream.<init>(Unknown Source)

............................................................................
.....

RC2_ECB
java.lang.ArrayIndexOutOfBoundsException: -1
        at iaik.security.cipher.h.a(Unknown Source)
        at iaik.security.cipher.h.engineInit(Unknown Source)
        at iaik.security.cipher.v.engineInit(Unknown Source)
        at javax.crypto.Cipher.init(Unknown Source)
        at iaik.pkcs.pkcs7.EncryptedContentInfoStream.setupCipher(Unknown
Source)
        at iaik.pkcs.pkcs7.EncryptedContentInfoStream.setupCipher(Unknown
Source)
        at iaik.pkcs.pkcs7.EnvelopedDataStream.<init>(Unknown Source)

............................................................................
.....

RC4
java.lang.ArrayIndexOutOfBoundsException: 0
        at iaik.security.cipher.g.a(Unknown Source)
        at iaik.security.cipher.g.engineInit(Unknown Source)
        at iaik.security.cipher.v.engineInit(Unknown Source)
        at javax.crypto.Cipher.init(Unknown Source)
        at iaik.pkcs.pkcs7.EncryptedContentInfoStream.setupCipher(Unknown
Source)
        at iaik.pkcs.pkcs7.EncryptedContentInfoStream.setupCipher(Unknown
Source)
        at iaik.pkcs.pkcs7.EnvelopedDataStream.<init>(Unknown Source)

............................................................................
.....

CAST5_CBC
iaik.utils.InternalErrorException: Internal Key problem.
        at iaik.pkcs.pkcs7.EncryptedContentInfoStream.setupCipher(Unknown
Source)
        at iaik.pkcs.pkcs7.EnvelopedDataStream.<init>(Unknown Source)

............................................................................
.....


I'm wondering if this ciphers requires a particular key/parameter
handling and in this case the contructor

EnvelopedDataStream(RecipientInfo[], EncryptedContentInfoStream)

must be use as you explained me in a previous e-mail.

If it's true what I suppose
( and so the code
-------> algorithm.setParameter( new OCTET_STRING( bytes ) )
is wrong )
how can I  create AlgorithmParameters  object  for  this  ciphers to use in
AlgortihmID.setAlgortihmParameters(AlgorithmPAramters ap )
and in  EncryptedContentInfoStream.setupCipher( algorithm, secretKey,
ap.getParameterSpec(paramSpec.class)
methods ?

Sorry, but I didin't find the example you suggested me to see.

P.S. AlgorithmParameters.getInstance( "name", "providr" ) is only available
for DiffieHellman and PBE. But I found in  JCE Specification & Reference
that  the following names can be
used when requesting an instance of AlgortihmParameters:
DES, DESede, PBE, Blowfish, DiffieHellmann. So I expected implementation
for these ciphers and for those you add  in IAIK-JCE (RC2, RC4 ...).
In what I'm failing?


Thanks very much (also for previous answers),
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