Hi, i have a doubt, i'm not able to resolve about crypto key generation:
when i genererate a 3des key in this way:
SecretKey key1 = new SecretKeySpec("key24Byte".getBytes("UTF-8"), "DESede");
and this other:
DESedeKeySpec keySpec = new DESedeKeySpec(("key24Byte".getBytes("UTF-8"));
SecretKeyFactory skf = SecretKeyFactory.getInstance("DESede");
SecretKey key2 = skf.generateSecret(keySpec);
and perform:
System.out.println(base64(key1.getEncoded()));
System.out.println(base64(key2.getEncoded()));
i can see 2 different strings?
thanks!
Michael Amling - 19 Dec 2003 01:23 GMT
> Hi, i have a doubt, i'm not able to resolve about crypto key generation:
> when i genererate a 3des key in this way:
[quoted text clipped - 12 lines]
>
> i can see 2 different strings?
Are you asking why two randomly selected keys would be different?
--Mike Amling
climber666[X]libero[.]it - 19 Dec 2003 08:38 GMT
> > Hi, i have a doubt, i'm not able to resolve about crypto key generation:
> > when i genererate a 3des key in this way:
[quoted text clipped - 14 lines]
>
> Are you asking why two randomly selected keys would be different?
the initial key string is the same, but key1 and key2 are different, why?
Thanks.
Michael Amling - 20 Dec 2003 03:13 GMT
>>>Hi, i have a doubt, i'm not able to resolve about crypto key generation:
>>>when i genererate a 3des key in this way:
[quoted text clipped - 16 lines]
>
> the initial key string is the same, but key1 and key2 are different, why?
It would be easier if you dumped the results out in hex. For
instance, do they both start with 6B657932 34427974 65? Are the parity
bits treated differently?
--Mike Amling
Karl Scheibelhofer - 22 Dec 2003 13:54 GMT
your key will have the wrong size anyway. a triple DES key has to be 16 byte
or 24 byte (112 or 168 bit effectively). the SecretKeySpec class does not
check this. i am rather surprised that the DESedeKeySpec constructor did not
throw an exception because of the too short size.
note that 16 byte (112 bit effectively) key are not supported by all
implementations.
Karl
--
Karl Scheibelhofer, IAIK - Graz University of Technology
Inffeldgasse 16a, 8010 Graz, Austria
Fax: +43 316 873 5520
http://jce.iaik.tugraz.at/
> Hi, i have a doubt, i'm not able to resolve about crypto key generation:
> when i genererate a 3des key in this way:
[quoted text clipped - 13 lines]
> i can see 2 different strings?
> thanks!