From owner-freebsd-java@FreeBSD.ORG Fri Nov 4 12:52:48 2005 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 57EA616A41F for ; Fri, 4 Nov 2005 12:52:48 +0000 (GMT) (envelope-from NCoelle@gmx.de) Received: from mail.gmx.net (pop.gmx.net [213.165.64.20]) by mx1.FreeBSD.org (Postfix) with SMTP id CC23A43D58 for ; Fri, 4 Nov 2005 12:52:45 +0000 (GMT) (envelope-from NCoelle@gmx.de) Received: (qmail 22076 invoked by uid 0); 4 Nov 2005 12:52:44 -0000 Received: from 213.68.205.168 by www53.gmx.net with HTTP; Fri, 4 Nov 2005 13:52:44 +0100 (MET) Date: Fri, 4 Nov 2005 13:52:44 +0100 (MET) From: =?ISO-8859-1?Q?=22Niels_C=F6lle=22?= To: Panagiotis Astithas MIME-Version: 1.0 References: <436B2CB6.8080205@ebs.gr> X-Priority: 3 (Normal) X-Authenticated: #3587294 Message-ID: <4978.1131108764@www53.gmx.net> X-Mailer: WWW-Mail 1.6 (Global Message Exchange) X-Flags: 0001 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Cc: freebsd-java@freebsd.org Subject: Re: JDK15: Cipher.getInstance throws UnsupportedOperationException X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2005 12:52:48 -0000 Hello Panagiotis, > Could you post a small example program that demonstrates the issue? That > would help a lot, I think. I think, I found the problem. We are using the IAIK-Provider. If it is inserted at the first position, the exception is thrown. If it is added as last Provider, the test works (See my example below). I am not sure if it is a problem of the IAIK Provider or the JDK. On the other platforms I mentioned, the code works with IAIK as the first provider in the list. Without the strong encryption policy! Setting the strong encryption policy for jdk15 does not help... Strange. Thanks. Niels *** snip *** import iaik.security.provider.IAIK; import java.security.GeneralSecurityException; import java.security.Provider; import java.security.Security; import javax.crypto.Cipher; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Logger; public class TokenTest { // ------------------------------------------------------------------------- // ATTRIBUTES // ------------------------------------------------------------------------- public static final String AES_ALGORITHM = "AES/CBC/NoPadding"; // Token attributes private static Logger mLog = null; private Cipher mAesCipher; /** * Constructor, which adds the IAIK Provider at the end of the provider * list. * * @throws Exception * If anything goes wrong, thrown an exception. */ public TokenTest() throws Exception { init(false); } /** * Constructor which puts the IAIK Provider at the end or beginning of the * provider list. * * @param pInsertProvider * true puts the provider at position 1 of the * provider list; false adds the provider at the * end of the provider list. * @throws Exception * If anything goes wrong, thrown an exception. */ public TokenTest(final boolean pInsertProvider) throws Exception { init(pInsertProvider); } public Cipher getAesCipher() { return mAesCipher; } /** * Does the initialization of the TokenTest. It adds the IAIK Provider to * the provider list and creates an AES-Cipher. * * @param pInsertProvider * true puts the provider at position 1 of the * provider list; false adds the provider at the * end of the provider list. * @throws Exception * If anything goes wrong, thrown an exception. */ private void init(boolean pInsertProvider) throws Exception { mLog.debug("Function -init- called"); // Check, if the IAIK Provider is already in the provider list. If so, // remove it. String providerName = (new IAIK()).getName(); Provider[] aprovider = Security.getProviders(); for (int i = 0; i < aprovider.length; i++) { Provider provider = aprovider[i]; if (provider.getName().equals(providerName)) { mLog.info("Removing provider '" + providerName + "'"); Security.removeProvider(providerName); } } // Add the IAIK provider to the provider list depending on // pInsertProvider. mLog.info("Adding IAIK Provider as default"); if (pInsertProvider) { Security.insertProviderAt(new IAIK(), 1); } else { Security.addProvider(new IAIK()); } // Create the AES-Cipher try { mAesCipher = Cipher.getInstance(AES_ALGORITHM); } catch (GeneralSecurityException e) { mLog.error("Error getting AES cipher object: " + e.getMessage()); throw new Exception("Error getting AES cipher object: " + e.getMessage()); } // Debug mLog.debug("Token object initialized"); } public static void main(String pArgs[]) { // Configure Log4J logging without a properties file. mLog = Logger.getLogger("TokenTest"); BasicConfigurator.configure(); // Do the test. try { // TokenTest(false) works fine, TokenTest(true) throws an exception. TokenTest TokenError = new TokenTest(false); // TokenTest TokenError = new TokenTest(true); mLog.info("Using " + TokenError.getAesCipher().getAlgorithm()); } catch (Throwable t) { mLog.fatal("An exception was thrown: ", t); } mLog.info("Finished."); } } *** snap *** -- Niels Cölle Hauptstr. 30 85586 Poing +49-(0)8121-71620