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
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