|
|
Problems using crypto library
Hi to all,
I have checked out the following code from the Sun site:
import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
public class SecurityTest {
public static void main(String[] args) throws Exception {
String name = "HmacMD5";
// Generate secret key for HMAC-MD5
SecretKey sk = null;
KeyGenerator kg = KeyGenerator.getInstance(name);
sk = kg.generateKey();
// Get instance of Mac object implementing HMAC-MD5, and
// initialize it with the above secret key
Mac mac = Mac.getInstance(name);
mac.init(sk);
byte[] result = mac.doFinal("Hi There".getBytes());
}
}
It works fine using java 1.4.2.
Updating to 1.5.0_03 I get the following Exception:
Exception in thread "main" java.security.NoSuchAlgorithmException: HmacMD5
KeyGenerator not available
at javax.crypto.KeyGenerator.<init>(Dash0A12275)
at javax.crypto.KeyGenerator.getInstance(DashoA12275)
at SecurityTest.main(SecurityTest.java:10)
What I am doing wrong
Thanks in advance
Uwe
|
|
0
|
|
|
|
Reply
|
Uwe
|
5/25/2005 7:11:28 AM |
|
Have you installed and registered the JCE provider?
Bye
Giovanni
Uwe Peuker wrote:
> Hi to all,
>
> I have checked out the following code from the Sun site:
>
> import javax.crypto.KeyGenerator;
> import javax.crypto.Mac;
> import javax.crypto.SecretKey;
>
> public class SecurityTest {
> public static void main(String[] args) throws Exception {
> String name = "HmacMD5";
> // Generate secret key for HMAC-MD5
> SecretKey sk = null;
> KeyGenerator kg = KeyGenerator.getInstance(name);
> sk = kg.generateKey();
> // Get instance of Mac object implementing HMAC-MD5, and
> // initialize it with the above secret key
> Mac mac = Mac.getInstance(name);
> mac.init(sk);
> byte[] result = mac.doFinal("Hi There".getBytes());
> }
> }
>
> It works fine using java 1.4.2.
>
> Updating to 1.5.0_03 I get the following Exception:
> Exception in thread "main" java.security.NoSuchAlgorithmException: HmacMD5
> KeyGenerator not available
> at javax.crypto.KeyGenerator.<init>(Dash0A12275)
> at javax.crypto.KeyGenerator.getInstance(DashoA12275)
> at SecurityTest.main(SecurityTest.java:10)
>
> What I am doing wrong
>
> Thanks in advance
>
> Uwe
|
|
0
|
|
|
|
Reply
|
marossi51
|
5/26/2005 9:57:06 AM
|
|
I havn't done this on any installation. In my opinion it will be done using
the default installation procedure for java.
In subdirectory "security" file "java.security" I found the items:
security.provider.1=sun.security.provider.Sun
security.provider.2=sun.security.rsa.SunRsaSign
security.provider.3=com.sun.net.ssl.internal.sslProvider
security.provider.4=com.sun.crypto.provider.SunJCE
security.provider.5=sun.security.jgss.SunProvider
security.provider.6=com.sun.security.sasl.Provider
In subdirectory "ext" I have at least the File:
sunjce_provider.jar
What else is to do ?
Thanks
Uwe
<marossi51@infinito.it> schrieb im Newsbeitrag
news:1117101425.998891.77450@g44g2000cwa.googlegroups.com...
> Have you installed and registered the JCE provider?
>
> Bye
> Giovanni
>
>
> Uwe Peuker wrote:
>> Hi to all,
>>
>> I have checked out the following code from the Sun site:
>>
>> import javax.crypto.KeyGenerator;
>> import javax.crypto.Mac;
>> import javax.crypto.SecretKey;
>>
>> public class SecurityTest {
>> public static void main(String[] args) throws Exception {
>> String name = "HmacMD5";
>> // Generate secret key for HMAC-MD5
>> SecretKey sk = null;
>> KeyGenerator kg = KeyGenerator.getInstance(name);
>> sk = kg.generateKey();
>> // Get instance of Mac object implementing HMAC-MD5, and
>> // initialize it with the above secret key
>> Mac mac = Mac.getInstance(name);
>> mac.init(sk);
>> byte[] result = mac.doFinal("Hi There".getBytes());
>> }
>> }
>>
>> It works fine using java 1.4.2.
>>
>> Updating to 1.5.0_03 I get the following Exception:
>> Exception in thread "main" java.security.NoSuchAlgorithmException:
>> HmacMD5
>> KeyGenerator not available
>> at javax.crypto.KeyGenerator.<init>(Dash0A12275)
>> at javax.crypto.KeyGenerator.getInstance(DashoA12275)
>> at SecurityTest.main(SecurityTest.java:10)
>>
>> What I am doing wrong
>>
>> Thanks in advance
>>
>> Uwe
>
|
|
0
|
|
|
|
Reply
|
Uwe
|
5/26/2005 10:20:12 AM
|
|
I did a standard install of jdk 1.5.0_03 and I can run your example
without any problem.
I'm sorry but I don't know what's wrong.
Bye
Giovanni
Uwe Peuker wrote:
> I havn't done this on any installation. In my opinion it will be done using
> the default installation procedure for java.
>
> In subdirectory "security" file "java.security" I found the items:
>
> security.provider.1=sun.security.provider.Sun
> security.provider.2=sun.security.rsa.SunRsaSign
> security.provider.3=com.sun.net.ssl.internal.sslProvider
> security.provider.4=com.sun.crypto.provider.SunJCE
> security.provider.5=sun.security.jgss.SunProvider
> security.provider.6=com.sun.security.sasl.Provider
>
> In subdirectory "ext" I have at least the File:
> sunjce_provider.jar
>
> What else is to do ?
>
> Thanks
> Uwe
>
> <marossi51@infinito.it> schrieb im Newsbeitrag
> news:1117101425.998891.77450@g44g2000cwa.googlegroups.com...
> > Have you installed and registered the JCE provider?
> >
> > Bye
> > Giovanni
> >
> >
> > Uwe Peuker wrote:
> >> Hi to all,
> >>
> >> I have checked out the following code from the Sun site:
> >>
> >> import javax.crypto.KeyGenerator;
> >> import javax.crypto.Mac;
> >> import javax.crypto.SecretKey;
> >>
> >> public class SecurityTest {
> >> public static void main(String[] args) throws Exception {
> >> String name = "HmacMD5";
> >> // Generate secret key for HMAC-MD5
> >> SecretKey sk = null;
> >> KeyGenerator kg = KeyGenerator.getInstance(name);
> >> sk = kg.generateKey();
> >> // Get instance of Mac object implementing HMAC-MD5, and
> >> // initialize it with the above secret key
> >> Mac mac = Mac.getInstance(name);
> >> mac.init(sk);
> >> byte[] result = mac.doFinal("Hi There".getBytes());
> >> }
> >> }
> >>
> >> It works fine using java 1.4.2.
> >>
> >> Updating to 1.5.0_03 I get the following Exception:
> >> Exception in thread "main" java.security.NoSuchAlgorithmException:
> >> HmacMD5
> >> KeyGenerator not available
> >> at javax.crypto.KeyGenerator.<init>(Dash0A12275)
> >> at javax.crypto.KeyGenerator.getInstance(DashoA12275)
> >> at SecurityTest.main(SecurityTest.java:10)
> >>
> >> What I am doing wrong
> >>
> >> Thanks in advance
> >>
> >> Uwe
> >
|
|
0
|
|
|
|
Reply
|
Gio
|
5/26/2005 3:04:11 PM
|
|
The problem seems to be disappeared. I thing it has been a bug in the
milestones of the Eclipse IDE 3.1. Using the the RC1 of Eclipse 3.1 I can't
verify the behaviour.
Thanks
Uwe
"Gio" <marossi51@infinito.it> schrieb im Newsbeitrag
news:1117119851.469721.70460@o13g2000cwo.googlegroups.com...
>I did a standard install of jdk 1.5.0_03 and I can run your example
> without any problem.
> I'm sorry but I don't know what's wrong.
>
> Bye
> Giovanni
>
>
> Uwe Peuker wrote:
>> I havn't done this on any installation. In my opinion it will be done
>> using
>> the default installation procedure for java.
>>
>> In subdirectory "security" file "java.security" I found the items:
>>
>> security.provider.1=sun.security.provider.Sun
>> security.provider.2=sun.security.rsa.SunRsaSign
>> security.provider.3=com.sun.net.ssl.internal.sslProvider
>> security.provider.4=com.sun.crypto.provider.SunJCE
>> security.provider.5=sun.security.jgss.SunProvider
>> security.provider.6=com.sun.security.sasl.Provider
>>
>> In subdirectory "ext" I have at least the File:
>> sunjce_provider.jar
>>
>> What else is to do ?
>>
>> Thanks
>> Uwe
>>
>> <marossi51@infinito.it> schrieb im Newsbeitrag
>> news:1117101425.998891.77450@g44g2000cwa.googlegroups.com...
>> > Have you installed and registered the JCE provider?
>> >
>> > Bye
>> > Giovanni
>> >
>> >
>> > Uwe Peuker wrote:
>> >> Hi to all,
>> >>
>> >> I have checked out the following code from the Sun site:
>> >>
>> >> import javax.crypto.KeyGenerator;
>> >> import javax.crypto.Mac;
>> >> import javax.crypto.SecretKey;
>> >>
>> >> public class SecurityTest {
>> >> public static void main(String[] args) throws Exception {
>> >> String name = "HmacMD5";
>> >> // Generate secret key for HMAC-MD5
>> >> SecretKey sk = null;
>> >> KeyGenerator kg = KeyGenerator.getInstance(name);
>> >> sk = kg.generateKey();
>> >> // Get instance of Mac object implementing HMAC-MD5, and
>> >> // initialize it with the above secret key
>> >> Mac mac = Mac.getInstance(name);
>> >> mac.init(sk);
>> >> byte[] result = mac.doFinal("Hi There".getBytes());
>> >> }
>> >> }
>> >>
>> >> It works fine using java 1.4.2.
>> >>
>> >> Updating to 1.5.0_03 I get the following Exception:
>> >> Exception in thread "main" java.security.NoSuchAlgorithmException:
>> >> HmacMD5
>> >> KeyGenerator not available
>> >> at javax.crypto.KeyGenerator.<init>(Dash0A12275)
>> >> at javax.crypto.KeyGenerator.getInstance(DashoA12275)
>> >> at SecurityTest.main(SecurityTest.java:10)
>> >>
>> >> What I am doing wrong
>> >>
>> >> Thanks in advance
>> >>
>> >> Uwe
>> >
>
|
|
0
|
|
|
|
Reply
|
Uwe
|
5/30/2005 6:00:12 AM
|
|
On 30-5-2005 8:00, Uwe Peuker wrote:
> The problem seems to be disappeared. I thing it has been a bug in the
> milestones of the Eclipse IDE 3.1. Using the the RC1 of Eclipse 3.1 I can't
> verify the behaviour.
>
> Thanks
> Uwe
>
> "Gio" <marossi51@infinito.it> schrieb im Newsbeitrag
> news:1117119851.469721.70460@o13g2000cwo.googlegroups.com...
>
>>I did a standard install of jdk 1.5.0_03 and I can run your example
>>without any problem.
>>I'm sorry but I don't know what's wrong.
>>
>>Bye
>> Giovanni
>>
>>
>>Uwe Peuker wrote:
>>
>>>I havn't done this on any installation. In my opinion it will be done
>>>using
>>>the default installation procedure for java.
>>>
>>>In subdirectory "security" file "java.security" I found the items:
>>>
>>>security.provider.1=sun.security.provider.Sun
>>>security.provider.2=sun.security.rsa.SunRsaSign
>>>security.provider.3=com.sun.net.ssl.internal.sslProvider
>>>security.provider.4=com.sun.crypto.provider.SunJCE
>>>security.provider.5=sun.security.jgss.SunProvider
>>>security.provider.6=com.sun.security.sasl.Provider
>>>
>>>In subdirectory "ext" I have at least the File:
>>>sunjce_provider.jar
>>>
>>>What else is to do ?
>>>
>>>Thanks
>>>Uwe
>>>
>>><marossi51@infinito.it> schrieb im Newsbeitrag
>>>news:1117101425.998891.77450@g44g2000cwa.googlegroups.com...
>>>
>>>>Have you installed and registered the JCE provider?
>>>>
>>>>Bye
>>>> Giovanni
>>>>
>>>>
>>>>Uwe Peuker wrote:
>>>>
>>>>>Hi to all,
>>>>>
>>>>>I have checked out the following code from the Sun site:
>>>>>
>>>>>import javax.crypto.KeyGenerator;
>>>>>import javax.crypto.Mac;
>>>>>import javax.crypto.SecretKey;
>>>>>
>>>>>public class SecurityTest {
>>>>> public static void main(String[] args) throws Exception {
>>>>> String name = "HmacMD5";
>>>>> // Generate secret key for HMAC-MD5
>>>>> SecretKey sk = null;
>>>>> KeyGenerator kg = KeyGenerator.getInstance(name);
>>>>> sk = kg.generateKey();
>>>>> // Get instance of Mac object implementing HMAC-MD5, and
>>>>> // initialize it with the above secret key
>>>>> Mac mac = Mac.getInstance(name);
>>>>> mac.init(sk);
>>>>> byte[] result = mac.doFinal("Hi There".getBytes());
>>>>> }
>>>>>}
>>>>>
>>>>>It works fine using java 1.4.2.
>>>>>
>>>>>Updating to 1.5.0_03 I get the following Exception:
>>>>>Exception in thread "main" java.security.NoSuchAlgorithmException:
>>>>>HmacMD5
>>>>>KeyGenerator not available
>>>>>at javax.crypto.KeyGenerator.<init>(Dash0A12275)
>>>>>at javax.crypto.KeyGenerator.getInstance(DashoA12275)
>>>>>at SecurityTest.main(SecurityTest.java:10)
>>>>>
>>>>>What I am doing wrong
>>>>>
>>>>>Thanks in advance
>>>>>
>>>>>Uwe
>>>>
>
>
It's probably caused by the way how/when Eclipse passes the
-Xbootclasspath parameter to the java executable that's being launched.
Don't know for 3.1RC1, but for older releases it depends on the setting
"Use system default libraries" in the JRE configuration (Window ->
Preferences -> Java -> Installed JREs -> (select JRE) -> Edit)
When "Use system default libraries" is unchecked (off), Eclipse adds the
-Xbootclasspath parameter --with all the libs in the list-- to the java
executable. If the list doesn't include the crypto libraries, it results
in the NoSuchAlgorithmException.
Otherwise, when "Use system default libraries" is checked, Eclipse
doesn't add -Xbootclasspath, so it allows the java executable to
discover its own boot classpath including the crypto libraries.
--
Regards,
Roland de Ruiter
___ ___
/__/ w_/ /__/
/ \ /_/ / \
|
|
0
|
|
|
|
Reply
|
Roland
|
5/30/2005 12:03:40 PM
|
|
Great, that was the problem. Checking the parameter the problem disappears
in older eclipse versions too.
Thanks
Uwe
"Roland" <roland@phony.biz> schrieb im Newsbeitrag
news:429b0100$0$158$e4fe514c@news.xs4all.nl...
> On 30-5-2005 8:00, Uwe Peuker wrote:
>
> It's probably caused by the way how/when Eclipse passes
> the -Xbootclasspath parameter to the java executable that's being
> launched.
>
> Don't know for 3.1RC1, but for older releases it depends on the setting
> "Use system default libraries" in the JRE configuration (Window ->
> Preferences -> Java -> Installed JREs -> (select JRE) -> Edit)
>
> When "Use system default libraries" is unchecked (off), Eclipse adds
> the -Xbootclasspath parameter --with all the libs in the list-- to the
> java executable. If the list doesn't include the crypto libraries, it
> results in the NoSuchAlgorithmException.
> Otherwise, when "Use system default libraries" is checked, Eclipse doesn't
> add -Xbootclasspath, so it allows the java executable to discover its own
> boot classpath including the crypto libraries.
> --
> Regards,
>
> Roland de Ruiter
> ___ ___
> /__/ w_/ /__/
> / \ /_/ / \
|
|
0
|
|
|
|
Reply
|
Uwe
|
5/31/2005 6:41:08 AM
|
|
|
6 Replies
205 Views
(page loaded in 0.139 seconds)
|
|
|
|
|
|
|
|
|