Creating native binaries using GNU-Crypto

Stefan Prelle prelle@informatik.uni-bremen.de
Thu Dec 11 14:41:00 GMT 2003


On Thu, 2003-12-11 at 10:25, Raif S. Naffah wrote:
> can you provide a minimal code that causes the exception; i.e. after 
> adding the GnuCrypto Provider, and when acquiring an algorithm.

Now I can :-)

Class
---------------------
import java.security.Provider;
import java.security.Security;
import javax.crypto.Mac;

public class GetClassTest {
    public static void main(String[] args) {
	try {
	    Provider prov = new gnu.crypto.jce.GnuCrypto();
	    Security.addProvider(prov);
	    Mac mac = Mac.getInstance("HMAC-MD5");
	    System.out.println("Mac is "+mac);
	} catch (Exception e){
	    e.printStackTrace();
	}
    }
}

Compilation
-----------------------
gcj -g -O2 -o GetClassTest --main=GetClassTest GetClassTest.java
/home/prelle/platform/linuxpc/lib/lib-gnu-crypto.so
/home/prelle/platform/linuxpc/lib/lib-javax-crypto.so
-I/home/prelle/platform/linuxpc/share/javax-crypto.jar
-I/home/prelle/platform/linuxpc/share/gnu-crypto.jar

Execution
-----------------------
rubin->./GetClassTest
java.lang.IllegalStateException: algorithm HMAC-MD5 in provider
GNU-CRYPTO but no class "gnu.crypto.jce.mac.HMacMD5Spi" found!
   at javax.crypto.JCEUtil.getImplementation(java.lang.String,
java.lang.String, java.security.Provider)
(/home/prelle/platform/linuxpc/lib/lib-javax-crypto.so.1.0.1)
   at javax.crypto.JCEUtil.getImplementation(java.lang.String,
java.lang.String, java.lang.String)
(/home/prelle/platform/linuxpc/lib/lib-javax-crypto.so.1.0.1)
   at javax.crypto.Mac.getInstance(java.lang.String)
(/home/prelle/platform/linuxpc/lib/lib-javax-crypto.so.1.0.1)
   at gnu.gcj.runtime.FirstThread.call_main()
(/local/prelle/lib/libgcj.so.4.0.0)
   at gnu.gcj.runtime.FirstThread.run()
(/local/prelle/lib/libgcj.so.4.0.0)
   at _Jv_ThreadRun(java.lang.Thread)
(/local/prelle/lib/libgcj.so.4.0.0)
   at _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean)
(/local/prelle/lib/libgcj.so.4.0.0)
   at JvRunMain (/local/prelle/lib/libgcj.so.4.0.0)
   at __libc_start_main (/lib/libc-2.2.4.so)

Regards,
  Stefan



More information about the Java mailing list