Re: problem with JCE and JDK1.2Beta3

Jan Luehe (Jan.Luehe@Eng)
Tue, 7 Apr 1998 09:20:47 -0700 (PDT)

Date: Tue, 7 Apr 1998 09:20:47 -0700 (PDT)
From: Jan Luehe <Jan.Luehe@Eng>
Subject: Re: problem with JCE and JDK1.2Beta3
To: java-security@web1.javasoft.com, brierchecks@msx.upmc.edu

Scott:

> I've downloaded the latest JCE and JDK 1.2 beta3,
>
> I'm following the instructions to install and use the JCE
>
> I've set CLASSPATH to
> c:\jdk1.2beta3\jce12-ea2-dom\lib\jce12-ea2-dom.jar;
>
> I've added the following into \lib\security\java.security
> security.provider.2=com.sun.crypto.provider.SunJCE
>
> When I compile a program that uses some JCE calls with JDK 1.2 beta 3, I
> get the following error
>
> "Class or Interface Declaration expected". Then it proceeds to error
> out on every JCE call.
>

You need to do 2 things:

1. Move the

> Provider sunJCE = new com.sun.crypto.provider.SunJCE();
> Security.addProvider(sunJCE);

lines (following your "import" statements) into your "main" routine.

2. Add the following import statement:

import javax.crypto.*;

This will do it.

Jan

> import java.io.*;
> import java.security.*;
>
> Provider sunJCE = new com.sun.crypto.provider.SunJCE();
> Security.addProvider(sunJCE);
>
> public class scrypt2 {
>
> public static void main(String[] args)
> {
> try
> {
> KeyGenerator keygen =
> KeyGenerator.getInstance("DES");
> SecretKey desKey = keygen.generateKey();
> Cipher desCipher;
> // Create the cipher
> desCipher =
> Cipher.getInstance("DES/ECB/PKCS5Padding");
> // Initialize the cipher for encryption
> desCipher.init(Cipher.ENCRYPT_MODE, desKey);
> }
>
> catch (Exception e)
> {
> System.out.println(e.toString());
> }
> }
> }