Cipher.unwrap

G

Gary

I am trying to find a way to use the wrap/unwrap methods in
javax.crypto

I can wrap a key without any trouble, but I cannot unwrap a key
afterwards. The Cipher object must be initialized beforehand with a
key object, which I don't have because I have to unwrap it first.

I tried using a SecretKeySpec in placec as in:

SecretKeySpec skeySpec = new SecretKeySpec( rawBytes, "AES");
Cipher cipher = Cipher.getInstance( "AES");
cipher.init( Cipher.UNWRAP_MODE, skeySpec);

but it gives me an Exception line:
java.lang.SecurityException: Unsupported keysize or algorithm
parameters

I believe the key size is right, so I guess it must be the algorithm
parameters. Am I close here?

I know I can serialize the key in order to save it to disk, but I
wanted to see if it is possible to use the wrapping mechanism, first.

I have seen that there is a bug report on the Java website, but I
can't tell if that is a bug in the implementaion, or the
documentation. Also, I can't find anywhere if or when they plan on
fixing the bug.

Has anyone heard of this, and have you found a direct solution?

Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top