1

When I use keytool to generate a key with ECC, I get this error:

Error keytool: java.security.NoSuchAlgorithmException: EC KeyPairGenerator not available

Then syntax used to generate a key is:

keytool -genkey -alias testing -keyalg EC -keysize 256 -keystore try.jks -dname "CN=localhost,OU=dep,O=lks,L=ny,ST=ny,C=USA"

I have this Java version:

openjdk version "1.8.0_60"
OpenJDK Runtime Environment (build 1.8.0_60-b16)                            
OpenJDK 64-Bit Server VM (build 25.60-b16, mixed mode)

3 Answers 3

3

I had the same error with pepk (Play Encrypt Private Key) on Ubuntu 16.04.

I solved this with a solution close to CipherX's answer:

  1. Download Java Oracle (tar.gz)
  2. Extract the files
  3. Instead of launching java installed on the sytem, launch java from the extracted files:
~/Downloads/android/jdk-9.0.1/bin/java -jar pepk.jar --keystore=acme.keystore \
--alias=acme --output=encrypted_private_key_path --encryptionkey=eb…

And the Error: EC KeyPairGenerator not available error disappeared.

1
  • This is the only google result when searching for "pepk" and the error message. You might move it to its own question and answer it yourself.
    – ki9
    Jan 30, 2018 at 17:51
2

This error indicates that your EC security provider is missing, please do the following to add it:

  • Edit the file "jdk1.8.0_65\lib\security\java.security"
  • Search for "List of providers and their preference order"
  • Add "security.provider.[Last security provider id +1]=sun.security.ec.SunEC" to the list of security providers.

see this link for more details about the sunEC security provider.

5
  • I have already this provider on java.security (the third element) -> imgur.com/LdQt5jt
    – CipherX
    Dec 4, 2016 at 10:29
  • 1
    I guess you don't have the sunec.jar in your jdk/lib/ext folder, please try to download it and add It there.
    – QuakeCore
    Dec 4, 2016 at 10:43
  • Sorry @QuakeCore, but I have this library too -> imgur.com/a/yETIL The stranger thing is that if I use RSA I can generate the key, but with ECC, nope.
    – CipherX
    Dec 4, 2016 at 10:53
  • Take a look at this armoredbarista.blogspot.com/2013/10/…
    – QuakeCore
    Dec 4, 2016 at 12:40
  • keytool seems entirely broken since a long time (at least for MacOS releases). I tested both Java8, 11, and 14 and both with OpenJDK and OracleJDK. I always get keytool error: java.security.NoSuchAlgorithmException: *** KeyGenerator not available No matter what I try for "-keyalg" - I tried with RSA, EC, ECDSA, etc. Also there is no file "lib\security\java.security" in the MacOS version or Java (yes, I looked under Contents/Home).
    – Jörg
    Apr 17, 2020 at 15:14
2

I solved the problem by reading the following article (linked by the user @QuakeCore). If someone has the same issue, he/she can solve by following my steps:

  1. Download Java Oracle (tar.gz);
  2. Copy the file jdk1.8.0_*/jre/lib/amd64/libsunec.so from extracted folder to /usr/lib/jvm/java-1.8.0-openjdk.x86_64/jre/lib/amd64/libsunec.so;
  3. Use the syntax written in my original question to generate the key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.