# Re: JCE 1.2 Problems

Gigi Ankeny (Gigi.Ankeny@Eng)
Tue, 20 Jan 1998 11:16:48 -0800 (PST)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Jan Luehe: "Re: JCE 1.2 Problems"
- Previous message: Dan Cieslak: "JCE 1.2 Problems"
- Maybe in reply to: Dan Cieslak: "JCE 1.2 Problems"
- Next in thread: Jan Luehe: "Re: JCE 1.2 Problems"

    Date: Tue, 20 Jan 1998 11:16:48 -0800 (PST)

    From: Gigi Ankeny <Gigi.Ankeny@Eng>

    Subject: Re: JCE 1.2 Problems

    To: java-security@web2.javasoft.com, cieslakd@ssax.com

--Singular_of_Boars_661_000
Content-Type: TEXT/plain; charset=us-ascii
Content-MD5: IzF3/N6yjBiSIUHNyFvZtA==

Dan,

I compiled your example code and noticed that you specified
DES algorithm using a string like: DES/ECB, which is not
OK for JCE implementation. Our JCE allows flexible plug in
by different providers and thus does not restrict what padding
scheme it will be and what block modes it could have. In this
case, you would have to specify padding scheme as well since
otherwise, we won't be able to tell the last / indicates
a padding scheme or a block mode.
I modified your example with DES/ECB/PKCS5Padding and I don't
see any algorithm not found exception being thrown, the
test String is correctly encoded and decoded.
Will it be possible that the classpath is not pointing to the
JCE implementation?
Thanks for your feedback, let us know if the Algorithm modification helps.

Gigi

> From: "Dan Cieslak" <cieslakd@ssax.com>
> To: <java-security@web2.javasoft.com>
> Cc: <cieslakd@ssax.com>
> Subject: JCE 1.2 Problems
> Date: Tue, 20 Jan 1998 12:58:49 -0600
> Mime-Version: 1.0
> X-Priority: 3
> X-Msmail-Priority: Normal
> X-Mimeole: Produced By Microsoft MimeOLE Engine V4.71.1008.3
>

===============================================================

( Gigi Ankeny
( ( JavaSoft Security Group Engineer
------
( Java )= 408-8633135
------ gigi.ankeny@eng.sun.com
http://www-cs-students.stanford.edu/~gigi
================================================================

--Singular_of_Boars_661_000
Content-Type: TEXT/plain; name=NoName; charset=us-ascii
Content-Description: NoName
Content-MD5: Byq2X4T4r8qBQQy12C92FQ==

I'm having trouble getting simple applications to work

with the new JCE package using JDK 1.2 Beta 2. I have

included the source in this email. The errors that I get occur at

runtime and are complaints that the PBE With MD5 and DES

algorithm either can't be found or wasn't implemented. The DES

one complains that SHA-1 could not be found.

Thanks,

Dan Cieslak

--Singular_of_Boars_661_000
Content-Type: TEXT/plain; name=NoName; charset=us-ascii
Content-Description: NoName
Content-MD5: Ym0RMeadHVPGdLs/+uELYg==

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">

I'm having trouble getting simple applications to work

with the new JCE package using JDK 1.2 Beta 2. I have

included the source in this email. The errors that I get occur at

runtime and are complaints that the PBE With MD5 and DES

algorithm either can't be found or wasn't implemented. The DES

one complains that SHA-1 could not be found.

Thanks,

Dan Cieslak

--Singular_of_Boars_661_000 Content-Type: TEXT/plain; name="DESexample.java"; charset=us-ascii Content-Description: DESexample.java Content-MD5: HM+nf1ZPUeRCPGSaarc2ww== /** * Password Based Encryption Example * Dan Cieslak * 01/12/98 * * No copyright information. * * Note this uses the JCE 1.2 Early Access API. It * requires JDK 1.2 Beta. */ import javax.crypto.*; import javax.crypto.spec.*; import javax.crypto.interfaces.*; import com.sun.crypto.provider.*; import java.security.*; /** * Class to demonstrate DES using Java * @author Dan Cieslak * @version 1.0 * */ public class DESexample { public static void main(String args[]) { try { Provider sunJce = new SunJCE(); Security.addProvider(sunJce); KeyGenerator keygen = KeyGenerator.getInstance("DES"); SecretKey desKey = keygen.generateKey(); Cipher desCipher = Cipher.getInstance("DES/ECB"); // Initialize the cipher for encryption desCipher.init(Cipher.ENCRYPT_MODE, desKey); // Our cleartext byte[] cleartext = "This is just an example".getBytes(); // Encrypt the cleartext byte[] ciphertext = desCipher.doFinal(cleartext); // Initialize the same cipher for decryption desCipher.init(Cipher.DECRYPT_MODE, desKey); // Decrypt the ciphertext byte[] cleartext1 = desCipher.doFinal(ciphertext); // Print the strings String clearStr = new String(cleartext); String cipherStr = new String(ciphertext); String clearStr1 = new String(cleartext1); System.out.println(clearStr); System.out.println(cipherStr); System.out.println(clearStr1); } catch (Exception e) { e.printStackTrace(); } } } --Singular_of_Boars_661_000 Content-Type: TEXT/plain; name="PBEexample.java"; charset=us-ascii Content-Description: PBEexample.java Content-MD5: QMUAkhGC0V30/mVzVbuWfw== /** * Password Based Encryption Example * Dan Cieslak * 01/12/98 * * No copyright information. * * Note this uses the JCE 1.2 Early Access API. It * requires JDK 1.2 Beta. */ import javax.crypto.*; import javax.crypto.spec.*; import javax.crypto.interfaces.*; import com.sun.crypto.provider.*; /** * Class to demonstrate PBE using Java * @author Dan Cieslak * @version 1.0 * */ public class PBEexample { public static void main(String args[]) { PBEKeySpec pbeKeySpec; PBEParameterSpec pbeParamSpec; SecretKeyFactory keyFac; try { // Salt byte[] salt = { (byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c, (byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99 }; // Iteration count int count = 20; // Create PBE parameter set pbeParamSpec = new PBEParameterSpec(salt, count); // Convert password into SecretKey object, // using a PBE key factory pbeKeySpec = new PBEKeySpec("Do not share this with anybody"); keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES"); SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec); // Create PBE Cipher Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES"); // Initialize PBE Cipher with key and parameters pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec); // Our cleartext byte[] cleartext = "This is another example".getBytes(); // Encrypt the cleartext byte[] ciphertext = pbeCipher.doFinal(cleartext); System.out.println(cleartext); System.out.println(ciphertext); } catch (Exception e) { e.printStackTrace(); } } } --Singular_of_Boars_661_000--

- Next message: Jan Luehe: "Re: JCE 1.2 Problems"
- Previous message: Dan Cieslak: "JCE 1.2 Problems"
- Maybe in reply to: Dan Cieslak: "JCE 1.2 Problems"
- Next in thread: Jan Luehe: "Re: JCE 1.2 Problems"