classpathx-crypto
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Classpathx-crypto] GCJ JUnit result.


From: Olivier LF
Subject: Re: [Classpathx-crypto] GCJ JUnit result.
Date: Wed, 3 Jul 2002 23:38:28 +1000
User-agent: Mutt/1.3.28i

On Wed, Jul 03, 2002 at 07:24:47PM +1000, Raif S. Naffah wrote:
> 
> i had a look at the classpath implementation of the
> MessageDigest.getInstance and i know why this is throwing the exception:
> the implemetation *does not* handle algorithm aliasing at all!

First of all be aware that "classpath" and "gcj" don't always share
the same code. They are merging differences step by step. 
In gcj the classes are under:

   gcc/libjava/java

> a simple fix is to replace the following line in the above method (with
> 2 arguments) with the following:
> 
> - return getInstance(p.getProperty("MessageDigest." + algorithm),
> algorithm, p);
> 
> + // try the name as is
> + String className = p.getProperty("MessageDigest." + algorithm);
> + if (className == null) { // try all uppercase
> +    String upper = algorithm.toUpperCase();
> +    className = p.getProperty("MessageDigest." + upper);
> +    if (className == null) { // try if it's an alias
> +       String alias = p.getProperty("Alg.Alias.MessageDigest." +
> algorithm);
> +       if (alias == null) { // spit the dummy
> +          throw new NoSuchAlgorithmException(algorithm);
> +       }
> +       className = p.getProperty("MessageDigest." + alias);
> +       if (className == null) {
> +          throw new NoSuchAlgorithmException(algorithm);
> +       }
> +    }
> + }
> + return getInstance(className, algorithm, p);


The gcj implementation of MessageDigest looks the same as classpath.
I haven't tried your patch yet. I did try the naive approach of replacing:

   MessageDigest md = MessageDigest.getInstance("SHA", GNU);
   ...
   ...
   MessageDigest md = MessageDigest.getInstance("WHirlpool", GNU);

with:

   MessageDigest md = MessageDigest.getInstance("SHA-160", GNU);
   ...
   ...
   MessageDigest md = MessageDigest.getInstance("WHIRLPOOL", GNU);

In TestOfProvider.java, I now get:

java.lang.ClassCastException: gnu.crypto.jce.Sha160Spi cannot be cast to
java.security.MessageDigest
...
...
java.lang.ClassCastException: gnu.crypto.jce.WhirlpoolSpi cannot be cast
to java.security.MessageDigest

???

Oli

-- 
----------------------------------------------------------------------
Olivier Louchart-Fletcher
Email: address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]