|
List Info
Thread: About Wrap Key
|
|
| About Wrap Key |
  China |
2007-09-26 07:06:06 |
|
|
Hi,
I
found a problem as follows
Key
toBeWrappedKey = Generator("DESede",
168);
Key wrapKey = Generator("DESede", 112);
Cipher cipher =
Cipher.getInstance("DESede/CBC/ISO10126Padding");
cipher.init(Cipher.WRAP_MODE,
wrapKey); byte[] wrappedKey =
cipher.wrap(toBeWrappedKey);
System.out.println(new String(wrappedKey)); // result 1
XMLCipher xcipher =
XMLCipher.getInstance(XMLCipher.TRIPLEDES);
xcipher.init(XMLCipher.WRAP_MODE,
wrapKey); EncryptedKey ek =
xcipher.encryptKey(getEncryptedData(),
toBeWrappedKey); byte[]
wrappedKey2 =
Base64.decode(ek.getCipherData().getCipherValue().getValue().getBytes());
System.out.println(new String(wrappedKey2)); // result
2
Why
the 2 results are different ?
Thanks
|
| Re: About Wrap Key |
  United States |
2007-09-27 00:55:41 |
|
When using TripleDES the resulting cipher text is prefixed by an
Initialization Vector (IV) which is probably different for the two
different wrap operations. Did you try and unwrap/decrypt the wrapped
key in the two cases and see if that results back in the same key?
Vishal
on 09/26/2007 5:36 PM Rio wrote:
RioPC" type="cite">
Hi,
I found a problem as
follows
Key toBeWrappedKey =
Generator("DESede", 168);
Key wrapKey = Generator("DESede", 112);
Cipher cipher =
Cipher.getInstance("DESede/CBC/ISO10126Padding");
cipher.init(Cipher.WRAP_MODE, wrapKey);
byte[] wrappedKey = cipher.wrap(toBeWrappedKey);
System.out.println(new String(wrappedKey)); // result 1
XMLCipher xcipher =
XMLCipher.getInstance(XMLCipher.TRIPLEDES);
xcipher.init(XMLCipher.WRAP_MODE, wrapKey);
EncryptedKey ek = xcipher.encryptKey(getEncryptedData(),
toBeWrappedKey);
byte[] wrappedKey2 =
Base64.decode(ek.getCipherData().getCipherValue().getValue().getBytes());
System.out.println(new String(wrappedKey2)); // result 2
Why the 2 results are
different ?
Thanks
|
| Re: About Wrap Key |
  China |
2007-09-27 00:59:03 |
|
|
Hi
yes, I didn't use
the IV for my test case
----- Original Message -----
Sent: Thursday, September 27, 2007 1:55
PM
Subject: Re: About Wrap Key
When using TripleDES the resulting cipher text is prefixed by
an Initialization Vector (IV) which is probably different for the two
different wrap operations. Did you try and unwrap/decrypt the wrapped key in
the two cases and see if that results back in the same
key?
Vishal
on 09/26/2007 5:36 PM Rio wrote:
RioPC type="cite">
Hi,
I
found a problem as follows
Key toBeWrappedKey = Generator("DESede",
168);
Key wrapKey = Generator("DESede", 112);
Cipher cipher =
Cipher.getInstance("DESede/CBC/ISO10126Padding");
cipher.init(Cipher.WRAP_MODE,
wrapKey); byte[] wrappedKey =
cipher.wrap(toBeWrappedKey);
System.out.println(new String(wrappedKey)); // result 1
XMLCipher xcipher =
XMLCipher.getInstance(XMLCipher.TRIPLEDES);
xcipher.init(XMLCipher.WRAP_MODE,
wrapKey); EncryptedKey ek =
xcipher.encryptKey(getEncryptedData(),
toBeWrappedKey); byte[]
wrappedKey2 =
Base64.decode(ek.getCipherData().getCipherValue().getValue().getBytes());
System.out.println(new String(wrappedKey2)); // result
2
Why the 2 results are different ?
Thanks
|
| Re: About Wrap Key |
  China |
2007-09-27 01:41:07 |
|
|
I
have another question , that is when I get the CipherValue of wrappedKey ,
I use org.apache.util.BASE64 to decode it to bytes , then
Cipher.unwrap(wrappedKey, Alg, Cipher.SECRET) ,it throw a InvalidKeyException .
When I use other BASE64 implementation to do that , the exception didn't
appear.
thanks
Rio
----- Original Message -----
Sent: Thursday, September 27, 2007 1:59
PM
Subject: Re: About Wrap Key
Hi
yes, I didn't use
the IV for my test case
----- Original Message -----
Sent: Thursday, September 27, 2007 1:55
PM
Subject: Re: About Wrap Key
When using TripleDES the resulting cipher text is prefixed by
an Initialization Vector (IV) which is probably different for the two
different wrap operations. Did you try and unwrap/decrypt the wrapped key in
the two cases and see if that results back in the same
key?
Vishal
on 09/26/2007 5:36 PM Rio wrote:
RioPC type="cite">
Hi,
I found a problem as follows
Key toBeWrappedKey = Generator("DESede",
168);
Key wrapKey = Generator("DESede", 112);
Cipher cipher =
Cipher.getInstance("DESede/CBC/ISO10126Padding");
cipher.init(Cipher.WRAP_MODE,
wrapKey); byte[] wrappedKey
=
cipher.wrap(toBeWrappedKey);
System.out.println(new String(wrappedKey)); // result 1
XMLCipher xcipher =
XMLCipher.getInstance(XMLCipher.TRIPLEDES);
xcipher.init(XMLCipher.WRAP_MODE,
wrapKey); EncryptedKey ek =
xcipher.encryptKey(getEncryptedData(),
toBeWrappedKey); byte[]
wrappedKey2 =
Base64.decode(ek.getCipherData().getCipherValue().getValue().getBytes());
System.out.println(new String(wrappedKey2)); // result
2
Why the 2 results are different ?
Thanks
|
[1-4]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|