Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Issue while converting byte[] to Key

843811Mar 25 2009 — edited Apr 9 2009
Hi there,

In our application ,we are successfully able to decrypt an encrypted byte[].
But while trying to convert a byte[] into a Key object we are getting the following exception:


java.security.NoSuchAlgorithmException: no such algorithm: AES for provider BC
at sun.security.jca.GetInstance.getService(GetInstance.java:86)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:206)
at java.security.KeyFactory.getInstance(KeyFactory.java:190)
at com.cisco.magellan.common.PvtKeyProviderImpl.decryptKey(PvtKeyProviderImpl.java:96)
at com.cisco.magellan.common.TestSecurity.main(TestSecurity.java:57)
java.lang.NullPointerException
at com.cisco.magellan.common.TestSecurity.main(TestSecurity.java:58)

The part of code giving exception is as below:

PublicKey key = null;
AESKeySpec keyspec;
try {

keyspec = new AESKeySpec(decryptedKeyBytes);
KeyFactory keyfactory = KeyFactory.getInstance("AES","BC");
key = keyfactory.generatePublic(keyspec);
}

decryptedKeyBytes is the decryted byte[].
"AES" is the algorithm we are using.

Do we need to set the java.security file under JAVA_HOME/jre/lib/security?

Any pointers in this regard are highly appreciated.

Thanks and Regards,
Partha.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 7 2009
Added on Mar 25 2009
2 comments
268 views