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: Raif S. Naffah
Subject: Re: [Classpathx-crypto] GCJ JUnit result.
Date: Wed, 03 Jul 2002 19:24:47 +1000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.0) Gecko/20020530

it does not look as bad is it might first seems ;-)


Olivier LF wrote:
> ...
> Anyway, this is the output I get from the JUnit test suite under GCJ
> version: gcc (GCC) 3.2 20020518.
>
> ...
> ..java.security.NoSuchAlgorithmException: SHA
> at 0x403eeee6: java.security.NoSuchAlgorithmException.NoSuchAlgorithmException(java.lang.String) (/usr/local/gcc/lib/libgcj.so.3) > at 0x403ee972: java.security.MessageDigest.getInstance(java.lang.String, java.lang.String, java.security.Provider) (/usr/local/gcc/lib/libgcj.so.3) > at 0x403ee8ab: java.security.MessageDigest.getInstance(java.lang.String, java.lang.String) (/usr/local/gcc/lib/libgcj.so.3) > at 0x080585eb: test::jce::TestOfProvider::testSha() (/home/olivier/program/cvsrsh/crypto/gcj/source/test/jce/TestOfProvider.java:85)

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!

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);


> F.java.security.NoSuchAlgorithmException: Whirlpool

idem


> F...java.security.NoSuchAlgorithmException: ripemd128

idem


> F.E..E.E..E.E
> Time: 440.928
> There were 13 errors:
> 1) testKeyPairGeneration(test.sig.rsa.TestOfRSAKeyGeneration)
> java.lang.ArithmeticException: not invertible
> at 0x40308f56: java.lang.ArithmeticException.ArithmeticException(java.lang.String) (/usr/local/gcc/lib/libgcj.so.3) > at 0x403d53a9: java.math.BigInteger.modInverse(java.math.BigInteger) (/usr/local/gcc/lib/libgcj.so.3) > at 0x40075ccb: gnu.crypto.sig.rsa.RSAKeyPairGenerator.generate() (/home/olivier/tmp/ccc/source/.libs/lib-gnu-crypto.so.1) > at 0x0805ee1f: test::sig::rsa::TestOfRSAKeyGeneration::testKeyPairGeneration() (/home/olivier/program/cvsrsh/crypto/gcj/source/test/sig/rsa/TestOfRSAKeyGeneration.java:101)

looking at gnu.crypto.rsa.RSAKeyPairGenerator, and the classpath
BigInteger implementation, the exception is thrown from line 205 (in the
RSA keypair generator):

d = e.modInverse(phi);

the problem is that if we made it to that line, this exception should
not be thrown, hence the cause may be in how modInverse is implemented in the concrete BigInteger class. i'll inspect the source later.


> 2) testRSAParams(test.sig.rsa.TestOfRSAKeyGeneration)
> java.lang.ArithmeticException: not invertible...
> 3) testRSAPrimitives(test.sig.rsa.TestOfRSAKeyGeneration)
> java.lang.ArithmeticException: not invertible...
> 4) testSigWithDefaults(test.sig.rsa.TestOfRSAPSSSignature)
> java.lang.ArithmeticException: not invertible...
> 5) testSigWithShaSalt16(test.sig.rsa.TestOfRSAPSSSignature)
> java.lang.ArithmeticException: not invertible...
> 6) testSigWithRipeMD160Salt8(test.sig.rsa.TestOfRSAPSSSignature)
> java.lang.ArithmeticException: not invertible...
> 7) testKeyPairRawCodec(test.sig.rsa.TestOfRSACodec)
> java.lang.ArithmeticException: not invertible...

idem.


> 8) testSignatureRawCodec(test.sig.rsa.TestOfRSACodec)
> at 0x40075ccb: gnu.crypto.sig.rsa.RSAKeyPairGenerator.generate() (/home/olivier/tmp/ccc/source/.libs/lib-gnu-crypto.so.1) > at 0x0805eb95: test::sig::rsa::TestOfRSACodec::setUp() (/home/olivier/program/cvsrsh/crypto/gcj/source/test/sig/rsa/TestOfRSACodec.java:148)

suspect (without knowing at which line it was thrown) that it's at the same place as 2) - 7) above.


> 9) testCloneability(test.jce.TestOfMessageDigest)
> java.security.NoSuchAlgorithmException: ripemd128

same as the Failures earlier.


> 10) testDSAKeyPairGenerator(test.jce.TestOfKeyPairGenerator)
> java.lang.NullPointerException...
> 11) testRSAKeyPairGenerator(test.jce.TestOfKeyPairGenerator)
> java.lang.NullPointerException...
> 12) testDSSRawSignature(test.jce.TestOfSignature)
> java.lang.NullPointerException...
> 13) testRSAPSSRawSignature(test.jce.TestOfSignature)
> java.lang.NullPointerException...

similar problem (and similar work-around) to the MessageDigest.getInstance()


cheers;
rsn




reply via email to

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