From owner-freebsd-java@FreeBSD.ORG Tue Oct 26 22:17:51 2004 Return-Path: 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 F130416A4CE for ; Tue, 26 Oct 2004 22:17:50 +0000 (GMT) Received: from www.enhyper.com (mailgate.enhyper.com [62.49.250.18]) by mx1.FreeBSD.org (Postfix) with ESMTP id D3D7243D2D for ; Tue, 26 Oct 2004 22:17:49 +0000 (GMT) (envelope-from iang@systemics.com) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by www.enhyper.com (8.11.6/8.11.6) with SMTP id i9QMHW213049; Tue, 26 Oct 2004 23:17:43 +0100 X-Authentication-Warning: www.enhyper.com: localhost.localdomain [127.0.0.1] didn't use HELO protocol Message-ID: <417ECD08.8010805@systemics.com> Date: Tue, 26 Oct 2004 23:17:44 +0100 From: Ian Grigg User-Agent: Mozilla Thunderbird 0.7.3 (X11/20041002) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-java@freebsd.org Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Crypto takes 17 seconds to wind up for the throw... X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Oct 2004 22:17:51 -0000 It seems that a call into javax.crypto.Cipher.getInstance() takes about 17 seconds to come back with the trivial object of a cipher. See follow-on test program and results. Now, getting a Cipher should be a matter of milliseconds. It's just an object that feeds some blocks into a bunch of spinning rotors. So there's definately a blockage in there somewhere. I'm pretty sure the blockage is deep within the SUN JCE code. I'm pretty sure it's for a really dumb reason. While I keep looking, has anyone come across this? Or got any clues? iang galland$ /usr/local/jdk1.4.2/bin/javac CipherSlowTest.java && CLASSPATH=::$CLASSPATH $JAVA CipherSlowTest ....................default provider: SUN MessDig SHA-1: 126 ....................default crypto provider: SunJCE Cipher DES: 17025 ....................addProvider(CryptixCrypto): 12 MessDig SHA-1: 16 Cipher DES: 349 Cipher Null: 5 Cipher AES: 30 Wfgalland$ /usr/local/jdk1.4.2/bin/javac CipherSlowTest.java && CLASSPATH=::$CLASSPATH $JAVA CipherSlowTest .......................................default provider: SUN MessDig SHA-1: 129 .......................................default crypto provider: SunJCE Cipher DES: 17034 .......................................addProvider(CryptixCrypto): 11 MessDig SHA-1: 19 Cipher DES: 355 Cipher Null: 5 Cipher AES: 31 galland$ import javax.crypto.*; import java.security.*; /** * JDK 1.4.2 * java version "1.4.2-p6" * Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-p6-toor_21_jul_2004_13_48) * Java HotSpot(TM) Client VM (build 1.4.2-p6-toor_21_jul_2004_13_48, mixed mode) * * FreeBSD galland 4.9-RC FreeBSD 4.9-RC #7: Tue Sep 30 03:21:16 EDT 2003 * */ public class CipherSlowTest { public static void main(String[] args) throws Exception { long t1 = System.currentTimeMillis(); long t2; String provider; String line = "......................................."; provider = "SUN"; System.out.println(line+"default provider: " + provider); MessageDigest.getInstance("SHA-1", provider); t2 = System.currentTimeMillis(); System.out.println("MessDig SHA-1: "+(t2-t1)); t1 = t2; provider = "SunJCE"; System.out.println(line+"default crypto provider: " + provider); Cipher.getInstance("DES", provider); t2 = System.currentTimeMillis(); System.out.println("Cipher DES: "+(t2-t1)); t1 = t2; provider = "CryptixCrypto"; Security.addProvider(new cryptix.jce.provider.CryptixCrypto()); t2 = System.currentTimeMillis(); System.out.println(line+"addProvider("+provider+"): "+(t2-t1)); t1 = t2; MessageDigest.getInstance("SHA-1", provider); t2 = System.currentTimeMillis(); System.out.println("MessDig SHA-1: "+(t2-t1)); t1 = t2; Cipher.getInstance("DES", provider); t2 = System.currentTimeMillis(); System.out.println("Cipher DES: "+(t2-t1)); t1 = t2; Cipher.getInstance("null", provider); t2 = System.currentTimeMillis(); System.out.println("Cipher Null: "+(t2-t1)); t1 = t2; Cipher.getInstance("Rijndael/ECB/NoPadding", provider); t2 = System.currentTimeMillis(); System.out.println("Cipher AES: "+(t2-t1)); t1 = t2; } }