gnu-crypto-discuss
[Top][All Lists]
Advanced

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

[GNU Crypto] java.lang.NoSuchMethodError at gnu.crypto.mode.ModeFactory.


From: tabun
Subject: [GNU Crypto] java.lang.NoSuchMethodError at gnu.crypto.mode.ModeFactory.getInstance
Date: Mon, 23 Jan 2006 23:58:05 -0500
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051013)

Hi there,

I'm attempting to use a SealedObject with GNU Crypto. I had the source working with the sun jdk but my source at runtime doesn't succeed to get past the "nosuchmethoderror".

Any gcj guru out there willing to nudge me in the right direction?

Thanks in advance.

Cheers :)
-----------------------------------------------------------------------
Here is the output:

export LD_LIBRARY_PATH=/usr/local/gnu-crypto/lib:/usr/local/gnu-crypto/share:.;./testaes
provider:GNU-CRYPTO
getInfo:GNU Crypto JCE Provider
getVersion:2.0
rijndael cipher created...
with keysize:16
with blocksize:16
Running 1 iterations:
Encryption: time = 1.0, speed = 0.015625 KB/s
Decryption: decryptedMessage:<<0123456789ABCDEF>>
time = 1.0, speed = 0.015625 KB/s
cipher algorithm count:113
algorithm:PBEWITHHMACHAVALANDKHAZAD
algorithm:PBEWITHHMACTIGERANDCAST5
algorithm:PBEWITHHMACMD5ANDCAST5
algorithm:PBEWITHHMACSHA256ANDCAST5
algorithm:KHAZAD
algorithm:PBEWITHHMACMD4ANDSQUARE
algorithm:PBEWITHHMACWHIRLPOOLANDSQUARE
algorithm:PBEWITHHMACWHIRLPOOLANDKHAZAD
algorithm:PBEWITHHMACSHA384ANDCAST5
algorithm:PBEWITHHMACSHA384ANDSERPENT
algorithm:PBEWITHHMACMD4ANDTWOFISH
algorithm:PBEWITHHMACMD2ANDANUBIS
algorithm:PBEWITHHMACSHA256ANDAES
algorithm:PBEWITHHMACHAVALANDTWOFISH
algorithm:PBEWITHHMACMD4ANDANUBIS
algorithm:PBEWITHHMACTIGERANDBLOWFISH
algorithm:PBEWITHHMACSHA384ANDANUBIS
algorithm:PBEWITHHMACSHA384ANDTWOFISH
algorithm:PBEWITHHMACSHA256ANDDES
algorithm:PBEWITHHMACMD2ANDSQUARE
algorithm:PBEWITHHMACWHIRLPOOLANDCAST5
algorithm:DES
algorithm:PBEWITHHMACSHA384ANDTRIPLEDES
algorithm:PBEWITHHMACWHIRLPOOLANDSERPENT
algorithm:PBEWITHHMACSHA384ANDSQUARE
algorithm:PBEWITHHMACWHIRLPOOLANDANUBIS
algorithm:PBEWITHHMACMD2ANDTWOFISH
algorithm:PBEWITHHMACHAVALANDBLOWFISH
algorithm:PBEWITHHMACMD4ANDBLOWFISH
algorithm:PBEWITHHMACSHA256ANDBLOWFISH
algorithm:AES
algorithm:PBEWITHHMACSHA256ANDTWOFISH
algorithm:PBEWITHHMACSHA512ANDTRIPLEDES
algorithm:TRIPLEDES
algorithm:PBEWITHHMACSHA1ANDSERPENT
algorithm:ARCFOUR
algorithm:PBEWITHHMACSHA384ANDKHAZAD
algorithm:PBEWITHHMACMD2ANDCAST5
algorithm:ANUBIS
algorithm:PBEWITHHMACHAVALANDAES
algorithm:PBEWITHHMACSHA384ANDBLOWFISH
algorithm:PBEWITHHMACMD5ANDTWOFISH
algorithm:PBEWITHHMACTIGERANDDES
algorithm:PBEWITHHMACSHA256ANDTRIPLEDES
algorithm:PBEWITHHMACWHIRLPOOLANDBLOWFISH
algorithm:PBEWITHHMACMD5ANDKHAZAD
algorithm:PBEWITHHMACMD4ANDTRIPLEDES
algorithm:PBEWITHHMACSHA1ANDBLOWFISH
algorithm:PBEWITHHMACTIGERANDKHAZAD
algorithm:PBEWITHHMACSHA512ANDANUBIS
algorithm:PBEWITHHMACHAVALANDDES
algorithm:PBEWITHHMACSHA256ANDANUBIS
algorithm:PBEWITHHMACSHA1ANDDES
algorithm:PBEWITHHMACTIGERANDAES
algorithm:PBEWITHHMACSHA512ANDTWOFISH
algorithm:CAST5
algorithm:PBEWITHHMACMD5ANDBLOWFISH
algorithm:PBEWITHHMACMD5ANDSQUARE
algorithm:PBEWITHHMACMD4ANDAES
algorithm:PBEWITHHMACSHA1ANDCAST5
algorithm:PBEWITHHMACSHA512ANDSQUARE
algorithm:PBEWITHHMACTIGERANDSQUARE
algorithm:PBEWITHHMACSHA256ANDSQUARE
algorithm:PBEWITHHMACMD4ANDCAST5
algorithm:PBEWITHHMACSHA1ANDAES
algorithm:PBEWITHHMACSHA1ANDANUBIS
algorithm:NULL
algorithm:PBEWITHHMACMD5ANDANUBIS
algorithm:PBEWITHHMACSHA1ANDTRIPLEDES
algorithm:PBEWITHHMACMD2ANDTRIPLEDES
algorithm:PBEWITHHMACMD4ANDDES
algorithm:PBEWITHHMACSHA512ANDSERPENT
algorithm:TWOFISH
algorithm:PBEWITHHMACTIGERANDANUBIS
algorithm:PBEWITHHMACSHA512ANDKHAZAD
algorithm:PBEWITHHMACSHA256ANDKHAZAD
algorithm:PBEWITHHMACMD5ANDAES
algorithm:PBEWITHHMACSHA512ANDBLOWFISH
algorithm:PBEWITHHMACSHA1ANDSQUARE
algorithm:PBEWITHHMACMD5ANDSERPENT
algorithm:PBEWITHHMACTIGERANDTRIPLEDES
algorithm:PBEWITHHMACSHA256ANDSERPENT
algorithm:PBEWITHHMACSHA1ANDTWOFISH
algorithm:PBEWITHHMACTIGERANDSERPENT
algorithm:PBEWITHHMACWHIRLPOOLANDAES
algorithm:PBEWITHHMACSHA512ANDAES
algorithm:PBEWITHHMACSHA384ANDAES
algorithm:SERPENT
algorithm:PBEWITHHMACMD5ANDDES
algorithm:PBEWITHHMACHAVALANDANUBIS
algorithm:PBEWITHHMACMD2ANDDES
algorithm:BLOWFISH
algorithm:PBEWITHHMACSHA1ANDKHAZAD
algorithm:PBEWITHHMACMD2ANDBLOWFISH
algorithm:RIJNDAEL
algorithm:PBEWITHHMACMD2ANDSERPENT
algorithm:PBEWITHHMACWHIRLPOOLANDTWOFISH
algorithm:PBEWITHHMACWHIRLPOOLANDTRIPLEDES
algorithm:PBEWITHHMACMD5ANDTRIPLEDES
algorithm:PBEWITHHMACWHIRLPOOLANDDES
algorithm:PBEWITHHMACHAVALANDCAST5
algorithm:PBEWITHHMACSHA512ANDDES
algorithm:PBEWITHHMACSHA384ANDDES
algorithm:PBEWITHHMACHAVALANDSQUARE
algorithm:PBEWITHHMACHAVALANDTRIPLEDES
algorithm:PBEWITHHMACTIGERANDTWOFISH
algorithm:PBEWITHHMACMD2ANDAES
algorithm:PBEWITHHMACMD2ANDKHAZAD
algorithm:PBEWITHHMACSHA512ANDCAST5
algorithm:PBEWITHHMACMD4ANDKHAZAD
algorithm:SQUARE
algorithm:PBEWITHHMACHAVALANDSERPENT
algorithm:PBEWITHHMACMD4ANDSERPENT
keypair generator algorithm count:113
algorithm:PBEWITHHMACHAVALANDKHAZAD
algorithm:PBEWITHHMACTIGERANDCAST5
algorithm:PBEWITHHMACMD5ANDCAST5
algorithm:PBEWITHHMACSHA256ANDCAST5
algorithm:KHAZAD
algorithm:PBEWITHHMACMD4ANDSQUARE
algorithm:PBEWITHHMACWHIRLPOOLANDSQUARE
algorithm:PBEWITHHMACWHIRLPOOLANDKHAZAD
algorithm:PBEWITHHMACSHA384ANDCAST5
algorithm:PBEWITHHMACSHA384ANDSERPENT
algorithm:PBEWITHHMACMD4ANDTWOFISH
algorithm:PBEWITHHMACMD2ANDANUBIS
algorithm:PBEWITHHMACSHA256ANDAES
algorithm:PBEWITHHMACHAVALANDTWOFISH
algorithm:PBEWITHHMACMD4ANDANUBIS
algorithm:PBEWITHHMACTIGERANDBLOWFISH
algorithm:PBEWITHHMACSHA384ANDANUBIS
algorithm:PBEWITHHMACSHA384ANDTWOFISH
algorithm:PBEWITHHMACSHA256ANDDES
algorithm:PBEWITHHMACMD2ANDSQUARE
algorithm:PBEWITHHMACWHIRLPOOLANDCAST5
algorithm:DES
algorithm:PBEWITHHMACSHA384ANDTRIPLEDES
algorithm:PBEWITHHMACWHIRLPOOLANDSERPENT
algorithm:PBEWITHHMACSHA384ANDSQUARE
algorithm:PBEWITHHMACWHIRLPOOLANDANUBIS
algorithm:PBEWITHHMACMD2ANDTWOFISH
algorithm:PBEWITHHMACHAVALANDBLOWFISH
algorithm:PBEWITHHMACMD4ANDBLOWFISH
algorithm:PBEWITHHMACSHA256ANDBLOWFISH
algorithm:AES
algorithm:PBEWITHHMACSHA256ANDTWOFISH
algorithm:PBEWITHHMACSHA512ANDTRIPLEDES
algorithm:TRIPLEDES
algorithm:PBEWITHHMACSHA1ANDSERPENT
algorithm:ARCFOUR
algorithm:PBEWITHHMACSHA384ANDKHAZAD
algorithm:PBEWITHHMACMD2ANDCAST5
algorithm:ANUBIS
algorithm:PBEWITHHMACHAVALANDAES
algorithm:PBEWITHHMACSHA384ANDBLOWFISH
algorithm:PBEWITHHMACMD5ANDTWOFISH
algorithm:PBEWITHHMACTIGERANDDES
algorithm:PBEWITHHMACSHA256ANDTRIPLEDES
algorithm:PBEWITHHMACWHIRLPOOLANDBLOWFISH
algorithm:PBEWITHHMACMD5ANDKHAZAD
algorithm:PBEWITHHMACMD4ANDTRIPLEDES
algorithm:PBEWITHHMACSHA1ANDBLOWFISH
algorithm:PBEWITHHMACTIGERANDKHAZAD
algorithm:PBEWITHHMACSHA512ANDANUBIS
algorithm:PBEWITHHMACHAVALANDDES
algorithm:PBEWITHHMACSHA256ANDANUBIS
algorithm:PBEWITHHMACSHA1ANDDES
algorithm:PBEWITHHMACTIGERANDAES
algorithm:PBEWITHHMACSHA512ANDTWOFISH
algorithm:CAST5
algorithm:PBEWITHHMACMD5ANDBLOWFISH
algorithm:PBEWITHHMACMD5ANDSQUARE
algorithm:PBEWITHHMACMD4ANDAES
algorithm:PBEWITHHMACSHA1ANDCAST5
algorithm:PBEWITHHMACSHA512ANDSQUARE
algorithm:PBEWITHHMACTIGERANDSQUARE
algorithm:PBEWITHHMACSHA256ANDSQUARE
algorithm:PBEWITHHMACMD4ANDCAST5
algorithm:PBEWITHHMACSHA1ANDAES
algorithm:PBEWITHHMACSHA1ANDANUBIS
algorithm:NULL
algorithm:PBEWITHHMACMD5ANDANUBIS
algorithm:PBEWITHHMACSHA1ANDTRIPLEDES
algorithm:PBEWITHHMACMD2ANDTRIPLEDES
algorithm:PBEWITHHMACMD4ANDDES
algorithm:PBEWITHHMACSHA512ANDSERPENT
algorithm:TWOFISH
algorithm:PBEWITHHMACTIGERANDANUBIS
algorithm:PBEWITHHMACSHA512ANDKHAZAD
algorithm:PBEWITHHMACSHA256ANDKHAZAD
algorithm:PBEWITHHMACMD5ANDAES
algorithm:PBEWITHHMACSHA512ANDBLOWFISH
algorithm:PBEWITHHMACSHA1ANDSQUARE
algorithm:PBEWITHHMACMD5ANDSERPENT
algorithm:PBEWITHHMACTIGERANDTRIPLEDES
algorithm:PBEWITHHMACSHA256ANDSERPENT
algorithm:PBEWITHHMACSHA1ANDTWOFISH
algorithm:PBEWITHHMACTIGERANDSERPENT
algorithm:PBEWITHHMACWHIRLPOOLANDAES
algorithm:PBEWITHHMACSHA512ANDAES
algorithm:PBEWITHHMACSHA384ANDAES
algorithm:SERPENT
algorithm:PBEWITHHMACMD5ANDDES
algorithm:PBEWITHHMACHAVALANDANUBIS
algorithm:PBEWITHHMACMD2ANDDES
algorithm:BLOWFISH
algorithm:PBEWITHHMACSHA1ANDKHAZAD
algorithm:PBEWITHHMACMD2ANDBLOWFISH
algorithm:RIJNDAEL
algorithm:PBEWITHHMACMD2ANDSERPENT
algorithm:PBEWITHHMACWHIRLPOOLANDTWOFISH
algorithm:PBEWITHHMACWHIRLPOOLANDTRIPLEDES
algorithm:PBEWITHHMACMD5ANDTRIPLEDES
algorithm:PBEWITHHMACWHIRLPOOLANDDES
algorithm:PBEWITHHMACHAVALANDCAST5
algorithm:PBEWITHHMACSHA512ANDDES
algorithm:PBEWITHHMACSHA384ANDDES
algorithm:PBEWITHHMACHAVALANDSQUARE
algorithm:PBEWITHHMACHAVALANDTRIPLEDES
algorithm:PBEWITHHMACTIGERANDTWOFISH
algorithm:PBEWITHHMACMD2ANDAES
algorithm:PBEWITHHMACMD2ANDKHAZAD
algorithm:PBEWITHHMACSHA512ANDCAST5
algorithm:PBEWITHHMACMD4ANDKHAZAD
algorithm:SQUARE
algorithm:PBEWITHHMACHAVALANDSERPENT
algorithm:PBEWITHHMACMD4ANDSERPENT
message authentication codes algorithm count:15
algorithm:HMAC-SHA160
algorithm:TMMH16
algorithm:HMAC-MD2
algorithm:UMAC32
algorithm:HMAC-MD4
algorithm:HMAC-SHA256
algorithm:UHASH32
algorithm:HMAC-MD5
algorithm:HMAC-RIPEMD160
algorithm:HMAC-RIPEMD128
algorithm:HMAC-WHIRLPOOL
algorithm:HMAC-HAVAL
algorithm:HMAC-SHA512
algorithm:HMAC-TIGER
algorithm:HMAC-SHA384
message digest algorithm count:12
algorithm:SHA-160
algorithm:RIPEMD160
algorithm:RIPEMD128
algorithm:WHIRLPOOL
algorithm:TIGER
algorithm:HAVAL
algorithm:SHA-384
algorithm:SHA-512
algorithm:MD5
algorithm:MD4
algorithm:SHA-256
algorithm:MD2
secure random algorithm count:15
algorithm:SHA-512PRNG
algorithm:HAVALPRNG
algorithm:ICM
algorithm:UMAC-KDF
algorithm:TIGERPRNG
algorithm:SHA-256PRNG
algorithm:SHA-160PRNG
algorithm:ARCFOUR
algorithm:WHIRLPOOLPRNG
algorithm:RIPEMD128PRNG
algorithm:RIPEMD160PRNG
algorithm:MD5PRNG
algorithm:MD4PRNG
algorithm:SHA-384PRNG
algorithm:MD2PRNG
signature algorithm count:2
algorithm:DSS/RAW
algorithm:RSA-PSS/RAW
Exception in thread "main" java.lang.NoSuchMethodError
at gnu.crypto.mode.ModeFactory.getInstance(java.lang.String, gnu.crypto.cipher.IBlockCipher, int) (/usr/local/gnu-crypto/lib/lib-gnu-crypto.so.2.0.0) at gnu.crypto.jce.cipher.CipherAdapter.CipherAdapter(java.lang.String, int) (/usr/local/gnu-crypto/lib/lib-gnu-crypto.so.2.0.0) at gnu.crypto.jce.cipher.RijndaelSpi.RijndaelSpi() (/usr/local/gnu-crypto/lib/lib-gnu-crypto.so.2.0.0)
   at java.lang.Class.newInstance() (/usr/lib/libgcj.so.6.0.0)
at javax.crypto.JCEUtil.getImplementationFromProvider(java.lang.String, java.lang.String, java.security.Provider) (/usr/local/gnu-crypto/lib/lib-javax-crypto.so.1.0.0) at javax.crypto.JCEUtil.getImplementation(java.lang.String, java.lang.String, java.lang.String) (/usr/local/gnu-crypto/lib/lib-javax-crypto.so.1.0.0) at javax.crypto.Cipher.getInstance(java.lang.String) (/usr/local/gnu-crypto/lib/lib-javax-crypto.so.1.0.0)
   at testaes.main(java.lang.String[]) (Unknown Source)
   at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
   at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)


Here is the example associated:
import java.io.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;
import java.util.HashSet;
import java.util.Set;

import gnu.crypto.Registry;
import gnu.crypto.cipher.CipherFactory;
import gnu.crypto.cipher.IBlockCipher;
import gnu.crypto.jce.GnuCrypto;

import java.security.Provider;
import java.security.Security;

import javax.crypto.SecretKey;
import javax.crypto.KeyGenerator;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.Cipher;
import javax.crypto.SealedObject;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.SecretKeySpec;

public class testaes
{
    static class mytestdata implements java.io.Serializable
    {
    String s1;
    int x1;
    int y1;
    int x2;
    int y2;

        mytestdata(String sOne, int xOne, int yOne, int xTwo, int yTwo)
    {
        s1 = new String(sOne);
        x1 = xOne;
        y1 = yOne;
        x2 = xTwo;
        y2 = yTwo;
    }
    }

    public static void main( String args[])
    throws
        Exception
    {
    Provider gnu = java.security.Security.getProvider(Registry.GNU_CRYPTO);
    if (gnu == null)
        {
        java.security.Security.addProvider(
                           new gnu.crypto.jce.GnuCrypto()
                           );
        }

    HashSet names = new HashSet();
    //get rid of older version of provider
    java.security.Security.removeProvider("GNU");
    Provider[] providers = Security.getProviders();
    for(int provCount = 0; provCount < providers.length ; provCount++)
        {
        System.out.println("provider:" + providers[provCount].getName());
        System.out.println("getInfo:" + providers[provCount].getInfo());
System.out.println("getVersion:" + providers[provCount].getVersion());
        }

    IBlockCipher cipher = CipherFactory.getInstance("rijndael");
    int keysize = cipher.defaultKeySize();
    int blocksize = cipher.defaultBlockSize();
    System.out.println("rijndael cipher created...");
    System.out.println("with keysize:" + Integer.toString(keysize));
    System.out.println("with blocksize:" + Integer.toString(blocksize));

    String myKey = "FEDCBA9876543210"; //must be 16 characters long
    byte[] myKeyBytes = myKey.getBytes();

    try
        {
        int iterations = 1;


        String myPlainTextMessage = "0123456789ABCDEF";
        byte[] myPlainTextMessageBytes = myPlainTextMessage.getBytes();

        System.out.println("Running "+iterations+" iterations:");
        System.out.print("Encryption: ");

        HashMap map = new HashMap();
        map.put(IBlockCipher.KEY_MATERIAL, myKeyBytes);
        cipher.init(map);

        byte[] myCryptedText = (byte[]) myPlainTextMessageBytes.clone();
        long elapsed = -System.currentTimeMillis();
        int i;
        for (i = 0; i < iterations; i++)
            {
            cipher.encryptBlock(myCryptedText, 0, myCryptedText, 0);
            }

        elapsed += System.currentTimeMillis();
        float secs = (elapsed > 1) ? (float) elapsed / 1000 : 1;
        float speed = (float) iterations * blocksize / 1024 / secs;

        System.out.println("time = "+secs+", speed = "+speed+" KB/s");
        System.out.print("Decryption: ");

        byte[] myDecryptedTextBytes = (byte[]) myCryptedText.clone();
        elapsed = -System.currentTimeMillis();
        for (i = 0; i < iterations; i++) {
cipher.decryptBlock(myDecryptedTextBytes, 0, myDecryptedTextBytes, 0);
            String myDecryptedText = new String(myDecryptedTextBytes);
System.out.println("decryptedMessage:<<" + myDecryptedText + ">>");
        }

        elapsed += System.currentTimeMillis();
        secs = (elapsed > 1) ? (float) elapsed / 1000 : 1;
        speed = (float) iterations * blocksize / 1024 / secs;

        System.out.println("time = "+secs+", speed = "+speed+" KB/s");

        if (!Arrays.equals(myPlainTextMessageBytes, myDecryptedTextBytes))
            {
            throw new RuntimeException("Symmetric operation failed");
            }
        }
    catch (Exception x)
        {
        x.printStackTrace(System.err);
        }

Object[] myCipherAlgorithmArray = java.security.Security.getAlgorithms("cipher").toArray(); Object[] myKeyPairGeneratorAlgorithmArray = java.security.Security.getAlgorithms("cipher").toArray(); Object[] myMessageAuthenticationCodesAlgorithmArray = java.security.Security.getAlgorithms("mac").toArray(); Object[] myMessageDigestAlgorithmArray = java.security.Security.getAlgorithms("messagedigest").toArray(); Object[] mySecureRandomAlgorithmArray = java.security.Security.getAlgorithms("securerandom").toArray(); Object[] mySignatureAlgorithmArray = java.security.Security.getAlgorithms("signature").toArray();

System.out.println("cipher algorithm count:" + myCipherAlgorithmArray.length);
    dumpAlgorithmNames(myCipherAlgorithmArray);

System.out.println("keypair generator algorithm count:" + myKeyPairGeneratorAlgorithmArray.length);
    dumpAlgorithmNames(myKeyPairGeneratorAlgorithmArray);

System.out.println("message authentication codes algorithm count:" + myMessageAuthenticationCodesAlgorithmArray.length);
    dumpAlgorithmNames(myMessageAuthenticationCodesAlgorithmArray);

System.out.println("message digest algorithm count:" + myMessageDigestAlgorithmArray.length);
    dumpAlgorithmNames(myMessageDigestAlgorithmArray);

System.out.println("secure random algorithm count:" + mySecureRandomAlgorithmArray.length);
    dumpAlgorithmNames(mySecureRandomAlgorithmArray);

System.out.println("signature algorithm count:" + mySignatureAlgorithmArray.length);
    dumpAlgorithmNames(mySignatureAlgorithmArray);

    String symAlgorithm="AES";

//javax.crypto.SecretKeyFactory KeyFac = javax.crypto.SecretKeyFactory.getInstance(symAlgorithm);

     myKey = "FEDCBA9876543210"; //must be 16 characters long
     myKeyBytes = myKey.getBytes();
//javax.crypto.spec.SecretKeySpec desKeySpec = new javax.crypto.spec.SecretKeySpec(myKeyBytes, symAlgorithm);
         //javax.crypto.SecretKey sKey = KeyFac.generateSecret(desKeySpec);

//KeyGenerator kgen = KeyGenerator.getInstance("PBEWITHHMACMD4ANDAES");
     //kgen.init(128);
     ////kgen.init(192);
     ////kgen.init(256);

     //SecretKey skey = kgen.generateKey();
     //byte[] raw = skey.getEncoded();

//SecretKeySpec skeySpec = new SecretKeySpec(myKeyBytes, "PBEWITHHMACMD4ANDAES");

    //instantiate the cipher
    javax.crypto.Cipher jccipher = javax.crypto.Cipher.getInstance("AES");
     //jccipher.init(Cipher.ENCRYPT_MODE, sKey);
     //jccipher.init(Cipher.ENCRYPT_MODE, skeySpec);

//     mytestdata myTest = new mytestdata("test", 1, 2, 3, 4);
//     SealedObject sealedTest = new SealedObject(myTest, cipher);
//     System.out.println("Encrypted:" + sealedTest.toString() );

//     cipher.init(Cipher.DECRYPT_MODE, skeySpec);
// mytestdata myDecryptedResult = (mytestdata)sealedTest.getObject(skeySpec);
//     System.out.println("s1:" + myDecryptedResult.s1);
//     System.out.println("x1:" + myDecryptedResult.x1);
//     System.out.println("y1:" + myDecryptedResult.y1);
//     System.out.println("x2:" + myDecryptedResult.x2);
//     System.out.println("y2:" + myDecryptedResult.y2);

    }

    static public void dumpAlgorithmNames(Object[] tmpArray)
    {
    int algoCount;
    for(algoCount = 0; algoCount < tmpArray.length; algoCount++)
        {
        System.out.println("algorithm:" + ((String)tmpArray[algoCount]) );
        }
    }
}

Here are the steps I used to build the example:
export LD_LIBRARY_PATH=/usr/local/gnu-crypto/lib:/usr/local/gnu-crypto/share:.

#here is what is gnu crypto related
#/usr/local/gnu-crypto/lib/lib-javax-crypto.a
#/usr/local/gnu-crypto/lib/lib-javax-security.a
#/usr/local/gnu-crypto/lib/lib-gnu-crypto.so.2.0.0
#/usr/local/gnu-crypto/lib/lib-gnu-crypto.a

#compile the .java files into native object code(.o)
gcj-4.0 -v --CLASSPATH=".:/usr/local/gnu-crypto/share/javax-crypto.jar:/usr/local/gnu-crypto/share/javax-security.jar:/usr/local/gnu-crypto/share/gnu-crypto.jar" -c -o testaes.o testaes.java -L/usr/local/gnu-crypto/lib -lgnu-crypto -ljavax-crypto -ljavax-security

#assemble them all into the main executable called testaes in this case.
gcj-4.0 -v --CLASSPATH=".:/usr/local/gnu-crypto/share/javax-crypto.jar:/usr/local/gnu-crypto/share/javax-security.jar:/usr/local/gnu-crypto/share/gnu-crypto.jar" --main=testaes -o testaes testaes.o -L/usr/local/gnu-crypto/lib -l-gnu-crypto -l-javax-crypto -l-javax-security





reply via email to

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