Raif S. Naffah wrote: > hello tabun, > > On Thursday 26 January 2006 16:59, tabun@xxxxxxxx wrote: > >>Hi there, >> >>I'm attempting to use a SealedObject with gcj.... > > > please post a minimal code that causes the exception to occur. > > > TIA + cheers; > rsn Ok, I recoded it into two different functions, 1)with only GNU Classpath which seems to be the default provider, try to instantiate an instance of KeyGenerator using the AES algorithm I named this service testGnuClasspath() 2)with the GNU Crypto also as a provider, try to instantiate an instance of KeyGenerator using the AES algorithm I named this service testGnuCrypto() As it runs, I made it display a bit of provider info and available algorithms. Both give exceptions when trying to instantiate an symmetric AES KeyGenerator.(jdk conformant class) I also need KeySpec, and SealedObject, but can't use them until I get KeyGenerator to return me valid Secretkey object. I could bypass this entire infrastructure with just the ICipher and create my own classes and Serialize them but I am wanting to conform by using already existing jdk classes that already do use SealedObject with the AES algorithm. Here is my output: export LD_LIBRARY_PATH=/usr/local/gnu-crypto/lib:/usr/local/gnu-crypto/share:.;./testaes2 Testing Gnu Classpath... Number of providers:1 provider:GNU getInfo:GNU provider v1.0 implementing SHA-1, MD5, DSA, RSA, X.509 Certificates and CRLs, PKIX certificate path validators, Collection cert stores getVersion:1.0 cipher algorithm count:0 keypair generator algorithm count:0 message authentication codes algorithm count:0 message digest algorithm count:2 algorithm:MD5 algorithm:SHA secure random algorithm count:1 algorithm:SHA1PRNG signature algorithm count:5 algorithm:MD2WITHRSA algorithm:SHA1WITHDSA algorithm:MD5WITHRSA algorithm:SHA1WITHRSA algorithm:MD4WITHRSA java.security.NoSuchAlgorithmException: AES not found at javax.crypto.KeyGenerator.getInstance(java.lang.String) (/usr/local/gnu-crypto/lib/lib-javax-crypto.so.1.0.0) at testaes2.testGnuClasspath() (Unknown Source) at testaes2.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) Testing Gnu Crypto... Number of providers:2 provider:GNU getInfo:GNU provider v1.0 implementing SHA-1, MD5, DSA, RSA, X.509 Certificates and CRLs, PKIX certificate path validators, Collection cert stores getVersion:1.0 provider:GNU-CRYPTO getInfo:GNU Crypto JCE Provider getVersion:2.0 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:13 algorithm:SHA 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:16 algorithm:SHA-512PRNG algorithm:HAVALPRNG algorithm:ICM algorithm:UMAC-KDF algorithm:TIGERPRNG algorithm:SHA-256PRNG algorithm:SHA-160PRNG algorithm:WHIRLPOOLPRNG algorithm:ARCFOUR algorithm:RIPEMD128PRNG algorithm:RIPEMD160PRNG algorithm:SHA1PRNG algorithm:MD5PRNG algorithm:MD4PRNG algorithm:SHA-384PRNG algorithm:MD2PRNG signature algorithm count:7 algorithm:DSS/RAW algorithm:MD2WITHRSA algorithm:SHA1WITHDSA algorithm:RSA-PSS/RAW algorithm:MD5WITHRSA algorithm:SHA1WITHRSA algorithm:MD4WITHRSA java.security.NoSuchAlgorithmException: AES not found at javax.crypto.KeyGenerator.getInstance(java.lang.String) (/usr/local/gnu-crypto/lib/lib-javax-crypto.so.1.0.0) at testaes2.testGnuCrypto() (Unknown Source) at testaes2.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 how I build testaes2.java: export LD_LIBRARY_PATH=/usr/local/gnu-crypto/lib:/usr/local/gnu-crypto/share:. #compile the .java files into native code 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 testaes2.o testaes2.java -L/usr/local/gnu-crypto/lib -lgnu-crypto -ljavax-crypto -ljavax-security #assemble them all into the main executable called Calc 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=testaes2 -o testaes2 testaes2.o -L/usr/local/gnu-crypto/lib -l-gnu-crypto -l-javax-crypto -l-javax-security Here is testaes2.java: 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 testaes2 { 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; } } //Main Driver public static void main( String args[]) throws Exception { try { testGnuClasspath(); } catch(Exception E) { E.printStackTrace(); } System.out.println(""); try { testGnuCrypto(); } catch(Exception E) { E.printStackTrace(); } } static public void testGnuClasspath() throws Exception { System.out.println("Testing Gnu Classpath..."); dumpAlgorithmsAvailable(); String myKey = "FEDCBA9876543210"; //must be 16 characters long byte[] myKeyBytes = myKey.getBytes(); String myPlainTextMessage = "0123456789ABCDEF"; byte[] myPlainTextMessageBytes = myPlainTextMessage.getBytes(); byte[] myCryptedTextBytes = (byte[]) myPlainTextMessageBytes.clone(); byte[] myDecryptedTextBytes = (byte[]) myCryptedTextBytes.clone(); KeyGenerator kgen = KeyGenerator.getInstance("AES"); kgen.init(128); ////kgen.init(192); ////kgen.init(256); SecretKey skey = kgen.generateKey(); byte[] raw = skey.getEncoded(); SecretKeySpec skeySpec = new SecretKeySpec(myKeyBytes, "AES"); //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); } public static void testGnuCrypto() throws Exception { System.out.println("Testing Gnu Crypto..."); //java.security.Security.removeProvider("GNU"); //java.security.Security.removeProvider("GNU-CRYPTO"); //Add the Gnu Crypto provider Provider gnu = java.security.Security.getProvider(Registry.GNU_CRYPTO); if (gnu == null) { java.security.Security.addProvider( new gnu.crypto.jce.GnuCrypto() ); } dumpAlgorithmsAvailable(); String myKey = "FEDCBA9876543210"; //must be 16 characters long byte[] myKeyBytes = myKey.getBytes(); String myPlainTextMessage = "0123456789ABCDEF"; byte[] myPlainTextMessageBytes = myPlainTextMessage.getBytes(); byte[] myCryptedTextBytes = (byte[]) myPlainTextMessageBytes.clone(); byte[] myDecryptedTextBytes = (byte[]) myCryptedTextBytes.clone(); KeyGenerator kgen = KeyGenerator.getInstance("AES"); kgen.init(128); ////kgen.init(192); ////kgen.init(256); SecretKey skey = kgen.generateKey(); byte[] raw = skey.getEncoded(); SecretKeySpec skeySpec = new SecretKeySpec(myKeyBytes, "AES"); //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); } public static void dumpAlgorithmsAvailable() throws Exception { Provider[] providers = Security.getProviders(); System.out.println("Number of providers:" + providers.length); 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()); } 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); } static public void dumpAlgorithmNames(Object[] tmpArray) { int algoCount; for(algoCount = 0; algoCount < tmpArray.length; algoCount++) { System.out.println("algorithm:" + ((String)tmpArray[algoCount]) ); } System.out.println(""); } }