sun.security.provider.DES question

allan mays (civstaff@civ.com)
Mon, 5 May 1997 15:52:27 -0400

Message-Id: <199705052002.QAA24961@www5.clever.net>
From: "allan mays" <civstaff@civ.com>
To: <java-security@web2.javasoft.com>
Subject: sun.security.provider.DES question
Date: Mon, 5 May 1997 15:52:27 -0400

I have the following java program which throws the
exception "NoSuchAlgorithm: algorithm DES not available".
Is it necessary to add some configuration information into
the java.security file in order to get rid of this exception?

Any help would be appreciated.

Thanks,
allan mays
Creative Internet Ventures, Inc.

import java.security.*;

/**
*
*/
class Des {
public static void main(String[] args) throws NoSuchAlgorithmException,
KeyException {

String s = new String("test1234567890");
byte[] byteTest = new byte[14];

s.getBytes (0, s.length(),byteTest, 0) ;

SecureRandom random = new SecureRandom();

KeyGenerator keygen = KeyGenerator.getInstance("DES");

keygen.initialize(random);
Key key = keygen.generateKey();

Cipher des = Cipher.getInstance("DES/ECB/PKCS#5");
des.initEncrypt(key);

byte[] ciphertext = des.crypt(byteTest);

des.initDecrypt(key);

byte[] decrypted = des.crypt(ciphertext);

for (int i = 0; i < byteTest.length; i++){
if (decrypted[i] != byteTest[i])
System.out.println("no good");
else
System.out.println("good!!!");
}

}
}

Here is my java.security file:

#
# General java.security properties
#
# In this file, various security properties are set for use by
# java.security classes. This is where users will register security
# packages that they want to use (sun.security is the default).
#
# When the implementation of a given algorithm is request without
# specifying an implementation, security packages are scanned in
# descending order for the implementation of a given algorithm.
#
# If a particular package is requested, the algorithm is looked up
# in that package, and used.
#
# Package specific properties are specified in files named <package>
# in the security preferences directory (the present directory).
#
# which security packages are present in order of preference.
#
security.provider.1=sun.security.provider.Sun

#
# system scope. Class name to instantiate as the system scope.
#
system.scope=sun.security.provider.IdentityDatabase